New submission from Thierry Parmentelat <thierry.parmente...@inria.fr>:
Hi; this is my first entry in this repo I ran today into a rather frustrating experience, that I'd to avoid it for others as far as possible In a nutshell I had a sphinx stub that read: import sys sys.path.append("..") <snip> import mymodule and because I was switching from os.path to pathlib.Path, I rather stupidly changed it into this import sys sys.path.append(Path("..").resolve()) <snip> import mymodule --- When trying to run this new code, the message I got was ModuleNotFoundError So I tried to troubleshoot the situation, and inserted something like for x in sys.path: print(x) and so the proper path showed up, and that's the point where I started banging my head against the screen Granted, I was doing too many changes at the same time, and it's entirely my fault if it took me ages really to figure it out eventually. --- Still, my proposal would be to *) either accept Path instances in sys.path, or *) somehow send a warning message stating that the Path instance is totally ignored; at least, I haven't found the corresponding piece of code yet, but as far as I am concerned it's truly as if this Path instance had been completely ignored when executing the import statement *) or at the very least add a mention about this possible issue in the import documentation I understand it was a stupid mistake, but with Path becoming THE right way to deal with paths, I think it is safe to predict that I won't be the only one making it. As I said I am a complete newbie with cpython's codebase and devel practices, so I'll warmly welcome all inputs on this one. thanks ---------- components: Library (Lib) messages: 329864 nosy: thierry.parmentelat priority: normal severity: normal status: open title: Allow Path instances in sys.path ? type: enhancement versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35237> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com