Ticket #393 (new support)

Opened 6 years ago

Last modified 3 years ago

Upgrade to Python 3.2 - chapter in WIKI

Reported by: gecco Owned by: jortel
Priority: minor Milestone: 0.4
Component: suds (general) Version: 0.4
Keywords: Cc: keith.hughitt@…
Blocked By: Blocking:


Hi guys,

I think that Python 3 branch is now mature enough to earn at least a chapter in your WIKI...

I think that the Python 3 community is going to grow quickly in the next months and that many of those projects would like to take advantage of the greatest SOAP library -> SUDS

I am such a Python 3 developer and I investigated in upgrading SUDS to Python 3.2 ... and I succeed. Ok, probably ... no: for certain, there are some features that are not working... but simple SOAP calls are working great now within Python 3.

Of course, I am willing to share my experience. This could perhaps be a beginning of a completer upgrade guide...

Here my experience: UPGRADE SUDS TO PYTHON 3.2 1) Manually apply the following changes

Search all "__uniface__"-methods
    - drop them all and adapt __str__ (sometime you have to change some things, but mostly, their content becomes __str__)

    remove    "from urlparse import urlparse" 
    remove    "urllib2" 
    add        "import urllib.request, urllib.error" 
    change    "u2.HTTPError" to "urllib.error.HTTPError" 
    change    "u2.Request" to "urllib.request.Request" 
    change    "u2.build_opener" to "urllib.request.build_opener" 
    change    "u2.ProxyHandler" to "urllib.request.ProxyHandler" 
    change    "u2.__version__" to "urllib.request.__version__" 
    u2opener -> change "u2.Request.build_opener(*self.u2handlers())" to "urllib.request.build_opener()" 
    send ->    change "url = request.url" to "url = request.url.decode()" 
            change "result = Reply(200, fp.headers.dict, fp.read())" -> "result = Reply(200, fp.headers, fp.read())" 

    change "import urllib2 as u2" to "import urllib2" 
    change "u2.HTTPBasicAuthHandler" to "urllib2.HTTPBasicAuthHandler" 

    remove "from new import classobj" 
    change "subclass = classobj(name, bases, dict)" to "subclass = type(name, bases, dict)" 

    remove "self.types.sort(cmp=tc)" 

	change "content = ctx.document" to "content = ctx.document.decode()"

    remove "import re, soaparray" 
    add "import re" 
    add "import soaparray" 

    subclass -> remove "name = name.encode('utf-8')" 

    change "content = ctx.document" to "content = ctx.document.decode()" 

    change    2x    "reply = self.replyfilter(reply)" to "reply = self.replyfilter(reply).decode()"

2) run the script "2to3"

python C:\Python32\Tools\scripts\2to3.py -n -w C:\python-suds-0.4\suds


(I can provide a diff file if people are interested)


python3.patch (11.1 KB) - added by bernh 6 years ago.
python3.patch2 (15.5 KB) - added by bernh 6 years ago.

Change History

comment:1 in reply to: ↑ description Changed 6 years ago by sorim

Thanks! I'd really appreciate the diff file if you could attach it.

Changed 6 years ago by bernh

comment:2 follow-up: ↓ 3 Changed 6 years ago by bernh

Patch created by geccos instsructions attached. Works for me after running 2to3 for tests/builtin.py and tests/public.py

In its current form, the patch breaks python 2 support but I think it should be possible to support both python 2 and 3 from one codebase without too much effort (the patch is not that big).

comment:3 in reply to: ↑ 2 Changed 6 years ago by bernh

New patch uploaded (python3.patch2). This one does NOT break Python 2 support. Python 3 works after running 2to3 (or running python3 setup.py build).

The latest version of my patches can be found at https://bitbucket.org/bernh/suds-python-3-patches

Changed 6 years ago by bernh

comment:4 Changed 5 years ago by khughitt


I was wondering if someone could tell me if there is a timeline for adding Python 3 support to suds? We are currently using suds as a dependency for a project and would like to be able to support Python 3.

Thanks, Keith

comment:5 Changed 5 years ago by khughitt

  • Cc keith.hughitt@… added

comment:6 Changed 3 years ago by arkster

I'd like to know as well if there is a timeline. Python 3 has been out for a long time and suds is the main package that is preventing me from adopting Python 3 (as it may also for many other users out there).

comment:7 Changed 3 years ago by khughitt

Unfortunately as far as I can tell, development for suds has ceased.

You might want to check out a fork that is being actively maintained at: https://bitbucket.org/jurko/suds

Note: See TracTickets for help on using tickets.