Skip to content

Raise RuntimeError when trying to encode coreapi objects #4790

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

Merged
merged 1 commit into from
Jan 6, 2017

Conversation

archy-rock3t-cloud
Copy link
Contributor

@archy-rock3t-cloud archy-rock3t-cloud commented Jan 6, 2017

JSONEncoder.default didn't raise RuntimeError as intended because there is another "if" above which returns earlier.
Maybe it is better to put check for coreapi objects on top of default method?

raise RuntimeError(
'Cannot return a coreapi object from a JSON view. '
'You should be using a schema renderer instead for this view.'
)
elif hasattr(obj, '__getitem__'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "if" blocks coreapi check

@tomchristie tomchristie added the Bug label Jan 6, 2017
@tomchristie tomchristie added this to the 3.5.4 Release milestone Jan 6, 2017
@tomchristie
Copy link
Member

Good catch, thanks!

@tomchristie tomchristie merged commit a5fcf10 into encode:master Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants