diff --git a/src/App/tests/testImageFile.py b/src/App/tests/testImageFile.py index 954c1c8edb..0783783fe4 100644 --- a/src/App/tests/testImageFile.py +++ b/src/App/tests/testImageFile.py @@ -63,7 +63,7 @@ def test_index_html(self): 'www', 'zopelogo.png') image = App.ImageFile.ImageFile(path) result = image.index_html(request, response) - self.assertEqual(stdout.getvalue(), '') + self.assertEqual(stdout.getvalue(), b'') self.assertTrue(isinstance(result, io.FileIO)) self.assertTrue(b''.join(result).startswith(b'\x89PNG\r\n')) self.assertEqual(len(result), image.size) diff --git a/src/Products/Five/browser/decode.py b/src/Products/Five/browser/decode.py index 960c7c93de..a44081b220 100644 --- a/src/Products/Five/browser/decode.py +++ b/src/Products/Five/browser/decode.py @@ -21,8 +21,7 @@ from ZPublisher.HTTPRequest import isCGI_NAMEs from zope.i18n.interfaces import IUserPreferredCharsets -if sys.version_info >= (3, ): - unicode = str +from six import text_type, binary_type def _decode(text, charsets): @@ -31,7 +30,7 @@ def _decode(text, charsets): # taken and adapted from zope.publisher.browser.BrowserRequest for charset in charsets: try: - text = unicode(text, charset) + text = text_type(text, charset) break except UnicodeError: pass @@ -54,16 +53,16 @@ def processInputValue(value, charsets): for k, v in list(value.items()): value[k] = processInputValue(v, charsets) return value - elif isinstance(value, str): + elif isinstance(value, binary_type): return _decode(value, charsets) else: return value def processInputs(request, charsets=None): - """Process the values in request.form to decode strings to unicode, using - the passed-in list of charsets. If none are passed in, look up the user's - preferred charsets. The default is to use utf-8. + """Process the values in request.form to decode binary_type to text_type, + using the passed-in list of charsets. If none are passed in, look up the + user's preferred charsets. The default is to use utf-8. """ warn(u'processInputs() is deprecated and will be removed in Zope 5.0. If ' u'your view implements IBrowserPage, similar processing is now ' diff --git a/src/Products/Five/tests/test_i18n.py b/src/Products/Five/tests/test_i18n.py index 55811f30a2..0a27bf240b 100644 --- a/src/Products/Five/tests/test_i18n.py +++ b/src/Products/Five/tests/test_i18n.py @@ -46,10 +46,10 @@ def test_directive(): As you can see, both the default functionality and translation to German work: - >>> translate(msg) - u'This is an explicit message' - >>> translate(msg, target_language='de') - u'Dies ist eine explizite Nachricht' + >>> translate(msg) == u'This is an explicit message' + True + >>> translate(msg, target_language='de') == u'Dies ist eine explizite Nachricht' + True """ diff --git a/src/Products/Five/utilities/marker.py b/src/Products/Five/utilities/marker.py index da7c2a88ce..aa8ab3bd26 100644 --- a/src/Products/Five/utilities/marker.py +++ b/src/Products/Five/utilities/marker.py @@ -16,8 +16,6 @@ Allows for arbitrary application of marker interfaces to objects. """ -from sets import Set - from zope.interface import implementer, implementedBy, providedBy from zope.interface import directlyProvides, directlyProvidedBy from zope.interface.interfaces import IInterface @@ -105,12 +103,12 @@ def update(self, add=(), remove=()): marker_ifaces = self.getAvailableInterfaces() if len(add): [mark(self.context, interface) - for interface in Set(marker_ifaces) & Set(add)] + for interface in set(marker_ifaces) & set(add)] direct_ifaces = self.getDirectlyProvided() if len(remove): [erase(self.context, interface) - for interface in Set(direct_ifaces) & Set(remove)] + for interface in set(direct_ifaces) & set(remove)] def _getInterfaceNames(self, interfaces): return [interfaceToName(self, iface) for iface in interfaces] diff --git a/src/Testing/ZopeTestCase/zopedoctest/functional.py b/src/Testing/ZopeTestCase/zopedoctest/functional.py index 20fb1bfb8e..a2b7c79d6e 100644 --- a/src/Testing/ZopeTestCase/zopedoctest/functional.py +++ b/src/Testing/ZopeTestCase/zopedoctest/functional.py @@ -305,8 +305,8 @@ def setup_globs(self): globs['http'] = http globs['getRootFolder'] = getRootFolder globs['sync'] = sync - globs['user_auth'] = base64.encodestring( - '%s:%s' % (user_name, user_password)) + unencoded_user_auth = ('%s:%s' % (user_name, user_password)).encode('utf-8') + globs['user_auth'] = base64.encodestring(unencoded_user_auth) def setup_test_class(self): test_class = self._kw.get('test_class', FunctionalTestCase)