[Soap-Python] Small error running rpclib under python3 - found and fixed

Frank Millman frank at chagford.com
Mon Dec 5 09:10:26 CET 2011


Hi all

I am dabbling with rpclib - 2.4.7-beta. I am running python 3.2, so I ran
2to3 and it imports ok.

I wanted to run the UserManager example, so I downloaded server_basic.py,
ran 2to3 on it, and tried to run it. It failed with the following traceback
-

DEBUG:rpclib.interface.xml_schema._base:generating schema for
targetNamespace='r
pclib.examples.user_manager', prefix: 'tns'
Traceback (most recent call last):
  File "F:\junk\rpclib\usermanager\server_basic.py", line 61, in <module>
    interface=Wsdl11(), in_protocol=Soap11(), out_protocol=Soap11())
  File
"C:\Python32\lib\site-packages\rpclib-2.4.7_beta-py3.2.egg\rpclib\applica
tion.py", line 76, in __init__
    self.in_protocol.set_app(self)
  File
"C:\Python32\lib\site-packages\rpclib-2.4.7_beta-py3.2.egg\rpclib\protoco
l\xml\_base.py", line 237, in set_app
    wsdl.build_validation_schema()
  File
"C:\Python32\lib\site-packages\rpclib-2.4.7_beta-py3.2.egg\rpclib\interfa
ce\xml_schema\_base.py", line 134, in build_validation_schema
    etree.ElementTree(v).write(f, pretty_print=True)
  File "lxml.etree.pyx", line 1853, in lxml.etree._ElementTree.write
(src/lxml\l
xml.etree.c:44355)
  File "serializer.pxi", line 478, in lxml.etree._tofilelike
(src/lxml\lxml.etre
e.c:90649)
  File "lxml.etree.pyx", line 282, in
lxml.etree._ExceptionContext._raise_if_sto
red (src/lxml\lxml.etree.c:7972)
  File "serializer.pxi", line 378, in lxml.etree._FilelikeWriter.write
(src/lxml
\lxml.etree.c:89527)
TypeError: must be str, not bytes

After a bit of investigation I made the following change, in
rpclib/interface/xml_schema/_base.py, line 133 -

-   f = open(file_name, 'w')
+   f = open(file_name, 'wb')

The program then ran successfully, and I could view the wsdl in a browser.

Hope this is useful.

Frank Millman



More information about the Soap mailing list