[issue21969] WindowsPath constructor does not check for invalid characters

Antony Lee report at bugs.python.org
Sun Jul 13 06:24:06 CEST 2014


Antony Lee added the comment:

There is a list of always forbidden characters (http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions), and then a couple of obscure fs-dependent cases (http://en.wikipedia.org/wiki/Comparison_of_file_systems) but I believe excluding the main list should be enough for most purposes.
Note that PosixPath is not immune to this either, as there is one forbidden character: the null byte.

I would prefer if path.open() can only raise one of the OSError subclasses that correspond to errnos mentioned in "man 2 open".  Currently, on Windows, "Path('*').open()" raises an OSError ("invalid argument"); on Linux, "Path('\0').open()" raises a TypeError(!).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21969>
_______________________________________


More information about the Python-bugs-list mailing list