@@ -246,14 +246,17 @@ The following classes are provided:
246246 server, or ``None `` if no such data is needed. Currently HTTP
247247 requests are the only ones that use *data *. The supported object
248248 types include bytes, file-like objects, and iterables of bytes-like objects.
249- Mappings, such as :class: `dict `, are not accepted and raise
250- :exc: `TypeError `.
251249 If no ``Content-Length `` nor ``Transfer-Encoding `` header field
252250 has been provided, :class: `HTTPHandler ` will set these headers according
253251 to the type of *data *. ``Content-Length `` will be used to send
254252 bytes objects, while ``Transfer-Encoding: chunked `` as specified in
255253 :rfc: `7230 `, Section 3.3.1 will be used to send files and other iterables.
256254
255+ *data * is not serialized before it is sent: the elements of an iterable
256+ are sent as is, so a :class: `dict ` yields only its keys. Structured
257+ data such as a JSON object must be encoded to bytes first, for example
258+ with :func: `json.dumps `.
259+
257260 For an HTTP POST request method, *data * should be a buffer in the
258261 standard :mimetype: `application/x-www-form-urlencoded ` format. The
259262 :func: `urllib.parse.urlencode ` function takes a mapping or sequence
@@ -320,9 +323,6 @@ The following classes are provided:
320323 provided and *data * is neither ``None `` nor a bytes object.
321324 Fall back to use chunked transfer encoding instead.
322325
323- .. versionchanged :: next
324- Raise :exc: `TypeError ` if *data * is a mapping.
325-
326326.. class :: OpenerDirector()
327327
328328 The :class: `OpenerDirector ` class opens URLs via :class: `BaseHandler `\ s chained
0 commit comments