[Python-ideas] natively logging sys.path modifications

Chris Angelico rosuav at gmail.com
Thu Jun 25 02:12:07 CEST 2015


On Thu, Jun 25, 2015 at 4:26 AM, anatoly techtonik <techtonik at gmail.com> wrote:
> That object will be broken if somebody decides to use assignment:
>
> sys.path = []
>
> And as far as I know it is not possible to prevent this case or guard
> against this replacement.

So what you want is for the sys module to log all assignments to a
particular attribute, AND for all mutations of that attribute to be
logged as well. That sounds like two completely separate problems to
be solved, but neither is fundamentally impossible (although you'd
need to fiddle with the sys module itself to do the other). I suggest
you investigate ways of solving this that require zero core code
changes, as those ways will work on all existing Python versions. Then
once you run up against an actual limitation, you'll have a better
argument for code changes.

ChrisA


More information about the Python-ideas mailing list