| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Don't call the constructor of the subclass, but frozendict constructor instead.
There was a problem hiding this comment.
I think we should discuss this before taking any action here.
Do we really need to handle cases where users shoot themselves in the foot? It doesn’t cause a crash at the moment, right?
Sorry, something went wrong.
|
Currently, frozendict.fromkeys() allows modifying an immutable frozendict using a special subclass. Example: class SpecialDict(frozendict):
def __new__(self):
return frozendict(x=None)
print(SpecialDict.fromkeys("y"))Current output: frozendict({'x': None, 'y': None})
That's bad: the immutable frozendict is mutated! |
Sorry, something went wrong.
|
How about copy whole object at Line 3319 in dd64e42 It follows the original intention of immutable data structures: copy instead of mutating. |
Sorry, something went wrong.
Ok, good idea: I wrote #144952 to copy the frozendict. |
Sorry, something went wrong.
|
I close this PR in favor of #144952 fix. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Don't call the constructor of the subclass, but frozendict constructor instead.