Loading django/contrib/humanize/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -190,7 +190,7 @@ class HumanizeTests(TestCase): orig_humanize_datetime = humanize.datetime orig_timesince_datetime = timesince.datetime humanize.datetime = MockDateTime timesince.datetime = new.module("mock_datetime") timesince.datetime = new.module(b"mock_datetime") timesince.datetime.datetime = MockDateTime try: Loading django/core/context_processors.py +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ def csrf(request): # In order to be able to provide debugging info in the # case of misconfiguration, we use a sentinel value # instead of returning an empty dict. return 'NOTPROVIDED' return b'NOTPROVIDED' else: return token _get_val = lazy(_get_val, str) Loading django/core/files/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ class ContentFile(File): A File-like object that takes just raw content, rather than an actual file. """ def __init__(self, content, name=None): content = content or '' content = content or b'' super(ContentFile, self).__init__(BytesIO(content), name=name) self.size = len(content) Loading django/core/files/uploadedfile.py +2 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,8 @@ class UploadedFile(File): self.charset = charset def __repr__(self): return "<%s: %s (%s)>" % ( self.__class__.__name__, smart_str(self.name), self.content_type) return smart_str("<%s: %s (%s)>" % ( self.__class__.__name__, self.name, self.content_type)) def _get_name(self): return self._name Loading django/core/handlers/wsgi.py +5 −5 Original line number Diff line number Diff line Loading @@ -78,14 +78,14 @@ class LimitedStream(object): def __init__(self, stream, limit, buf_size=64 * 1024 * 1024): self.stream = stream self.remaining = limit self.buffer = '' self.buffer = b'' self.buf_size = buf_size def _read_limited(self, size=None): if size is None or size > self.remaining: size = self.remaining if size == 0: return '' return b'' result = self.stream.read(size) self.remaining -= len(result) return result Loading @@ -93,17 +93,17 @@ class LimitedStream(object): def read(self, size=None): if size is None: result = self.buffer + self._read_limited() self.buffer = '' self.buffer = b'' elif size < len(self.buffer): result = self.buffer[:size] self.buffer = self.buffer[size:] else: # size >= len(self.buffer) result = self.buffer + self._read_limited(size - len(self.buffer)) self.buffer = '' self.buffer = b'' return result def readline(self, size=None): while '\n' not in self.buffer and \ while b'\n' not in self.buffer and \ (size is None or len(self.buffer) < size): if size: # since size is not None here, len(self.buffer) < size Loading Loading
django/contrib/humanize/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -190,7 +190,7 @@ class HumanizeTests(TestCase): orig_humanize_datetime = humanize.datetime orig_timesince_datetime = timesince.datetime humanize.datetime = MockDateTime timesince.datetime = new.module("mock_datetime") timesince.datetime = new.module(b"mock_datetime") timesince.datetime.datetime = MockDateTime try: Loading
django/core/context_processors.py +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ def csrf(request): # In order to be able to provide debugging info in the # case of misconfiguration, we use a sentinel value # instead of returning an empty dict. return 'NOTPROVIDED' return b'NOTPROVIDED' else: return token _get_val = lazy(_get_val, str) Loading
django/core/files/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ class ContentFile(File): A File-like object that takes just raw content, rather than an actual file. """ def __init__(self, content, name=None): content = content or '' content = content or b'' super(ContentFile, self).__init__(BytesIO(content), name=name) self.size = len(content) Loading
django/core/files/uploadedfile.py +2 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,8 @@ class UploadedFile(File): self.charset = charset def __repr__(self): return "<%s: %s (%s)>" % ( self.__class__.__name__, smart_str(self.name), self.content_type) return smart_str("<%s: %s (%s)>" % ( self.__class__.__name__, self.name, self.content_type)) def _get_name(self): return self._name Loading
django/core/handlers/wsgi.py +5 −5 Original line number Diff line number Diff line Loading @@ -78,14 +78,14 @@ class LimitedStream(object): def __init__(self, stream, limit, buf_size=64 * 1024 * 1024): self.stream = stream self.remaining = limit self.buffer = '' self.buffer = b'' self.buf_size = buf_size def _read_limited(self, size=None): if size is None or size > self.remaining: size = self.remaining if size == 0: return '' return b'' result = self.stream.read(size) self.remaining -= len(result) return result Loading @@ -93,17 +93,17 @@ class LimitedStream(object): def read(self, size=None): if size is None: result = self.buffer + self._read_limited() self.buffer = '' self.buffer = b'' elif size < len(self.buffer): result = self.buffer[:size] self.buffer = self.buffer[size:] else: # size >= len(self.buffer) result = self.buffer + self._read_limited(size - len(self.buffer)) self.buffer = '' self.buffer = b'' return result def readline(self, size=None): while '\n' not in self.buffer and \ while b'\n' not in self.buffer and \ (size is None or len(self.buffer) < size): if size: # since size is not None here, len(self.buffer) < size Loading