Import within a function causes internal error sometimes
In my project, importing inside of a function sometimes causes an rpython internal error. My project runs pypy 3.6.9 [Pypy 7.3.1 with MSC v.1912 32 bit] on 64 bit windows.
It gives the following error:
SystemError: unexpected internal exception (please report a bug): RThreadErrorObject at 0x5a69f61c; internal traceback was dumped to stderr.
Rpython traceback:
File "rpython_jit_metainterp.c" line 19319, in BlackholeInterperter__resume_mainloop
File "rpython_jit_metainterp.c" line 27865, in BlackholeInterperter_handle_exception_in_frame
Rpython traceback:
File "pypy_interperter.c" line 52579, in BuiltinCode0_fastcall_0
File "pypy_module_imp.c", line 5361, in release_lock
File "pypy_module_imp.c", line 5417, in ImportRLock_release_lock
In my project, this happens in two places:
in pytest, under _pytest/python_api.py,
def _is_numpy_array(obj):
import sys
and
in asgiref, under local.py,
class Local:
def _get_context_id(self):
from .sync import AsyncToSync, SyncToAsync
In addition, another error has also happened when running importlib. A similar error has also happened in django/db/utils.py:110:
return _import_module('%s.base' % backend_name)
which calls importlib/__init__.py:126: in import_module.
return _bootstrap._gcd_import(name[level:],package, level)
there rest of the traceback for this error is as follows:
frozen importlib._bootstrap:1003: in _gcd_import
???
frozen importlib._bootstrap:977: in _find_and_load
???
frozen importlib._bootstrap:157: in __enter__
???
name = 'django.db.backends.mysql.base'
???
SystemError: unexpected internal exception (please report a bug): RThreadErrorObject at 0x5a69f61c; internal traceback was dumped to stderr.
Thanks for the hard work on this project. If I can give any more information, please let me know.