Converting negative integer string to integer results in error #111

Open
pyjsorg opened this Issue Apr 27, 2012 · 2 comments

Projects

None yet

1 participant

@pyjsorg
Contributor
pyjsorg commented Apr 27, 2012

What steps will reproduce the problem?

  1. int('-1')

I believe the problem arises due to the radix_regex not properly matching against numbers that start with '-'.

I've attached a patch that fixes the issue for me, but I am no regex expert so there may be a better way to accomplish this.

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=612 (May 04, 2011 22:14:07)

@pyjsorg
Contributor
pyjsorg commented Apr 27, 2012

From andrewre...@gmail.com on May 04, 2011 23:05:11:
Additional patch to add this to libtest.

@pyjsorg
Contributor
pyjsorg commented Apr 27, 2012

From cornelis...@gmail.com on May 09, 2011 09:06:56:
I've changed the regexes. The second star in /^ -[01]+ *$/i, should be an question mark, otherwise --1 would also match. In python ' - 1' is also valid, so I've changed it to /^ *-? *[01]+ *$/i, (etc.) and added some code to get rid of the spaces before feeding it to the javascript function parseInt

I've also added tests for '- 2' and ' - 3'.

See commit 8cadc3c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment