Message215832
os.fdopen() should either:
* consume file descriptor and return file/io object, or
* leave file descriptor alone and raise an exception
this invariant is broken in the following test case:
fd = os.open("/", os.O_RDONLY)
try:
obj = os.fdopen(fd, "r")
except EnvironmentError:
os.close(fd) # cleanup
what happens:
fd = os.open("/", os.O_RDONLY) --> some fd
os.fdopen(fd, "r") --> exception, fd refers to a directory
os.close(fd) --> exception, no such fd
For reference:
1. invariant is held in Python 3.3.
2. following positive test case works correctly
fd = os.open("/etc/passwd", os.O_RDONLY)
try: obj = os.fdopen(fd, "r") # success
except EnvironmentError: os.close(fd) # not reached
3. following negative test case works correctly
fd = os.open("/etc/passwd", os.O_RDONLY)
try: obj = os.fdopen(fd, "w") # wrong mode on purpose
except EnvironmentError: os.close(fd) # closed ok |
|
Date |
User |
Action |
Args |
2014-04-09 18:24:55 | Dima.Tisnek | set | recipients:
+ Dima.Tisnek |
2014-04-09 18:24:55 | Dima.Tisnek | set | messageid: <1397067895.73.0.194150876234.issue21191@psf.upfronthosting.co.za> |
2014-04-09 18:24:55 | Dima.Tisnek | link | issue21191 messages |
2014-04-09 18:24:55 | Dima.Tisnek | create | |
|