Skip to content
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

UnboundLocalError exception when exiting trial -j via an interrupt (i.e. ctrl-C) #11707

Closed
glyph opened this issue Oct 6, 2022 · 3 comments · Fixed by #11897
Closed

UnboundLocalError exception when exiting trial -j via an interrupt (i.e. ctrl-C) #11707

glyph opened this issue Oct 6, 2022 · 3 comments · Fixed by #11897
Labels

Comments

@glyph
Copy link
Member

glyph commented Oct 6, 2022

running trial --reporter=bwverbose -j 10 twisted.internet.test for unrelated reasons:

trial --reporter=bwverbose -j 10 twisted.internet.test

^CTraceback (most recent call last):
  File "/Users/glyph/.virtualenvs/Twisted/bin/trial", line 8, in <module>
    sys.exit(run())
  File "/Users/glyph/Projects/Twisted/src/twisted/scripts/trial.py", line 647, in run
    testResult = trialRunner.run(suite)
  File "/Users/glyph/Projects/Twisted/src/twisted/trial/_dist/disttrial.py", line 473, in run
    return self._run(test, untilFailure=False)
  File "/Users/glyph/Projects/Twisted/src/twisted/trial/_dist/disttrial.py", line 455, in _run
    if isinstance(result, Failure):
UnboundLocalError: local variable 'result' referenced before assignment
@glyph glyph added the bug label Oct 6, 2022
@glyph
Copy link
Member Author

glyph commented Oct 6, 2022

The hang that provokes this seems to only occur with the bwverbose reporter, oddly. The default reporter runs to completion on this suite.

@exarkun
Copy link
Member

exarkun commented Oct 6, 2022

Sounds related to #10340 but no mention of bwverbose there.

@glyph
Copy link
Member Author

glyph commented Nov 24, 2022

On Python 3.11, we get a different exception type, so recording this here in case anyone is searching for it:

^CTraceback (most recent call last):                                                                                                                                              
  File "<frozen runpy>", line 198, in _run_module_as_main                                                                                                                         
  File "<frozen runpy>", line 88, in _run_code                                                                                                                                    
  File "/Users/glyph/Projects/Twisted/.tox/alldeps-macos-nocov/lib/python3.11/site-packages/twisted/trial/__main__.py", line 9, in <module>                                       
    sys.exit(run())                                                                                                                                                               
             ^^^^^                                                                                                                                                                
  File "/Users/glyph/Projects/Twisted/.tox/alldeps-macos-nocov/lib/python3.11/site-packages/twisted/scripts/trial.py", line 647, in run                                           
    testResult = trialRunner.run(suite)                                                                                                                                           
                 ^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                           
  File "/Users/glyph/Projects/Twisted/.tox/alldeps-macos-nocov/lib/python3.11/site-packages/twisted/trial/_dist/disttrial.py", line 473, in run                                   
    return self._run(test, untilFailure=False)                                                                                                                                    
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                    
  File "/Users/glyph/Projects/Twisted/.tox/alldeps-macos-nocov/lib/python3.11/site-packages/twisted/trial/_dist/disttrial.py", line 455, in _run                                  
    if isinstance(result, Failure):                                                                                                                                               
                  ^^^^^^                                                                                                                                                          
UnboundLocalError: cannot access local variable 'result' where it is not associated with a value                                                                                  

@glyph glyph changed the title trial -j / disttrial / hang / control-C traceback UnboundLocalError exception when exiting trial -j via an interrupt (i.e. ctrl-C) Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants