-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected __module__
attribute for NamedTupleType.__new__
method: namedtuple_{typename}
#127187
Comments
Is there any reason users would care about this? Is there any real world impact? The current result seems reasonable to me. The |
I'm trying to improve namedtuple support in PyTorch Dynamo, an ML compiler backend with a lightweight Python interpreter. Dynamo traces the Python frames and generates performat inlined functions via traced opcodes. The The codegen tries to import the def get_globals_source_and_value(self, name):
if "__name__" in self.f_globals:
module_name = self.f_globals["__name__"]
module_source = self.import_source(module_name)
if "torch_package" in module_name:
fglobals_value = torch.package.package_importer._package_imported_modules[module_name] # type: ignore[assignment]
else:
fglobals_value = importlib.import_module(module_name) # type: ignore[assignment]
fglobals_vt = VariableTracker.build(self, fglobals_value, module_source)
global_source = AttrSource(module_source, name) |
For PyTorch is this a show stopper or is a workaround available? How would |
Bug report
Bug description:
The
__module__
attribute forNamedTupleType.__new__
method isnamedtuple_{typename}
. It does not exist. The__module__
attribute for methods should respect themodule
argument passed tocollections.namedtuple
.CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
__module__
attribute for methods of named tuple types #127188The text was updated successfully, but these errors were encountered: