This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unittest: _is_relevant_tb_level() fails because tb.tb_frame.f_globals=None
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Globals (and presumably builtins) are cleared premuturely in FrameObject
View: 44442
Assigned To: Nosy List: Mark.Shannon, gvanrossum, vstinner
Priority: normal Keywords:

Created on 2021-06-02 15:05 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg394920 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-02 15:05
Sometimes, when a test fails in the main branch, unittest fails with the following error:

...
  File "C:\vstinner\python\main\lib\unittest\result.py", line 205, in _is_relevant_tb_level
    return '__unittest' in tb.tb_frame.f_globals
TypeError: argument of type 'NoneType' is not iterable

I only see this error in the main branch, so I suspect that it's a recent change.

Mark, Guido: can it be related to the recent optimization work?


Full log:

vstinner@DESKTOP-DK7VBIL C:\vstinner\python\main>python -u -m test test_ssl -u all -v -m test_pha_required_nocert -F -j5
(...)
0:00:27 load avg: 15.68 [ 47/1] test_ssl failed
test_ssl: testing with 'OpenSSL 1.1.1k  25 Mar 2021' (1, 1, 1, 11, 15)
          under Windows ('10', '10.0.19043', 'SP0', 'Multiprocessor Free')
          HAS_SNI = True
          OP_ALL = 0x-7fffffac
          OP_NO_TLSv1_1 = 0x10000000
test_pha_required_nocert (test.test_ssl.TestPostHandshakeAuth) ...  server:  new connection from ('127.0.0.1', 57613)
 client cert is None
 client did not provide a cert
 server: connection cipher is now ('TLS_AES_256_GCM_SHA384', 'TLSv1.3', 256)
TLS: (<ssl.SSLSocket fd=644, family=AF_INET, type=SOCK_STREAM, proto=0, laddr=('127.0.0.1', 57612), raddr=('127.0.0.1', 57613)>, 'write', TLSVersion.TLSv1_3, _TLSContentType.ALERT, _TLSAlertType.CERTIFICA
TE_REQUIRED, b'\x02t')
Test server failure:
Traceback (most recent call last):
   File "C:\vstinner\python\main\lib\test\test_ssl.py", line 2444, in run
    msg = self.read()
   File "C:\vstinner\python\main\lib\test\test_ssl.py", line 2421, in read
    return self.sslconn.read()
   File "C:\vstinner\python\main\lib\ssl.py", line 1131, in read
    return self._sslobj.read(len)
 ssl.SSLError: [SSL: PEER_DID_NOT_RETURN_A_CERTIFICATE] peer did not return a certificate (_ssl.c:2522)
Warning -- threading_cleanup() failed to cleanup 0 threads (count: 0, dangling: 2)
Warning -- Dangling thread: <ThreadedEchoServer(Thread-1, stopped daemon 540)>
Warning -- Dangling thread: <_MainThread(MainThread, started 1592)>
Warning -- threading._dangling was modified by test_ssl
  Before: {<weakref at 0x00000235F1D3A210; to '_MainThread' at 0x00000235F0E9C730>}
  After:  {<weakref at 0x00000235F1D3B050; to 'ThreadedEchoServer' at 0x00000235F1687890>, <weakref at 0x00000235F1D3B2F0; to '_MainThread' at 0x00000235F0E9C730>}
test test_ssl crashed -- Traceback (most recent call last):
  File "C:\vstinner\python\main\lib\test\libregrtest\runtest.py", line 282, in _runtest_inner
    refleak = _runtest_inner2(ns, test_name)
  File "C:\vstinner\python\main\lib\test\libregrtest\runtest.py", line 246, in _runtest_inner2
    test_runner()
  File "C:\vstinner\python\main\lib\test\test_ssl.py", line 5010, in test_main
    support.run_unittest(*tests)
  File "C:\vstinner\python\main\lib\test\support\__init__.py", line 1083, in run_unittest
    _run_suite(suite)
  File "C:\vstinner\python\main\lib\test\support\__init__.py", line 960, in _run_suite
    result = runner.run(suite)
  File "C:\vstinner\python\main\lib\unittest\runner.py", line 176, in run
    test(result)
  File "C:\vstinner\python\main\lib\unittest\suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "C:\vstinner\python\main\lib\unittest\suite.py", line 122, in run
    test(result)
  File "C:\vstinner\python\main\lib\unittest\suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "C:\vstinner\python\main\lib\unittest\suite.py", line 122, in run
    test(result)
  File "C:\vstinner\python\main\lib\unittest\case.py", line 652, in __call__
    return self.run(*args, **kwds)
  File "C:\vstinner\python\main\lib\unittest\case.py", line 600, in run
    self._feedErrorsToResult(result, outcome.errors)
  File "C:\vstinner\python\main\lib\unittest\case.py", line 516, in _feedErrorsToResult
    result.addFailure(test, exc_info)
  File "C:\vstinner\python\main\lib\test\support\testresult.py", line 123, in addFailure
    super().addFailure(test, err)
  File "C:\vstinner\python\main\lib\unittest\runner.py", line 75, in addFailure
    super(TextTestResult, self).addFailure(test, err)
  File "C:\vstinner\python\main\lib\unittest\result.py", line 17, in inner
    return method(self, *args, **kw)
  File "C:\vstinner\python\main\lib\unittest\result.py", line 122, in addFailure
    self.failures.append((test, self._exc_info_to_string(err, test)))
  File "C:\vstinner\python\main\lib\unittest\result.py", line 182, in _exc_info_to_string
    length = self._count_relevant_tb_levels(tb)
  File "C:\vstinner\python\main\lib\unittest\result.py", line 209, in _count_relevant_tb_levels
    while tb and not self._is_relevant_tb_level(tb):
  File "C:\vstinner\python\main\lib\unittest\result.py", line 205, in _is_relevant_tb_level
    return '__unittest' in tb.tb_frame.f_globals
TypeError: argument of type 'NoneType' is not iterable
msg394970 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-03 01:51
Oops, I wanted to ping Mark Shannon, not Mark Dickinson.
msg396260 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-21 15:47
Is it possible that bpo-44442 is a duplicate of this issue? Is it already fixed by GH-26768, commit ba2f32a983a08c4f64c23c187432e38908639c12?
msg396691 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-29 01:37
I mark this issue as a duplicate of bpo-44442.
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88454
2021-06-29 01:37:20vstinnersetstatus: open -> closed
superseder: Globals (and presumably builtins) are cleared premuturely in FrameObject
messages: + msg396691

resolution: duplicate
stage: resolved
2021-06-21 15:47:02vstinnersetmessages: + msg396260
2021-06-03 01:51:53vstinnersetnosy: + Mark.Shannon, - mark.dickinson
messages: + msg394970
2021-06-02 15:05:01vstinnercreate