Skip to content

Commit 146585b

Browse files
committed
Fix 3 issues found on Python 3.14.beta
1 parent 40ed831 commit 146585b

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

.github/workflows/my_github_action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ jobs:
145145
- '3.13.1'
146146
- '3.13.2'
147147
- '3.14.0-alpha.0'
148+
- '3.14.0-alpha.7'
148149
- '3.14.0-beta.1'
149150
# Disabled because of issue #67 - '3.14.0-alpha.1', ..., '3.14.0-alpha.6'
150151
- 'pypy-2.7'

didyoumean/didyoumean_re.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@
5757
INDEXOUTOFRANGE_RE = r"^list index out of range$"
5858
ZERO_LEN_FIELD_RE = r"^zero length field name in format$"
5959
MATH_DOMAIN_ERROR_RE = r"^math domain error|" \
60-
r"expected a positive input, got -\d+$"
60+
r"expected a positive input(?:, got -\d+)?$"
6161
TOO_MANY_VALUES_UNPACK_RE = r"^too many values " \
6262
r"to unpack(?: \(expected.*\))?$"
6363
OUTSIDE_FUNCTION_RE = r"^'?(\w+)'? outside function$"
6464
NEED_MORE_VALUES_RE = r"^(?:need more than \d+|not enough) values to unpack" \
6565
r"(?: \(expected \d+, got \d+\))?$"
66-
UNHASHABLE_RE = r"^(?:unhashable type: )?'({0})'" \
67-
r"(?: objects are unhashable)?$".format(TYPE_NAME)
66+
UNHASHABLE_RE = r"^(?:cannot use '{0}' as a {0} element \(?)?" \
67+
r"(?:unhashable type: )?'({0})'" \
68+
r"(?: objects are unhashable)?.?$".format(TYPE_NAME)
6869
MISSING_PARENT_RE = r"^Missing parentheses in call to " \
6970
r"'(?P<func>{0})'(?:. Did you mean.*)?$".format(FUNC_NAME)
7071
INVALID_LITERAL_RE = r"^invalid literal for (\w+)\(\) with base \d+: '(.*)'$"

didyoumean/didyoumean_re_tests.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,12 @@ def test_zero_length_field(self):
370370

371371
def test_math_domain_error(self):
372372
"""Test MATH_DOMAIN_ERROR_RE."""
373-
# Python 2.6/2.7/3.2/3.3/3.4/3.5/PyPy/PyPy3
374373
msgs = [
374+
# Python 2.6/2.7/3.2/3.3/3.4/3.5/PyPy/PyPy3
375375
"math domain error",
376376
"expected a positive input, got -1",
377+
# Python 3.14.0.b
378+
"expected a positive input",
377379
]
378380
for msg in msgs:
379381
self.re_matches(msg, re.MATH_DOMAIN_ERROR_RE, NO_GROUP)
@@ -396,6 +398,8 @@ def test_unhashable_type(self):
396398
msgs = [
397399
# Python 2.6/2.7/3.2/3.3/3.4/3.5
398400
"unhashable type: 'list'",
401+
# Python 3.14.0.b
402+
"cannot use 'list' as a set element (unhashable type: 'list')",
399403
# PyPy/PyPy3
400404
"'list' objects are unhashable",
401405
]
@@ -701,6 +705,11 @@ def test_unsupported_operand(self):
701705
'-',
702706
'builtin_function',
703707
'int'),
708+
# Python 3.14.0.b
709+
("unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'",
710+
'>>',
711+
'builtin_function_or_method',
712+
'_io.TextIOWrapper'),
704713
]
705714
for msg, op, t1, t2 in msgs:
706715
groups = op, t1, t2

didyoumean/didyoumean_sugg_tests.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,14 +1909,16 @@ def test_old_print_syntax(self):
19091909

19101910
def test_old_print_chevron_syntax(self):
19111911
"""Trying old print chevron syntax (before Python 3)."""
1912-
before, mid, after = before_mid_and_after((3, 0), (3, 6))
1912+
before, mid1, mid2, after = ranges_between((3, 0), (3, 6), (3, 14, 0, 'beta'))
19131913
code = "with open('/dev/null', 'w') as f:\n\tprint >> f, 5"
19141914
sugg = '"print(<message>, file=<output_stream>)"'
19151915
good_code = "with open('/dev/null', 'w') as f:\n\tprint('5', file=f)"
19161916
self.runs(code, before)
1917-
self.throws(code, UNSUPPORTEDOPERAND, sugg, mid)
1918-
self.throws(code, UNSUPPORTEDOPERANDSUGG, [], after)
1919-
self.runs(good_code, mid)
1917+
self.throws(code, UNSUPPORTEDOPERAND, sugg, mid1)
1918+
self.throws(code, UNSUPPORTEDOPERANDSUGG, [], mid2)
1919+
self.throws(code, UNSUPPORTEDOPERAND, sugg, after)
1920+
self.runs(good_code, mid2)
1921+
self.runs(good_code, mid2)
19201922
self.runs(good_code, after)
19211923

19221924
def test_assignment_to_range(self):

0 commit comments

Comments
 (0)