Skip to content
Permalink
Browse files
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.
  • Loading branch information
astitcher committed Aug 9, 2022
1 parent 401606f commit a4375a8351c3435bd5025bb2481307efe97dc99e
Show file tree
Hide file tree
Showing 38 changed files with 8 additions and 108 deletions.
@@ -18,7 +18,6 @@
# under the License.
#

from __future__ import print_function
import mllib
import optparse
import os
@@ -18,7 +18,6 @@
# under the License.
#

from __future__ import print_function
from protocol import *

print("/* generated */")
@@ -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
@@ -26,7 +26,6 @@
- :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
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from cproton import PN_TIMEOUT, PN_INTR


@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import errno
import socket
import select
@@ -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, \
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import socket

from urllib.parse import urlparse, urlunparse, quote, unquote
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from ._handlers import MessagingHandler, IncomingMessageHandler, OutgoingMessageHandler, \
EndpointStateHandler, TransactionHandler, TransactionalClientHandler,\
Reject, Release,\
@@ -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, \
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from ._tracing import (
get_tracer, init_tracer
)
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from ._utils import BlockingConnection, BlockingSender, BlockingReceiver, SyncRequestResponse, SendException, LinkDetached, ConnectionClosed

__all__ = [
@@ -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
@@ -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
@@ -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
@@ -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
@@ -22,10 +22,6 @@
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
@@ -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
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from . import codec
from . import engine
from . import message
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import sys
from uuid import uuid4

@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from unittest import TestCase
from unittest import SkipTest

@@ -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
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import os
import gc
from time import time, sleep
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import os
import gc
import traceback
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import os

from proton import *
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from uuid import uuid4
from sys import version_info

@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import time

from proton.reactor import Container, ApplicationEvent, EventInjector, Selector, Backoff
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import os

from proton import *
@@ -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 @@
# under the License.
#

from __future__ import absolute_import

import os

from .common import Test, Skipped, free_tcp_ports, \
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import os

from proton import *
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

import sys

from proton import *
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from proton import Url

from . import common
@@ -17,8 +17,6 @@
# under the License.
#

from __future__ import absolute_import

from threading import Thread, Event
from uuid import uuid4

@@ -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:
@@ -21,30 +21,20 @@
This module provides document parsing and transformation utilities for XML.
"""

from __future__ import absolute_import

import os
import sys
import xml.sax
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
@@ -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:
@@ -20,8 +20,6 @@
"""
Parsers for XML to dom.
"""
from __future__ import absolute_import

import xml.sax.handler
from .dom import *

@@ -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:

0 comments on commit a4375a8

Please sign in to comment.