FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

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

Repository navigation

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

Closed

Description

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

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Apr 6, 2025
  2. added a commit that references this issue on Apr 6, 2025
  3. added a commit that references this issue on Apr 6, 2025
  4. added a commit that references this issue on Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL