-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Closed as not planned
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The __module__
attribute for NamedTupleType.__new__
method is namedtuple_{typename}
. It does not exist. The __module__
attribute for methods should respect the module
argument passed to collections.namedtuple
.
In [1]: import collections
In [2]: MyTuple = collections.namedtuple('MyTuple', ['x', 'y', 'z'])
In [3]: MyTuple.__module__
Out[3]: '__main__'
In [4]: MyTuple.__new__.__module__
Out[4]: 'namedtuple_MyTuple'
In [5]: MyTuple._make.__module__
Out[5]: 'collections'
In [6]: import typing
In [7]: class MyAnotherTuple(typing.NamedTuple):
...: a: int
...: b: float
...:
In [8]: MyAnotherTuple.__module__
Out[8]: '__main__'
In [9]: MyAnotherTuple.__new__.__module__
Out[9]: 'namedtuple_MyAnotherTuple'
In [10]: MyAnotherTuple._make.__module__
Out[10]: 'collections'
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error