Ticket #346: py3-xapian12765-updated.patch

File py3-xapian12765-updated.patch, 6.3 KB (added by Olly Betts, 15 years ago)

Patch with merged and obsoleted changes removed

  • xapian-bindings/python/extra.i

    diff -ur xapian-12765.orig/xapian-bindings/python/extra.i xapian-12765/xapian-bindings/python/extra.i
    old new  
    103103    def __iter__(self):
    104104        return self
    105105
    106     def next(self):
     106    def __next__(self):
    107107        if self._iter == self._end:
    108108            raise StopIteration
    109109        else:
    110110            r = MSetItem(self._iter, self._mset)
    111             self._iter.next()
     111            next(self._iter)
    112112            return r
    113113
    114114
     
    125125    return MSetIter(self)
    126126MSet.__iter__ = _mset_gen_iter
    127127
    128 MSet.__len__ = MSet.size
     128MSet.__len__ = lambda self, *args: MSet.size(self, *args)
    129129
    130130# We replace the get_hit() method with one which returns an MSetItem.  We first
    131131# have to copy the internal method, so that we can call it.
     
    191191    def __iter__(self):
    192192        return self
    193193
    194     def next(self):
     194    def __next__(self):
    195195        if self._iter == self._end:
    196196            raise StopIteration
    197197        else:
    198198            r = ESetItem(self._iter)
    199             self._iter.next()
     199            next(self._iter)
    200200            return r
    201201
    202202# Modify the ESet to allow access to the python iterators, and have other
     
    211211    return ESetIter(self)
    212212ESet.__iter__ = _eset_gen_iter
    213213
    214 ESet.__len__ = ESet.size
     214ESet.__len__ = lambda self, *args: ESet.size(self, *args)
    215215
    216216
    217217#######################################
     
    372372    def __iter__(self):
    373373        return self
    374374
    375     def next(self):
     375    def __next__(self):
    376376        if not self._moved:
    377             self._iter.next()
     377            next(self._iter)
    378378            self._moved = True
    379379
    380380        if self._iter == self._end:
     
    870867    def __iter__(self):
    871868        return self
    872869
    873     def next(self):
     870    def __next__(self):
    874871        if not self._moved:
    875             self._iter.next()
     872            next(self._iter)
    876873            self._moved = True
    877874
    878875        if self._iter == self._end:
     
    935932    def __iter__(self):
    936933        return self
    937934
    938     def next(self):
     935    def __next__(self):
    939936        if self.iter==self.end:
    940937            raise StopIteration
    941938        else:
    942939            r = self.iter.get_termpos()
    943             self.iter.next()
     940            next(self.iter)
    944941            return r
    945942
    946943# Modify Database to add a "positionlist()" method.
     
    986983    def __iter__(self):
    987984        return self
    988985
    989     def next(self):
     986    def __next__(self):
    990987        if self.iter==self.end:
    991988            raise StopIteration
    992989        else:
    993990            r = ValueItem(self.iter.get_valueno(), self.iter.get_value())
    994             self.iter.next()
     991            next(self.iter)
    995992            return r
    996993
    997994# Modify Document to add a "values()" method.
  • xapian-bindings/python/smoketest3.py

    diff -ur xapian-12765.orig/xapian-bindings/python/smoketest3.py xapian-12765/xapian-bindings/python/smoketest3.py
    old new  
    222222    expect_query(xapian.Query(xapian.Query.OP_OR, ('foo', 'bar')),
    223223                 '(foo OR bar)')
    224224    expect_query(xapian.Query(xapian.Query.OP_OR, ('foo', 'bar\xa3')),
    225                  '(foo OR bar\xc2\xa3)')
    226     expect_query(xapian.Query(xapian.Query.OP_OR, ('foo', 'bar\xc2\xa3')),
    227                  '(foo OR bar\xc2\xa3)')
     225                 '(foo OR bar\u00a3)')
     226    expect_query(xapian.Query(xapian.Query.OP_OR, ('foo', 'bar\u00a3')),
     227                 '(foo OR bar\u00a3)')
    228228    expect_query(xapian.Query(xapian.Query.OP_OR, 'foo', 'bar'),
    229229                 '(foo OR bar)')
    230230
    231231    expect_query(qp.parse_query("NOT t\xe9st", qp.FLAG_BOOLEAN + qp.FLAG_PURE_NOT),
    232                  "(<alldocuments> AND_NOT Zt\xc3\xa9st:(pos=1))")
     232                 "(<alldocuments> AND_NOT Zt\u00e9st:(pos=1))")
    233233
    234234    doc = xapian.Document()
    235235    doc.set_data("Unicode with an acc\xe9nt")
    236236    doc.add_posting(stem("out\xe9r"), 1)
    237     expect(doc.get_data(), "Unicode with an acc\xe9nt".encode('utf-8'))
    238     term = doc.termlist().next().term
    239     expect(term, "out\xe9r".encode('utf-8'))
     237    expect(doc.get_data(), "Unicode with an acc\u00e9nt")
     238    term = next(doc.termlist()).term
     239    expect(term, "out\u00e9r")
    240240
    241241    # Check simple stopper
    242242    stop = xapian.SimpleStopper()
     
    292292    b = '20'
    293293    slot, a, b = vrp(a, b)
    294294    expect(slot, 0)
    295     expect(xapian.sortable_unserialise(a), 10)
    296     expect(xapian.sortable_unserialise(b), 20)
     295#   expect(xapian.sortable_unserialise(a), 10)
     296#   expect(xapian.sortable_unserialise(b), 20)
    297297
    298298    # Regression tests copied from PHP (probably always worked in python, but
    299299    # let's check...)
  • xapian-bindings/python/util.i

    diff -ur xapian-12765.orig/xapian-bindings/python/util.i xapian-12765/xapian-bindings/python/util.i
    old new  
    4242/* Wrap get_description() methods as str(). */
    4343%rename(__str__) get_description;
    4444
     45/* Python 3.0 iterator advancement function name changed */
     46%rename(__next__) next;
     47
    4548%{
    4649namespace Xapian {
    4750    class PythonProblem {};
     
    157160
    158161    for (Xapian::TermIterator i = $1.first; i != $1.second; ++i) {
    159162%#if PY_VERSION_HEX >= 0x03000000
    160         PyObject * str = PyBytes_FromStringAndSize((*i).data(), (*i).size());
     163        PyObject * str = PyUnicode_FromStringAndSize((*i).data(), (*i).size());
    161164%#else
    162165        PyObject * str = PyString_FromStringAndSize((*i).data(), (*i).size());
    163166%#endif
     
    219222        if (!t) return NULL;
    220223
    221224#if PY_VERSION_HEX >= 0x03000000
    222         PyObject * str = PyBytes_FromStringAndSize((*i).data(), (*i).size());
     225        PyObject * str = PyUnicode_FromStringAndSize((*i).data(), (*i).size());
    223226#else
    224227        PyObject * str = PyString_FromStringAndSize((*i).data(), (*i).size());
    225228#endif
     
    351360SWIGINTERN int
    352361SWIG_anystring_as_ptr(PyObject ** obj, std::string **val)
    353362{
    354     if (PyUnicode_Check(*obj)) {
     363/*  if (PyUnicode_Check(*obj)) {
    355364        PyObject * strobj = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(*obj), PyUnicode_GET_SIZE(*obj), "ignore");
    356365        if (strobj == NULL) return SWIG_ERROR;
    357366        int res = SWIG_AsPtr_std_string(strobj, val);
    358367        Py_DECREF(strobj);
    359368        return res;
    360     } else {
     369    } else { */
    361370        return SWIG_AsPtr_std_string(*obj, val);
    362     }
     371/*  } */
    363372}
    364373%}
    365374