[PyKDE] __unicode__ unsupported by sip?
    Nigel Stewart 
    ns at fluent.com
       
    Thu Mar 16 19:16:20 GMT 2006
    
    
  
Hello all,
In our mixed C++/python environment we want to interchange strings
between C++ and python as either QString or python unicode strings.
We have some sip bindings providing __str__ conversion to python
strings, but when we converted these to __unicode__ methods producing
python unicode strings, things mysteriously stopped working.
It appears that sip doesn't generate any C++ code for __unicode__
methods, wheras it does for __str__ methods.  Grepping sipgen
for the 20060315 sip snapshot seems to confirm this.  (see attachment)
Is it reasonable for the MethodCode of a __str__ method to produce
a unicode string, or is it sipgen that needs attention?
There is one __unicode__ method in PyQt, for QString.
PyQt also provides QString::__str__, also returning a
unicode string.
So, why does sip accept __unicode__ if it is ignored?
Regards,
Nigel Stewart
---------------
ns at nslnx ~/Wares/sip-snapshot-20060315/sipgen $ grep __str__ *.c *.h
parser.c:               {"__str__", str_slot, TRUE, 0},
ns at nslnx ~/Wares/sip-snapshot-20060315/sipgen $ grep str_slot *.c *.h
gencode.c:      return (st == str_slot || st == int_slot || st == long_slot ||
gencode.c:      case str_slot:
gencode.c:              sn = "str_slot";
parser.c:               {"__str__", str_slot, TRUE, 0},
sip.h:  str_slot,
ns at nslnx ~/Wares/sip-snapshot-20060315/sipgen $ grep __unicode__ *.c *.h
parser.c:               {"__unicode__", unicode_slot, TRUE, 0},
ns at nslnx ~/Wares/sip-snapshot-20060315/sipgen $ grep unicode_slot *.c *.h
gencode.c:              else if (md -> slot != no_slot && md -> slot != unicode_slot)
parser.c:               {"__unicode__", unicode_slot, TRUE, 0},
sip.h:  unicode_slot,
    
    
More information about the PyQt
mailing list