You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2017-06-13.17:12:32.797>created_at=<Date2015-07-28.16:11:28.031>labels= ['3.7', 'type-bug', 'library']
title='Lack of type checks in pkgutil.walk_packages and friends'updated_at=<Date2017-06-13.17:12:32.796>user='https://bugs.python.org/sleepycal'
The documentation states that pkgutil.walk_packages() path must be None or a list of paths . After passing in a string, the result was a blank list rather than a type error or automatic conversion to a list.
If this method is documented that it must only accept a list or None, then there should surely be type checks to this effect? This was a bit of a gotcha that left me head scratching for 30 minutes (after not realising it only took a list, not an str, which in itself seems a bit odd)
Well, normally no, we don't use type checks. On the other hand, having it produce an incorrect result rather than an error of *some* sort is not so good (the problem is that it is ultimately calling map(func, path), and map happily iterates the string applying func to each character in turn), so in this case I think it is worth the explicit check for string.
In thinking about merging this, I realize something I should have thought about earlier: we are proposing to raise an error where none was previously raised. Now, any code that would hit this would be broken, but nonetheless, by our backward compatibility policy we should do this only in 3.7, and we should add a note to the porting section of What's New. And the PR needs a news entry.