Message416037
Are there any problems with converting a Path to string before adding it to sys.path? You do this one time, and any users of sys.path will not need to bother about conversion. It is better even for performance.
Otherwise we will need to revise and update every code that uses sys.path, and many bugs will left in third-party code for years. For example, in unittest the code
if not top_level_dir in sys.path:
sys.path.insert(0, top_level_dir)
should be replaced with more cumbersome
for path in sys.path:
if os.fsdecode(path) == top_level_dir:
break
else:
sys.path.insert(0, top_level_dir)
In multiprocessing the code
sys_path=sys.path.copy()
try:
i = sys_path.index('')
except ValueError:
pass
else:
sys_path[i] = process.ORIGINAL_DIR
should be replaced with
sys_path=sys.path.copy()
for i, path in enumerate(sys_path):
if os.fsdecode(path) == '':
sys_path[i] = process.ORIGINAL_DIR
break
It is just two examples. I did not review the whole stdlib, and there should be more third-party code. |
|
Date |
User |
Action |
Args |
2022-03-26 05:34:01 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, brett.cannon, jaraco, ncoghlan, eric.araujo, chris.jerdonek, python-dev, eric.snow, jayyin11043, ncohen |
2022-03-26 05:34:01 | serhiy.storchaka | set | messageid: <1648272841.31.0.945515696145.issue32642@roundup.psfhosted.org> |
2022-03-26 05:34:01 | serhiy.storchaka | link | issue32642 messages |
2022-03-26 05:34:01 | serhiy.storchaka | create | |
|