File tree Expand file tree Collapse file tree 6 files changed +26
-4
lines changed Expand file tree Collapse file tree 6 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ Version 0.10.2
21
21
(bugfix release, release date to be announced)
22
22
23
23
- Fixed broken `test_appcontext_signals()` test case.
24
+ - Raise an :exc:`AttributeError` in :func:`flask.helpers.find_package` with a
25
+ useful message explaining why it is raised when a PEP 302 import hook is used
26
+ without an `is_package()` method.
24
27
25
28
Version 0.10.1
26
29
--------------
Original file line number Diff line number Diff line change @@ -350,7 +350,7 @@ JSON Support
350
350
Flask uses ``simplejson `` for the JSON implementation. Since simplejson
351
351
is provided both by the standard library as well as extension Flask will
352
352
try simplejson first and then fall back to the stdlib json module. On top
353
- of that it will delegate access to the current application's JSOn encoders
353
+ of that it will delegate access to the current application's JSON encoders
354
354
and decoders for easier customization.
355
355
356
356
So for starters instead of doing::
Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ A basic FastCGI configuration for lighttpd looks like that::
149
149
url.rewrite-once = (
150
150
"^(/static($|/.*))$" => "$1",
151
151
"^(/.*)$" => "/yourapplication.fcgi$1"
152
+ )
152
153
153
154
Remember to enable the FastCGI, alias and rewrite modules. This configuration
154
155
binds the application to `/yourapplication `. If you want the application to
Original file line number Diff line number Diff line change @@ -1547,7 +1547,7 @@ def make_response(self, rv):
1547
1547
:class:`tuple` A tuple in the form ``(response, status,
1548
1548
headers)`` where `response` is any of the
1549
1549
types defined here, `status` is a string
1550
- or an integer and `headers` is a list of
1550
+ or an integer and `headers` is a list or
1551
1551
a dictionary with header values.
1552
1552
======================= ===========================================
1553
1553
Original file line number Diff line number Diff line change @@ -679,8 +679,13 @@ def find_package(import_name):
679
679
filename = sys .modules [import_name ].__file__
680
680
package_path = os .path .abspath (os .path .dirname (filename ))
681
681
# package_path ends with __init__.py for a package
682
- if loader .is_package (root_mod_name ):
683
- package_path = os .path .dirname (package_path )
682
+ if hasattr (loader , 'is_package' ):
683
+ if loader .is_package (root_mod_name ):
684
+ package_path = os .path .dirname (package_path )
685
+ else :
686
+ raise AttributeError (
687
+ ('%s.is_package() method is missing but is '
688
+ 'required by Flask of PEP 302 import hooks' ) % loader .__class__ .__name__ )
684
689
685
690
site_parent , site_folder = os .path .split (package_path )
686
691
py_prefix = os .path .abspath (sys .prefix )
Original file line number Diff line number Diff line change 16
16
import unittest
17
17
from contextlib import contextmanager
18
18
from flask .testsuite import FlaskTestCase
19
+ from flask ._compat import PY2
19
20
20
21
21
22
# config keys used for the ConfigTestCase
@@ -291,6 +292,18 @@ def test_egg_installed_paths(self):
291
292
if 'site_egg' in sys .modules :
292
293
del sys .modules ['site_egg' ]
293
294
295
+ if PY2 :
296
+ def test_meta_path_loader_without_is_package (self ):
297
+ class Loader (object ):
298
+ def find_module (self , name ):
299
+ return self
300
+ sys .meta_path .append (Loader ())
301
+ try :
302
+ with self .assert_raises (AttributeError ):
303
+ flask .Flask (__name__ )
304
+ finally :
305
+ sys .meta_path .pop ()
306
+
294
307
295
308
def suite ():
296
309
suite = unittest .TestSuite ()
You can’t perform that action at this time.
0 commit comments