Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String arguments parsing null from JSON as string "None" #390

Merged
merged 1 commit into from
Feb 28, 2015

Conversation

joshfriend
Copy link
Member

#159 introduced a bug where the following happens:

parser = RequestParser()
parser.add_argument('name')
POST /foo {"name": null}
args = parser.parse_args()
# resulting args:
{'name': 'None'}

There was (is) a check for skipping a cast to a string if the input is string but the value in the request is None here, but 442db82 altered the default type of Argument such that it no longer works:

>>> import six, inspect
>>> value = None
# Before 442db82
>>> arg_type = six.text_type
>>> value is None and inspect.isclass(arg_type) and issubclass(arg_type, six.string_types)
True
# After 442db82
>>> arg_type = lambda x: six.text_type(x)
>>> s is None and inspect.isclass(arg_type) and issubclass(arg_type, six.string_types)
False
>>> type(six.text_type)
<type 'type'>
>>> type(text_type)
<type 'function'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant