forked from orbit-oss/flask
#2341: Accept default argument value when args lenght equal 1
This commit is contained in:
parent
6a8c8c3484
commit
4f689c41d9
1 changed files with 5 additions and 2 deletions
|
|
@ -87,12 +87,15 @@ def call_factory(app_factory, script_info, arguments=()):
|
|||
of arguments. Checks for the existence of a script_info argument and calls
|
||||
the app_factory depending on that and the arguments provided.
|
||||
"""
|
||||
arg_names = getargspec(app_factory).args
|
||||
args_spec = getargspec(app_factory)
|
||||
arg_names = args_spec.args
|
||||
arg_defaults = args_spec.defaults
|
||||
|
||||
if 'script_info' in arg_names:
|
||||
return app_factory(*arguments, script_info=script_info)
|
||||
elif arguments:
|
||||
return app_factory(*arguments)
|
||||
elif not arguments and len(arg_names) == 1:
|
||||
elif not arguments and len(arg_names) == 1 and arg_defaults is None:
|
||||
return app_factory(script_info)
|
||||
return app_factory()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue