This PR allows Lazy Import to raise LazyImportError in a case like from bakery import applepie.
We added LazyImportError into exception_hierarchy.txt, allowing the backporting can pass test_baseexception. (may need a minor format change when backporting to cinder3.10)
We also found a way to fix the error in test_doctest, but test_doctest.py has a lot of difference between the crashy branch and cinder3.10. Thus, we noted the fix down here.
Traceback (most recent call last):
File "/Users/harperlin/Documents/GitHub/crashy_0623/run_foo2.py", line 1, in <module>
import foo2
^^^^^^^^^^^
File "/Users/harperlin/Documents/GitHub/crashy_0623/foo2.py", line 1, in <module>
from bakery import applepie
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'bakery'
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'bakery'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/harperlin/Documents/GitHub/crashy_0623/run_foo2.py", line 2, in <module>
foo2
^^^^
File "/Users/harperlin/Documents/GitHub/crashy_0623/foo2.py", line 2, in <module>
applepie
^^^^^^^^
LazyImportError: Error occurred when loading a lazy import. Original import was at file /Users/harperlin/Documents/GitHub/crashy_0623/foo2.py, line 1
We should increase one object count in builtins for LazyImportError. Therefore, if we change the upper bound value from 836 to 837, we can fix this testing failure.
Summary
LazyImportError
in a case likefrom bakery import applepie
.LazyImportError
intoexception_hierarchy.txt
, allowing the backporting can passtest_baseexception
. (may need a minor format change when backporting to cinder3.10)test_doctest
, buttest_doctest.py
has a lot of difference between the crashy branch and cinder3.10. Thus, we noted the fix down here.Test Plan
Pre-req
We has the same test plan as https://github.com/facebookincubator/cinder/pull/82, but we additionally create
foo2.py
andrun_foo2.py
under the same path ofpython.exe
.foo2.py
run_foo2.py
Test without Lazy Import
Run
Expected result:
Other testing results should be the same as https://github.com/facebookincubator/cinder/pull/82.
Test with Lazy Import
Run
Expected result:
Other testing results should be the same as https://github.com/facebookincubator/cinder/pull/82.
Fix test_doctest failure in cinder3.10
We should increase one object count in
builtins
forLazyImportError
. Therefore, if we change the upper bound value from836
to837
, we can fix this testing failure.