lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Petrus Hyvönen (Jira) <>
Subject [jira] [Commented] (PYLUCENE-51) "AttributeError: __module__" when running doctest
Date Wed, 16 Oct 2019 20:55:00 GMT


Petrus Hyvönen commented on PYLUCENE-51:



Looks like the name in a PyTypeObject tp_name should be of form "", and module
is automagically assigned to __module__. I think this is done for some of the special classes
but not for the wrapped classes if I understand correctly. I tried to add a "jcc." in front
of the name and it seems to propagate to the __module__ parameter. However this should preferably
be the wrapped module path instead of just "jcc", is there a good way to extract this path?
One way could be to have a new parameter, module to the DEFINE_TYPE but that would require
a bit of changes all around.

from the macros.h file:

#define DEFINE_TYPE(name, t_name, javaClass) \
PyType_Def PY_TYPE_DEF(name) = { \
 { \
 "jcc." #name, \                                                 
                                 /* default is #name added the "jcc." part
 sizeof(t_name), \
 0, \
 PY_TYPE_SLOTS(name) \
 }, \
 NULL, \
 PY_TYPE_BASES(name), \

> "AttributeError: __module__" when running doctest
> -------------------------------------------------
>                 Key: PYLUCENE-51
>                 URL:
>             Project: PyLucene
>          Issue Type: Bug
>         Environment: Ubuntu 19.04, Python 3.7
>            Reporter: Clément Jonglez
>            Priority: Major
> Dear all,
> I am using the Orekit Python wrapper by [~petrush] . I am running into errors & warnings
when trying to run tests with doctest. When collecting tests, it analyzes the classes (all
the 1000+ wrapped Java classes it seems) and runs into the following error:
> {noformat}
> [...]/lib/python3.7/site-packages/pytest_doctestplus/ in collect
>  for test in finder.find(module):
>  [...]/lib/python3.7/site-packages/pytest_doctestplus/ in find
>  extraglobs)
>  [...]/lib/python3.7/ in find
>  self._find(tests, obj, name, module, source_lines, globs, {})
>  [...]/lib/python3.7/ in _find
>  self._from_module(module, val)):
>  [...]/lib/python3.7/ in _from_module
>  return module._name_ == object._module_
>  E AttributeError: _module_{noformat}
> In doctest ([]), the
> {code:java}
> inspect.isclass(object) {code}
> condition at line 959 returns `True`, and therefore doctest tries to access the object's
__module__ attribute, which does not seem to exist.
> Besides, pytest prints a warning for each Java class being wrapped, also because they
have no __module__ attribute (this is one example of 1000+ warnings):
> {noformat}
> [...]/lib/python3.7/importlib/ DeprecationWarning: builtin type ExtendedKalmanFilter
has no __module_ attribute
>  return f(*args, **kwds){noformat}
> This phenomenon is new because 6 months ago I could run pytest & doctest successfully
with Orekit. I could not find which module contains the change that broke stuff since then
> To reproduce the phenomenon, you can check out []
>  I was trying to validate some poliastro features using the Orekit python wrapper. So
this code requires poliastro, it is available on conda-forge.
> Cheers
> Clément

This message was sent by Atlassian Jira

View raw message