Help: Can you explain this error? (contains code snip)
H. P. Friedrichs
" HPeter.Friedrichs" at alliedsignal.com
Wed Jun 30 19:49:58 EDT 1999
Hello:
This is week 2 for me in python...What fun!
I have stumbled across an interesting problem. When the code below is
run under Win95 (python 1.5.2),it works without problems. If the same
code is run under Linux (python 1.4) I get the error:
Traceback (innermost last):
File "socksrv3.py", line 100, in ?
han=int(handle) #extract integer representation of handle
TypeError: int() argument can't be converted to int
The code section below is part of a larger program that receives ascii
"link messages" through a TCPIP socket. The format for the message is as
follows: an ascii "handle" followed by a tilde, followed by an ascii
"verb", followed by a tilde, and concludes with an ascii "value" An
example looks like this: "123~opensym~0"
Anyhow, the code below uses splitfields to break the message into it's
constituent parts. Later, at the line signified by the marker "====>"
the
program blows up when I attempt to convert the string "handle" into it's
integer equivalent.
What gives? Is the 1.4 version of python buggy, or am I overlooking
something? Thanks for your help in advance.
Pete
#*** receive link msg ****
cmd=conn.recv(1024) #try to get a message
if not cmd:
print"closing connection..."
conn.close() #good housekeeping...close
cnnctn
break
#*** extract components of link message ***********
fieldlist=splitfields(cmd,"~") #break message to
constituents
handle=fieldlist[0] #extract handle
verb=fieldlist[1] #extract verb
value=fieldlist[2] #extract value
#****** if command requested write to existing symbol, do this:
if verb == "writesym":
====> han=int(handle) #extract integer representation of
handle
masterdict[han]=float(value)
response=handle+"~"+verb+"~"+value #build response string
print "tx'd response:",response
print "dict status: ",masterdict
conn.send(response) #send response
continue
--
-----------------------------------------------
| The opinions expressed here are my own, |
| and not necessarily those of my employer. |
-----------------------------------------------
More information about the Python-list
mailing list