Skip to content
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

[BUG] deepfreeze modifies the original dict #96

Closed
kenodegard opened this issue Apr 13, 2024 · 5 comments
Closed

[BUG] deepfreeze modifies the original dict #96

kenodegard opened this issue Apr 13, 2024 · 5 comments
Assignees
Labels
Effort: Low easy task Needs: Test Hey, it compiles! Ship it! Priority: High A blocking bug or an important feature Status: Fixed Now it works! Type: Defect Something works, but can work better

Comments

@kenodegard
Copy link
Contributor

Welcome! You should write in your Bug Report:

OS version (https://www.google.com/search?channel=fs&q=check+os+version&ie=utf-8&oe=utf-8):
macOS 14.3

Python3 version (python3 -V -V):
Python 3.12.2

Steps to reproduce:

  1. Create some nested dict and call deepfreeze on it.

Actual result (with the python stack trace if present):

>>> o = {'a': 1, 'nested': {'b': 2}}
>>> d = deepfreeze(o)
>>> d
frozendict.frozendict({'a': 1, 'nested': frozendict.frozendict({'b': 2})})
>>> o
{'a': 1, 'nested': frozendict.frozendict({'b': 2})}

I expected deepfreeze to leave the original object untouched.

@Marco-Sulla
Copy link
Owner

Well, that's why is called deepfreeze. If you want to freeze only the main object, do

d = frozendict.frozendict(o)

@kenodegard
Copy link
Contributor Author

But frozendict will only make the outter most object immutable.

Isn't the goal of deepfreeze to create a recursively immutable object?

I'm not understanding why deepfreeze should have any affect the original data structure.

@Marco-Sulla
Copy link
Owner

I'm not understanding why deepfreeze should have any affect the original data structure.

Can you please provide the expected output?

@Marco-Sulla
Copy link
Owner

Sorry for misunderstanding, the patch will be released in v2.4.2

@Marco-Sulla Marco-Sulla added Type: Defect Something works, but can work better Status: Fixed Now it works! Priority: High A blocking bug or an important feature Effort: Low easy task Needs: Test Hey, it compiles! Ship it! labels Apr 14, 2024
@Marco-Sulla
Copy link
Owner

v2.4.2 released on Pypi and on Conda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Effort: Low easy task Needs: Test Hey, it compiles! Ship it! Priority: High A blocking bug or an important feature Status: Fixed Now it works! Type: Defect Something works, but can work better
Projects
None yet
Development

No branches or pull requests

2 participants