-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix unusued fout var in "finally" block in case of exception #28
Conversation
@tier2003
|
@tier2003
fout = None
try:
...
finally:
if fout is not None:
... |
d2075bf
to
2caa3d7
Compare
2caa3d7
to
2ae7fd9
Compare
|
Stream will not be closed if we fail on open, I think. |
Try-except is attractive, but it's not obvious. If it fails, it should be fail, I think. |
Well, I`ve started the issue because I had problems with opening during file upload. |
well, if we don`t need exception mess at that place - maybe if else would be enough |
@tier2003 |
maybe combine both? fout = None
try:
fout = yield from connection.path_io.open(real_path, mode=mode)
while True:
data = yield from stream.read(connection.block_size)
if not data:
break
yield from connection.path_io.write(fout, data)
except OSError:
connection.response("451", "operation aborted")
else:
connection.response("226", "data transfer done")
finally:
stream.close()
if fout is not None:
yield from connection.path_io.close(fout) |
@rsichny |
Discussion will continue at #31 |
No description provided.