hroncok · GitHub

Bug report

Bug description:

In Fedora, when we build and test Python 3.15.0a1, we get:

======================================================================
FAIL: test_parse_makefile_renamed_vars (test.test_sysconfig.MakefileTests.test_parse_makefile_renamed_vars)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/python3.15-3.15.0_a1-build/Python-3.15.0a1/Lib/test/test_sysconfig.py", line 824, in test_parse_makefile_renamed_vars
    self.assertEqual(vars, {
    ~~~~~~~~~~~~~~~~^^^^^^^^
        'var1': '-Wall',
        ^^^^^^^^^^^^^^^^
    ...<5 lines>...
        'var3': '',
        ^^^^^^^^^^^
    })
    ^^
AssertionError: {'var1': '-flto=auto -ffat-lto-objects -fexceptions [552 chars]: ''} != {'var1': '-Wall', 'CFLAGS': '-Wall', 'PY_CFLAGS': '-[67 chars]: ''}
Diff is 762 characters long. Set self.maxDiff to None to see it.

This is because we set environment variables during the build, like CFLAGS.

To reproduce outside of Fedora, you can:

[cpython (main %)]$ ./python -m test test_sysconfig
...
== Tests result: SUCCESS ==
[cpython (main %)]$ CFLAGS=-02 ./python -m test test_sysconfig
...
test test_sysconfig failed -- Traceback (most recent call last):
  File ".../cpython/Lib/test/test_sysconfig.py", line 811, in test_parse_makefile_renamed_vars
    self.assertEqual(vars, {
    ~~~~~~~~~~~~~~~~^^^^^^^^
        'var1': '-Wall',
        ^^^^^^^^^^^^^^^^
    ...<5 lines>...
        'var3': '',
        ^^^^^^^^^^^
    })
    ^^
AssertionError: {'var1': -2, 'PY_CFLAGS': '-Wall', 'CFLAGS': '-Wal[64 chars]: ''} != {'var1': '-Wall', 'CFLAGS': '-Wall', 'PY_CFLAGS': [69 chars]: ''}
  {'CFLAGS': '-Wall',
   'LDFLAGS': '-lm',
   'PY_CFLAGS': '-Wall',
   'PY_LDFLAGS': '-lm',
-  'var1': -2,
?           ^
+  'var1': '-Wall',
?          + ^^^^^
   'var2': '-lm',
   'var3': ''}
0:00:00 load avg: 17.34 [1/1/1] test_sysconfig failed (1 failure)
== Tests result: FAILURE ==

I believe the tests needs to isolate itself from os.environ.

CPython versions tested on:

3.15, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗