Ticket #346: py3-xapian12765-updated2.patch

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

Second update of patch

  • 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  
    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