Skip to content

Commit

Permalink
Fixed some Py3 bytes vs strings bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
alga committed Apr 2, 2013
1 parent 8523159 commit 74847bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CHANGES
4.0.1 (unreleased)
==================

- Nothing changed yet.
- Fixed some Python 3 string vs bytes issues.


4.0.0 (2013-02-20)
Expand Down
8 changes: 4 additions & 4 deletions src/zope/browserresource/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def browserDefault(self, request):
>>> request = TestRequest(REQUEST_METHOD='HEAD')
>>> resource = factory(request)
>>> view, next = resource.browserDefault(request)
>>> view() == ''
>>> view() == b''
True
>>> next == ()
True
Expand Down Expand Up @@ -244,7 +244,7 @@ def GET(self):

if can_return_304 and all_cache_checks_passed:
response.setStatus(304)
return ''
return b''

# 304 responses SHOULD NOT or MUST NOT include other entity headers,
# depending on whether the conditional GET used a strong or a weak
Expand All @@ -261,7 +261,7 @@ def HEAD(self):
>>> factory = FileResourceFactory(testFilePath, nullChecker, 'test.txt')
>>> request = TestRequest()
>>> resource = factory(request)
>>> resource.HEAD() == ''
>>> resource.HEAD() == b''
True
>>> request.response.getHeader('Content-Type') == 'text/plain'
True
Expand All @@ -275,7 +275,7 @@ def HEAD(self):
if etag:
response.setHeader('ETag', etag)
setCacheControl(response, self.cacheTimeout)
return ''
return b''

# for unit tests
def _testData(self):
Expand Down
4 changes: 2 additions & 2 deletions src/zope/browserresource/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Resources(BrowserView):
futher traversing steps.
>>> view, path = resources.browserDefault(request)
>>> view() == ''
>>> view() == b''
True
>>> path == ()
True
Expand Down Expand Up @@ -113,4 +113,4 @@ def __getitem__(self, name):


def empty():
return ''
return b''
6 changes: 3 additions & 3 deletions src/zope/browserresource/tests/test_i18nfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def testFileHEAD(self):
resource = I18nFileResourceFactory(self._createDict('test.txt'), 'en')\
(TestRequest())

self.assertEqual(resource.HEAD(), '')
self.assertEqual(resource.HEAD(), b'')

response = resource.request.response
self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
Expand All @@ -142,7 +142,7 @@ def testFileHEAD(self):
self._createDict('test.txt'), 'en')\
(TestRequest(HTTP_ACCEPT_LANGUAGE='lt'))

self.assertEqual(resource.HEAD(), '')
self.assertEqual(resource.HEAD(), b'')

response = resource.request.response
self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
Expand All @@ -152,7 +152,7 @@ def testFileHEAD(self):
self._createDict('test.pt', 'test2.pt'), 'en')\
(TestRequest(HTTP_ACCEPT_LANGUAGE='fr'))

self.assertEqual(resource.HEAD(), '')
self.assertEqual(resource.HEAD(), b'')

response = resource.request.response
self.assertEqual(response.getHeader('Content-Type'), 'text/html')
Expand Down

0 comments on commit 74847bb

Please sign in to comment.