mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
gh-109218: Deprecate weird cases in the complex() constructor (GH-119620)
* Passing a string as the "real" keyword argument is now an error; it should only be passed as a single positional argument. * Passing a complex number as the "real" or "imag" argument is now deprecated; it should only be passed as a single positional argument.
This commit is contained in:
parent
deda85717b
commit
ef01e95ae3
6 changed files with 164 additions and 61 deletions
|
|
@ -806,7 +806,10 @@ class FractionTest(unittest.TestCase):
|
|||
self.assertTypedEquals(F(3, 2) * Polar(4, 2), Polar(F(6, 1), 2))
|
||||
self.assertTypedEquals(F(3, 2) * Polar(4.0, 2), Polar(6.0, 2))
|
||||
self.assertTypedEquals(F(3, 2) * Rect(4, 3), Rect(F(6, 1), F(9, 2)))
|
||||
self.assertTypedEquals(F(3, 2) * RectComplex(4, 3), RectComplex(6.0+0j, 4.5+0j))
|
||||
with self.assertWarnsRegex(DeprecationWarning,
|
||||
"argument 'real' must be a real number, not complex"):
|
||||
self.assertTypedEquals(F(3, 2) * RectComplex(4, 3),
|
||||
RectComplex(6.0+0j, 4.5+0j))
|
||||
self.assertRaises(TypeError, operator.mul, Polar(4, 2), F(3, 2))
|
||||
self.assertTypedEquals(Rect(4, 3) * F(3, 2), 6.0 + 4.5j)
|
||||
self.assertEqual(F(3, 2) * SymbolicComplex('X'), SymbolicComplex('3/2 * X'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue