Repository navigation
Encode bool and datetime list elements like top-level values - #1978
alphasafal wants to merge 3 commits into
Conversation
_api_encode converts top-level and nested-dict bool and datetime values (bool -> "true"/"false", datetime -> unix timestamp) but yielded them raw when they appeared as direct elements of a list. A list param therefore serialized booleans as "True"/"False" and datetimes as their str() repr instead of the forms the API expects. Handle bool and datetime in the list branch the same way as at the top level. Adds regression tests.
|
|
1 similar comment
|
|
jar-stripe
left a comment
There was a problem hiding this comment.
Looks good, thanks for the contribution!
|
Oh, just a heads up. After I approved I edited the "Fixes" out of your PR description. We leave issues open until after we release, and GitHub automation would have closed the ticket once this merges with that left in. Otherwise, looks good! |
|
Thanks for reviewing and approving this! I appreciate the clarification about keeping issues open until the fix is released. I'll follow that convention in future contributions. Thanks again! |
Why?
_api_encodeconvertsboolvalues to"true"/"false"anddatetimevalues to unix timestamps at the top level and inside nested dicts, but yields them unchanged when they are direct elements of a list. So{"flags": [True, False]}is sent asflags[0]=True&flags[1]=False, and{"created": [dt]}is sent as the datetime'sstr()form instead of a timestamp. Both form-encoded and multipart requests are affected, since both go through_api_encode.What?
datetime.datetimeandboolin the list branch of_api_encode, mirroring the top-level handling.tests/test_encode.py; both fail onmasterwithout the change and pass with it..harkchangefile.See Also
_api_encodeencodes bool/datetime list elements raw (e.g.flags[0]=Trueinstead oftrue) #1956Configuration
skip-changefile: This PR is not a user-facing change, so there's no changefile.