[issue14710] pkgutil.get_loader is broken
New submission from Pavel Aslanov : if module was marked as not existing by setting sys.modules [fullname] to None, then pkgutil.get_loader (fullname) will throw AttributeError. Example: #! /usr/bin/evn python import unittest import pkgutil def main (): pkgutil.get_loader ('unittest.functools') if __name__ == '__main__': main () Patch is attached -- components: Library (Lib) files: python_pkgutil_bug.patch keywords: patch messages: 159848 nosy: Pavel.Aslanov priority: normal severity: normal status: open title: pkgutil.get_loader is broken type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file25442/python_pkgutil_bug.patch ___ Python tracker <http://bugs.python.org/issue14710> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14710] pkgutil.get_loader is broken
Pavel Aslanov added the comment: Main use case of pkgutil.get_loader is to determine if its possible to load module and either return loader or None. But it throws exception more over it is AttributeErrror exception. -- ___ Python tracker <http://bugs.python.org/issue14710> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14710] pkgutil.get_loader is broken
Pavel Aslanov added the comment: This function is broken again in version 3.4 The way it should look is: Python 2.7.6 (default, Feb 26 2014, 12:07:17) [GCC 4.8.2 20140206 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pkgutil >>> pkgutil.get_loader('no_such_module') # returns None >>> How it really looks: Python 3.4.0 (default, Apr 27 2014, 23:33:09) [GCC 4.8.2 20140206 (prerelease)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pkgutil >>> pkgutil.get_loader('no_such_module') Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.4/pkgutil.py", line 467, in get_loader return find_loader(fullname) File "/usr/lib/python3.4/pkgutil.py", line 488, in find_loader return spec.loader AttributeError: 'NoneType' object has no attribute 'loader' >>> find_loader is at fault (change "return spec.loader" -> "return spec and spec.loader"). Thanks. -- ___ Python tracker <http://bugs.python.org/issue14710> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com