Skip to content

Commit

Permalink
Merge pull request suds-community#1 from jaraco/feature/py3
Browse files Browse the repository at this point in the history
Require Python 3.6 or later
  • Loading branch information
jaraco authored Sep 24, 2021
2 parents e46afd5 + 045427c commit 6e872a1
Show file tree
Hide file tree
Showing 61 changed files with 621 additions and 642 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v1.0.0
======

* Require Python 3.6 or later.


v0.6.0
======

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[build-system]
# pin to Setuptools prior to 58 for use_2to3 support
requires = ["setuptools<58"]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ formats = bztar,zip
# Folders 'pytest' unit testing framework should avoid when collecting test
# cases to run, e.g. internal build & version control system folders.
norecursedirs=.git .hg .svn build dist

[options]
python_requires = >=3.6
28 changes: 3 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,13 @@ def read_python_code(filename):
print("ERROR: Suds library setup script needs to be run from the folder "
"containing it.")
print()
print("Current folder: %s" % current_folder)
print("Script folder: %s" % script_folder)
print(("Current folder: %s" % current_folder))
print(("Script folder: %s" % script_folder))
sys.exit(-2)

# Load the suds library version information directly into this module without
# having to import the whole suds library itself. Importing the suds package
# would have caused problems like the following:
# * Forcing the imported package module to be Python 3 compatible without any
# lib2to3 fixers first being run on it (since such fixers get run only
# later as a part of the setup procedure).
# * Making the setup module depend on the package module's dependencies, thus
# forcing the user to install them manually (since the setup procedure that
# is supposed to install them automatically will not be able to run unless
Expand All @@ -87,17 +84,6 @@ def read_python_code(filename):
# distutils.setup() 'obsoletes' parameter not introduced until Python 2.5.
extra_setup_params["obsoletes"] = ["suds"]

if sys.version_info >= (3, 0):
extra_setup_params["use_2to3"] = True

# Teach Python's urllib lib2to3 fixer that the old urllib2.__version__
# data member is now stored in the urllib.request module.
import lib2to3.fixes.fix_urllib
for x in lib2to3.fixes.fix_urllib.MAPPING["urllib2"]:
if x[0] == "urllib.request":
x[1].append("__version__")
break;

with open('README.rst') as strm:
long_description = strm.read()

Expand Down Expand Up @@ -172,16 +158,8 @@ def run_tests(self):
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.0",
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Internet"],

# PEP-314 states that if possible license & platform should be specified
Expand Down
34 changes: 17 additions & 17 deletions suds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Project properties
#

from version import __build__, __version__
from .version import __build__, __version__


#
Expand All @@ -34,19 +34,19 @@

class MethodNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, u"Method not found: '%s'" % name)
Exception.__init__(self, "Method not found: '%s'" % name)

class PortNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, u"Port not found: '%s'" % name)
Exception.__init__(self, "Port not found: '%s'" % name)

class ServiceNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, u"Service not found: '%s'" % name)
Exception.__init__(self, "Service not found: '%s'" % name)

class TypeNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, u"Type not found: '%s'" % tostr(name))
Exception.__init__(self, "Type not found: '%s'" % tostr(name))

class BuildError(Exception):
msg = """
Expand All @@ -71,7 +71,7 @@ def __init__(self, name):
class WebFault(Exception):
def __init__(self, fault, document):
if hasattr(fault, 'faultstring'):
Exception.__init__(self, u"Server raised fault: '%s'" %
Exception.__init__(self, "Server raised fault: '%s'" %
fault.faultstring)
self.fault = fault
self.document = document
Expand Down Expand Up @@ -104,15 +104,15 @@ def objid(obj):

def tostr(object, encoding=None):
""" get a unicode safe string representation of an object """
if isinstance(object, basestring):
if isinstance(object, str):
if encoding is None:
return object
else:
return object.encode(encoding)
if isinstance(object, tuple):
s = ['(']
for item in object:
if isinstance(item, basestring):
if isinstance(item, str):
s.append(item)
else:
s.append(tostr(item))
Expand All @@ -122,7 +122,7 @@ def tostr(object, encoding=None):
if isinstance(object, list):
s = ['[']
for item in object:
if isinstance(item, basestring):
if isinstance(item, str):
s.append(item)
else:
s.append(tostr(item))
Expand All @@ -131,21 +131,21 @@ def tostr(object, encoding=None):
return ''.join(s)
if isinstance(object, dict):
s = ['{']
for item in object.items():
if isinstance(item[0], basestring):
for item in list(object.items()):
if isinstance(item[0], str):
s.append(item[0])
else:
s.append(tostr(item[0]))
s.append(' = ')
if isinstance(item[1], basestring):
if isinstance(item[1], str):
s.append(item[1])
else:
s.append(tostr(item[1]))
s.append(', ')
s.append('}')
return ''.join(s)
try:
return unicode(object)
return str(object)
except:
return str(object)

Expand All @@ -155,7 +155,7 @@ def tostr(object, encoding=None):
#

if sys.version_info < (3, 0):
from cStringIO import StringIO as BytesIO
from io import StringIO as BytesIO
else:
from io import BytesIO

Expand All @@ -165,7 +165,7 @@ class UnicodeMixin(object):
# For Python 3, __str__() and __unicode__() should be identical.
__str__ = lambda x: x.__unicode__()
else:
__str__ = lambda x: unicode(x).encode('utf-8')
__str__ = lambda x: str(x).encode('utf-8')

# Used instead of byte literals because they are not supported on Python
# versions prior to 2.6.
Expand All @@ -177,8 +177,8 @@ def byte_str(s='', encoding='utf-8', input_encoding='utf-8', errors='strict'):
strings encoded using the given input encoding.
"""
assert isinstance(s, basestring)
if isinstance(s, unicode):
assert isinstance(s, str)
if isinstance(s, str):
return s.encode(encoding, errors)
if s and encoding != input_encoding:
return s.decode(input_encoding, errors).encode(encoding, errors)
Expand Down
4 changes: 2 additions & 2 deletions suds/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __check_for_extra_arguments(self, args_required, args_allowed):
return

if self.__kwargs:
param_name = self.__kwargs.keys()[0]
param_name = list(self.__kwargs.keys())[0]
if param_name in self.__params_with_arguments:
msg = "got multiple values for parameter '%s'"
else:
Expand Down Expand Up @@ -263,7 +263,7 @@ def __match_ancestry(self, ancestry):
if len(stack) == 1:
return stack[0], ancestry
previous = stack[0]
for frame, n in zip(stack[1:], xrange(len(ancestry))):
for frame, n in zip(stack[1:], range(len(ancestry))):
if frame.id() is not ancestry[n]:
return previous, ancestry[n:]
previous = frame
Expand Down
6 changes: 3 additions & 3 deletions suds/bindings/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def param_defs(self, method):
@return: A collection of parameter definitions
@rtype: [I{pdef},..]
"""
raise Exception, 'not implemented'
raise Exception('not implemented')

def get_message(self, method, args, kwargs):
"""
Expand Down Expand Up @@ -286,7 +286,7 @@ def bodycontent(self, method, args, kwargs):
@return: The XML content for the <body/>
@rtype: [L{Element},..]
"""
raise Exception, 'not implemented'
raise Exception('not implemented')

def headercontent(self, method):
"""
Expand Down Expand Up @@ -339,7 +339,7 @@ def replycontent(self, method, body):
@return: The body content.
@rtype: [L{Element},...]
"""
raise Exception, 'not implemented'
raise Exception('not implemented')

def body(self, content):
"""
Expand Down
2 changes: 1 addition & 1 deletion suds/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, resolver):

def build(self, name):
""" build a an object for the specified typename as defined in the schema """
if isinstance(name, basestring):
if isinstance(name, str):
type = self.resolver.find(name)
if type is None:
raise TypeNotFound(name)
Expand Down
4 changes: 2 additions & 2 deletions suds/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import os
from tempfile import gettempdir as tmp
try:
import cPickle as pickle
import pickle as pickle
except Exception:
import pickle

Expand Down Expand Up @@ -136,7 +136,7 @@ def setduration(self, **duration):
@type duration: {unit:value}
"""
if len(duration) == 1:
arg = duration.items()[0]
arg = list(duration.items())[0]
if not arg[0] in self.units:
raise Exception('must be: %s' % str(self.units))
self.duration = arg
Expand Down
Loading

0 comments on commit 6e872a1

Please sign in to comment.