diff options
| author | Damian Johnson <atagar@torproject.org> | 2015-12-30 08:01:14 -0800 |
|---|---|---|
| committer | Damian Johnson <atagar@torproject.org> | 2015-12-30 08:01:14 -0800 |
| commit | ae9d81b279bb51b2f1c3d088b86c7aa310b9db11 (patch) | |
| tree | ceaab96d28bf1d08486b226ef1ae485ddb534141 | |
| parent | 75f311db973412f3754eadacdd08104173f768a1 (diff) | |
Re-raise the same type of exception we get in launch_tor()
On #17946 germn argues we should re-raise our original exception type and I can
can see that. In normal scenarios we should *only* raise an OSError (as
documented), but if the caller invokes an exception within us (like
KeyboardInterrupt) then no reason not to give them that.
| -rw-r--r-- | stem/process.py | 8 | ||||
| -rw-r--r-- | test/integ/process.py | 6 |
2 files changed, 4 insertions, 10 deletions
diff --git a/stem/process.py b/stem/process.py index f2d63f05..08af42cd 100644 --- a/stem/process.py +++ b/stem/process.py @@ -22,7 +22,6 @@ import os import re import signal import subprocess -import sys import tempfile import stem.prereq @@ -166,12 +165,7 @@ def launch_tor(tor_cmd = 'tor', args = None, torrc_path = None, completion_perce tor_process.kill() # don't leave a lingering process tor_process.wait() - exc = sys.exc_info()[1] - - if type(exc) == OSError: - raise # something we're raising ourselves - else: - raise OSError('Unexpected exception while starting tor (%s): %s' % (type(exc).__name__, exc)) + raise finally: if timeout: signal.alarm(0) # stop alarm diff --git a/test/integ/process.py b/test/integ/process.py index 3b44ef5b..1cce8c75 100644 --- a/test/integ/process.py +++ b/test/integ/process.py @@ -212,11 +212,11 @@ class TestProcess(unittest.TestCase): try: stem.process.launch_tor() self.fail("tor shoudn't have started") - except OSError as exc: + except KeyboardInterrupt as exc: if os.path.exists('/proc/%s' % mock_tor_process.pid): - self.fail("launch_tor() left a lingering tor process") + self.fail('launch_tor() left a lingering tor process') - self.assertEqual('Unexpected exception while starting tor (KeyboardInterrupt): nope', str(exc)) + self.assertEqual('nope', str(exc)) def test_torrc_arguments(self): """ |
