8000 gh-109311: Remove support for non-complex/float types in __complex/float__ by skirpichev · Pull Request #112680 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

gh-109311: Remove support for non-complex/float types in __complex/float__ #112680

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
+ adjust more tests
  • Loading branch information
skirpichev committed May 31, 2024
commit 47a4622526e82b2e48b66cd8ba65b22ae3a4c26c
15 changes: 3 additions & 12 deletions Lib/test/test_capi/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ def test_realasdouble(self):
# Test types with __complex__ dunder method
self.assertEqual(realasdouble(Complex()), 4.25)
self.assertRaises(TypeError, realasdouble, BadComplex())
with self.assertWarns(DeprecationWarning):
self.assertEqual(realasdouble(BadComplex2()), 4.25)
with warnings.catch_warnings():
warnings.simplefilter("error", DeprecationWarning)
self.assertRaises(DeprecationWarning, realasdouble, BadComplex2())
self.assertRaises(TypeError, realasdouble, BadComplex2())
self.assertRaises(RuntimeError, realasdouble, BadComplex3())

# Test types with __float__ dunder method
Expand Down Expand Up @@ -112,18 +108,13 @@ def test_imagasdouble(self):
# Test types with __complex__ dunder method
self.assertEqual(imagasdouble(Complex()), 0.5)
self.assertRaises(TypeError, imagasdouble, BadComplex())
with self.assertWarns(DeprecationWarning):
self.assertEqual(imagasdouble(BadComplex2()), 0.5)
with warnings.catch_warnings():
warnings.simplefilter("error", DeprecationWarning)
self.assertRaises(DeprecationWarning, imagasdouble, BadComplex2())
self.assertRaises(TypeError, imagasdouble, BadComplex2())
self.assertRaises(RuntimeError, imagasdouble, BadComplex3())

# Test types with __float__ dunder method
self.assertEqual(imagasdouble(Float()), 0.0)
self.assertRaises(TypeError, imagasdouble, BadFloat())
with self.assertWarns(DeprecationWarning):
self.assertEqual(imagasdouble(BadFloat2()), 0.0)
self.assertRaises(TypeError, imagasdouble, BadFloat2())

self.assertRaises(TypeError, imagasdouble, object())

Expand Down
0