[Python-ideas] Security: remove "." from sys.path?

Pavol Lisy pavol.lisy at gmail.com
Mon Jun 5 16:13:53 EDT 2017


On 6/5/17, Chris Barker <chris.barker at noaa.gov> wrote:
> On Mon, Jun 5, 2017 at 3:55 AM, Victor Stinner <victor.stinner at gmail.com>
> wrote:
>
>> A minimum change would be to add the (empty string) at the end of
>> sys.path
>> in Python 3.7 rather than adding it at the start.
>>
>> It would increase Python usability since it avoids the "random has no
>> randint() function" caused by a random.py file in the script directory.
>> In
>> my experience, this bug hits every developers starting to learn Python
>> and
>> it can be very strange when you get the error when trying to run IDLE.
>>
>
> But it would add the "why won't python import my file?!??!" problem, which
> newbies also struggle with.
>
> Which leaves me with no suggestion for a solution...

Maybe help() could check sys.last_value and get some hints?


More information about the Python-ideas mailing list