Skip to content

Commit

Permalink
replace calls to aspen.utils.ascii_dammit()
Browse files Browse the repository at this point in the history
That function has been removed in AspenWeb/aspen.py#20
  • Loading branch information
Changaco committed Aug 9, 2016
1 parent 7b08464 commit d911de6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pando/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
import sys
import pkg_resources

import aspen.utils as _x # this registers the 'repr' codec error strategy
del _x

# imports of convenience
from aspen.simplates import json_ as json
from aspen.simplates.renderers import BUILTIN_RENDERERS, RENDERERS
Expand Down
5 changes: 2 additions & 3 deletions pando/http/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import urlparse

from aspen.http.request import Path as _Path, Querystring as _Querystring
from aspen.utils import ascii_dammit

from .. import Response
from .baseheaders import BaseHeaders
Expand Down Expand Up @@ -402,7 +401,7 @@ def __new__(cls, raw):
#
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

safe = ascii_dammit(raw)
safe = raw.decode('ascii', 'repr')
raise Response(501, "Your request-method violates RFC "
"2616: %s" % safe)

Expand Down Expand Up @@ -498,7 +497,7 @@ class Version(unicode):
def __new__(cls, raw):
version = versions.get(raw, None)
if version is None: # fast for 99.999999% case
safe = ascii_dammit(raw)
safe = raw.decode('ascii', 'repr')
if version_re.match(raw) is None:
raise Response(400, "Bad HTTP version: %s." % safe)
else:
Expand Down
10 changes: 4 additions & 6 deletions pando/http/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import re
import sys

from aspen.utils import ascii_dammit

from . import status_strings
from .baseheaders import BaseHeaders as Headers

Expand Down Expand Up @@ -97,14 +95,14 @@ def __call__(self, environ, start_response):
try: # XXX This is a hack. It's red hot, baby.
k = k.encode('US-ASCII')
except UnicodeEncodeError:
k = ascii_dammit(k)
raise ValueError("Header key %s must be US-ASCII.")
k = k.decode('US-ASCII', 'repr')
raise ValueError("Header key %s isn't US-ASCII." % k)
for v in vals:
try: # XXX This also is a hack. It is also red hot, baby.
v = v.encode('US-ASCII')
except UnicodeEncodeError:
v = ascii_dammit(v)
raise ValueError("Header value %s must be US-ASCII.")
v = v.decode('US-ASCII', 'repr')
raise ValueError("Header value %s isn't US-ASCII." % k)
wsgi_headers.append((k, v))

start_response(wsgi_status, wsgi_headers)
Expand Down

0 comments on commit d911de6

Please sign in to comment.