Commit a69d44dd authored by Kirill Smelkov's avatar Kirill Smelkov

fixup! X golang_str: More fixes for bstr to be accepted as name of an attribute

Contrary to py3.11, py3.9 also explicitly checks for unicode inside
builtin getattr. -> Patch that explicitly as well.
parent 84ed3e79
Pipeline #34425 running with stage
in 0 seconds
......@@ -2057,6 +2057,36 @@ cdef _patch_capi_object_attr_bstr():
cpatch(<void**>&_pobject_HasAttr, <void*>_object_xHasAttr)
cpatch(<void**>&_pobject_LookupAttr, <void*>_object_xLookupAttr)
# py3 < 3.11 also verifies name to be unicode
# XXX move out of _patch_capi* ?
import builtins
cdef object builtins_getattr = builtins.getattr
cdef object builtins_setattr = builtins.setattr
cdef object builtins_delattr = builtins.delattr
cdef object builtins_hasattr = builtins.hasattr
def xgetattr(obj, name, *argv):
if isbstr(name):
name = pyustr(name)
return builtins_getattr(obj, name, *argv)
def xsetattr(obj, name, value):
if isbstr(name):
name = pyustr(name)
return builtins_setattr(obj, name, value)
def xdelattr(obj, name):
if isbstr(name):
name = pyustr(name)
return builtins_delattr(obj, name)
def xhasattr(obj, name):
if isbstr(name):
name = pyustr(name)
return builtins_hasattr(obj, name)
builtins.getattr = xgetattr
builtins.setattr = xsetattr
builtins.delattr = xdelattr
builtins.hasattr = xhasattr
# ---- misc ----
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment