1

When trying to open a directory, an exception is thrown:

>>> try:
...   open( '/' )
... except IOError, e:
...   print e.filename
None

Is it possible (preferrably in python 2.3.4) for the handler of the exception to get the name of the directory from the exception object?

Daenyth
  • 35,856
  • 13
  • 85
  • 124
William Pursell
  • 204,365
  • 48
  • 270
  • 300

1 Answers1

1

This is a bug in older versions of Python: http://bugs.python.org/issue4764

Supplying the open function with a mode, open('/', 'r'), might allow you to retrieve the filename via e.filename.

philofinfinitejest
  • 3,987
  • 1
  • 24
  • 22