You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-commits@lucene.apache.org by va...@apache.org on 2019/10/16 23:36:09 UTC
svn commit: r1868527 - in /lucene/pylucene/trunk/jcc: CHANGES
jcc3/sources/JArray.cpp jcc3/sources/JCCEnv.cpp jcc3/sources/functions.cpp
Author: vajda
Date: Wed Oct 16 23:36:09 2019
New Revision: 1868527
URL: http://svn.apache.org/viewvc?rev=1868527&view=rev
Log:
added setting of type.__module__ for all generated wrapper types (python 3)
Modified:
lucene/pylucene/trunk/jcc/CHANGES
lucene/pylucene/trunk/jcc/jcc3/sources/JArray.cpp
lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp
lucene/pylucene/trunk/jcc/jcc3/sources/functions.cpp
Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=1868527&r1=1868526&r2=1868527&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Wed Oct 16 23:36:09 2019
@@ -1,6 +1,7 @@
Version 3.6 ->
------------------
- fixed bug with wrongly assuming 1BYTE_KIND python strings to be utf-8
+ - added setting of type.__module__ for all generated wrapper types (python 3)
-
Version 3.5 -> 3.6
Modified: lucene/pylucene/trunk/jcc/jcc3/sources/JArray.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc3/sources/JArray.cpp?rev=1868527&r1=1868526&r2=1868527&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc3/sources/JArray.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc3/sources/JArray.cpp Wed Oct 16 23:36:09 2019
@@ -57,7 +57,15 @@ public:
static void dealloc(_t_iterator *self)
{
Py_XDECREF(self->obj);
+#if PY_VERSION_HEX >= 0x03080000
+ PyObject *type = Py_TYPE(self);
+#endif
+
self->ob_base.ob_type->tp_free((PyObject *) self);
+
+#if PY_VERSION_HEX >= 0x03080000
+ Py_DECREF(type);
+#endif
}
static PyObject *iternext(_t_iterator *self)
@@ -124,7 +132,15 @@ template<typename T, typename U>
static void dealloc(U *self)
{
self->array = JArray<T>((jobject) NULL);
+#if PY_VERSION_HEX >= 0x03080000
+ PyObject *type = Py_TYPE(self);
+#endif
+
self->ob_base.ob_type->tp_free((PyObject *) self);
+
+#if PY_VERSION_HEX >= 0x03080000
+ Py_DECREF(type);
+#endif
}
template<typename U>
Modified: lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp?rev=1868527&r1=1868526&r2=1868527&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp Wed Oct 16 23:36:09 2019
@@ -1008,11 +1008,11 @@ jstring JCCEnv::fromPyString(PyObject *o
case PyUnicode_1BYTE_KIND: {
Py_ssize_t len = PyUnicode_GET_LENGTH(object);
Py_UCS1 *pchars = PyUnicode_1BYTE_DATA(object);
- std::vector<jchar> jchars((size_t) len, 0);
+ std::vector<jchar> jchars((size_t) len);
for (std::vector<jchar>::iterator it = jchars.begin();
it != jchars.end(); ++it)
- *it = (jchar) *(pchars++);
+ *it = (jchar) *(pchars++);
return get_vm_env()->NewString(jchars.data(), (size_t) len);
}
Modified: lucene/pylucene/trunk/jcc/jcc3/sources/functions.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc3/sources/functions.cpp?rev=1868527&r1=1868526&r2=1868527&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc3/sources/functions.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc3/sources/functions.cpp Wed Oct 16 23:36:09 2019
@@ -1735,6 +1735,15 @@ void installType(PyTypeObject **type, Py
}
PyModule_AddObject(module, name, (PyObject *) *type);
+
+ PyObject *module_name = PyModule_GetNameObject(module);
+
+ if (module_name != NULL)
+ {
+ PyObject_SetAttrString(
+ (PyObject *) *type, "__module__", module_name);
+ Py_DECREF(module_name);
+ }
}
}