diff --git a/ProtoText/hook_helper.py b/ProtoText/hook_helper.py index 7ef4cd1..64dd5a9 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__' @@ -14,11 +14,11 @@ 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: - 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 @@ -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: @@ -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)