| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -16057,6 +16057,35 @@ _PyUnicode_FiniTypes(PyInterpreterState *interp) | |
| } | ||
|
|
||
|
|
||
| static void unicode_static_dealloc(PyObject *op) | ||
| { | ||
| PyASCIIObject* ascii = (PyASCIIObject*)op; | ||
|
|
||
| assert(ascii->state.compact); | ||
|
|
||
| if (ascii->state.ascii) { | ||
| if (ascii->wstr) { | ||
| PyObject_Free(ascii->wstr); | ||
| ascii->wstr = NULL; | ||
| } | ||
| } | ||
| else { | ||
| PyCompactUnicodeObject* compact = (PyCompactUnicodeObject*)op; | ||
| void* data = (void*)(compact + 1); | ||
| if (ascii->wstr && ascii->wstr != data) { | ||
| PyObject_Free(ascii->wstr); | ||
| ascii->wstr = NULL; | ||
| compact->wstr_length = 0; | ||
| } | ||
| if (compact->utf8) { | ||
| PyObject_Free(compact->utf8); | ||
| compact->utf8 = NULL; | ||
| compact->utf8_length = 0; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| void | ||
| _PyUnicode_Fini(PyInterpreterState *interp) | ||
| { | ||
| Expand All | @@ -16070,6 +16099,21 @@ _PyUnicode_Fini(PyInterpreterState *interp) | |
| _PyUnicode_FiniEncodings(&state->fs_codec); | ||
|
|
||
| unicode_clear_identifiers(state); | ||
|
|
||
| // Clear the single character singletons | ||
| for (int i = 0; i < 128; i++) { | ||
| unicode_static_dealloc((PyObject*)&_Py_SINGLETON(strings).ascii[i]); | ||
| } | ||
| for (int i = 0; i < 128; i++) { | ||
| unicode_static_dealloc((PyObject*)&_Py_SINGLETON(strings).latin1[i]); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| void | ||
| _PyStaticUnicode_Dealloc(PyObject *op) | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWould it make sense to share code between this function and unicode_dealloc()? Maybe add an unicode_dealloc_common() function?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes, there is the duplication of the PyObect_Free() calls, but not really to the level of what I would consider "in common". I did, however, refactor out the duplication of the 1-character singletons and frozen strings deallocation into a standalone static function.
Sorry, something went wrong.
All reactions
|
||
| { | ||
| unicode_static_dealloc(op); | ||
| } | ||
|
|
||
|
|
||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan you please use with self.subTest(flag=flag, stmt=stmt):? Otherwise, it will be more complicated to debug if a test fails. With that, you can omit f"{xopt}, stmt='{stmt}' -> {out}") below.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDidn't know about TestCase.subTest(), thanks.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.