[Python] Stats properties doesn't return values

Bug #515526 reported by Sulan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ADCH++
Confirmed
Undecided
Unassigned

Bug Description

When i run adch++ via python module and try to access attributes in Stats class, they return property object.
Using something like print pyadchpp.Stats.queueBytes

Expected result:
print an integer

Actuall result:
printing <property object at 0x00C247E0>

Providing a testscript, put it in bin directory and run it.

Revision history for this message
Sulan (sulan80) wrote :
Revision history for this message
poy (poy) wrote :

some of these stats are 64-bit ints, or "long long"s, and Python doesn't have built-in support for these types as far as i know. so it is understandable that SWIG would use some kind of holder to get around these limitations and still be able to maintain precision.

i assume "print repr(stat)" would work, no?

Changed in adchpp:
status: New → Won't Fix
Revision history for this message
poy (poy) wrote :

documented on <http://www.swig.org/Doc1.3/SWIG.html#SWIG_nn10> actually, notice how "long long" is not in the list of standard int types, and this paragraph:
"Although the SWIG parser supports the long long datatype, not all language modules support it. This is because long long usually exceeds the integer precision available in the target language. In certain modules such as Tcl and Perl5, long long integers are encoded as strings. This allows the full range of these numbers to be represented. However, it does not allow long long values to be used in arithmetic expressions. It should also be noted that although long long is part of the ISO C99 standard, it is not universally supported by all C compilers. Make sure you are using a compiler that supports long long before trying to use this type with SWIG."

Revision history for this message
Sulan (sulan80) wrote :

i tested repr, didnt work. Could not these be returned as strings?

Revision history for this message
poy (poy) wrote :

looks like SWIG constructs an object and the int value can be retreived with:
a.Stats.queueBytes.fget()

this is really SWIG-specific behavior, i don't think it should be changed. also, for the Lua module, it seems to be able to give the stat value just fine.

Revision history for this message
Sulan (sulan80) wrote :

Ahh thanks that will do, didnt know about it.

Revision history for this message
Jacek Sieka (arnetheduck) wrote :

I'd say we should look into this...natural usage of the available functions should be a requirement...

Changed in adchpp:
status: Won't Fix → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.