Export to GitHub

hcpy - issue #7

sign_0b_0o_0x bug


Posted on May 2, 2012 by Happy Panda

hcpy_version6 bug: > hex > 0x11 x: 0x11 > 0x-12 x: -0x12 > +0x13 Command '+0x13' not recognized >

patch:

--- hcpy_version6.ori/number.py 2009-03-18 02:54:53.000000000 +0800 +++ hcpy_version6/number.py 2012-05-02 14:44:04.502491496 +0800 @@ -165,10 +165,15 @@

 def i(self, s):
     # Handle special cases like 0x, 0o, and 0b
     try:

+ if integer.match(s): + return Zn(int(s)) value = 0 match = False + sign=1 + if s[:1]=='+':s=s[1:] + elif s[:1]=='-':s=s[1:];sign=-1 if len(s) > 2: if s[:2] == "0x": value = int(s[2:], 16) match = True @@ -177,12 +182,10 @@ match = True elif s[:2] == "0b": value = int(s[2:], 2) match = True - if integer.match(s): - return Zn(int(s)) if match: - return Zn(value) + return Zn(value)*sign except ValueError: pass except Exception: raise

Status: New

Labels:
Type-Defect Priority-Medium