From 91e3d0180e6b3f34f5a73bdd100663e7b58d173f Mon Sep 17 00:00:00 2001 From: flagos Date: Wed, 15 Jan 2020 10:02:18 +0100 Subject: [PATCH 1/2] fixes #1: builtins change module name python3 --- ProtoText/hook_helper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ProtoText/hook_helper.py b/ProtoText/hook_helper.py index 7ef4cd1..d229f42 100644 --- a/ProtoText/hook_helper.py +++ b/ProtoText/hook_helper.py @@ -1,5 +1,5 @@ import types -import __builtin__ +import builtins import logging HOOK_TABLE_NAME = '__ZX_PY_HOOK_TABLE__' @@ -18,7 +18,7 @@ def register_class_hook(cls, strategy='safe', skip_buildin=True): "The input object must be a class object" base_classes = cls.__bases__ for base_class in base_classes: - if skip_buildin and base_class.__name__ in __builtin__.__dict__: + if skip_buildin and base_class.__name__ in builtins.__dict__: logger.warn("Skip hooking build-in base class '%s' in sub-class '%s' ..." % (base_class.__name__, cls.__name__)) continue @@ -63,4 +63,4 @@ def deregister_class_hook(cls): setattr(base_class, x, _hook_table[x]) else: delattr(base_class, x) - delattr(base_class, HOOK_TABLE_NAME) \ No newline at end of file + delattr(base_class, HOOK_TABLE_NAME) From 3a77742e548ce6b74f972d6f6e7bc78c7c9916f1 Mon Sep 17 00:00:00 2001 From: flagos Date: Wed, 15 Jan 2020 10:18:05 +0100 Subject: [PATCH 2/2] fixes #1: ClassType no more in types --- ProtoText/hook_helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProtoText/hook_helper.py b/ProtoText/hook_helper.py index d229f42..64dd5a9 100644 --- a/ProtoText/hook_helper.py +++ b/ProtoText/hook_helper.py @@ -14,7 +14,7 @@ def register_class_hook(cls, strategy='safe', skip_buildin=True): :param skip_buildin: determine if we skip the build in object :return: """ - assert isinstance(cls, (type, types.ClassType)), \ + assert isinstance(cls, type), \ "The input object must be a class object" base_classes = cls.__bases__ for base_class in base_classes: @@ -49,7 +49,7 @@ def deregister_class_hook(cls): :param cls: the class object of the class to unhook :return: """ - assert isinstance(cls, (type, types.ClassType)), \ + assert isinstance(cls, type), \ "The input object must be a class object" base_classes = cls.__bases__ for base_class in base_classes: