Erik Groeneveld created PYLUCENE-59:
---------------------------------------
Summary: Python warns about missing __module__, but means that
type names have no '.' in them.
Key: PYLUCENE-59
URL: https://issues.apache.org/jira/browse/PYLUCENE-59
Project: PyLucene
Issue Type: Improvement
Reporter: Erik Groeneveld
When starting JCC, Python emits warnings such as
{code:java}
DeprecationWarning: builtin type Object has no __module__ attribute
{code}
It does this because, early in de process of creating types, it does not find a
'.' in de name of the type. The warning is somewhat misleading. The code from
Python is (fragment from typeobject.c):
{code:java}
/* Set type.__module__ */
s = strrchr(spec->name, '.');
if (s != NULL) {
int err;
modname = PyUnicode_FromStringAndSize(
spec->name, (Py_ssize_t)(s - spec->name));
if (modname == NULL) {
goto fail;
}
err = _PyDict_SetItemId(type->tp_dict, &PyId___module__, modname);
Py_DECREF(modname);
if (err != 0)
goto fail;
} else {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"builtin type %.200s has no __module__ attribute",
spec->name))
goto fail;
}
{code}
The name of the types in JCC do not include a package name and hence no dot.
Python 3.10 still does it like this.
The __module__ is set correctly later on in the JCC code!
Maybe you could add a package name (and a dot) to the typename to avoid these
warning?
I am just reporting this for your convenience and maybe it helps others seeing
these warnings.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)