fiuba08 / robotframework

Automatically exported from code.google.com/p/robotframework
Apache License 2.0
0 stars 0 forks source link

`BuiltIn.Convert to Hex/Octal` add 'L' suffix when input is bigger than sys.maxint #1739

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
$ python --version
Python 2.7.3

$ pybot --version
Robot Framework 2.8.5 (Python 2.7.3 on linux2)

>>> hex(0x7fffffff)
'0x7fffffff'
>>> hex(0x80000000)
'0x80000000L'

Original issue reported on code.google.com by heiko.th...@gmail.com on 24 Jun 2014 at 1:01

GoogleCodeExporter commented 9 years ago
As robot just uses directly python, this is sort of a python bug actually. It 
doesnt make sense to add that L to strings.

The actual limit depends from sys.maxint which again depends on whether you are 
running  on 32bit or 64bit python.

hex(sys.maxint+1) and also oct(sys.maxint+1) add that L. We can strip it away 
in future.

Original comment by jussi.ao...@gmail.com on 24 Jun 2014 at 2:45

GoogleCodeExporter commented 9 years ago
maybe you should consider using the __format__ function of the int type.

eg instead of
  ret = method(self._convert_to_integer(item, base)).upper()
where method is either hex, oct or bin

you could use
  ret = format(self._convert_to_integer(item, base), fmt)

where fmt is either 'X', 'x', 'o', 'b'.

in this case you don't need to strip the suffix and don't need to use upper(). 
And you could merge the length handling and probably the prefix struff into the 
format string .

Original comment by michael....@gmail.com on 25 Jun 2014 at 8:48

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 70b63d951a8b.

Fixed by stripping the offending 'L'. Cannot use 'format' as suggested
in comments because it is not supported by Python/Jython 2.5 that we
still need to support.

Original comment by pekka.klarck on 25 Jun 2014 at 11:48