Skip to content

Commit 51d7c8d

Browse files
committed
Merge branch 'master' of github.com:mitsuhiko/flask
2 parents 05161d3 + 29f3a1a commit 51d7c8d

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Version 0.10.2
2121
(bugfix release, release date to be announced)
2222

2323
- 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.
2427

2528
Version 0.10.1
2629
--------------

docs/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ JSON Support
350350
Flask uses ``simplejson`` for the JSON implementation. Since simplejson
351351
is provided both by the standard library as well as extension Flask will
352352
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
354354
and decoders for easier customization.
355355

356356
So for starters instead of doing::

docs/deploying/fastcgi.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ A basic FastCGI configuration for lighttpd looks like that::
149149
url.rewrite-once = (
150150
"^(/static($|/.*))$" => "$1",
151151
"^(/.*)$" => "/yourapplication.fcgi$1"
152+
)
152153

153154
Remember to enable the FastCGI, alias and rewrite modules. This configuration
154155
binds the application to `/yourapplication`. If you want the application to

flask/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ def make_response(self, rv):
15471547
:class:`tuple` A tuple in the form ``(response, status,
15481548
headers)`` where `response` is any of the
15491549
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
15511551
a dictionary with header values.
15521552
======================= ===========================================
15531553

flask/helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,13 @@ def find_package(import_name):
679679
filename = sys.modules[import_name].__file__
680680
package_path = os.path.abspath(os.path.dirname(filename))
681681
# 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__)
684689

685690
site_parent, site_folder = os.path.split(package_path)
686691
py_prefix = os.path.abspath(sys.prefix)

flask/testsuite/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import unittest
1717
from contextlib import contextmanager
1818
from flask.testsuite import FlaskTestCase
19+
from flask._compat import PY2
1920

2021

2122
# config keys used for the ConfigTestCase
@@ -291,6 +292,18 @@ def test_egg_installed_paths(self):
291292
if 'site_egg' in sys.modules:
292293
del sys.modules['site_egg']
293294

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+
294307

295308
def suite():
296309
suite = unittest.TestSuite()

0 commit comments

Comments
 (0)