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:
Serhiy Storchaka 2024-05-30 23:30:57 +03:00 committed by GitHub
parent deda85717b
commit ef01e95ae3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 164 additions and 61 deletions

View file

@ -449,6 +449,10 @@ are always available. They are listed here in alphabetical order.
Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and
:meth:`~object.__float__` are not defined.
.. deprecated:: 3.14
Passing a complex number as the *real* or *imag* argument is now
deprecated; it should only be passed as a single positional argument.
.. function:: delattr(object, name)

View file

@ -103,6 +103,10 @@ Optimizations
Deprecated
==========
* Passing a complex number as the *real* or *imag* argument in the
:func:`complex` constructor is now deprecated; it should only be passed
as a single positional argument.
(Contributed by Serhiy Storchaka in :gh:`109218`.)
Removed