Steve Dower added the comment:

Actually, I'd be inclined to never use the prefix within pathlib and then add 
it on if necessary when converting to a string. That would also solve a problem 
like:

>>> p = Path("C:\\") / ('a'*150) / ('a'*150)
>>> p.stat()
FileNotFoundError: [WinError 3] The system cannot find the path specified: ...
>>> p2 = Path("\\\\?\\" + str(p))
>>> p2.stat()
os.stat_result(...)

The hardest part about this is knowing with certainty whether it's needed. We 
can certainly detect most cases automatically.

Maybe we also need an extra method or a format character to force a str() with 
prefix? Or maybe having an obvious enough function that people can monkey-patch 
if necessary - the "\\?\" prefix is an edge case for most people already, and 
checking the total length would bring that to >99% IME.

----------

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

Reply via email to