Skip to content

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

Closed
sevdog wants to merge 1 commit intoencode:masterfrom
sevdog:requests-attribute-errors
Closed

Wrap exceptions caused by parsers in ParseError in request wrapper#9453
sevdog wants to merge 1 commit intoencode:masterfrom
sevdog:requests-attribute-errors

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
Collaborator

@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
Contributor

@sevdog sevdog force-pushed the requests-attribute-errors branch from 3640913 to c375e15 Compare July 8, 2024 08:11
@auvipy
Copy link
Collaborator

auvipy commented Jul 8, 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.

can you please check the approach followed here please? #9455

@sevdog
Copy link
Contributor Author

sevdog commented Jul 8, 2024

@auvipy yes, that may work better.

I can also point out that the WrappedAttributeError it should be added every other properties (inside them, as it was pointed out that a custom decorator is slower).

I belive that "wrapping" the response may not be an optimal solution (I got in the past errors when handling with DRF requests in non-DRF code which was expecting an instance of HTTPRequest because there is no inheritance). However this would require a bigger rework and a deeper discussion.

Than I close this PR in favor or #9455.

@sevdog sevdog closed this Jul 8, 2024
@sevdog
Copy link
Contributor Author

sevdog commented Jul 8, 2024

PS: I am curious to see if the same issue would be raised by cached_property, this because many properties on DRF Request looks something which can also be implemented using that descriptor.

@sevdog sevdog deleted the requests-attribute-errors branch July 8, 2024 09:07
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.

4 participants