Skip to content

fix for deduperreload global env in case of function decorator from imported module#14922

Merged
krassowski merged 1 commit intoipython:mainfrom
smacke:deduperreload-decorator-from-imported-module-fix
Jun 27, 2025
Merged

fix for deduperreload global env in case of function decorator from imported module#14922
krassowski merged 1 commit intoipython:mainfrom
smacke:deduperreload-decorator-from-imported-module-fix

Conversation

@smacke
Copy link
Copy Markdown
Contributor

@smacke smacke commented Jun 12, 2025

What changes are proposed in this pull request?

In deduperreload, if the function we're patching is decorated by a function coming from another file, we don't want to use the __globals__ of that function coming from the other file when we exec code, since it won't have the same references as the function we're trying to patch. Actually, I think we always should be using the module's __dict__ as globals regardless for this case -- so I think we can just delete some code that was trying to be clever around setting the global env.

How is this tested?

Tested with existing unit tests + added a new one that only passes with the new changes in this PR

@smacke
Copy link
Copy Markdown
Contributor Author

smacke commented Jun 12, 2025

FYI @jaysarva

Copy link
Copy Markdown
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @smacke!

@krassowski krassowski added this to the 9.4 milestone Jun 25, 2025
@krassowski krassowski merged commit cf2221a into ipython:main Jun 27, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants