| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
had it right! Reported by Tim Hochberg <tim.hochberg@ieee.org>.
|
|
|
|
|
| |
done by _PyImport_Init(), comes to late to affect the import of
exceptions.py by _PyBuiltin_Init_2(). Move _PyImport_Init() up few lines.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We occasionally received reports from people getting "invalid tstate"
crashes (this is a fatal error in PyThreadState_Delete()). Finally
several people were able to reproduce it reliably and Tim Peters
discovered that there is a race condition when multiple threads are
calling this function without holding the global interpreter lock (the
function may be called without holding that).
Solved the race condition by adding a lock around the mutating uses of
interp->tstate_head. Tim and Jonathan Giddy have run tests that make
it likely that this fixes the crashes -- although Tim hasn't heard
from the person who reported the original problem.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ExtensionClasses in isinstance() and issubclass().
- abstract instance and class protocols are used *only* in those
cases that would generate errors before the patch. That is, there's
no penalty for the normal case.
- instance protocol: an object smells like an instance if it
has a __class__ attribute that smells like a class.
- class protocol: an object smells like a class if it has a
__bases__ attribute that is a tuple with elements that
smell like classes (although not all elements may actually get
sniffed ;).
|
|
|
|
| |
compiler info.
|
|
|
|
| |
strerror(). This improves the quality of the error messages.
|
|
|
|
|
|
| |
man pages suggest that the proper thing to do is to add THR_NEW_LWP to
the flags on thr_create(), and that there really isn't a downside, so
I'll do that.
|
| |
|
|
|
|
|
| |
before exiting when an error happened. This didn't work right when
Python is invoked from a daemon.
|
|
|
|
| |
#ifdef DONT_HAVE_header_H ... #endif around #include <header.h>.
|
| |
|
|
|
|
| |
argument. This closes TODO item 2.19.
|
|
|
|
| |
object that supports the buffer interface (e.g. strings, arrays).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
"""
Spec says that on success pthread_create returns 0. It does not say
that an error code will be < 0. Linux glibc2 pthread_create() returns
ENOMEM (12) when one exceed process limits. (It looks like it should
return EAGAIN, but that's another story.)
For reference, see:
http://www.opengroup.org/onlinepubs/7908799/xsh/pthread_create.html
"""
[I have a feeling that similar bugs were fixed before; perhaps someone
could check that all error checks no check for != 0?]
|
|
|
|
| |
an exception.
|
|
|
|
|
| |
string-based exceptions are used) reflect the real class hierarchy,
i.e. that SystemExit derives from Exception not StandardError.
|
|
|
|
|
|
|
| |
xrange(), especially for platforms where int and long are different
sizes (so sys.maxint isn't actually the theoretical limit for the
length of a list, but the largest C int is -- sys.maxint is the
largest Python int, which is actually a C long).
|
|
|
|
|
| |
is used in the format string, instead of requiring a tuple. This is
in line with the general trend towards accepting arbitrary sequences.
|
| |
|
|
|
|
| |
leaf_exc flag to zero otherwise the name leaks memory.
|
|
|
|
|
|
| |
PyList_Append steals a reference even if it fails).
builtin_filter(): Had the same leak problem as builtin_map().
|
|
|
|
| |
Marc-Andre Lemburg.
|
|
|
|
|
| |
reference, so you have to DECREF the appended value. This was a fun
one!
|
|
|
|
|
|
| |
test for classes with a __complex__() method. The attribute is pulled
out of the instance with PyObject_GetAttr() but this transfers
ownership and the function object was never DECREF'd.
|
|
|
|
|
| |
else-clause of the subname test, the parentname object was never
DECREF'd.
|
| |
|
|
|
|
|
|
|
|
|
| |
v temporary variable was never decref'd. Test this by starting up the
interpreter, hitting C-c, then immediately exiting.
Same potential leak can occur if error is E_NOMEM, since the return is
done in the case block. Added Py_XDECREF(v); to both blocks, just
before the return.
|
|
|
|
| |
sys.version was missing a Py_XDECREF().
|
| |
|
|
|
|
| |
1.5. Omit the second part.
|
|
|
|
| |
unavoidable overflow as OverflowError.
|
|
|
|
|
|
|
|
|
| |
think we have our own DOS box (i.e. we're not started from a command
line shell), we print a message and wait for the user to hit a key
before the DOS box is closed.
The hacky heuristic for determining whether we have our *own* DOS box
(due to Mark Hammond) is to test whether we're on line zero...
|
|
|
|
|
|
|
|
|
| |
The following patches (relative to 1.5.2b1) enable Python dynamic
loading to work on NetBSD platforms that use ELF (presnetly mips and
alpha systems). They automaticly determine wether the system is ELF or
a.out rather than using astatic list of platforms so that when other
NetBSD platforms move to ELF, python will continue to work without
change.
|
|
|
|
| |
Donn Cave tells me the PyImport_BeImageID() function isn't needed anymore.
|
|
|
|
|
|
| |
In other words, hex(sys.hexversion) == 0x010502b2 for Python 1.5.2b2.
This is derived from the new variable PY_VERSION_HEX defined in patchlevel.h.
(Cute, eh?)
|
| |
|
| |
|
| |
|
|
|
|
| |
Patch and suggestion by Greg Couch.
|
| |
|
|
|
|
|
| |
names in the source code (they already had those for the linker,
through some smart macros; but the source still had the old, un-Py names).
|
| |
|
|
|
|
| |
support a macro in pystate.h.
|
|
|
|
|
| |
If we're going to put the PyOS_strtol() proto in intobject.h we should
include it here or the symbol isn't exported on PowerPC.
|
|
|
|
| |
have to use a const-correct prototype on BeOS or the compiler gets uppity.
|
|
|
|
| |
(This only applies when COUNT_ALLOCS is defined.)
|
| |
|
| |
|