[tor-bugs] #23043 [Obfuscation/BridgeDB]: leekspin's except/error code handling in generator.py is strange
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu Jul 27 03:23:51 UTC 2017
#23043: leekspin's except/error code handling in generator.py is strange
--------------------------------------+----------------------
Reporter: Samdney | Owner: isis
Type: defect | Status: new
Priority: Low | Milestone:
Component: Obfuscation/BridgeDB | Version:
Severity: Minor | Keywords: leekspin
Actual Points: | Parent ID:
Points: | Reviewer:
Sponsor: |
--------------------------------------+----------------------
In /leekspin/generator.py you have in "def
createRelayOrBridgeDescriptors(...)"
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!python
def createRelayOrBridgeDescriptors(count, bridge=True, **kwargs):
...
try:
...
except KeyboardInterrupt as keyint:
logging.warn("Received keyboard interrupt.")
logging.warn("Stopping descriptor creation and exiting.")
code = 1515
finally:
...
logging.info("Done.")
code = 0
sys.exit(code)
}}}
}}}
The same in a similiar way also in "def
createHiddenServiceDescriptors(...)"
I think your way of handling the code-variable isn't right. If you have an
Keyboard exception if follows: code = 1515. But the "try ... except ...
finally" - block always "finally" execute the code within the finally
block. So it will always exit with code = 0, sys.exit(0)!
In generally, the execution of (some) parts of the finally block after an
keyboard interruption makes no sense for me.
(I haven't found time to examinate the full source code until now. Hence,
for the case that all has a good reason, please ignore me :)
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23043>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list