Skip to content

Commit 4d6c417

Browse files
authored
clear out CFLAGS from the environement (#21033)
While packaging from Debian we set `CFLAGS=-g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/package/package=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection` This causes the following test failures: ``` FAILED mypyc/test/test_run.py::TestRun::run-i64.test::testI64GlueMethodsAndInheritance - data: /build/package/package/mypyc/test-data/run-i64.test:1338: FAILED mypyc/test/test_run.py::TestRun::run-bools.test::testBoolOps - data: /build/package/package/mypyc/test-data/run-bools.test:17: FAILED mypyc/test/test_run.py::TestRun::run-i64.test::testI64ErrorValuesAndUndefined - data: /build/package/package/mypyc/test-data/run-i64.test:519: FAILED mypyc/test/test_run.py::TestRun::run-i64.test::testI64BasicOps - data: /build/package/package/mypyc/test-data/run-i64.test:1: FAILED mypyc/test/test_run.py::TestRun::run-i64.test::testI64DefaultArgValues - data: /build/package/package/mypyc/test-data/run-i64.test:906: ``` All with the same underlying error: > python3.13: /usr/include/python3.13/object.h:352: Py_SIZE: Assertion `ob->ob_type != &PyLong_Type' failed. Therefore this PR clears `CFLAGS` environement variable while running the mypyc data driven test cases.
1 parent 0e6cfd4 commit 4d6c417

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

mypyc/test/test_run.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from collections.abc import Iterator
1515
from typing import Any
1616

17+
import pytest
18+
1719
from mypy import build
1820
from mypy.errors import CompileError
1921
from mypy.options import Options
@@ -162,13 +164,15 @@ class TestRun(MypycDataSuite):
162164
strict_dunder_typing = False
163165

164166
def run_case(self, testcase: DataDrivenTestCase) -> None:
165-
# setup.py wants to be run from the root directory of the package, which we accommodate
166-
# by chdiring into tmp/
167-
with (
168-
use_custom_builtins(os.path.join(self.data_prefix, ICODE_GEN_BUILTINS), testcase),
169-
chdir_manager("tmp"),
170-
):
171-
self.run_case_inner(testcase)
167+
with pytest.MonkeyPatch.context() as mp:
168+
mp.delenv("CFLAGS", raising=False)
169+
# setup.py wants to be run from the root directory of the package, which we accommodate
170+
# by chdiring into tmp/
171+
with (
172+
use_custom_builtins(os.path.join(self.data_prefix, ICODE_GEN_BUILTINS), testcase),
173+
chdir_manager("tmp"),
174+
):
175+
self.run_case_inner(testcase)
172176

173177
def run_case_inner(self, testcase: DataDrivenTestCase) -> None:
174178
if not os.path.isdir(WORKDIR): # (one test puts something in build...)

0 commit comments

Comments
 (0)