Skip to content

gh-136438: Make sure test_compile pass with all optimization levels - #136478

Merged
encukou merged 4 commits into
python:mainfrom
donbarbos:issue-136438-compile
Aug 28, 2025
Merged

gh-136438: Make sure test_compile pass with all optimization levels#136478
encukou merged 4 commits into
python:mainfrom
donbarbos:issue-136438-compile

Conversation

@donbarbos

@donbarbosdonbarbos commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

output before:

======================================================================
ERROR: test_compile_ast (test.test_compile.TestSpecifics.test_compile_ast)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../cpython/Lib/test/test_compile.py", line 597, in test_compile_ast
co2 = compile(ast, '%s3' % fname, 'exec')
ValueError: empty body on FunctionDef
======================================================================
FAIL: test_remove_unused_consts (test.test_compile.TestSpecifics.test_remove_unused_consts)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../cpython/Lib/test/test_compile.py", line 826, in test_remove_unused_consts
self.assertEqual(f.__code__.co_consts,
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
(f.__doc__, "used"))
^^^^^^^^^^^^^^^^^^^^
AssertionError: Tuples differ: (True, 'used') != (None, 'used')
First differing element 0:
True
None
- (True, 'used')
? ^^^
+ (None, 'used')
? ^^^
======================================================================
FAIL: test_strip_unused_None (test.test_compile.TestSpecifics.test_strip_unused_None)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../cpython/Lib/test/test_compile.py", line 872, in test_strip_unused_None
self.assertEqual(f1.__code__.co_consts, (f1.__doc__,))
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Tuples differ: (42,) != (None,)
First differing element 0:
42
None
- (42,)
+ (None,)
----------------------------------------------------------------------

@bedevere-appbedevere-appBot added awaiting review tests Tests in the Lib/test dir labels Jul 9, 2025
@bedevere-appbedevere-appBot mentioned this pull request Jul 9, 2025
8 tasks
@aisk

aisk commented Aug 13, 2025

Copy link
Copy Markdown
Member

Hi, I found that the failed test test_compile_ast is caused when try to compile this function:

defno_code1():
"doc string"

It will failed because the doc string in function body is omitted by the -OO flag. But this is more like a bug, and have been fixed in current main branch (I didn't found which commit but I think it don't matters). So I think we can merge current main branch (click the 'Update branch' button in this page bellow), and revert the changes in test_compile_ast function.

@encukou
encukou merged commit f914e0a into python:mainAug 28, 2025
46 checks passed
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x Fedora Stable Refleaks 3.x (tier-3) has failed when building commit f914e0a.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1641/builds/822) and take a look at the build logs.
  4. Check if the failure is related to this commit (f914e0a) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1641/builds/822

Failed tests:

  • test_external_inspection
  • test_os

Failed subtests:

  • test_only_active_thread - test.test_external_inspection.TestGetStackTrace.test_only_active_thread
  • test_timerfd_select - test.test_os.TimerfdTests.test_timerfd_select

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-s390x.refleak/build/Lib/test/test_external_inspection.py", line 1246, in test_only_active_threadself.assertEqual(
~~~~~~~~~~~~~~~~^len(gil_traces), 1, "Should have exactly one GIL holder"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^AssertionError: 0 != 1 : Should have exactly one GIL holder
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-s390x.refleak/build/Lib/test/test_os.py", line 4465, in test_timerfd_selectself.assertEqual(self.read_count_signaled(fd), 1)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError: 5 != 1

lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@donbarbos@aisk@bedevere-bot@encukou@StanFromIreland