diff options
author | Sanyam Khurana <CuriousLearner@users.noreply.github.com> | 2017-06-13 17:11:14 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2017-06-13 17:11:14 (GMT) |
commit | b9c3da5c89c66dcccf382e8f196746da2a06d4cc (patch) | |
tree | cc99f575ae032c7e98b7cc5d1cc707e4b52dc4a2 /Lib/test/test_pkgutil.py | |
parent | 1eb6c0074d17f4fd425cacfdda893d65f5f77f0a (diff) | |
download | cpython-b9c3da5c89c66dcccf382e8f196746da2a06d4cc.zip cpython-b9c3da5c89c66dcccf382e8f196746da2a06d4cc.tar.gz cpython-b9c3da5c89c66dcccf382e8f196746da2a06d4cc.tar.bz2 |
bpo-24744: Raises error in pkgutil.walk_packages if path is str (#1926)
bpo-24744: Raise error in pkgutil.walk_packages if path is str
Previously an empty result list was accidentallly returned, since the
code iterated over the string as if it were the expected list of paths,
and of course found nothing.
Diffstat (limited to 'Lib/test/test_pkgutil.py')
-rw-r--r-- | Lib/test/test_pkgutil.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index fc04dcf..2887ce6 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -176,6 +176,15 @@ class PkgutilTests(unittest.TestCase): continue del sys.modules[pkg] + def test_walk_packages_raises_on_string_or_bytes_input(self): + + str_input = 'test_dir' + with self.assertRaises((TypeError, ValueError)): + list(pkgutil.walk_packages(str_input)) + + bytes_input = b'test_dir' + with self.assertRaises((TypeError, ValueError)): + list(pkgutil.walk_packages(bytes_input)) class PkgutilPEP302Tests(unittest.TestCase): |