Repository navigation
test: main is red on 3.11/3.12 — the re.sub DeprecationWarning test is ungated and CPython only warns from 3.13 #819
Description
Describe the bug
main is red on Python 3.11 and 3.12. tests/vendor/test_re_sub_positional_flag_unit.py::RuntimeDeprecationWarningTests::test_positional_flag_shape_would_warn asserts a DeprecationWarning that CPython only emits from 3.13, with no version guard:
tests/vendor/test_re_sub_positional_flag_unit.py:218
with self.assertWarns(DeprecationWarning):
re.sub(self.PATTERN, ' ', 'a\nb', re.MULTILINE)
AssertionError: DeprecationWarning not triggered
tests/vendor/test_re_sub_positional_flag_unit.py:221: AssertionError
1 failed, 1831 passed, 76 skipped, 45005 subtests passed in 485.74s
Four failing legs — Python 3.11, Python 3.12, Engines Python 3.11, Engines Python 3.12 — are one defect, not four.
Measured: on 3.14.7 the call warns; on 3.11/3.12 it does not. The 'count' is passed as positional argument deprecation landed in CPython 3.13.
Expected behavior
The test skips, or asserts the absence of the warning, below 3.13. The file's own module docstring at :25 already states the boundary — "It is also a live DeprecationWarning on Python 3.13+" — so the knowledge was there and the guard was not. grep -nE "version_info|skipIf|skipUnless" over the file returns nothing.
Additional context
Introduced by #813 (merged as 55e1b756e), and I cleared that PR as review: good-to-go on incomplete CI — it showed 27✅ 0❌ when I looked, but the 3.11/3.12 legs had not finished. That is my error, not the author's: its own verification ran on 3.14 only, which is the documented local interpreter, and the matrix is what exists to catch exactly this.
The sibling test immediately below, test_flags_keyword_shape_does_not_warn, is version-independent and correct — it asserts the absence of a warning, which holds on every version. Only the positive assertion needs gating.
Fix shape, cheapest first:
@unittest.skipIf(sys.version_info < (3, 13), '...')on that one method, naming the CPython version in the reason.- Or invert it: assert the warning on 3.13+ and its absence below, so both branches are pinned rather than one being skipped.
(2) is better — it keeps coverage on every leg instead of going dark on two of them, and it makes the version boundary itself a tested fact rather than a comment.
Note this is the second time today a test pinned a runtime symptom without gating its version. #788 had the mirror image: typing.final only records __final__ from 3.11, and the guard's boundary had to be pinned by an AST-derived test (test_the_shim_switches_at_the_version_that_added_the_dunder). That is the pattern to copy here.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
JarryShaw commentedon Sep 25, 2026
Correcting this issue's own scope: it is three Python versions and six legs, not two and four. #817's CI has now completed (
inc=0), and the full picture is:I wrote "3.11 and 3.12" and "four failing legs" from a partial run — the same error that caused this issue in the first place, reading an incomplete check set as complete. The deprecation landed in CPython 3.13, so every matrix leg below it fails, and the repo tests 3.10 upward.
That makes the fix shape more clearly right, not less: a
skipIfwould take six of the legs dark rather than four, leaving coverage only on 3.13 and 3.14. Inverting the assertion — warn on 3.13+, must not warn below — keeps all six pinned and makes the boundary itself the tested fact.Nothing else about the diagnosis changes: one defect,
tests/vendor/test_re_sub_positional_flag_unit.py:218, noversion_info/skipIf/skipUnlessanywhere in the file, and its module docstring at:25already naming the 3.13+ boundary it failed to gate on.