AspenWeb / pando.py

Filesystem dispatch + Simplates + Python = a nice web framework.
http://aspen.io/
Other
149 stars 38 forks source link

Error passing string to Response #591

Closed jaraco closed 3 years ago

jaraco commented 5 years ago

Attempting to redirect to another URL, I pass the text representation in a raised Response, but when I do, I get a TypeError:

  File "/Users/jaraco/code/yg/deploy/mongs/www/%server/%database/%collection/index.html.spt", line 16, in <module>
    raise Response(302, headers={'Location': './/1/'})
  File "/Users/jaraco/code/yg/deploy/mongs/.tox/python/lib/python3.7/site-packages/pando/http/response.py", line 66, in __init__
    self.headers = Headers(headers)
  File "/Users/jaraco/code/yg/deploy/mongs/.tox/python/lib/python3.7/site-packages/pando/http/baseheaders.py", line 59, in __init__
    CaseInsensitiveMapping.__init__(self, headers)
  File "/Users/jaraco/code/yg/deploy/mongs/.tox/python/lib/python3.7/site-packages/pando/http/mapping.py", line 36, in __init__
    self[k] = v
  File "/Users/jaraco/code/yg/deploy/mongs/.tox/python/lib/python3.7/site-packages/pando/http/baseheaders.py", line 78, in __setitem__
    _check_for_CRLF(value)
  File "/Users/jaraco/code/yg/deploy/mongs/.tox/python/lib/python3.7/site-packages/pando/http/baseheaders.py", line 23, in _check_for_CRLF
    if b'\r' in value or b'\n' in value:
TypeError: 'in <string>' requires string as left operand, not bytes

A workaround seems to be to pass b'.//1/' as the target path, but that seems sub-optimal. Pando should allow if not expect text from its interfaces.

Changaco commented 3 years ago

Fixed in #601.