It's probably the best we can do to keep the calling code quite simple.
I was thinking to reintroduce the errno attribute to the File class, if the file object creation fails, returns the class and check for the errno. Given that the application if not threaded, it could be reliable:
It's probably the best we can do to keep the calling code quite simple.
I was thinking to reintroduce the errno attribute to the File class, if the file object creation fails, returns the class and check for the errno. Given that the application if not threaded, it could be reliable:
class File(io.FileIO):
__slots__ = (
"errno",
)
def __init__(self, *args, **kwargs): _init__ (*args, **kwargs)
super(File, self)._
self.errno = 0
[...]
def create_file(*args, **kwargs):
try:
return File(*args, **kwargs)
except (EnvironmentError, ValueError), error:
f = File
f.errno = error.errno
return f
Even if I prefer your proposal, what do you think of mine ?