-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for compatibility with Python 3.13 #1321
base: unstable
Are you sure you want to change the base?
Changes from all commits
f27d9ea
bcd883a
eb2232e
f73364b
48070e9
29706ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,6 +468,8 @@ def get_functions(self, prefix="eval", is_pymodule=False): | |
for name in dir(self): | ||
if name.startswith(prefix): | ||
function = getattr(self, name) | ||
if not hasattr(function, "__call__"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, |
||
continue | ||
pattern = function.__doc__ | ||
if pattern is None: # Fixes PyPy bug | ||
continue | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ | |
r"""(?mx)^ # re.MULTILINE (multi-line match) | ||
# and re.VERBOSE (readable regular expressions | ||
((?:.|\n)*?) | ||
^\s+([>#SX])>[ ](.*) # test-code indicator | ||
^\s*([>#SX])>[ ](.*) # test-code indicator | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Python 3.13, doctrings are trimmed of "margin" spaces. |
||
((?:\n\s*(?:[:|=.][ ]|\.).*)*) # test-code results""" | ||
) | ||
TESTCASE_OUT_RE = re.compile(r"^\s*([:|=])(.*)$") | ||
|
@@ -216,10 +216,7 @@ def parse_docstring_to_DocumentationEntry_items( | |
logging.warning("``key_part`` is deprecated. Its value is discarded.") | ||
|
||
# Remove commented lines. | ||
doc = filter_comments(doc).strip(r"\s") | ||
|
||
# Remove leading <dl>...</dl> | ||
# doc = DL_RE.sub("", doc) | ||
doc = filter_comments(doc) # .strip("\s") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not remember the reason of the r"\s" strip, but it breaks some tests now. |
||
|
||
# pre-substitute Python code because it might contain tests | ||
doc, post_substitutions = pre_sub( | ||
|
@@ -394,11 +391,16 @@ def compare_out(self, outs: tuple = tuple()) -> bool: | |
# Mismatched number of output lines, and we don't have "..." | ||
return False | ||
|
||
# Python 3.13 replaces tabs by a single space in docstrings. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python 3.13 converts tab characters in docstrings to simple spaces. This "hack" helps to keep the doctests compatible with this change. |
||
# In doctests we replace tabs by sequences of four spaces. | ||
def tabs_to_spaces(val): | ||
return val.text.replace("\t", 4 * " ") | ||
|
||
# Need to check all output line by line | ||
for got, wanted in zip(outs, wanted_outs): | ||
if wanted.text == "...": | ||
return True | ||
if not got == wanted: | ||
if not tabs_to_spaces(got) == tabs_to_spaces(wanted): | ||
return False | ||
|
||
return True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In docstrings, use 4 spaces instead of a tab character.