Skip to content

Conversation

@dr-carlos
Copy link
Contributor

@dr-carlos dr-carlos commented Nov 4, 2025

@JelleZijlstra JelleZijlstra added the needs backport to 3.14 bugs and security fixes label Nov 6, 2025
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks! Could you also add a unit test asserting that if a locals dictionary is passed in, it's not modified?

try:
globals[cell_name] = cell_value.cell_contents
if cell_name not in locals:
locals[cell_name] = cell_value.cell_contents
Copy link
Member

Choose a reason for hiding this comment

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

Can you narrow the try-except so it only covers this line? (The part that can raise ValueError is the .cell_contents attribute read.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully replacing with setdefault is fine - if the object doesn't have a 'setdefault' attribute, it will raise an AttributeError not ValueError.

@dr-carlos
Copy link
Contributor Author

Thanks! Could you also add a unit test asserting that if a locals dictionary is passed in, it's not modified?

Added one to test globals and locals, since they're both dicts which are mutable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants