-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
bpo-41842: Add a unregister function in _codecs module #22360
Conversation
0692346
to
03645a7
Compare
03645a7
to
fefda70
Compare
Pls take a look if you have free times, thanks. @vstinner @serhiy-storchaka |
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.
Can you please add an entry in the Doc/whatsnew/3.10.rst document? You have to add a news "codecs" section near:
https://docs.python.org/dev/whatsnew/3.10.html#improved-modules
Misc/NEWS.d/next/Library/2020-09-22-20-54-18.bpo-39337.zX2e5M.rst
Outdated
Show resolved
Hide resolved
It would be nice to use this new function to remove an old side effect of test_codecs: codecs.register(_get_test_codec) registers a search function which is never unregistered. Maybe ExceptionChainingTest.setUp() method should register the search function and use self.addCleanup(codecs.unregister, _get_test_codec)? |
See this comment of test_codecs.py:
|
Old email requesting codecs.unregister() function: https://mail.python.org/pipermail/python-dev/2011-September/113588.html |
https://bugs.python.org/issue39337 is not directly related to codecs.unregister(). @shihai1991: I created https://bugs.python.org/issue41842 "Add codecs.unregister() to unregister a codec search function": please use this bpo for your PR. |
+1, it is in my TODO list :) |
Updating test_codecs can be done in a second following PR if you prefer. |
copy that, this bpo have been used in this PR. |
Misc/NEWS.d/next/Library/2020-09-23-22-52-24.bpo-41842.lIuhC9.rst
Outdated
Show resolved
Hide resolved
* origin/master: (27 commits) bpo-41428: Fix compiler warnings in unionobject.c (pythonGH-22388) bpo-41654: Fix compiler warning in MemoryError_dealloc() (pythonGH-22387) bpo-41833: threading.Thread now uses the target name (pythonGH-22357) bpo-30155: Add macros to get tzinfo from datetime instances (pythonGH-21633) bpo-33822: Update IDLE section of What's New 3.8 (pythonGH-22383) bpo-41844: Add IDLE section to What's New 3.9 (GN-22382) bpo-41841: Prepare IDLE News for 3.10 (pythonGH-22379) bpo-37779 : Add information about the overriding behavior of ConfigParser.read (pythonGH-15177) bpo-40170: Use inline _PyType_HasFeature() function (pythonGH-22375) bpo-40941: Fix stackdepth compiler warnings (pythonGH-22377) bpo-40941: Fix fold_tuple_on_constants() compiler warnings (pythonGH-22378) bpo-40521: Fix PyUnicode_InternInPlace() (pythonGH-22376) bpo-41834: Remove _Py_CheckRecursionLimit variable (pythonGH-22359) bpo-1635741, unicodedata: add ucd_type parameter to UCD_Check() macro (pythonGH-22328) bpo-1635741: Port _lsprof extension to multi-phase init (PEP 489) (pythonGH-22220) bpo-41513: Improve order of adding fractional values. Improve variable names. (pythonGH-22368) bpo-41816: `StrEnum.__str__` is `str.__str__` (pythonGH-22362) bpo-35764: Rewrite the IDLE Calltips doc section (pythonGH-22363) bpo-41810: Reintroduce `types.EllipsisType`, `.NoneType` & `.NotImplementedType` (pythonGH-22336) bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (python#21956) ...
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.
LGTM. I just requested a bunch of minor edits.
I leave the PR open a few days if @malemburg wants to have a look.
Python/codecs.c
Outdated
return 0; | ||
} | ||
|
||
Py_ssize_t n = PyList_Size(codec_search_path); |
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.
Please use the macro PyList_GET_SIZE()
instead of PyList_Size()
, as codec_search_path
is guaranteed to be a list.
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.
While it's a list right now, its type can change tomorrow.
@shihai1991: If you modify the code to use fast macros, please add the following assertion before using it:
assert(PyList_CheckExact(interp->codec_search_path));
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.
@vstinner Copy that, I have already updated it.
But I have a question. assert(PyList_Check(op)
in _PyList_CAST()
is not good enough?
Misc/NEWS.d/next/Library/2020-09-23-22-52-24.bpo-41842.lIuhC9.rst
Outdated
Show resolved
Hide resolved
Merged, thank you @shihai1991! |
Thanks for everyone's review: ). |
* origin/master: (113 commits) bpo-41773: Raise exception for non-finite weights in random.choices(). (pythonGH-22441) bpo-41873: Add vectorcall for float() (pythonGH-22432) bpo-41861: Convert _sqlite3 PrepareProtocolType to heap type (pythonGH-22428) bpo-41842: Add codecs.unregister() function (pythonGH-22360) bpo-41875: Use __builtin_unreachable when possible (pythonGH-22433) bpo-40105: ZipFile truncate in append mode with shorter comment (pythonGH-19337) bpo-41870: Use PEP 590 vectorcall to speed up bool() (pythonGH-22427) [doc] Leverage the fact that the actual types can now be indexed for typing (pythonGH-22340) bpo-41861: Convert _sqlite3 cache and node static types to heap types (pythonGH-22417) bpo-41858: Clarify line in optparse doc (pythonGH-22407) Revert "Fix all Python Cookbook links (python#22205)" (pythonGH-22424) bpo-1635741: Port _bisect module to multi-phase init (pythonGH-22415) bpo-41428: Fix compiler warning in unionobject.c (pythonGH-22416) Fix logging error message (pythonGH-22410) bpo-39934: Account for control blocks in 'except' in compiler. (pythonGH-22395) bpo-41775: Make 'IDLE Shell' the shell title (python#22399) bpo-41428: Fix compiler warnings in unionobject.c (pythonGH-22388) bpo-41654: Fix compiler warning in MemoryError_dealloc() (pythonGH-22387) bpo-41833: threading.Thread now uses the target name (pythonGH-22357) bpo-30155: Add macros to get tzinfo from datetime instances (pythonGH-21633) ...
Add codecs.unregister() and PyCodec_Unregister() functions to unregister a codec search function.
Add a _codecs.unregister() in _codecs module to unregister search function.
https://bugs.python.org/issue41842