8000 gh-102840: Fix confused traceback when `floordiv` or `mod` operations happens between `Fraction` and `complex` objects by Eclips4 · Pull Request #102842 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-102840: Fix confused traceback when floordiv or mod operations happens between Fraction and complex objects #102842

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

Merged
merged 10 commits into from
Feb 10, 2024
Prev Previous commit
Next Next commit
Merge branch 'main' into issue-102840
  • Loading branch information
Eclips4 authored Jan 1, 2024
commit 7dd8996b432c1cdba7559abe091f3b79d727ea5a
26 changes: 25 additions & 1 deletion Lib/test/test_fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,31 @@ def test_invalid_formats(self):
with self.assertRaises(ValueError):
format(fraction, spec)

def test_traceback_in_mod_and_floordiv_with_complex_objects(self):
@requires_IEEE_754
def test_float_format_testfile(self):
with open(format_testfile, encoding="utf-8") as testfile:
for line in testfile:
if line.startswith('--'):
continue
line = line.strip()
if not line:
continue

lhs, rhs = map(str.strip, line.split('->'))
fmt, arg = lhs.split()
if fmt == '%r':
continue
fmt2 = fmt[1:]
with self.subTest(fmt=fmt, arg=arg):
f = F(float(arg))
self.assertEqual(format(f, fmt2), rhs)
if f: # skip negative zero
self.assertEqual(format(-f, fmt2), '-' + rhs)
f = F(arg)
self.assertEqual(float(format(f, fmt2)), float(rhs))
self.assertEqual(float(format(-f, fmt2)), float('-' + rhs))

def test_traceback_in_mod_and_floordiv_with_complex_objects(self):
# See issue gh-102840 for more details.

a = F(1, 2)
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0