Skip to content

Conversation

efimov-mikhail
Copy link
Contributor

@efimov-mikhail efimov-mikhail commented Jul 12, 2025

Now tests pass with all combinations of -OO and --without-doc-strings.

Before:

======================================================================
FAIL: test_info (test.test_dis.BytecodeTests.test_info)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 2324, in test_info
    self.assertRegex(b.info(), expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'Name:              code_info\nFilename:          (.*)\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        \\d+\nFlags:             OPTIMIZED, NEWLOCALS, HAS_DOCSTRING\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x' not found in 'Name:              code_info\nFilename:          /home/sikko/projects/cpython/Lib/dis.py\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        5\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x'

======================================================================
FAIL: test_code_info (test.test_dis.CodeInfoTests.test_code_info)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 1625, in test_code_info
    self.assertRegex(dis.code_info(x), expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'Name:              code_info\nFilename:          (.*)\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        \\d+\nFlags:             OPTIMIZED, NEWLOCALS, HAS_DOCSTRING\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x' not found in 'Name:              code_info\nFilename:          /home/sikko/projects/cpython/Lib/dis.py\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        5\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x'

======================================================================
FAIL: test_show_code (test.test_dis.CodeInfoTests.test_show_code)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 1632, in test_show_code
    self.assertRegex(output.getvalue(), expected+"\n")
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'Name:              code_info\nFilename:          (.*)\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        \\d+\nFlags:             OPTIMIZED, NEWLOCALS, HAS_DOCSTRING\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x\n' not found in 'Name:              code_info\nFilename:          /home/sikko/projects/cpython/Lib/dis.py\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        5\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x\n'

======================================================================
FAIL: test_disassemble_recursive (test.test_dis.DisTests.test_disassemble_recursive)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 1258, in test_disassemble_recursive
    check(dis_nested_1, depth=1)
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 1255, in check
    self.assertEqual(dis, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: '  --[965 chars]     0 (<code object <genexpr> at 0x..., file [306 chars]UE\n' != '  --[965 chars]     1 (<code object <genexpr> at 0x..., file [306 chars]UE\n'
    --           MAKE_CELL                0 (y)
  
   794           RESUME                   0
  
   795           LOAD_FAST_BORROW         0 (y)
                 BUILD_TUPLE              1
                 LOAD_CONST               0 (<code object foo at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 795>)
                 MAKE_FUNCTION
                 SET_FUNCTION_ATTRIBUTE   8 (closure)
                 STORE_FAST               1 (foo)
  
   798           LOAD_FAST_BORROW         1 (foo)
                 RETURN_VALUE
  
  Disassembly of <code object foo at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 795>:
    --           COPY_FREE_VARS           1
                 MAKE_CELL                0 (x)
  
   795           RESUME                   0
  
   797           LOAD_GLOBAL              1 (list + NULL)
                 LOAD_FAST_BORROW         0 (x)
                 BUILD_TUPLE              1
-                LOAD_CONST               0 (<code object <genexpr> at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 797>)
?                                         ^
+                LOAD_CONST               1 (<code object <genexpr> at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 797>)
?                                         ^
                 MAKE_FUNCTION
                 SET_FUNCTION_ATTRIBUTE   8 (closure)
                 LOAD_DEREF               1 (y)
                 CALL                     0
                 CALL                     1
                 RETURN_VALUE


======================================================================
FAIL: test_disassemble_recursive (test.test_dis.DisWithFileTests.test_disassemble_recursive)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 1258, in test_disassemble_recursive
    check(dis_nested_1, depth=1)
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 1255, in check
    self.assertEqual(dis, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: '  --[965 chars]     0 (<code object <genexpr> at 0x..., file [306 chars]UE\n' != '  --[965 chars]     1 (<code object <genexpr> at 0x..., file [306 chars]UE\n'
    --           MAKE_CELL                0 (y)
  
   794           RESUME                   0
  
   795           LOAD_FAST_BORROW         0 (y)
                 BUILD_TUPLE              1
                 LOAD_CONST               0 (<code object foo at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 795>)
                 MAKE_FUNCTION
                 SET_FUNCTION_ATTRIBUTE   8 (closure)
                 STORE_FAST               1 (foo)
  
   798           LOAD_FAST_BORROW         1 (foo)
                 RETURN_VALUE
  
  Disassembly of <code object foo at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 795>:
    --           COPY_FREE_VARS           1
                 MAKE_CELL                0 (x)
  
   795           RESUME                   0
  
   797           LOAD_GLOBAL              1 (list + NULL)
                 LOAD_FAST_BORROW         0 (x)
                 BUILD_TUPLE              1
-                LOAD_CONST               0 (<code object <genexpr> at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 797>)
?                                         ^
+                LOAD_CONST               1 (<code object <genexpr> at 0x..., file "/home/sikko/projects/cpython/Lib/test/test_dis.py", line 797>)
?                                         ^
                 MAKE_FUNCTION
                 SET_FUNCTION_ATTRIBUTE   8 (closure)
                 LOAD_DEREF               1 (y)
                 CALL                     0
                 CALL                     1
                 RETURN_VALUE

@bedevere-app bedevere-app bot mentioned this pull request Jul 12, 2025
8 tasks
@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Jul 12, 2025
@StanFromIreland StanFromIreland requested a review from sobolevn July 12, 2025 16:58
@encukou encukou merged commit 06dd635 into python:main Aug 19, 2025
42 checks passed
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…ls (pythonGH-136593)

Now tests pass with all combinations of -OO and --without-doc-strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants