mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.14] gh-139748: fix leaks in AC error paths when using unicode FS-b… (#139789)
* [3.14] gh-139748: fix leaks in AC error paths when using unicode FS-based converters (GH-139765)
(cherry picked from commit b04a57deef)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
077652b44f
commit
90cd009209
14 changed files with 88 additions and 46 deletions
|
|
@ -920,6 +920,26 @@ class unicode_converter(CConverter):
|
|||
return super().parse_arg(argname, displayname, limited_capi=limited_capi)
|
||||
|
||||
|
||||
class _unicode_fs_converter_base(CConverter):
|
||||
type = 'PyObject *'
|
||||
|
||||
def converter_init(self) -> None:
|
||||
if self.default is not unspecified:
|
||||
fail(f"{self.__class__.__name__} does not support default values")
|
||||
self.c_default = 'NULL'
|
||||
|
||||
def cleanup(self) -> str:
|
||||
return f"Py_XDECREF({self.parser_name});"
|
||||
|
||||
|
||||
class unicode_fs_encoded_converter(_unicode_fs_converter_base):
|
||||
converter = 'PyUnicode_FSConverter'
|
||||
|
||||
|
||||
class unicode_fs_decoded_converter(_unicode_fs_converter_base):
|
||||
converter = 'PyUnicode_FSDecoder'
|
||||
|
||||
|
||||
@add_legacy_c_converter('u')
|
||||
@add_legacy_c_converter('u#', zeroes=True)
|
||||
@add_legacy_c_converter('Z', accept={str, NoneType})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue