[New-bugs-announce] [issue11261] urlopen breaks when data parameter is used.

David Phillips report at bugs.python.org
Sun Feb 20 23:07:31 CET 2011


New submission from David Phillips <david.193.phillips at gmail.com>:

The following code works on python 3.1.3 but fails on Python 3.2rc2 (r32rc2:88269, Jan 30 2011, 14:30:28). (I run Mac OS X, version 10.6.6.)

-----------------------------

import urllib, urllib.request, urllib.error, urllib.parse

form = urllib.parse.urlencode({'field1':'Log in'})
try:
	response = urllib.request.urlopen('http://www.google.com/', form)
except urllib.error.HTTPError as exception:
	print (exception)

---------------------------------------

When loaded, the following error messages are generated:

---------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/urllib/request.py", line 1057, in do_request_
    mv = memoryview(data)
TypeError: cannot make memory view because object does not have the buffer interface

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/urllib/request.py", line 138, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/urllib/request.py", line 364, in open
    req = meth(req)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/urllib/request.py", line 1062, in do_request_
    data))
ValueError: Content-Length should be specified                                 for iterable data of type <class 'str'> 'field1=Log+in'

------------------------------------

----------
components: Library (Lib)
messages: 128922
nosy: david193
priority: normal
severity: normal
status: open
title: urlopen breaks when data parameter is used.
type: crash
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11261>
_______________________________________


More information about the New-bugs-announce mailing list