@@ -343,7 +343,10 @@ def __new__(cls, num, *args, **kwargs):
343343
344344class Complex (Object , complex ):
345345 """
346- Represents a literal floating-point complex number (:class:`complex`).
346+ Represents a literal floating-point complex number (:class:`complex`). If
347+ ``real`` is itself a :class:`complex` object, its imaginary part is extracted and
348+ added to the imaginary part of the new model, but ``imag``, if provided, must be
349+ real.
347350 """
348351
349352 def __new__ (cls , real , imag = 0 , * args , ** kwargs ):
@@ -354,6 +357,12 @@ def __new__(cls, real, imag=0, *args, **kwargs):
354357 if p2 :
355358 check_inf_nan_cap (p2 , value .imag )
356359 return value
360+ if isinstance (imag , complex ):
361+ raise TypeError ("`imag` must be real" )
362+ if isinstance (real , complex ):
363+ # This is deprecated by Python 3.14's `complex`, so
364+ # extract the imaginary part before passing through.
365+ real , imag = real .real , imag + real .imag
357366 return super ().__new__ (cls , real , imag )
358367
359368
0 commit comments