This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients brett.cannon, chris.jerdonek, eric.araujo, eric.snow, jaraco, jayyin11043, ncoghlan, ncohen, python-dev, serhiy.storchaka
Date 2022-03-26.05:34:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1648272841.31.0.945515696145.issue32642@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2022-03-26 05:34:01serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, jaraco, ncoghlan, eric.araujo, chris.jerdonek, python-dev, eric.snow, jayyin11043, ncohen
2022-03-26 05:34:01serhiy.storchakasetmessageid: <1648272841.31.0.945515696145.issue32642@roundup.psfhosted.org>
2022-03-26 05:34:01serhiy.storchakalinkissue32642 messages
2022-03-26 05:34:01serhiy.storchakacreate