Fixed an issue decoding Dataclass and TypedDict instances - #1126
mishmish66 wants to merge 1 commit into
Conversation
… unicode fields wouldn't decode properly since the nocheck path was run without cached unicode values.
There was a problem hiding this comment.
Mhm. I'm not sure if this is the best way to fix the issue. Invoking PyUnicode_AsUTF8 purely for its side effect doesn't seem to great. We're not doing this elsewhere for UTF8 either, so I would suggest not introducing this pattern for this particular path only.
Have you checked if other types (Struct, NamedTuple, attrs classes) are also affected? If not, dataclasses / TypedDicts should handle this the same way these do.
|
Pls run each of these tests in a fresh subprocess. If an earlier test encodes a dataclass with |
To reproduce try this snippet (in a fresh process):
Can't decode π because it is unicode and hasn't been loaded into the unicode cache yet
But this:
works fine since the cache is populated during encoding.
This PR should have a fix for this and also a test that fails the old unfixed version.