Skip to content

Commit

Permalink
Grep for Python 2 and fix the places where it was used.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Sep 18, 2019
1 parent fd1841e commit ea28101
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 36 deletions.
10 changes: 2 additions & 8 deletions docs/zdgbook/ComponentsAndInterfaces.rst
Expand Up @@ -135,7 +135,7 @@ Interfaces try to solve these problems by providing a way for you to
describe how to use an object, and a mechanism for discovering that
description.

Creating Interfaces
Creating Interfaces
===================

The first step to creating a component, as you've been shown, is to
Expand Down Expand Up @@ -247,12 +247,6 @@ interfaces and classes should never be confused.
Querying an Interface
=====================

.. attention::

The following explanation is only valid for Python 3. If you still
use Python 2, please note, that both ``names`` and
``namesAndDescriptions`` return a list, not a dict_view.

Interfaces can be queried for information. The simplest case is to
ask an interface the names of all the various interface items it
describes. From the Python interpreter, for example, you can walk
Expand Down Expand Up @@ -302,7 +296,7 @@ For example::
<zope.interface.interface.Method object at 0x7fc6875110f0>
>>> m.getSignatureString()
'(name)'
>>> m.getSignatureInfo()
>>> m.getSignatureInfo()
{'positional': ('name',), 'required': ('name',), 'optional': {},
'varargs': None, 'kwargs': None}

Expand Down
6 changes: 0 additions & 6 deletions docs/zdgbook/GettingStarted.rst
Expand Up @@ -74,12 +74,6 @@ command to build the system.

The initial build will take some time to complete.

.. attention::

You will see some warnings or error messages on the console. These
cannot be fixed until Python 2 support is dropped. Just ignore
them for now.

Creating the instance
=====================

Expand Down
9 changes: 1 addition & 8 deletions docs/zdgbook/ObjectPublishing.rst
Expand Up @@ -944,7 +944,7 @@ module. However, the converter may impose restrictions.

**Special cases**

If you are still on Python 2 or your pages use a different encoding,
If your pages use a different encoding,
such as ``Windows-1252`` or ``ISO-8859-1``, which was the default
encoding for HTML 4, you have to add the encoding, eg ``:cp1252``, for
all argument type converts, such as follows::
Expand Down Expand Up @@ -1277,13 +1277,6 @@ Other Network Protocols
XML-RPC
-------

.. note::

Code examples are valid for Python 3 only.

If you want to use Python 2, please refer to the
`offcial documentation <https://docs.python.org/2/library/xmlrpclib.html>`_

**XML-RPC** is a light-weight remote procedure call (RPC) protocol
that uses **XML** to encode its calls and **HTTP** as a transport
mechanism.
Expand Down
12 changes: 0 additions & 12 deletions src/OFS/tests/testProperties.py
Expand Up @@ -15,8 +15,6 @@

import unittest

import six


class TestPropertyManager(unittest.TestCase):

Expand Down Expand Up @@ -91,17 +89,12 @@ def test_updateProperty_transforms(self):
pm = self._makeOne()
pm._setProperty('test_lines', [], type='lines')

# text gets converted to bytes here as it's likely utf-8
# (or otherwise) encoded anyway (from use with Python 2)
pm._updateProperty('test_lines', 'foo\nbar')
self.assertEqual(pm.getProperty('test_lines'), (b'foo', b'bar'))

pm._updateProperty('test_lines', b'bar\nbaz')
self.assertEqual(pm.getProperty('test_lines'), (b'bar', b'baz'))

pm._updateProperty('test_lines', six.u('uni\ncode'))
self.assertEqual(pm.getProperty('test_lines'), (b'uni', b'code'))


class TestPropertySheets(unittest.TestCase):

Expand Down Expand Up @@ -153,13 +146,8 @@ def test_updateProperty_transforms(self):
ps = self._makeOne('foo')
ps._setProperty('test_lines', [], type='lines')

# text gets converted to bytes here as it's likely utf-8
# (or otherwise) encoded anyway (from use with Python 2)
ps._updateProperty('test_lines', 'foo\nbar')
self.assertEqual(ps.getProperty('test_lines'), (b'foo', b'bar'))

ps._updateProperty('test_lines', b'bar\nbaz')
self.assertEqual(ps.getProperty('test_lines'), (b'bar', b'baz'))

ps._updateProperty('test_lines', six.u('uni\ncode'))
self.assertEqual(ps.getProperty('test_lines'), (b'uni', b'code'))
2 changes: 0 additions & 2 deletions src/ZPublisher/tests/testHTTPResponse.py
Expand Up @@ -1339,8 +1339,6 @@ def test_exception_Internal_Server_Error(self):
def test_exception_500_text(self):
message = u'ERROR \xe4 VALUE'
exc = AttributeError(message)
# This gets called deep down in the zExceptions.ExceptionFormatter
# and produces different results in Python 2/3.
expected = traceback.format_exception_only(
exc.__class__, exc)[0].encode('utf-8')
response = self._makeOne()
Expand Down

0 comments on commit ea28101

Please sign in to comment.