{"action":"opened","issue":{"url":"https://api.github.com/repos/wbolster/qualname/issues/2","labels_url":"https://api.github.com/repos/wbolster/qualname/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/wbolster/qualname/issues/2/comments","events_url":"https://api.github.com/repos/wbolster/qualname/issues/2/events","html_url":"https://github.com/wbolster/qualname/issues/2","id":115890999,"number":2,"title":"AttributeError raised when using dynamically defined class","user":{"login":"jakirkham","id":3019665,"avatar_url":"https://avatars.githubusercontent.com/u/3019665?v=3","gravatar_id":"","url":"https://api.github.com/users/jakirkham","html_url":"https://github.com/jakirkham","followers_url":"https://api.github.com/users/jakirkham/followers","following_url":"https://api.github.com/users/jakirkham/following{/other_user}","gists_url":"https://api.github.com/users/jakirkham/gists{/gist_id}","starred_url":"https://api.github.com/users/jakirkham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakirkham/subscriptions","organizations_url":"https://api.github.com/users/jakirkham/orgs","repos_url":"https://api.github.com/users/jakirkham/repos","events_url":"https://api.github.com/users/jakirkham/events{/privacy}","received_events_url":"https://api.github.com/users/jakirkham/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-09T14:45:17Z","updated_at":"2015-11-09T14:45:17Z","closed_at":null,"body":"Given the following file.\r\n\r\n    # classmaker.py\r\n    def f():\r\n        return type('NewCls', (object,), dict())\r\n\r\nTrying to get the qualified name fails.\r\n\r\n    >>> import qualname\r\n    >>> import classmaker\r\n    >>> qualname.qualname(classmaker.f())\r\n    ---------------------------------------------------------------------------\r\n    AttributeError                            Traceback (most recent call last)\r\n    <ipython-input-7-03af44776c0f> in <module>()\r\n    ----> 1 qualname.qualname(c)\r\n    \r\n    /opt/conda/lib/python2.7/site-packages/qualname.pyc in qualname(obj)\r\n         53             _, lineno = inspect.getsourcelines(obj)\r\n         54         except (OSError, IOError):\r\n    ---> 55             return obj.__qualname__  # raises a sensible error\r\n         56     elif inspect.isfunction(obj) or inspect.ismethod(obj):\r\n         57         if hasattr(obj, 'im_func'):\r\n    \r\n    AttributeError: type object 'NewCls' has no attribute '__qualname__'\r\n\r\nTrying to do so with the object stored also fails.\r\n\r\n    >>> c = classmaker.f()\r\n    >>> qualname.qualname(c)\r\n    ---------------------------------------------------------------------------\r\n    AttributeError                            Traceback (most recent call last)\r\n    <ipython-input-7-03af44776c0f> in <module>()\r\n    ----> 1 qualname.qualname(c)\r\n    \r\n    /opt/conda/lib/python2.7/site-packages/qualname.pyc in qualname(obj)\r\n         53             _, lineno = inspect.getsourcelines(obj)\r\n         54         except (OSError, IOError):\r\n    ---> 55             return obj.__qualname__  # raises a sensible error\r\n         56     elif inspect.isfunction(obj) or inspect.ismethod(obj):\r\n         57         if hasattr(obj, 'im_func'):\r\n    \r\n    AttributeError: type object 'NewCls' has no attribute '__qualname__'\r\n\r\nWhen running the same sorts of things on Python 3.4.3, I see the following.\r\n\r\n    >>> classmaker.f().__qualname__\r\n    'NewCls'\r\n    >>> c.__qualname__\r\n    'NewCls'"}}