🚑 Clarify patch condition for doctest finder hack (#12471)

There was a regression caused by #12431 that excluded the patch on
broken CPython patch version ranges 3.11.0–3.11.8 and 3.12.0–3.12.2.

This change fixes that by adjusting the patching conditional clause
to include said versions.

Closes #12430.

Co-authored-by: Florian Bruhin <me@the-compiler.org>
This commit is contained in:
Sviatoslav Sydorenko (Святослав Сидоренко) 2024-06-18 11:21:25 +02:00 committed by GitHub
parent fe4961afae
commit 49374ec7a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -505,7 +505,13 @@ class DoctestModule(Module):
import doctest
class MockAwareDocTestFinder(doctest.DocTestFinder):
if sys.version_info < (3, 11):
py_ver_info_minor = sys.version_info[:2]
is_find_lineno_broken = (
py_ver_info_minor < (3, 11)
or (py_ver_info_minor == (3, 11) and sys.version_info.micro < 9)
or (py_ver_info_minor == (3, 12) and sys.version_info.micro < 3)
)
if is_find_lineno_broken:
def _find_lineno(self, obj, source_lines):
"""On older Pythons, doctest code does not take into account