New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkgutil.walk_packages fails on write-only directory in sys.path #51616
Comments
I spend the better part of a day figuring out this relatively simple I came about the solution by following the code errors all over Eventual I came about the public folder ex.. I spent time looking through the properties and settings tabs editing my I simply right clicked on the public folder and my permission was set Hope i just saved some one some time. |
Can you be more specific about how to reproduce the problem you saw? Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) |
Python 2.6.4 From the best I can tell the error came about The solution as I said came about from simply changing the user access I initially came across the error when attempting to get a modules list Hope that clears things. |
A more specific issue title will also help others hitting the same |
OK, now that makes more sense! The problem is that somehow you had a write-only directory ("~/Public/Drop import sys
sys.path you will likely see the "Drop Box" directory in the list of paths (assuming When you run the "modules" help command, the python help module, pydoc, uses While the pkgutil.walk_packages function tries to handle most errors, it import os, pkgutil, sys
dirname_wo = os.tempnam()
os.mkdir(dirname_wo, 0222) # write permission only
try:
sys.path.insert(0, dirname_wo)
def onerror(pkgname):
print('onerror called for package %s' % pkgname)
for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
print modname
finally:
os.rmdir(dirname_wo) The long-term solution is to have pkgutil.walk_packages protect itself In your case, though, you should check for and remove whatever is adding |
More precisely: you should check for and remove whatever is adding |
New changeset 096b010ae90b by Ned Deily in branch '2.7': New changeset 1449095397ae by Ned Deily in branch '2.7': New changeset a1e6633ef3f1 by Ned Deily in branch '3.2': New changeset 77bac85f610a by Ned Deily in branch '3.2': New changeset 5a4018570a59 by Ned Deily in branch '3.2': New changeset 0408001e4765 by Ned Deily in branch 'default': |
The applied changesets correct pkgutil's walk_packages for "classic" imports to ignore unreadable directories the same way that the interpreter's import does. With this fix to pkgutil, pydoc -k also no longer fails in this case. Applied in 2.7 (for 2.7.3), 3.2 (for 3.2.3), and default (for 3.3.0). |
New changeset 17b5afd321a8 by Ned Deily in branch '2.7': New changeset ff72f76dcf43 by Ned Deily in branch '3.2': |
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
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: