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

Chris Jerdonek report at bugs.python.org
Wed Jan 24 00:27:12 EST 2018

New submission from Chris Jerdonek <chris.jerdonek at gmail.com>:

This issue is to suggest enhancing sys.path to recognize path-like objects, per PEP 519.

I recently ran into an issue where a path was getting added to sys.path, but the corresponding imports weren't working as they should, even though sys.path showed the path as being present. Eventually I tracked this down to the path being a pathlib.Path object rather than a string. This wasn't obvious because Path objects appear as strings in normal debug output, etc.

The sys.path docs currently say this:

> Only strings and bytes should be added to sys.path; all other data types are ignored during import.

components: Library (Lib)
messages: 310560
nosy: brett.cannon, chris.jerdonek
priority: normal
severity: normal
status: open
title: add support for path-like objects in sys.path
type: enhancement
versions: Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list