Hi,

I've been using and enjoying MetaKit on Mac OS X over the past couple
of days, but have run into a problem.  If I try to store a long int, I
sometimes get an coercion error, and sometimes get -1.  Here's an
example that demonstrates the latter:

% cat longtest.py   
import metakit

x = metakit.storage()
v = x.getas('hi[x:I,y:L]')
v.append(x=221400115,y=221400115)
v.append(x=221400115,y=2214001150)
print v[0].x, v[0].y
print v[1].x, v[1].y
% python2.2 longtest.py 
221400115 221400115
221400115 -1

I need to store large integers so this is somewhat of a problem.  Any
ideas what could be causing it?  If I use an 'I' column instead of the
'L' column, I get this error:

ValueError: int() literal too large: 2214001150

The coercion error is very strange, as the backtrace is incorrect and
it occurs _after_ the column is set, which makes me suspect some kind
of corruption at work.

metric3 count 2214001150 <type 'long'> L <type 'long'> set
Traceback (most recent call last):
  File "idvise.py", line 8, in ?
    ioms.addModelsFromIOMOX('~/Documents/Pablo/Idvisor/iomox-output')
  File "iom.py", line 31, in addModelsFromIOMOX
    [IOModel(self, os.path.join(self._iomoxDirPath, fn)) for fn in files]
  File "iom.py", line 116, in __init__
    for node in iomodel.getElementsByTagName('profile')]
  File "iom.py", line 136, in __init__
    models.addFragmentMetrics(IOFragment(fragmentNode), model, self)
  File "iom.py", line 69, in addFragmentMetrics
    for munit, mval in m.valDict.iteritems():
OverflowError: long int too large to convert to int

Obviously the for loop is not causing this issue :-)

In addition to OS X 10.2.2/Python 2.2.2 (compiled with GCC 3.1), I've
also tested on Linux with Python 2.2.1 (compiled with GCC 2.95.4).

I tested the Tcl binding as best I could - not being a Tcl person -
and it seemed that long ints can successfully be stored with the Tcl
binding.  There weren't any type specifiers so it was hard to tell!

Thanks,

-- 
=Nicholas Riley <[EMAIL PROTECTED]> | <http://www.uiuc.edu/ph/www/njriley>
        Pablo Research Group, Department of Computer Science and
  Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to