Issue2567

classification
Title: System state lost during JSR-223 initialisation
Type: behaviour Severity: normal
Components: Core Versions:
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jeff.allen
Priority: Keywords: test failure causes

Created on 2017-03-10.20:35:46 by jeff.allen, last changed 2017-03-10.20:35:46 by jeff.allen.

Messages
msg11216 (view) Author: Jeff Allen (jeff.allen) Date: 2017-03-10.20:35:45
I discovered this trying to re-enable test_jsr223. The ostensible symptom is that regrtest mysteriously becomes verbose:

> dist\bin\jython -m test.regrtest test_binhex test_jsr223 test_binhex
test_binhex
test_jsr223
C:\Users\Jeff\Documents\Eclipse\jython-trunk\dist\Lib\test\regrtest.py:679: RuntimeWarning: Parent module 'test' not found while handling absolute import
  import shutil
test_binhex
C:\Users\Jeff\Documents\Eclipse\jython-trunk\dist\Lib\test\regrtest.py:578: RuntimeWarning: Parent module 'test' not found while handling absolute import
  from test.junit_xml import Tee, write_direct_test
test_binhex (test.test_binhex.BinHexTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.029s

OK
All 3 tests OK.

But note also the warnings about having lost the 'test' module. Under pdb one may show that, after the JSR-223 test runs, and at the time of these imports, sys.modules and the module list that the import mechanism uses are different:
(Pdb) l
575         if verbose:
576             capture_stdout = None
577         else:
578             capture_stdout = cStringIO.StringIO()
579
580  ->     from test.junit_xml import Tee, write_direct_test
581         try:
582             save_stdout = sys.stdout
583
584             indirect_test = None
585             if junit_xml_dir:
(Pdb) gss = sys.modules['org'].__dict__['python'].__dict__['core'].Py.getSystemState()
(Pdb) id(sys)
198
(Pdb) id(gss)
202
(Pdb) len(sys.modules.keys()) - len(gss.modules.keys())
139
(Pdb)

When test_jsr233 is reduced to just initialising the engine:
    engine = ScriptEngineManager().getEngineByName("python")
we still get this result. (It's nothing in the test itself.)
History
Date User Action Args
2017-03-10 20:35:46jeff.allencreate