[issue23350] Content-length is incorrect when request body is a list or tuple
Vincent Alquier added the comment: Martin: You're right, it's the same issue, and only related to python2's old style classes. Sorry for the useless noise. Demian: My problem is `len(obj)` raises an Using AttributeError in python2 (with obj being old style class instance). It's python 2.X specific and I don't think it is going to be addressed (reading comments in #15267). But thanks for your code rework. -- ___ Python tracker <http://bugs.python.org/issue23350> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23350] Content-length is incorrect when request body is a list or tuple
Vincent Alquier added the comment: Another issue should be addressed by patch... When trying to guess the content-length, here is the code you find... try: thelen = str(len(body)) except TypeError as te: [...] The call to `len` will raise a `TypeError` in case of a C file "object". But if body is a python file-like object, it will often raise an `AttributeError`. So, the code should be replaced by (in both python 2.7 and 3): try: thelen = str(len(body)) except (TypeError, AttributeError): [...] -- nosy: +Pinz ___ Python tracker <http://bugs.python.org/issue23350> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com