[C++-sig] Extending/Embedding FAQ: How do I tell "incomplete input" from "invalid input"?

Dietrich Bollmann diresu at web.de
Wed Apr 23 04:13:28 CEST 2008


Hi,

some time ago I programmed an interactive python interpreter shell
using paragraph 16 of the Extending/Embedding FAQ

  - 16   How do I tell "incomplete input" from "invalid input"?

http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input

For emulating the interactive behaviour of the python shell, the
following problem has to be solved - in the words of the FAQ:

  Sometimes you want to emulate the Python interactive interpreter's
  behavior, where it gives you a continuation prompt when the input is
  incomplete (e.g. you typed the start of an "if" statement or you
  didn't close your parentheses or triple string quotes), but it gives
  you a syntax error message immediately when the input is invalid.

The code relies on python error messages and the return values of
PyParser_ParseString() in order to evaluate if an input is
syntactically erroneous or just incomplete.  But as both - error
messages and the return values of PyParser_ParseString() - have
changed the code does not work anymore.

I wrote two postings to the python-list explaining my problems:

  - http://mail.python.org/pipermail/python-list/2008-April/487616.html
  - http://mail.python.org/pipermail/python-list/2008-April/487644.html

but as I didn't get any answer I decided to post another message here.

Is there anybody who has been able to write some similar code which 
also works for the current Python version?

Thanks for your help, 

Dietrich


By the way: Probably the FAQ should be corrected also.  Does anybody
know who is responsible for the "Extending/Embedding FAQ" (
http://www.python.org/doc/faq/extending/ ) ?






More information about the Cplusplus-sig mailing list