[issue30641] No way to specify "File name too long" error in except statement.

Antoine Pitrou report at bugs.python.org
Mon Jun 12 16:54:34 EDT 2017


Antoine Pitrou added the comment:

On Unix, you can simply check the errno value:

>>> fn = "x" * 9999999
>>> try: open(fn, "r")
... except OSError as e: exc = e
... 
>>> exc.errno
36
>>> exc.errno == errno.ENAMETOOLONG
True

I don't know about Windows.

----------

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


More information about the Python-bugs-list mailing list