summaryrefslogtreecommitdiff
path: root/django/http/multipartparser.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-08-11 14:44:34 +0200
committerClaude Paroz <claude@2xlibre.net>2012-08-11 14:47:44 +0200
commitf10a1b06416e59a66cc9c3c8437fe045cb0fb03c (patch)
treebe78c5071375b094c5c8a79818b3228d0aa31b01 /django/http/multipartparser.py
parent22527a821bbca73a4900906be8b01c81a414ad95 (diff)
downloaddjango-f10a1b06416e59a66cc9c3c8437fe045cb0fb03c.tar.gz
[py3] Fixed Python 3 compatibility of http handling
* Using str() when Python 2 expects bytes and Python 3 Unicode * Fixed reraise-ing syntax * Fixed slicing of byte strings
Diffstat (limited to 'django/http/multipartparser.py')
-rw-r--r--django/http/multipartparser.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index 9c66827cbb..a324935d3d 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -507,9 +507,11 @@ class BoundaryIter(object):
end = index
next = index + len(self._boundary)
# backup over CRLF
- if data[max(0,end-1)] == b'\n':
+ last = max(0, end-1)
+ if data[last:last+1] == b'\n':
end -= 1
- if data[max(0,end-1)] == b'\r':
+ last = max(0, end-1)
+ if data[last:last+1] == b'\r':
end -= 1
return end, next
@@ -613,7 +615,7 @@ def parse_header(line):
if i >= 0:
name = p[:i].strip().lower().decode('ascii')
value = p[i+1:].strip()
- if len(value) >= 2 and value[0] == value[-1] == b'"':
+ if len(value) >= 2 and value[:1] == value[-1:] == b'"':
value = value[1:-1]
value = value.replace(b'\\\\', b'\\').replace(b'\\"', b'"')
pdict[name] = value