armoha / euddraft

System for pluginizing eudplib codes.
Other
28 stars 4 forks source link

`RuntimeError: generator raised StopIteration` happens for any compile error #109

Closed armoha closed 8 months ago

armoha commented 1 year ago

See https://cafe.naver.com/edac/120657

const owner = cunit.owner;
const exp = EUDBinaryMax(py_eval('lambda x: Kills(owner, AtLeast, x, "Men")'));

---------- Loading plugins... ----------
맵 ../../Save/basemap.scx 불러오는 중
Loading plugin EUDTurbo...
Loading plugin MSQC...
[MSQC] map size: 64x64, 7 men x 1 QCUnits (ID: 58)
MouseLoc=P1:m1, P2:m2, P3:m3, P4:m4, P5:m5, P6:m6, P7:m7
QCDebug enabled. You can disable it by writing 'QCDebug: false'.
Loading plugin main.eps...
[epScript] "main.eps" 컴파일 중...
                          *                                         *
        *                                        *
                        [[ freeze activated ]]
                                  *                       *
                *                                                          *
--------- Injecting plugins... ---------
Freeze - sectorSize disabled
CUnitTest.scx에 저장 중...
Exception ignored in: <function CtrlStruOpener.__del__ at 0x000001C151041580>
Exception ignored in: <function CtrlStruOpener.__del__ at 0x000001C151041580>
==========================================
Process Process-2:
Traceback (most recent call last):
  File "C:\euddraft\applyeuddraft.py", line 193, in applyEUDDraft
    ep.SaveMap(ofname, payloadMain, sectorSize=sectorSize)
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\maprw\savemap.py", line 54, in SaveMap
    root = _MainStarter(rootf)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\maprw\injector\mainloop.py", line 62, in _MainStarter
    mf()
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudtypedfuncn.py", line 67, in __call__
    rets = super().__call__(*args, ret=ret)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudfuncn.py", line 202, in __call__
    self._CreateFuncBody()
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudfuncn.py", line 102, in _CreateFuncBody
    final_rets = self._callerfunc(*self._fargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudf.py", line 31, in caller
    return fdecl_func(*args)
           ^^^^^^^^^^^^^^^^^
  File "C:\euddraft\applyeuddraft.py", line 61, in payloadMain
    onPluginStart()
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudtypedfuncn.py", line 67, in __call__
    rets = super().__call__(*args, ret=ret)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudfuncn.py", line 202, in __call__
    self._CreateFuncBody()
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudfuncn.py", line 102, in _CreateFuncBody
    final_rets = self._callerfunc(*self._fargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\core\eudfunc\eudf.py", line 31, in caller
    return fdecl_func(*args)
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\armo\Documents\StarCraft\Maps\TEST\CUnit\main.eps", line -1, in onPluginStart
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\eudplib\eudlib\utilf\binsearch.py", line 45, in EUDBinaryMax
    if cs.EUDIfNot()(cond(x)):
                     ^^^^^^^
  File "<string>", line 1, in <lambda>
NameError: name 'owner' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\P311\Lib\traceback.py", line 353, in _walk_tb_with_full_positions
    positions = _get_code_position(tb.tb_frame.f_code, tb.tb_lasti)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 367, in _get_code_position
    return next(itertools.islice(positions_gen, instruction_index // 2, None))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\P311\Lib\multiprocessing\process.py", line 314, in _bootstrap
    self.run()
  File "C:\P311\Lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "euddraft.py", line 65, in applyEUDDraft
  File "C:\euddraft\applyeuddraft.py", line 216, in applyEUDDraft
    excs = traceback.format_exception(exc_type, exc_value, exc_traceback)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 139, in format_exception
    te = TracebackException(type(value), value, tb, limit=limit, compact=True)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 690, in __init__
    self.stack = StackSummary._extract_from_extended_frame_gen(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 416, in _extract_from_extended_frame_gen
    for f, (lineno, end_lineno, colno, end_colno) in frame_gen:
RuntimeError: generator raised StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\P311\Lib\traceback.py", line 353, in _walk_tb_with_full_positions
    positions = _get_code_position(tb.tb_frame.f_code, tb.tb_lasti)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 367, in _get_code_position
    return next(itertools.islice(positions_gen, instruction_index // 2, None))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 139, in run
    module_init.run(name + "__main__")
  File "C:\Users\armo\AppData\Local\pypoetry\Cache\virtualenvs\euddraft-B4hPMJVp-py3.11\Lib\site-packages\cx_Freeze\initscripts\console.py", line 18, in run
    exec(code, module_main.__dict__)  # pylint: disable=exec-used
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "euddraft.py", line 107, in <module>
  File "C:\P311\Lib\multiprocessing\context.py", line 150, in freeze_support
    freeze_support()
  File "C:\P311\Lib\multiprocessing\spawn.py", line 77, in freeze_support
    spawn_main(**kwds)
  File "C:\P311\Lib\multiprocessing\spawn.py", line 120, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\multiprocessing\spawn.py", line 133, in _main
    return self._bootstrap(parent_sentinel)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\multiprocessing\process.py", line 330, in _bootstrap
    traceback.print_exc()
  File "C:\P311\Lib\traceback.py", line 183, in print_exc
    print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
  File "C:\P311\Lib\traceback.py", line 124, in print_exception
    te = TracebackException(type(value), value, tb, limit=limit, compact=True)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 745, in __init__
    context = TracebackException(
              ^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 690, in __init__
    self.stack = StackSummary._extract_from_extended_frame_gen(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\P311\Lib\traceback.py", line 416, in _extract_from_extended_frame_gen
    for f, (lineno, end_lineno, colno, end_colno) in frame_gen:
RuntimeError: generator raised StopIteration
armoha commented 1 year ago

Should be fixed by downgrading Python version for now...

armoha commented 1 year ago

Fixed in euddraft 0.9.9.8

armoha commented 11 months ago

Fixed in euddraft 0.9.9.8

It was not a real fix but just a workaround by downgrading to Python 3.10.8. We need to tackle this for real.

armoha commented 8 months ago

Fixed by following commits:

  1. https://github.com/armoha/eudplib/commit/952833d2b712a44878c912a570f95c37c7d4f351
  2. https://github.com/armoha/eudplib/commit/1b93a578d6564063f3660f50c1c7f4f6271f238b
  3. https://github.com/armoha/eudplib/commit/0fc372ad04a1159ede9ac86a90af143b441efe06