Re: Python 3.0 urllib.parse.parse_qs results in TypeError

2009-01-13 Thread Andy Grove
On Jan 13, 3:08 pm, John Machin  wrote:

> Please show the full traceback.

John,

Thanks. Here it is:

  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/socketserver.py", line 281, in _handle_request_noblock
self.process_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/socketserver.py", line 307, in process_request
self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/socketserver.py", line 320, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/socketserver.py", line 614, in __init__
self.handle()
  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/http/server.py", line 363, in handle
self.handle_one_request()
  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/http/server.py", line 357, in handle_one_request
method()
  File "/Users/andy/Development/EclipseWorkspace/dbsManage/kernel.py",
line 178, in do_POST
form = urllib.parse.parse_qs(qs, keep_blank_values=1)
  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/urllib/parse.py", line 351, in parse_qs

for name, value in parse_qsl(qs, keep_blank_values,
strict_parsing):
  File "/Library/Frameworks/Python.framework/Versions/3.0/lib/
python3.0/urllib/parse.py", line 377, in parse_qsl
pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
TypeError: Type str doesn't support the buffer API
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 urllib.parse.parse_qs results in TypeError

2009-01-13 Thread Andy Grove
I don't fully understand this but if I pass in "str(qs)" instead of
"qs" then the call works. However, qs is returned from file.read()
operation so shouldn't that be a string already?

In case it's not already obvious, I am new to Python :-) .. so I'm
probably missing something here.
--
http://mail.python.org/mailman/listinfo/python-list


cgi.FieldStorage hanging with Python 3.0 (but works with 2.5.1)

2009-01-13 Thread Andy Grove
I'm trying to get a Python web server running that I can upload files
to. I actually have the code running with the version of Python pre-
installed on Mac OS X but it doesn't work with ActivePython 3.0 - I
have not been able to compile Python from source myself to see if the
issue is specific to the ActivePython distribution.

Here is the relevant code:

class MyHandler(http.server.BaseHTTPRequestHandler):
  def do_POST(self):
try:
print( "Calling cgi.FieldStorage()" )
form = cgi.FieldStorage(
fp=self.rfile,
headers=self.headers,
environ={'REQUEST_METHOD':'POST',
 'CONTENT_TYPE':self.headers['Content-
Type'],
 })
print( "Calling cgi.FieldStorage()" )

The client is the following HTML form being submitted with Firefox
3.0.5 running on the same machine. The browser also hangs, waiting for
a response from the server.

http://localhost:8090/deploy"; method="POST"
enctype="multipart/form-data">

File:
 



As I said, this all works fine with Python 2.5.1 pre-installed.

Any suggestions?

Thanks,

Andy.

--
http://mail.python.org/mailman/listinfo/python-list