[issue42203] Unexpected behaviour NameError: name 'open' is not defined

john ryan report at bugs.python.org
Fri Oct 30 03:44:09 EDT 2020


New submission from john ryan <jryan at tactiq.co.uk>:

My test environment runs Ubuntu 18.04 in a virtualbox hosted on Windows 8.1 and Python executes within a venv running Python 3.9.0 (Python 3.9.0 (default, Oct 26 2020, 09:02:51) 
[GCC 7.5.0] on linux

Running a test with unittest.IsolatedAsyncioTestCase my code hung so I hit ctrl-C twice to stop it and got the below traceback.

The really odd behaviour is that open is reported as not defined.

The behaviour is repeatable in my test, but I do not know how to produce a simple test case. I do not know what the issue is with my code.


 ^C^CTraceback (most recent call last):
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/async_case.py", line 158, in run
    return super().run(result)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/case.py", line 593, in run
    self._callTestMethod(testMethod)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/async_case.py", line 65, in _callTestMethod
    self._callMaybeAsync(method)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/async_case.py", line 88, in _callMaybeAsync
    return self._asyncioTestLoop.run_until_complete(fut)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete
    self.run_forever()
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
    self._run_once()
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/asyncio/base_events.py", line 1854, in _run_once
    event_list = self._selector.select(timeout)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/selectors.py", line 469, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/__main__.py", line 18, in <module>
    main(module=None)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/main.py", line 101, in __init__
    self.runTests()
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/main.py", line 271, in runTests
    self.result = testRunner.run(self.test)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/runner.py", line 176, in run
    test(result)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/suite.py", line 122, in run
    test(result)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/suite.py", line 122, in run
    test(result)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/suite.py", line 122, in run
    test(result)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/case.py", line 653, in __call__
    return self.run(*args, **kwds)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/async_case.py", line 160, in run
    self._tearDownAsyncioLoop()
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/unittest/async_case.py", line 126, in _tearDownAsyncioLoop
    loop.run_until_complete(self._asyncioCallsQueue.join())
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete
    self.run_forever()
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
    self._run_once()
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/asyncio/base_events.py", line 1854, in _run_once
    event_list = self._selector.select(timeout)
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/selectors.py", line 469, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt
Exception ignored in: <bound method BaseEventLoop.call_exception_handler of <_UnixSelectorEventLoop running=False closed=False debug=True>>
Traceback (most recent call last):
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/asyncio/base_events.py", line 1771, in call_exception_handler
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/logging/__init__.py", line 1463, in error
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/logging/__init__.py", line 1577, in _log
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/logging/__init__.py", line 1587, in handle
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/logging/__init__.py", line 1649, in callHandlers
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/logging/__init__.py", line 948, in handle
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/logging/__init__.py", line 1182, in emit
  File "/home/john/.pyenv/versions/3.9.0/lib/python3.9/logging/__init__.py", line 1171, in _open
NameError: name 'open' is not defined

----------
components: asyncio
messages: 379931
nosy: asvetlov, jryan, yselivanov
priority: normal
severity: normal
status: open
title: Unexpected behaviour NameError: name 'open' is not defined
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42203>
_______________________________________


More information about the Python-bugs-list mailing list