hugetim / nbstata

A Jupyter kernel for Stata built on pystata
https://hugetim.github.io/nbstata/
GNU General Public License v3.0
26 stars 2 forks source link

Kernel crashes with certain comments #25

Closed hugetim closed 1 year ago

hugetim commented 1 year ago

For example, a cell with just /* on the first line causes the cell to fail upon run. (No error message. Cell number remains [*].)

hugetim commented 1 year ago

To replicate, ensure echo = None. Run the following cell:

/*
d

The message "program temp_nbstata_program_name not found" shows below the cell, with the following Traceback in the console:

[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata_more.py", line 99, in run_as_program
    run_direct_cleaned(_program_define_code, quietly=True)
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata_more.py", line 20, in run_direct_cleaned
    out = run_direct(cmds, quietly, echo, inline)
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata.py", line 64, in run_direct
    return pystata.stata.run(cmds, quietly, echo, inline)
  File "C:\Program Files\Stata18\utilities\pystata\stata.py", line 323, in run
    _stata_wrk2("qui include " + tmpf, None, False, 1)
  File "C:\Program Files\Stata18\utilities\pystata\stata.py", line 116, in _stata_wrk2
    raise SystemError(err)
SystemError: unexpected end of file
r(612);

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\tjhuegerich\AppData\Local\Continuum\anaconda3\envs\Python2022-05\lib\site-packages\ipykernel\kernelbase.py", line 406, in dispatch_shell
    await result
  File "C:\Users\tjhuegerich\AppData\Local\Continuum\anaconda3\envs\Python2022-05\lib\site-packages\ipykernel\kernelbase.py", line 721, in execute_request
    reply_content = self.do_execute(
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\kernel.py", line 124, in do_execute
    code_cell.run()
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\cell.py", line 27, in run
    self.stata_session.dispatch_run(self.code,
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata_session.py", line 183, in dispatch_run
    run_noecho(code, self.sc_delimiter, run_as_prog=self._run_as_program_w_locals)
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\noecho.py", line 86, in run_noecho
    run_non_prog_noecho(block['std_code'], run_as_prog=run_as_prog)
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\noecho.py", line 70, in run_non_prog_noecho
    run_as_prog(std_non_prog_code)
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata_session.py", line 130, in _run_as_program_w_locals
    return run_as_program_w_locals(std_code, local_dict=self.get_local_dict())
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\noecho.py", line 55, in run_as_program_w_locals
    sm.run_as_program(f"""{locals_code}\n{std_code}""")
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata_more.py", line 102, in run_as_program
    run_single(f"quietly program drop {_program_name}", show_exc_warning=False)
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata.py", line 73, in run_single
    raise e
  File "c:\users\tjhuegerich\onedrive - lrca\nbstata\nbstata\stata.py", line 70, in run_single
    sfi.SFIToolkit.stata(cmd, echo)
  File "C:\Program Files\Stata18/ado\base\py\sfi.py", line 5363, in stata
    _stp._st_executecommand(s, becho)
SyntaxError: failed to execute the specified Stata command