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

unittest: _is_relevant_tb_level() fails because tb.tb_frame.f_globals=None #88454

Closed
vstinner opened this issue Jun 2, 2021 · 4 comments
Closed
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@vstinner
Copy link
Member

vstinner commented Jun 2, 2021

BPO 44288
Nosy @gvanrossum, @vstinner, @markshannon
Superseder
  • bpo-44442: Globals (and presumably builtins) are cleared premuturely in FrameObject
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-06-29.01:37:20.515>
    created_at = <Date 2021-06-02.15:05:01.200>
    labels = ['interpreter-core', '3.11']
    title = 'unittest: _is_relevant_tb_level() fails because tb.tb_frame.f_globals=None'
    updated_at = <Date 2021-06-29.01:37:20.514>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2021-06-29.01:37:20.514>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-29.01:37:20.515>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2021-06-02.15:05:01.200>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44288
    keywords = []
    message_count = 4.0
    messages = ['394920', '394970', '396260', '396691']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'vstinner', 'Mark.Shannon']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '44442'
    type = None
    url = 'https://bugs.python.org/issue44288'
    versions = ['Python 3.11']

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 2, 2021

    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

    @vstinner vstinner added 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 2, 2021
    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 3, 2021

    Oops, I wanted to ping Mark Shannon, not Mark Dickinson.

    @vstinner
    Copy link
    Member Author

    Is it possible that bpo-44442 is a duplicate of this issue? Is it already fixed by #70955, commit ba2f32a?

    @vstinner
    Copy link
    Member Author

    I mark this issue as a duplicate of bpo-44442.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant