cpython/Python
Guido van Rossum 8746082175 Patch by Tim Peters:
Introduce a new builtin exception, UnboundLocalError, raised when ceval.c
tries to retrieve or delete a local name that isn't bound to a value.
Currently raises NameError, which makes this behavior a FAQ since the same
error is raised for "missing" global names too:  when the user has a global
of the same name as the unbound local, NameError makes no sense to them.
Even in the absence of shadowing, knowing whether a bogus name is local or
global is a real aid to quick understanding.

Example:

D:\src\PCbuild>type local.py
x = 42

def f():
    print x
    x = 13
    return x

f()

D:\src\PCbuild>python local.py
Traceback (innermost last):
  File "local.py", line 8, in ?
    f()
  File "local.py", line 4, in f
    print x
UnboundLocalError: x

D:\src\PCbuild>

Note that UnboundLocalError is a subclass of NameError, for compatibility
with existing class-exception code that may be trying to catch this as a
NameError.  Unfortunately, I see no way to make this wholly compatible
with -X (see comments in bltinmodule.c):  under -X, [UnboundLocalError
is an alias for NameError --GvR].

[The ceval.c patch differs slightly from the second version that Tim
submitted; I decided not to raise UnboundLocalError for DELETE_NAME,
only for DELETE_LOCAL.  DELETE_NAME is only generated at the module
level, and since at that level a NameError is raised for referencing
an undefined name, it should also be raised for deleting one.]
1999-06-22 14:47:32 +00:00
..
Makefile.in Changes to deal with the sigcheck+intrcheck vs. signalmodule controversy. 1998-10-07 22:51:56 +00:00
atof.c New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
bltinmodule.c Patch by Tim Peters: 1999-06-22 14:47:32 +00:00
ceval.c Patch by Tim Peters: 1999-06-22 14:47:32 +00:00
compile.c Implement -OO; "unsafe" optimization that removes docstrings. 1999-01-28 15:08:09 +00:00
dup2.c MPW changes 1994-08-29 10:43:12 +00:00
errors.c Patch by Christian Tismer for Win32, to use FormatMessage() instead of 1999-04-21 15:27:31 +00:00
fmod.c New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
frozen.c Add primitive test for frozen package. 1998-04-03 21:10:36 +00:00
frozenmain.c Call PyInitFrozenExtensions() as requested by Mark Hammond (his patch). 1999-01-02 21:42:48 +00:00
getargs.c Patch by Tommy Burnette to accept an arbitrary sequence when "(...)" 1999-02-17 23:16:43 +00:00
getcompiler.c Make it return a _const_ char*. 1997-07-19 19:48:41 +00:00
getcopyright.c New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
getcwd.c New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
getmtime.c First part of package support. 1997-09-05 07:33:22 +00:00
getopt.c Patch by Chris Herborth: 1998-12-17 18:03:10 +00:00
getplatform.c Make it return a _const_ char*. 1997-07-19 19:48:41 +00:00
getversion.c Allow longer strings (up to 80 chars each) for version, build, 1999-04-22 12:03:40 +00:00
graminit.c Make first raise argument optional 1998-04-09 21:39:57 +00:00
hypot.c *** empty log message *** 1996-08-29 18:10:41 +00:00
import.c Changes by Mark Hammond for Windows CE. Mostly of the form 1999-04-07 16:07:23 +00:00
importdl.c Patches by William Lewis for Nextstep descendants. 1999-01-27 17:53:11 +00:00
importdl.h Added declarations for Mac code resource modules (Jack Jansen). 1998-08-06 13:36:43 +00:00
marshal.c The previous checkin contained an experiment of Greg Stein's that wasn't 1998-10-08 01:45:47 +00:00
memmove.c New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
modsupport.c Change rare occurrences of #if HAVE_LONG_LONG to #ifdef. 1999-01-25 21:48:56 +00:00
mystrtoul.c Changes by Mark Hammond for Windows CE. Mostly of the form 1999-04-07 16:07:23 +00:00
pyfpe.c Restructure the file so that it is never empty. No longer needs 1998-08-25 17:48:25 +00:00
pystate.c CRITICAL PATCH! 1999-06-18 14:22:24 +00:00
pythonmain.c Allow mac user to set "command line flags" by option-starting python. 1995-07-29 13:53:59 +00:00
pythonrun.c Alas, get rid of the Win specific hack to ask the user to press Return 1999-04-07 18:32:51 +00:00
sigcheck.c Quickly renamed the remaining files -- this directory is done. 1997-04-29 20:08:16 +00:00
strdup.c Patches by William Lewis for Nextstep descendants. 1999-01-27 17:53:11 +00:00
strerror.c New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
strtod.c Changes by Mark Hammond for Windows CE. Mostly of the form 1999-04-07 16:07:23 +00:00
structmember.c Trivial little change: when setting a member to an object, hold the 1998-05-20 22:25:32 +00:00
sysmodule.c _PySys_Init(): Nailed small memory leak. The stringobject created for 1999-01-27 16:33:19 +00:00
thread.c Changes by Mark Hammond for Windows CE. Mostly of the form 1999-04-07 16:07:23 +00:00
thread_beos.h Thanks to Chris Herborth, the thread primitives now have proper Py* 1998-12-21 19:32:43 +00:00
thread_cthread.h Thanks to Chris Herborth, the thread primitives now have proper Py* 1998-12-21 19:32:43 +00:00
thread_foobar.h Thanks to Chris Herborth, the thread primitives now have proper Py* 1998-12-21 19:32:43 +00:00
thread_lwp.h Thanks to Chris Herborth, the thread primitives now have proper Py* 1998-12-21 19:32:43 +00:00
thread_nt.h Thanks to Chris Herborth, the thread primitives now have proper Py* 1998-12-21 19:32:43 +00:00
thread_os2.h Thanks to Chris Herborth, the thread primitives now have proper Py* 1998-12-21 19:32:43 +00:00
thread_pthread.h Rob Riggs wrote: 1999-03-15 20:27:53 +00:00
thread_sgi.h Thanks to Chris Herborth, the thread primitives now have proper Py* 1998-12-21 19:32:43 +00:00
thread_solaris.h While I can't really test this thoroughly, Pat Knight and the Solaris 1999-04-13 14:32:12 +00:00
thread_wince.h Win/CE thread support by Mark Hammond. 1999-04-08 13:57:06 +00:00
traceback.c PyFile_WriteString now returns an error indicator instead of calling 1997-05-22 22:35:47 +00:00