[issue11261] urlopen breaks when data parameter is used.

2011-02-20 Thread David Phillips

New submission from David Phillips :

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 "", line 2, in 
  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  '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 
<http://bugs.python.org/issue11261>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11261] urlopen breaks when data parameter is used.

2011-02-20 Thread David Phillips

David Phillips  added the comment:

Converting the type of my variable "form" from string to bytes did, indeed, 
allow the code to run, but I have to wonder about changing the inputs to 
urlopen like this. 

The 3.1.3 docs call for the data parameter to be string, and I presume that has 
been the case all along. Changing the data parameter from string to bytes may 
be a relatively clean change to make, but this change is going to break a lot 
of existing code. Are you sure you want to do that?

--

___
Python tracker 
<http://bugs.python.org/issue11261>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com