You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by "Andi Vajda (Jira)" <ji...@apache.org> on 2021/07/19 13:23:00 UTC

[jira] [Commented] (PYLUCENE-59) Python warns about missing __module__, but means that type names have no '.' in them.

    [ https://issues.apache.org/jira/browse/PYLUCENE-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17383336#comment-17383336 ] 

Andi Vajda commented on PYLUCENE-59:
------------------------------------

I did 'fix' that as much as possible by setting it later as you saw in the
code already. The warning is harmless and a proper fix to workaround what
looks like a kludge in Python is more involved than the problem is worth.


> 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
>            Priority: Trivial
>
> 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)