#28678: Multipart parser should decode those JSON parts that are flagged as such
-------------------------------------+-------------------------------------
Reporter: Facundo Batista | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: HTTP handling | Version: 1.11
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Claude Paroz):
Replying to [comment:2 timtaiwanliim]:
> > it could be backwards incompatible (data could now be a different type
in request.POST, correct?).
>
> Not so.
> Only if the parts have http header "content-type: application/json",
> then those parts become dict (the desired type; currently of str
> type).
> For the parts (of multiparts) that do not have "content-type" header,
> the results remain as str type.
That's indeed the backwards compatibility issue: typically, current code
expects a `str` and call `json.loads(data)` to convert it to a Python
structure. If suddenly the data is another Python structure (dict, list,
etc.), the same code will suddenly crash with an error like `TypeError:
the JSON object must be str, bytes or bytearray, not dict`. Do you have an
idea to avoid that issue?
--
Ticket URL: <https://code.djangoproject.com/ticket/28678#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018298322f47-f92d2e33-815e-474c-8c5e-204639dec8e9-000000%40eu-central-1.amazonses.com.