Mailing List Archive

Help: Can you explain this error? (contains code snip)
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. |
-----------------------------------------------
Help: Can you explain this error? (contains code snip) [ In reply to ]
On Wed, 30 Jun 1999 16:49:58 -0700, H. P. Friedrichs
<@alliedsignal.com> wrote:
>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:

Make things simpler:

>>> int("123")

this works in Python 1.5.x and fails in 1.4. I believe this feature is
present in all 1.5.x and no standard 1.4 versions.

Use

>>> string.atoi("123")
to work on both versions.

Jeff
Help: Can you explain this error? (contains code snip) [ In reply to ]
From: "H. P. Friedrichs" <" HPeter.Friedrichs"@alliedsignal.com>

Thanks!

Pete

Jeff Epler wrote:

> On Wed, 30 Jun 1999 16:49:58 -0700, H. P. Friedrichs
> <@alliedsignal.com> wrote:
> >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:
>
> Make things simpler:
>
> >>> int("123")
>
> this works in Python 1.5.x and fails in 1.4. I believe this feature is
> present in all 1.5.x and no standard 1.4 versions.
>
> Use
>
> >>> string.atoi("123")
> to work on both versions.
>
> Jeff

--

-----------------------------------------------
| The opinions expressed here are my own, |
| and not necessarily those of my employer. |
-----------------------------------------------
Help: Can you explain this error? (contains code snip) [ In reply to ]
Thanks!

Pete

Jeff Epler wrote:

> On Wed, 30 Jun 1999 16:49:58 -0700, H. P. Friedrichs
> <@alliedsignal.com> wrote:
> >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:
>
> Make things simpler:
>
> >>> int("123")
>
> this works in Python 1.5.x and fails in 1.4. I believe this feature is
> present in all 1.5.x and no standard 1.4 versions.
>
> Use
>
> >>> string.atoi("123")
> to work on both versions.
>
> Jeff

--

-----------------------------------------------
| The opinions expressed here are my own, |
| and not necessarily those of my employer. |
-----------------------------------------------