diff --git a/CHANGES.rst b/CHANGES.rst index cba97fb6..228022fd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,13 @@ Version 1.1 unreleased +Version 1.0.1 +------------- + +unreleased + +- Fix registering partials (with no ``__name__``) as view functions + Version 1.0 ----------- diff --git a/flask/blueprints.py b/flask/blueprints.py index d633685f..0a6ccfb7 100644 --- a/flask/blueprints.py +++ b/flask/blueprints.py @@ -201,7 +201,7 @@ class Blueprint(_PackageBoundObject): """ if endpoint: assert '.' not in endpoint, "Blueprint endpoints should not contain dots" - if view_func: + if view_func and hasattr(view_func, '__name__'): assert '.' not in view_func.__name__, "Blueprint view function name should not contain dots" self.record(lambda s: s.add_url_rule(rule, endpoint, view_func, **options)) diff --git a/tests/test_blueprints.py b/tests/test_blueprints.py index 7984a815..a2631241 100644 --- a/tests/test_blueprints.py +++ b/tests/test_blueprints.py @@ -9,6 +9,7 @@ :license: BSD, see LICENSE for more details. """ +import functools import pytest import flask @@ -382,6 +383,8 @@ def test_route_decorator_custom_endpoint_with_dots(app, client): ) ) + bp.add_url_rule('/bar/456', endpoint='foofoofoo', view_func=functools.partial(foo_foo_foo)) + app.register_blueprint(bp, url_prefix='/py') assert client.get('/py/foo').data == b'bp.foo'