Skip to content
Myr

Error handler deprecation

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 6094c85 · Browse files · 2 files+12 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+12 added−3 removed

  • other:+12 added−3 removed

2 files+12 added−3 removed

modified:scripts/testproj/test.py+5 added
7 unmodified lines
8app.register_module(mod)9app.register_module(mod2)101112def handle_404(error):13 return 'Testing', 40414app.error_handlers[404] = handle_404151617@app.after_request18def after_request(response):19 g.db.close()20 return response
15 unmodified lines
modified:scripts/flask-07-upgrade.py+7 added-3 removed
33 unmodified lines
343536TEMPLATE_LOOKAHEAD = 4096373839_from_import_re = re.compile(r'^\s*from flask import\s+')38_app_re_part = r'((?:[a-zA-Z_][a-zA-Z0-9_]*app)|app|application)'39_string_re_part = r"('([^'\\]*(?:\\.[^'\\]*)*)'" \40 r'|"([^"\\]*(?:\\.[^"\\]*)*)")'4142_from_import_re = re.compile(r'^\s*from flask import\s+')43_url_for_re = re.compile(r'\b(url_for\()(%s)' % _string_re_part)44_render_template_re = re.compile(r'\b(render_template\()(%s)' % _string_re_part)45_after_request_re = re.compile(r'((?:@\S+\.(?:app_)?))(after_request)(\b\s*$)(?m)')46_module_constructor_re = re.compile(r'([a-zA-Z0-9_][a-zA-Z0-9_]*)\s*=\s*Module'47 r'\(__name__\s*(?:,\s*(%s))?' %48 _string_re_part)49_error_handler_re = re.compile(r'%s\.error_handlers\[\s*(\d+)\s*\]' % _app_re_part)50_mod_route_re = re.compile(r'([a-zA-Z0-9_][a-zA-Z0-9_]*)\.route')51_blueprint_related = [52 (re.compile(r'request\.module'), 'request.blueprint'),53 (re.compile(r'register_module'), 'register_blueprint'),52 (re.compile(r'(app|application)\.modules'), '\\1.blueprints')54 (re.compile(r'%s\.modules' % _app_re_part), '\\1.blueprints')55]565758def make_diff(filename, old, new):
177 unmodified lines
236 if teardown:237 new_contents = fix_teardown_funcs(new_contents)238 new_contents = rewrite_for_blueprints(new_contents, filename,239 template_bundles)240 new_contents = _error_handler_re.sub('\\1.error_handler_spec[None][\\2]',241 new_contents)242 make_diff(filename, contents, new_contents)243244245def upgrade_template_file(filename, contents):
83 unmodified lines