-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement
Description
Bug report
Bug description:
An example:
>>> bytes.maketrans.__module__ is None
True
c.f. pure-python staticmethod:
>>> class Spam:
... @staticmethod
... def foo():
... pass
...
>>> Spam.foo.__module__
'__main__'
I'm not sure, maybe this should be treated rather as a feature request. Docs says about the attribute value: "The name of the module the function was defined in, or None if unavailable." But clearly, this value is available: the type_add_method()
has type
argument and we could query value of its __module__
attribute.
Edit: BTW, same happens for class methods, e.g.:
>>> int.from_bytes.__module__ is None
True
Probably this should be fixed as well.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement