-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Python 3.4 changed pkgutil.get_loader
behavior
#1011
Comments
Some forgotten information: Python 3.4 changed pkgutil.get_loader to align with PEP-451. |
That PR was done just using the inline editor. If I get time sometime I'll get another one with tests and such, but there's at least that. |
I chatted with Eric Snow about this at PyCon (Eric did the pkgutil work) and he's fixed it for 3.4.1. Until then, this is probably the best available solution. |
Closing this here. The latest code already deals with 3.4 support. |
Can you clarify? I have Flask 0.10.1 (the lastest, I believe) and Python 3.4.1, and I'm getting this error (specifically if I install snakemake and do |
@pfmoore It's because case problem. |
@methane - ah, thanks. I hadn't spotted that |
Avoid several test failures like: ====================================================================== ERROR: test_credentialed_request (tests.test_credentials.AppConfigExposeHeadersTestCase) AppConfigExposeHeadersTestCase.test_credentialed_request ---------------------------------------------------------------------- Traceback (most recent call last): File "/.../tests/base_test.py", line 82, in setUp self.app = Flask(self.__class__.__name__) File "/usr/lib64/python3.4/site-packages/flask/app.py", line 319, in __init__ template_folder=template_folder) File "/usr/lib64/python3.4/site-packages/flask/helpers.py", line 741, in __init__ self.root_path = get_root_path(self.import_name) File "/usr/lib64/python3.4/site-packages/flask/helpers.py", line 631, in get_root_path loader = pkgutil.get_loader(import_name) File "/usr/lib64/python3.4/pkgutil.py", line 469, in get_loader return find_loader(fullname) File "/usr/lib64/python3.4/pkgutil.py", line 490, in find_loader return spec.loader AttributeError: 'NoneType' object has no attribute 'loader' on Python 3.4 [1]. The solution is to use an importable name [2]: > About the First Parameter > > The idea of the first parameter is to give Flask an idea what > belongs to your application. This name is used to find resources on > the file system, can be used by extensions to improve debugging > information and a lot more. > > So it’s important what you provide there. If you are using a single > module, __name__ is always the correct value. If you however are > using a package, it’s usually recommended to hardcode the name of > your package there. Previously we were using the class name (not the module name), but you can't use that to import anything ;). [1]: pallets/flask#1011 [2]: http://flask.pocoo.org/docs/0.10/api/#flask.Flask
Can Flask revisit fixing this for Python 3.4.0? With Ubuntu Trusty having 3.4.0 installed, there are environments where upgrading to 3.4.1 to deal with this bug is a pain. |
Considering for next bugfix release. |
thank you for reconsidering! |
I am currently reconsidering fixing this issue. I don't think it's a good idea for Flask to work around this behavior, see #1481. The fix seems easy, but Flask/Werkzeug have already far too much cruft accumulated that results in accepting workarounds like these. I also don't think that Python 3 currently has a userbase big enough for our workaround to matter, which would probably be released when it's already too late and Ubuntu has updated its Python 3 package. If you really have to use 3.4.0, doing this fix seems easy enough to do in usercode through monkeypatching:
I'll still leave this issue open, because I'm not the only one to decide this, and we already recieved a considerable amount of bug reports because of this issue. |
I can relate with not wanting to add cruft to a code base. My understanding is that since Django switched to Python3 by default that the user base for 3 is a decent chunk (numbers I heard at PyCon ranged from 4-15%). I found some stats but I'm not sure how reliable they are. I'm unsure how large the user base really is at this point. But I am fairly sure it's large enough that if Monkey patch is an acceptable answer than a documentation change should happen (at least) because I spent a hefty chunk of time tracking this issue down. |
Agree completely.
Thanks for tracking this down! This issue (including the monkey-patch solution) should suffice for docs as it's easily found by googling the error message. For now, I'm going to go ahead and close this. If any of the other maintainers disagree, feel free to re-open. |
In doing a test upgrade to python 3.4 I encountered the following traceback (snippet)
I was able to resolve it with the following:
If you want a formal pull request, I'd be happy to provide one, and do it "right", this feels pretty brute-force, I'm sure there's a better way.
The text was updated successfully, but these errors were encountered: