This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients Nan Wu, ezio.melotti, martin.panter
Date 2015-10-31.22:44:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1446331441.74.0.0565411233503.issue25439@psf.upfronthosting.co.za>
In-reply-to
Content
The bytes-like thing applies equally well to both the direct and iterable cases. Your first attempt hangs because the client only sends the four bytes in b"post", but the server is waiting for a total of 10 bytes.

The SSL problem doesn’t show up unless you use more obscure types like ctypes or array.array, where len() does not work as expected. Here is a demo:

>>> import ctypes
>>> byteslike = ctypes.c_char(b"x")
>>> urlopen("http://python.org/", data=byteslike)  # Succeeds
<http.client.HTTPResponse object at 0xb6bc876c>
>>> urlopen("https://python.org/", data=byteslike)
  File "/usr/lib/python3.4/ssl.py", line 720, in sendall
    amount = len(data)
TypeError: object of type 'c_char' has no len()

During handling of the above exception, another exception occurred:

TypeError: data should be a bytes-like object or an iterable, got <class 'ctypes.c_char'>
History
Date User Action Args
2015-10-31 22:44:01martin.pantersetrecipients: + martin.panter, ezio.melotti, Nan Wu
2015-10-31 22:44:01martin.pantersetmessageid: <1446331441.74.0.0565411233503.issue25439@psf.upfronthosting.co.za>
2015-10-31 22:44:01martin.panterlinkissue25439 messages
2015-10-31 22:44:01martin.pantercreate