0
0
mirror of https://github.com/python/cpython.git synced 2024-11-28 08:20:55 +01:00
cpython/Python
Jeremy Hylton 9f1b9932b8 Print the offending line of code in the traceback for SyntaxErrors
raised by the compiler.

XXX For now, text entered into the interactive intepreter is not
printed in the traceback.

Inspired by a patch from Roman Sulzhyk

compile.c:

Add helper fetch_program_text() that opens a file and reads until it
finds the specified line number.  The code is a near duplicate of
similar code in traceback.c.

Modify com_error() to pass two arguments to SyntaxError constructor,
where the second argument contains the offending text when possible.

Modify set_error_location(), now used only by the symtable pass, to
set the text attribute on existing exceptions.

pythonrun.c:

Change parse_syntax_error() to continue of the offset attribute of a
SyntaxError is None.  In this case, it sets offset to -1.

Move code from PyErr_PrintEx() into helper function
print_error_text().  In the helper, only print the caret for a
SyntaxError if offset > 0.
2001-02-28 07:07:43 +00:00
..
.cvsignore
atof.c
bltinmodule.c
ceval.c Remove trailing comma from 'why_code' enum, which was introduced by the 2001-02-16 11:52:31 +00:00
codecs.c
compile.c Print the offending line of code in the traceback for SyntaxErrors 2001-02-28 07:07:43 +00:00
dup2.c
dynload_aix.c
dynload_beos.c
dynload_dl.c
dynload_hpux.c
dynload_mac.c
dynload_next.c
dynload_os2.c
dynload_shlib.c
dynload_stub.c
dynload_win.c
errors.c
exceptions.c
fmod.c
frozen.c
frozenmain.c
future.c Need to support single_input explicitly so from __future__ imports 2001-02-28 02:26:14 +00:00
getargs.c Related to SF bug 132008 (PyList_Reverse blows up). 2001-02-12 22:13:26 +00:00
getcompiler.c
getcopyright.c
getcwd.c
getmtime.c
getopt.c
getplatform.c
getversion.c
graminit.c
hypot.c
import.c Ack -- my eyes are getting bleary. Typos in the comment typo repairs. 2001-02-28 05:57:51 +00:00
importdl.c
importdl.h
marshal.c
memmove.c
modsupport.c
mystrtoul.c
pyfpe.c
pystate.c
pythonmain.c
pythonrun.c Print the offending line of code in the traceback for SyntaxErrors 2001-02-28 07:07:43 +00:00
sigcheck.c
strdup.c
strerror.c
strtod.c
structmember.c
symtable.c Improved __future__ parser; still more to do 2001-02-27 19:07:02 +00:00
sysmodule.c
thread_beos.h
thread_cthread.h
thread_foobar.h
thread_lwp.h
thread_nt.h
thread_os2.h
thread_pth.h
thread_pthread.h
thread_sgi.h
thread_solaris.h
thread_wince.h
thread.c
traceback.c