TypeError: initial_value must be unicode or None, not str,

I am using SOAPpy for soap wsdl services. I follow this totural . My code is as follow

from SOAPpy import WSDL
wsdlfile = 'http://track.tcs.com.pk/trackingaccount/track.asmx?WSDL'
server = WSDL.Proxy(wsdlfile)

I get this error in the last line of my code

Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/adil/Code/mezino/RoyalTag/royalenv/local/lib/python2.7/site-packages/SOAPpy/WSDL.py", line 85, in __init__
self.wsdl = reader.loadFromString(str(wsdlsource))
File "/home/adil/Code/mezino/RoyalTag/royalenv/local/lib/python2.7/site-packages/wstools/WSDLTools.py", line 52, in loadFromString
return self.loadFromStream(StringIO(data))
TypeError: initial_value must be unicode or None, not str

I tried to convert string to UTF using

wsdlFile = unicode('http://track.tcs.com.pk/trackingaccount/track.asmx?WSDL, "utf-8")

but still with the same error. What is missing here?

+6
source share
1 answer

I just ran into this problem with some very old 2.7 code that no longer worked due to the TLS update. After upgrading to the latest version of Python 2, I got this problem.

, , wstools , BytesIO StringIO.

StringIO. :

# WSDLTools.py
...
from IO import BytesIO
...
return self.loadFromStream(BytesIO(data))

, . , Python 3...

0

Source: https://habr.com/ru/post/1655947/


All Articles