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 "Erik Groeneveld (Jira)" <ji...@apache.org> on 2021/07/19 10:03:00 UTC

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

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)

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

Posted by Andi Vajda <va...@apache.org>.
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.

Andi..

> On Jul 19, 2021, at 12:03, Erik Groeneveld (Jira) <ji...@apache.org> wrote:
> 
> 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)