Martin Panter added the comment: 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'> ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25439> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com