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

Wrap exceptions caused by parsers in ParseError in request wrapper #9453

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sevdog
Copy link
Contributor

@sevdog sevdog commented Jun 28, 2024

Description

To address #9433 (which is caused by python/cpython#90143) simply wraps AttributeErrors which are raised in the parse process into a ParseError.

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

the change seems reasonable. can you fix the lint error please?

@james-mchugh
Copy link

Looking at request.py, it looks like there is already a precedent for handling this type of error with the wrap_attributeerror context manager defined at https://github.com/encode/django-rest-framework/blob/master/rest_framework/request.py#L68 and then used at

I've opened another PR (#9455) that utilizes this context manager through a safe_property decorator that is utilized by each of the properties in the Request class.

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

Successfully merging this pull request may close these issues.

None yet

3 participants