Suspicious code in #61

pyscripter opened this Issue Jan 7, 2012 · 0 comments


None yet

2 participants


In the load function of I see the following code:

if instantiate_custom_exceptions:
    if modname in sys.modules:
        cls = getattr(sys.modules[modname], clsname, None)
    elif not is_py3k and modname == "builtins":
        cls = getattr(exceptions_module, clsname, None)
        cls = None

The second if statement looks suspicious because it will never be true.

Furter below in the same function I see the following code:

if not isinstance(cls, (type, ClassType)):
    cls = None
elif issubclass(cls, ClassType) and not instantiate_oldstyle_exceptions:
    cls = None
elif not issubclass(cls, BaseException):
    cls = None

In python 3k ClassType will be pointing to type and issubclass will always return True and if it is combined with instantiate_oldstyle_exceptions set to True will give the unwantd result cls = None

@tomerfiliba tomerfiliba was assigned Feb 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment