[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:
Kumar Aditya 2025-10-08 22:16:21 +05:30 committed by GitHub
parent 077652b44f
commit 90cd009209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 88 additions and 46 deletions

View file

@ -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})