Ticket #579 (defect)
Opened 2 years ago
Last modified 2 years ago
request.query_string cannot be None
Status: closed (fixed)
| Reported by: | sl_church@yahoo.com | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | CherryPy code | Keywords: | |
| Cc: |
First let me note that I am a new user of CherryPy and also to WSGI in general so I may be mistaken on this. I was trying to use a simple cherrypy application (3.0 beta 2) with another WSGI server, specifically the twill wsgi_intercept mechanism (for testing). If a URL was submited with query arguments (ie ...?var=1&...) everything was fine. However a URL without query arguments produced a 500 error.
I tracked the problem to the initialization of the self.query_string variable in the run method of the Request object. If no query arguments were provided then self.query_string was set to None which caused problems later, in the process_headers method (line 563 self.params = http.parse_query_string...) where the query_string argument is None and parse_query_string expects a string paramater.
Per pep 333 the QUERY_STRING variable can be "empty or missing" so changing line 428 of the _cprequest module from:
self.query_string = query_string
to:
self.query_string = query_string or ""
fixed the problem. As an alternative, a test can be made wherever self.query_string is used and a string is expected. If you need more information please let me know. I can also submit a patch if you tell me how you want it.
Change History
09/29/06 18:32:50: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
09/29/06 18:33:47: Modified by fumanchu
- description changed.
- summary changed from Possible bug in CherryPy 3.0 beta 2 to request.query_string cannot be None.


Fixed in [1385]. Thanks!