[Xapian-tickets] [Xapian] #346: Python 3 support

Xapian nobody at xapian.org
Tue Jul 24 05:36:39 BST 2012

#346: Python 3 support
 Reporter:  olly                      |       Owner:  richard  
     Type:  defect                    |      Status:  assigned 
 Priority:  highest                   |   Milestone:  1.3.2    
Component:  Xapian-bindings (Python)  |     Version:  SVN trunk
 Severity:  normal                    |    Keywords:           
Blockedby:                            |    Platform:  All      
 Blocking:                            |  

Comment(by olly):

 If you don't like what SWIG does by default, you can specify your own
 typemaps for std::string and SWIG should just use those instead of the
 built-in ones.  We already do this for the Python 2 bindings, for example
 the input typemap (in python/util.i) is:

 %typemap(in, fragment="XapianSWIG_anystring_as_ptr") std::string {
     std::string *ptr = (std::string *)0;
     int res = XapianSWIG_anystring_as_ptr(&($input), &ptr);
     if (!SWIG_IsOK(res) || !ptr) {
         %argument_fail((ptr ? res : SWIG_TypeError), "$type", $symname,
     $1 = *ptr;
     if (SWIG_IsNewObj(res)) delete ptr;

 {{{XapianSWIG_anystring_as_ptr}}} is a helper function we provide which
 handles both unicode and str strings - this is how we get the Python2
 bindings to accept either sort of string.

Ticket URL: <http://trac.xapian.org/ticket/346#comment:47>
Xapian <http://xapian.org/>

More information about the Xapian-tickets mailing list