You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2022/08/09 14:23:00 UTC
[qpid-proton] branch main updated: PROTON-2590: [Python] Remove use of "from __future__ import ..."
This is an automated email from the ASF dual-hosted git repository.
astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push:
new a4375a835 PROTON-2590: [Python] Remove use of "from __future__ import ..."
a4375a835 is described below
commit a4375a8351c3435bd5025bb2481307efe97dc99e
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Tue Aug 9 10:20:23 2022 -0400
PROTON-2590: [Python] Remove use of "from __future__ import ..."
Every one of these future imports that we use is already the default for
Python 3 so we no longer need any of them.
- Also a couple of other small changes where we are checking for things
that are different with Python 2.
---
c/src/encodings.h.py | 1 -
c/src/protocol.h.py | 1 -
c/tests/fdlimit.py | 3 ---
python/proton/__init__.py | 1 -
python/proton/_exceptions.py | 2 --
python/proton/_io.py | 2 --
python/proton/_message.py | 2 --
python/proton/_url.py | 2 --
python/proton/handlers.py | 2 --
python/proton/reactor.py | 2 --
python/proton/tracing.py | 2 --
python/proton/utils.py | 2 --
.../broker_PROTON_2116_blocking_connection_object_leak.py | 4 ----
.../test_PROTON_1709_application_event_object_leak.py | 4 ----
.../test_PROTON_1800_syncrequestresponse_fd_leak.py | 4 ----
...test_PROTON_2111_container_ssl_ssldomain_object_leak.py | 4 ----
.../test_PROTON_2116_blocking_connection_object_leak.py | 4 ----
.../test_PROTON_2121_blocking_connection_fd_leak.py | 4 ----
python/tests/proton_tests/__init__.py | 2 --
python/tests/proton_tests/codec.py | 2 --
python/tests/proton_tests/common.py | 2 --
python/tests/proton_tests/connect.py | 1 -
python/tests/proton_tests/engine.py | 2 --
python/tests/proton_tests/handler.py | 2 --
python/tests/proton_tests/interop.py | 2 --
python/tests/proton_tests/message.py | 2 --
python/tests/proton_tests/reactor.py | 2 --
python/tests/proton_tests/sasl.py | 2 --
python/tests/proton_tests/soak.py | 3 ---
python/tests/proton_tests/ssl.py | 2 --
python/tests/proton_tests/transport.py | 2 --
python/tests/proton_tests/url.py | 2 --
python/tests/proton_tests/utils.py | 2 --
scripts/soak-check | 7 ++++---
tools/python/mllib/__init__.py | 14 ++------------
tools/python/mllib/dom.py | 10 +---------
tools/python/mllib/parsers.py | 2 --
tools/python/mllib/transforms.py | 7 +------
38 files changed, 8 insertions(+), 108 deletions(-)
diff --git a/c/src/encodings.h.py b/c/src/encodings.h.py
index 405656f52..f03f3a288 100644
--- a/c/src/encodings.h.py
+++ b/c/src/encodings.h.py
@@ -18,7 +18,6 @@
# under the License.
#
-from __future__ import print_function
import mllib
import optparse
import os
diff --git a/c/src/protocol.h.py b/c/src/protocol.h.py
index 0fecedf3c..a6a789e70 100644
--- a/c/src/protocol.h.py
+++ b/c/src/protocol.h.py
@@ -18,7 +18,6 @@
# under the License.
#
-from __future__ import print_function
from protocol import *
print("/* generated */")
diff --git a/c/tests/fdlimit.py b/c/tests/fdlimit.py
index ae750efb4..2f6b0807b 100644
--- a/c/tests/fdlimit.py
+++ b/c/tests/fdlimit.py
@@ -16,9 +16,6 @@
# specific language governing permissions and limitations
# under the License
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
import os
import subprocess
diff --git a/python/proton/__init__.py b/python/proton/__init__.py
index ddb41a41b..5f82a4bfe 100644
--- a/python/proton/__init__.py
+++ b/python/proton/__init__.py
@@ -26,7 +26,6 @@ The proton APIs consist of the following classes:
- :class:`Message` -- A class for creating and/or accessing AMQP message content.
- :class:`Data` -- A class for creating and/or accessing arbitrary AMQP encoded data.
"""
-from __future__ import absolute_import
import logging
import logging.config
diff --git a/python/proton/_exceptions.py b/python/proton/_exceptions.py
index ccff4c7ed..cad7a189e 100644
--- a/python/proton/_exceptions.py
+++ b/python/proton/_exceptions.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from cproton import PN_TIMEOUT, PN_INTR
diff --git a/python/proton/_io.py b/python/proton/_io.py
index 482f32795..fa814bb49 100644
--- a/python/proton/_io.py
+++ b/python/proton/_io.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import errno
import socket
import select
diff --git a/python/proton/_message.py b/python/proton/_message.py
index cf0f7b96d..82eaa58af 100644
--- a/python/proton/_message.py
+++ b/python/proton/_message.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from cproton import PN_DEFAULT_PRIORITY, PN_STRING, PN_UUID, PN_OVERFLOW, pn_error_text, pn_message, \
pn_message_annotations, pn_message_body, pn_message_clear, pn_message_decode, \
pn_message_encode, pn_message_error, pn_message_free, pn_message_get_address, pn_message_get_content_encoding, \
diff --git a/python/proton/_url.py b/python/proton/_url.py
index e24dd4d91..278b35fdd 100644
--- a/python/proton/_url.py
+++ b/python/proton/_url.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import socket
from urllib.parse import urlparse, urlunparse, quote, unquote
diff --git a/python/proton/handlers.py b/python/proton/handlers.py
index c32481251..5e1e8a6d0 100644
--- a/python/proton/handlers.py
+++ b/python/proton/handlers.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from ._handlers import MessagingHandler, IncomingMessageHandler, OutgoingMessageHandler, \
EndpointStateHandler, TransactionHandler, TransactionalClientHandler,\
Reject, Release,\
diff --git a/python/proton/reactor.py b/python/proton/reactor.py
index 2051fda28..6bb66d42d 100644
--- a/python/proton/reactor.py
+++ b/python/proton/reactor.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from ._reactor import Container, ApplicationEvent, EventInjector, Handler,\
LinkOption, ReceiverOption, SenderOption,\
AtLeastOnce, AtMostOnce, DynamicNodeProperties, Filter, Selector, \
diff --git a/python/proton/tracing.py b/python/proton/tracing.py
index a9e6e154e..35b2fa268 100644
--- a/python/proton/tracing.py
+++ b/python/proton/tracing.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from ._tracing import (
get_tracer, init_tracer
)
diff --git a/python/proton/utils.py b/python/proton/utils.py
index fb514c63c..bdc0e30ef 100644
--- a/python/proton/utils.py
+++ b/python/proton/utils.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from ._utils import BlockingConnection, BlockingSender, BlockingReceiver, SyncRequestResponse, SendException, LinkDetached, ConnectionClosed
__all__ = [
diff --git a/python/tests/integration/broker_PROTON_2116_blocking_connection_object_leak.py b/python/tests/integration/broker_PROTON_2116_blocking_connection_object_leak.py
index 9f84d7973..d4a3931fd 100644
--- a/python/tests/integration/broker_PROTON_2116_blocking_connection_object_leak.py
+++ b/python/tests/integration/broker_PROTON_2116_blocking_connection_object_leak.py
@@ -17,10 +17,6 @@
# under the License
#
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import optparse
import socket
import sys
diff --git a/python/tests/integration/test_PROTON_1709_application_event_object_leak.py b/python/tests/integration/test_PROTON_1709_application_event_object_leak.py
index cc6fee9e6..8fc9690e2 100644
--- a/python/tests/integration/test_PROTON_1709_application_event_object_leak.py
+++ b/python/tests/integration/test_PROTON_1709_application_event_object_leak.py
@@ -21,10 +21,6 @@
PROTON-1709 [python] ApplicationEvent causing memory growth
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import gc
import platform
import threading
diff --git a/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py b/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py
index 08932bfc5..32471ffd3 100644
--- a/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py
+++ b/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py
@@ -20,10 +20,6 @@
"""
PROTON-1800 BlockingConnection descriptor leak
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import contextlib
import gc
import os
diff --git a/python/tests/integration/test_PROTON_2111_container_ssl_ssldomain_object_leak.py b/python/tests/integration/test_PROTON_2111_container_ssl_ssldomain_object_leak.py
index 1563e2da7..c7708a179 100644
--- a/python/tests/integration/test_PROTON_2111_container_ssl_ssldomain_object_leak.py
+++ b/python/tests/integration/test_PROTON_2111_container_ssl_ssldomain_object_leak.py
@@ -21,10 +21,6 @@
PROTON-2111 python: memory leak on Container, SSL, and SSLDomain objects
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import contextlib
import gc
import os
diff --git a/python/tests/integration/test_PROTON_2116_blocking_connection_object_leak.py b/python/tests/integration/test_PROTON_2116_blocking_connection_object_leak.py
index b835b075c..3105ccb21 100644
--- a/python/tests/integration/test_PROTON_2116_blocking_connection_object_leak.py
+++ b/python/tests/integration/test_PROTON_2116_blocking_connection_object_leak.py
@@ -22,10 +22,6 @@ PROTON-2116 Memory leak in python client
PROTON-2192 Memory leak in Python client on Windows
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import gc
import logging
import os
diff --git a/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py b/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py
index 3160c88e8..229b9510f 100644
--- a/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py
+++ b/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py
@@ -21,10 +21,6 @@
PROTON-2121 python-qpid-proton 0.28 BlockingConnection leaks connections (does not close file descriptors)
"""
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
import contextlib
import gc
import os
diff --git a/python/tests/proton_tests/__init__.py b/python/tests/proton_tests/__init__.py
index eca82fe76..5d37bd5a7 100644
--- a/python/tests/proton_tests/__init__.py
+++ b/python/tests/proton_tests/__init__.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from . import codec
from . import engine
from . import message
diff --git a/python/tests/proton_tests/codec.py b/python/tests/proton_tests/codec.py
index a23bcd920..d8fb8f0d5 100644
--- a/python/tests/proton_tests/codec.py
+++ b/python/tests/proton_tests/codec.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import sys
from uuid import uuid4
diff --git a/python/tests/proton_tests/common.py b/python/tests/proton_tests/common.py
index 1e2e9a9b4..184b73b36 100644
--- a/python/tests/proton_tests/common.py
+++ b/python/tests/proton_tests/common.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from unittest import TestCase
from unittest import SkipTest
diff --git a/python/tests/proton_tests/connect.py b/python/tests/proton_tests/connect.py
index bc188856a..860f8acc6 100644
--- a/python/tests/proton_tests/connect.py
+++ b/python/tests/proton_tests/connect.py
@@ -1,4 +1,3 @@
-from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
diff --git a/python/tests/proton_tests/engine.py b/python/tests/proton_tests/engine.py
index 3bd339474..b9590a2b2 100644
--- a/python/tests/proton_tests/engine.py
+++ b/python/tests/proton_tests/engine.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import os
import gc
from time import time, sleep
diff --git a/python/tests/proton_tests/handler.py b/python/tests/proton_tests/handler.py
index e8fdebdd1..5035693e7 100644
--- a/python/tests/proton_tests/handler.py
+++ b/python/tests/proton_tests/handler.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import os
import gc
import traceback
diff --git a/python/tests/proton_tests/interop.py b/python/tests/proton_tests/interop.py
index 94e43b288..e69fb8ee5 100644
--- a/python/tests/proton_tests/interop.py
+++ b/python/tests/proton_tests/interop.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import os
from proton import *
diff --git a/python/tests/proton_tests/message.py b/python/tests/proton_tests/message.py
index 2e616f839..fd4937e3b 100644
--- a/python/tests/proton_tests/message.py
+++ b/python/tests/proton_tests/message.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from uuid import uuid4
from sys import version_info
diff --git a/python/tests/proton_tests/reactor.py b/python/tests/proton_tests/reactor.py
index 11b467e2e..eaa81ed6b 100644
--- a/python/tests/proton_tests/reactor.py
+++ b/python/tests/proton_tests/reactor.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import time
from proton.reactor import Container, ApplicationEvent, EventInjector, Selector, Backoff
diff --git a/python/tests/proton_tests/sasl.py b/python/tests/proton_tests/sasl.py
index c5a6e721d..9ea774f10 100644
--- a/python/tests/proton_tests/sasl.py
+++ b/python/tests/proton_tests/sasl.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import os
from proton import *
diff --git a/python/tests/proton_tests/soak.py b/python/tests/proton_tests/soak.py
index b90bdb8e7..25e5f21a9 100644
--- a/python/tests/proton_tests/soak.py
+++ b/python/tests/proton_tests/soak.py
@@ -1,4 +1,3 @@
-from __future__ import absolute_import
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -18,8 +17,6 @@ from __future__ import absolute_import
# under the License.
#
-from __future__ import absolute_import
-
import os
from .common import Test, Skipped, free_tcp_ports, \
diff --git a/python/tests/proton_tests/ssl.py b/python/tests/proton_tests/ssl.py
index 55facd079..c8f497d22 100644
--- a/python/tests/proton_tests/ssl.py
+++ b/python/tests/proton_tests/ssl.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import os
from proton import *
diff --git a/python/tests/proton_tests/transport.py b/python/tests/proton_tests/transport.py
index 77d21386a..077d8a4b5 100644
--- a/python/tests/proton_tests/transport.py
+++ b/python/tests/proton_tests/transport.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
import sys
from proton import *
diff --git a/python/tests/proton_tests/url.py b/python/tests/proton_tests/url.py
index dba971034..9e2fe05c1 100644
--- a/python/tests/proton_tests/url.py
+++ b/python/tests/proton_tests/url.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from proton import Url
from . import common
diff --git a/python/tests/proton_tests/utils.py b/python/tests/proton_tests/utils.py
index 5efd740ae..0b8d059b2 100644
--- a/python/tests/proton_tests/utils.py
+++ b/python/tests/proton_tests/utils.py
@@ -17,8 +17,6 @@
# under the License.
#
-from __future__ import absolute_import
-
from threading import Thread, Event
from uuid import uuid4
diff --git a/scripts/soak-check b/scripts/soak-check
index bf5b14713..3870ab2f7 100755
--- a/scripts/soak-check
+++ b/scripts/soak-check
@@ -17,9 +17,10 @@
# specific language governing permissions and limitations
# under the License.
#
-from __future__ import print_function
-import sys, optparse
-from subprocess import Popen,PIPE
+
+import optparse
+import sys
+from subprocess import Popen
def run_test(cmd):
try:
diff --git a/tools/python/mllib/__init__.py b/tools/python/mllib/__init__.py
index e520d6157..20daa3f9f 100644
--- a/tools/python/mllib/__init__.py
+++ b/tools/python/mllib/__init__.py
@@ -21,8 +21,6 @@
This module provides document parsing and transformation utilities for XML.
"""
-from __future__ import absolute_import
-
import os
import sys
import xml.sax
@@ -30,21 +28,13 @@ import types
from xml.sax.handler import ErrorHandler
from xml.sax.xmlreader import InputSource
-try:
- from io import StringIO
-except ImportError:
- from cStringIO import StringIO
-
-if sys.version_info[0] == 2:
- import types
- CLASS_TYPES = (type, types.ClassType)
-else:
- CLASS_TYPES = (type,)
+from io import StringIO
from . import dom
from . import transforms
from . import parsers
+CLASS_TYPES = (type,)
def transform(node, *args):
result = node
diff --git a/tools/python/mllib/dom.py b/tools/python/mllib/dom.py
index 3650a731e..b99174057 100644
--- a/tools/python/mllib/dom.py
+++ b/tools/python/mllib/dom.py
@@ -21,16 +21,8 @@
Simple DOM for both SGML and XML documents.
"""
-from __future__ import division
-from __future__ import generators
-from __future__ import nested_scopes
-from __future__ import absolute_import
-
import sys
-if sys.version_info[0] == 2:
- STRING_TYPES = (basestring,)
-else:
- STRING_TYPES = (str,)
+STRING_TYPES = (str,)
class Container:
diff --git a/tools/python/mllib/parsers.py b/tools/python/mllib/parsers.py
index 1287642af..9904b8831 100644
--- a/tools/python/mllib/parsers.py
+++ b/tools/python/mllib/parsers.py
@@ -20,8 +20,6 @@
"""
Parsers for XML to dom.
"""
-from __future__ import absolute_import
-
import xml.sax.handler
from .dom import *
diff --git a/tools/python/mllib/transforms.py b/tools/python/mllib/transforms.py
index 57f5a1fe6..b84c7f65d 100644
--- a/tools/python/mllib/transforms.py
+++ b/tools/python/mllib/transforms.py
@@ -20,13 +20,8 @@
"""
Useful transforms for dom objects.
"""
-from __future__ import absolute_import
-
from . import dom
-try:
- from io import StringIO
-except ImportError:
- from cStringIO import StringIO
+from io import StringIO
class Visitor:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org