variable has no type - ERROR!!

33 views
Skip to first unread message

Sans

unread,
Jun 6, 2011, 10:04:32 AM6/6/11
to shedskin-discuss
Dear all,

The above error is coming from this piece of code:

************************
field_nr = {'startdate': 3, 'enddate': 5, 'jobstatus': 4, 'cputime':
2, 'jobid': 0, 'queue': 7, 'user': 1, 'exechost': 6}
f_list = ['user', 'enddate', 'cputime']

fields = [field_nr[m] for m in f_list]
*************************

I get this error:
*WARNING* torque_history.py:399: variable 'm' has no type

during the file generation and it fails with this error:
error: invalid conversion from ‘void*’ to ‘__shedskin__::str*’
error: initializing argument 1 of ‘V __shedskin__::dict<K,
V>::__getitem__(K) [with K = __shedskin__::str*, V = int]’

in the end during compilation. How should I rewrite that bit?

Cheers, San

Mark Dufour

unread,
Jun 6, 2011, 11:23:03 AM6/6/11
to shedskin...@googlegroups.com
hi sans,

************************
field_nr =  {'startdate': 3, 'enddate': 5, 'jobstatus': 4, 'cputime':
2, 'jobid': 0, 'queue': 7, 'user': 1, 'exechost': 6}
f_list = ['user', 'enddate', 'cputime']

fields = [field_nr[m] for m in f_list]
*************************

thanks for reporting. looks like a bug! this fragment seems to work fine when compiled separately though.. could you perhaps send me a larger fragment (as small as possible) that shedskin fails on, or the whole program? my guess is that there is another variable 'm' somewhere that is interfering with this one, but that's just a hunch..


thanks again,
mark.
--
http://www.youtube.com/watch?v=E6LsfnBmdnk

Sans

unread,
Jun 6, 2011, 12:22:03 PM6/6/11
to shedskin-discuss
I'm puzzled now; replaced "m" with "mm" and the error still exists.
Then made this smaller one from the actual code and that works!

*********************************************************************************************
#!/usr/bin/env python26

q_list = [('94.vmtest2', 'sgmops', 'John Dee', '27/04 00:27:26', 'C',
'27/04 00:28:31', 'vmtest1.hep', 'express', '00:00:10', '00:01:04',
'https://lb-monit.physics.ox.ac.uk:9000/S2pcB8Wbtdn35b9w'),
('96.vmtest2', 'sgmops', 'John Dee', '27/04 01:27:26', 'C',
'27/04 01:28:33', 'vmtest1.hep', 'short', '00:00:09', '00:01:06',
'https://lcglb02.gridpp.rl.ac.uk:9000/8r8Ire9KxQI_LfeBOWhw'),
('98.vmtest2', 'sgmops', 'Andy Lapka', '27/04 06:21:07',
'C','27/04 06:22:22', 'vmtest1.hep', 'express', '00:00:10',
'00:01:13', 'https://wmssamtest01.cern.ch:9000/FiC4GP-LBiW55h5RAFdw'),
('99.vmtest2', 'sgmops', 'Andy Lampka', '27/04 07:19:56',
'C', '27/04 07:21:12', 'vmtest1.hep', 'express', '00:00:10',
'00:01:14', 'https://wms220.cern.ch:9000/cQg3Zy4WirC3ALmpzLw'),
('103.vmtest2', 'sgmops', 'And yLapka', '27/04 14:08:00',
'C', '27/04 14:09:16', 'vmtest1.hep', 'express', '00:00:10',
'00:01:16', 'https://wmssamtest02.cern.ch:9000/7C2EBltqVYV_iZ9Exw'),
('102.vmtest2', 'sgmops', 'John Dee', '27/04 14:02:38', 'C',
'27/04 14:10:12', 'vmtest1.hep', 'short', '00:00:10', '00:01:10',
'https://lb-monit.physics.ox.ac.uk:9000/XE1VavnZZEinCEKZQ')]

q_dict = {'realuser': 'johndee', 'queue': 'short'}
f_list = ['user', 'startdate', 'cputime','egiid']

# List of key fields
ttl_lst = ['Job Id','User','Real User','Start Date','S','End Date',\
'Exec Host','Queue','CPU Time','Wall Time','EGI Id']

def main(f=None):

if f is None: f = []
fld_lens = range(len(ttl_lst))

field_nr = dict([((ttl_lst[x].lower().replace(' ','')), x) for x
in fld_lens])
field_nr['jobstatus'] = field_nr.pop('s')

max_lens = [max([len(item[x]) for item in q_list]) for x in
fld_lens]
#print "Field_Nr: ", field_nr, "\n"

if len(f) == 0: fields = fld_lens[:8]
else:
fields = [field_nr[m] for m in f]
if 0 not in fields: fields.insert(0,0)

print "\n"," ".join([ttl_lst[ix].ljust(max_lens[ix]) for ix in
fields])
print " ".join(['-'*(max_lens[ix]) for ix in fields])

for tm in q_list:
ssd = tuple([ m.lower().replace(' ','') for m in tm ])
if all(ssd[field_nr[k]] == v for k,v in q_dict.iteritems()):
print ' '.join([tm[x].ljust(max_lens[x]) for x in
fields])

if __name__ == "__main__":
#main()
main(f_list)

****************************************************************************

Do you want me to send the actual one? Or any other further
thought(s)?

-San

Mark Dufour

unread,
Jun 7, 2011, 9:44:35 AM6/7/11
to shedskin...@googlegroups.com
On Mon, Jun 6, 2011 at 6:22 PM, Sans <r.sant...@gmail.com> wrote:
I'm puzzled now; replaced "m" with  "mm" and the error still exists.
Then made this smaller one from the actual code and that works!


fun with type inference.. :-) yeah, please send me the whole program, unless you'd like to try and pinpoint things further..


thanks!
mark.
--
http://www.youtube.com/watch?v=E6LsfnBmdnk

Reply all
Reply to author
Forward
0 new messages