[ovs-dev] [PATCH v2 1/2] Remove Python 2 leftovers.

Ilya Maximets i.maximets at ovn.org
Fri Jun 11 15:17:43 UTC 2021


On 6/9/21 11:25 PM, Rosemarie O'Riorden wrote:
> Fixes: 1ca0323e7c29 ("Require Python 3 and remove support for Python 2.")
> Reported at: https://bugzilla.redhat.com/show_bug.cgi?id=1949875
> Signed-off-by: Rosemarie O'Riorden <roriorde at redhat.com>
> ---
> Fix import errors in v1.
> Remove lines that indicate compatibility with python 2.
> 
>  ofproto/ipfix-gen-entities                    |  2 --
>  ovsdb/ovsdb-idlc.in                           |  1 -
>  .../ovs/compat/sortedcontainers/sortedlist.py |  2 --
>  python/ovstest/tests.py                       |  2 --
>  python/ovstest/util.py                        |  2 +-
>  python/setup.py                               |  4 ---
>  tests/test-jsonrpc.py                         |  2 --
>  utilities/checkpatch.py                       |  1 -
>  utilities/gdb/ovs_gdb.py                      |  1 -
>  utilities/ovs-l3ping.in                       | 14 +++++-----
>  utilities/ovs-parse-backtrace.in              | 12 ++++----
>  utilities/ovs-pcap.in                         |  4 +--
>  utilities/ovs-vlan-test.in                    | 28 +++++++++----------
>  13 files changed, 29 insertions(+), 46 deletions(-)

Hi, Rosemarie.  Thanks for v2!

I see at least few more files not covered by this patch:

1. python/ovstest/rpcserver.py

It has some problems with imports.  At least it imports wrong 'util'
module.  All local imports in this file should be converted to
relative imports, e.g. with 'from . import something',  otherwise
python3 will use absolute import and will get something unexpected.
This should be fixed for 'util', 'tcp', 'udp' and 'vswitch' imports.

And there is also issue with exceptions similar to what Timothy
reported for the other file.

(For some reason importing of twisted + pylint doesn't work for
me inside the virtual environment, but that is not the issue of OVS)

2. python/ovstest/vswitch.py

It has same issue with import of 'util'.  Import should be relative.
There are might be some other places there similar issues should
be fixed.

3. python/ovstest/tcp.py

This one is tricky as the issue cannot be caught by static analysis.
If you'll try to run it, it will throw exception like this:

  Traceback (most recent call last):
  File "ovs-python-env/lib64/python3.8/site-packages/zope/interface/declarations.py", line 778, in implements
    raise TypeError(_ADVICE_ERROR % 'implementer')
  TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead.

So, the implements() stuff in this file should be turned into a
decorator.  Something like this:

  from zope.interface.declarations import implementer

  @implementer(interfaces.IPushProducer)
  class Producer(object):
      ...

Best regards, Ilya Maximets.


More information about the dev mailing list