Skip to content

Commit e73cf71

Browse files
agattistinos
authored andcommitted
tests/extmod/re_sub.py: Fix test execution on Python 3.13.
This commit fixes a test failure for `extmod/re_sub.py` where the code, whilst being correct, would not make the test pass due to a newer Python version than expected. On Python 3.13, running `tests/extmod/re_sub.py` would yield a deprecation warning about `re.sub` not providing the match count as a keyword parameter. This warning would be embedded in the expected test result and thus the test would always fail. Co-authored-by: stijn <[email protected]> Signed-off-by: Alessandro Gatti <[email protected]>
1 parent 1b4c969 commit e73cf71

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/extmod/re_sub.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
print("SKIP")
1111
raise SystemExit
1212

13+
import sys
14+
1315

1416
def multiply(m):
1517
return str(int(m.group(0)) * 2)
@@ -47,7 +49,11 @@ def A():
4749
print(re.sub("a", "b", "c"))
4850

4951
# with maximum substitution count specified
50-
print(re.sub("a", "b", "1a2a3a", 2))
52+
if sys.implementation.name != "micropython":
53+
# On CPython 3.13 and later the substitution count must be a keyword argument.
54+
print(re.sub("a", "b", "1a2a3a", count=2))
55+
else:
56+
print(re.sub("a", "b", "1a2a3a", 2))
5157

5258
# invalid group
5359
try:

0 commit comments

Comments
 (0)