Content-Length: 274459 | pFad | https://github.com/python/cpython/issues/132159

D0 Do not shadow user arguments in generated `__new__` by `@warnings.deprecated` · Issue #132159 · python/cpython · GitHub
Skip to content

Do not shadow user arguments in generated __new__ by @warnings.deprecated #132159

@XuehaiPan

Description

@XuehaiPan

Bug report

Bug description:

Follow comment #132055 (comment)

from warnings import deprecated


@deprecated("MyMeta will go away soon")
class MyMeta(type):
    def __new__(mcs, name, bases, attrs, cls=None):
        return super().__new__(mcs, name, bases, attrs)


class Foo(metaclass=MyMeta, cls='haha'):
    pass

Output:

$ python3 test.py
Traceback (most recent call last):
  File "/Users/PanXuehai/Projects/cpython/test.py", line 10, in <module>
    class Foo(metaclass=MyMeta, cls='haha'):
        pass
TypeError: MyMeta.__new__() got multiple values for argument 'cls'

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/132159

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy