homepage

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 tzs
Recipients Ramchandra Apte, tim.golden, tzs
Date 2012年07月09日.16:19:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341850793.81.0.176061555511.issue15267@psf.upfronthosting.co.za>
In-reply-to
Content
Here is a program that demonstrates the problem:
 import httplib
 import tempfile
 f = tempfile.TemporaryFile()
 f.write("Hello, Temporary File!")
 f.seek(0)
 c = httplib.HTTPConnection('bugs.python.org')
 c.request('POST', '/', f, {'Content-type' : 'application/octet-stream'})
 r = c.getresponse()
 print r.status, r.reason
The expected output is "200 OK", and that's what happens on Mac and almost certainly on Linux. On Windows, this is the result:
 Traceback (most recent call last):
 File "bad.py", line 9, in <module>
 c.request('POST', '/', f, {'Content-type' : 'application/octet
 File "C:\Python27\lib\httplib.py", line 958, in request
 self._send_request(method, url, body, headers)
 File "C:\Python27\lib\httplib.py", line 989, in _send_request
 self._set_content_length(body)
 File "C:\Python27\lib\httplib.py", line 964, in _set_content_len
 thelen = str(len(body))
 File "C:\Python27\lib\tempfile.py", line 383, in __getattr__
 a = getattr(file, name)
 AttributeError: 'file' object has no attribute '__len__'
Changing the lines:
 f = tempfile.TemporaryFile()
 f.write("Hello, Temporary File!")
 f.seek(0)
to:
 f = open("temp.file", "w+")
 f.write("Hello, Less Temporary File!")
 f.seek(0)
makes it work on Windows.
History
Date User Action Args
2012年07月09日 16:19:53tzssetrecipients: + tzs, tim.golden, Ramchandra Apte
2012年07月09日 16:19:53tzssetmessageid: <1341850793.81.0.176061555511.issue15267@psf.upfronthosting.co.za>
2012年07月09日 16:19:53tzslinkissue15267 messages
2012年07月09日 16:19:52tzscreate

AltStyle によって変換されたページ (->オリジナル) /