Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32642>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to