[issue32642] add support for path-like objects in sys.path

Eryk Sun report at bugs.python.org
Sat Mar 26 14:25:50 EDT 2022


Eryk Sun <eryksun at gmail.com> added the comment:

> I've got in mind a PyListObject subclass with calls to PyOS_FSPath 
> before insert, append, extend and __getitem__.

The sys module doesn't prevent rebinding sys.path. Most code I think is careful to update sys.path. But surely some code replaces it with a new list instead of updating via insert(), append(), extend(), or updating a slice such as `sys.path[:] = new_path`. For example, ModifiedInterpreter.transfer_path() in Lib/idlelib/pyshell.py rebinds sys.path. It doesn't have to, but it does.

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32642>
_______________________________________


More information about the Python-bugs-list mailing list