mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
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.
This commit is contained in:
parent
1eb6c0074d
commit
b9c3da5c89
4 changed files with 19 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue