• Register
Forum Thread
  Posts  
Tricky Python Error (Forums : Support : Tricky Python Error ) Locked
Thread Options
Sep 25 2016 Anchor

Hey,

When I compile my module I'm getting a weird error that shouldn't exist since the code has never changed. Nevertheless, it can't process and output the correct .txt file because of it.

Here's the error returned by cmd:


Exporting item data...
Traceback (most recent call last):
File "process_items.py", line 72, in
write_items(variables,variable_uses,tag_uses,quick_strings)
File "process_items.py", line 31, in write_items
get_weight(item[6]),
File "C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\Diplomacy\source\header_items.py", line 188, in get_weight
a = (y >> ibf_weight_bits) & ibf_armor_mask
TypeError: unsupported operand type(s) for >>: 'AGGREGATE' and 'int'
Exporting scene data...
Exporting troops data
Traceback (most recent call last):
File "process_troops.py", line 111, in
save_troops()
File "process_troops.py", line 49, in save_troops
strength = (attrib & 0xff)
TypeError: unsupported operand type(s) for &: 'AGGREGATE' and 'int'

----------------------------------------------- These are the actual lines of code within the header_items.py

def get_weight(y):
a = (y >> ibf_weight_bits) & ibf_armor_mask
return 0.25 * a

This is a mod for Mount and Blade Warband. I have compared the affected files to a 'known working' set of files from a completely different mod for differences and have yet to notice ANY discrepancies between the two. I believe that the troops file won't process because of the hangup located in the *items files, but I could be wrong there too.

Any thoughts or suggestions would be great. Thanks in advance.

EDIT: does this have to do with my version of python? currently using 2.7.12

Edited by: Athen.

Sep 25 2016 Anchor

There's not enough information here to say anything worthwhile but the error is linked to "y" not being of int type but aggregate type. Thus somewhere get_weight() is called with a parameter that is not of int type. According to your output item[6] is not of int type which in turns means somwhere a non-int is assed to item array resulting in the problem. See if you can figure out where the item[6] is coming from. You can put a "print(y)" in the the function before the troublesome line to see what kind of value ended up in item[6] that should not. Can help find the source of the problem.

Sep 26 2016 Anchor

Hey Dragonlord,

Thank you for responding.

Wow, your're 100% correct. Upon printing (y) I get this: {'thrust': 522, 'size': 90, 'speed': 103, 'weight': 1.5, 'swing': 528} when it should look something more like this: 121013314768770040302927872 which, of course, is an int.

I was able to trace the problem this way. Why debug when I can print! Sigh.

Thank you again for looking into this.

Sep 26 2016 Anchor

print (or printf in C++) is your best friend to find problems. Forget debuggers... print for the win :D

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.