Commit Graph

885 Commits

Author SHA1 Message Date
Guido van Rossum 001b9bebca Patch by Vladimir Marangozov, inspired by a bug report from Gary
Duzan, for AIX, to support C++ objects with static initializers, when
using the genuine IBM C++ compiler (namely xlC/xlC_r).

See accompanying patches to configure.in and acconfig.h.
1999-11-16 15:54:16 +00:00
Guido van Rossum ba98a42a0f Change the last PyErr_Format %s format to %.400s. 1999-11-15 19:29:33 +00:00
Guido van Rossum 25da5bebd8 Fix PR117. The error message is "keywords must be strings". Perhaps
not as descriptive as what Barry suggests, but this also catches the
(in my opinion important) case where some other C code besides apply()
constructs a kwdict that doesn't have the right format.  All the other
possibilities of getting it wrong (non-dict, wrong keywords etc) are
already caught so this makes sense to check here.
1999-10-26 00:12:20 +00:00
Barry Warsaw 226ae6ca12 Mainlining the string_methods branch. See branch revision log
messages for specific changes.
1999-10-12 19:54:53 +00:00
Guido van Rossum be2033697f In PySys_GetObject(), it's possible that tstate->interp->sysdict is
NULL.  In that case, return NULL rather than dumping core.

This fixes PR#91, submitted by Lele Gaifax.
1999-10-05 22:17:41 +00:00
Guido van Rossum 3aca65312a Tim Peters fixed PR#75: very long lines cause incorrect tracebacks. 1999-09-18 20:49:39 +00:00
Guido van Rossum 2174dcb061 Tim Peters writes:
For a long time I've seen absurd tracebacks under -O (e.g., negative
line numbers), but very rarely.  Since I was looking at tracebacks
anyway, thought I'd track it down.  Turns out to be Guido's only
predictable blind spot <wink -- "char" is signed on some non-GvR
systems>.  Patch follows.
1999-09-15 22:48:09 +00:00
Guido van Rossum 2adac0a637 Tim Peters discovered a bug in the Python-supplied getopt():
it doesn't recognize a lone dash as a non-flag argument.
Now it does.
1999-09-13 13:45:32 +00:00
Barry Warsaw f6202635f9 call_trace(): A fix for PR#73, if an exception occurred in the
tracefunc (or profilefunc -- we're not sure which), zap the global
trace and profile funcs so that we can't get into recursive loop when
instantiating the resulting class based exception.
1999-09-08 16:26:33 +00:00
Guido van Rossum 933c91ebcf Vladimir Marangozov fixes an AIX-specific problem, writing:
"""
Following up Robin Dunn's troubles with freeze, here's a patch that
fixes an oddity regarding the import logic of shared modules on AIX.

Symbol resolution of shared modules is now handled properly for the cases
when the python library is linked to a binary with an arbitrary name.
This includes the standard python[version] executable, but also applications
that are embedding the python core (i.e. linked with libpython[version].a,
the latter being static or shared).
"""
1999-08-04 18:00:12 +00:00
Fred Drake 3d587442f9 Fixed order of parameters in slice() docstring. The Library Reference
had it right!  Reported by Tim Hochberg <tim.hochberg@ieee.org>.
1999-07-19 15:21:16 +00:00
Guido van Rossum 7c85ab829d Marc-Andre Lemburg discovered that the switch from .pyc to .pyo files,
done by _PyImport_Init(), comes to late to affect the import of
exceptions.py by _PyBuiltin_Init_2().  Move  _PyImport_Init() up few lines.
1999-07-08 17:26:56 +00:00
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
Guido van Rossum 1d5ad90c1c CRITICAL PATCH!
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.
1999-06-18 14:22:24 +00:00
Guido van Rossum 7f85186921 # Darn! Local variable l declared but not used in abstract_issubclass(). 1999-06-17 19:12:39 +00:00
Guido van Rossum 668213d3b8 Patch by Jim Fulton (code style tweaked a bit) to support
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 ;).
1999-06-16 17:28:37 +00:00
Guido van Rossum eda232fdac Allow longer strings (up to 80 chars each) for version, build,
compiler info.
1999-04-22 12:03:40 +00:00
Guido van Rossum 743007d2fe Patch by Christian Tismer for Win32, to use FormatMessage() instead of
strerror().  This improves the quality of the error messages.
1999-04-21 15:27:31 +00:00
Guido van Rossum 495894ee66 While I can't really test this thoroughly, Pat Knight and the Solaris
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.
1999-04-13 14:32:12 +00:00
Guido van Rossum b738d26e2d Win/CE thread support by Mark Hammond. 1999-04-08 13:57:06 +00:00
Guido van Rossum b6987b13fe Alas, get rid of the Win specific hack to ask the user to press Return
before exiting when an error happened.  This didn't work right when
Python is invoked from a daemon.
1999-04-07 18:32:51 +00:00
Guido van Rossum 2571cc8bf5 Changes by Mark Hammond for Windows CE. Mostly of the form
#ifdef DONT_HAVE_header_H ... #endif around #include <header.h>.
1999-04-07 16:07:23 +00:00
Guido van Rossum 99fb7c70f4 Remove unused variable from complex_from_string() code. 1999-04-07 16:05:47 +00:00
Guido van Rossum 1195023b89 Patch by Nick and Stephanie Lockwood to implement complex() with a string
argument.  This closes TODO item 2.19.
1999-03-25 21:16:07 +00:00
Guido van Rossum 0daf022225 New builtin buffer() creates a derived read-only buffer from any
object that supports the buffer interface (e.g. strings, arrays).
1999-03-19 19:07:19 +00:00
Guido van Rossum 701f25ef9d Rob Riggs wrote:
"""
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?]
1999-03-15 20:27:53 +00:00
Guido van Rossum eb894ebd0a Always test for an error return (usually NULL or -1) without setting
an exception.
1999-03-09 16:16:45 +00:00
Barry Warsaw 72b715d979 (initerrors): Make sure that the exception tuples ("base-classes" when
string-based exceptions are used) reflect the real class hierarchy,
i.e. that SystemExit derives from Exception not StandardError.
1999-02-24 00:35:43 +00:00
Guido van Rossum 124eff0225 Patch by Tim Peters to improve the range checks for range() and
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).
1999-02-23 16:11:01 +00:00
Guido van Rossum 66368ccc55 Patch by Tommy Burnette to accept an arbitrary sequence when "(...)"
is used in the format string, instead of requiring a tuple.  This is
in line with the general trend towards accepting arbitrary sequences.
1999-02-17 23:16:43 +00:00
Barry Warsaw 3d05b1a0ae initmain(): Nailed a memory leak. bimod must be DECREF'd! 1999-01-29 21:30:22 +00:00
Barry Warsaw 7890203f49 bltin_exc[]: EnvironmentError is not a "leaf exception", so set it's
leaf_exc flag to zero otherwise the name leaks memory.
1999-01-29 20:29:49 +00:00
Barry Warsaw fa77e09dd0 builtin_map(): A better fix for the previous leak plug (remember
PyList_Append steals a reference even if it fails).

builtin_filter(): Had the same leak problem as builtin_map().
1999-01-28 18:49:12 +00:00
Guido van Rossum 541563ec7e Implement -OO; "unsafe" optimization that removes docstrings.
Marc-Andre Lemburg.
1999-01-28 15:08:09 +00:00
Barry Warsaw 2133287c3e builtin_map(): Nailed memory leak. PyList_Append() borrows a
reference, so you have to DECREF the appended value.  This was a fun
one!
1999-01-28 04:21:35 +00:00
Barry Warsaw f988e687a1 builtin_complex(): Nailed memory leak. This one's in the instance
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.
1999-01-27 23:13:59 +00:00
Barry Warsaw 3879333b9e PyImport_ReloadModule(): Nailed a small memory leak. In the
else-clause of the subname test, the parentname object was never
DECREF'd.
1999-01-27 17:54:20 +00:00
Guido van Rossum 54ecc3d24f Patches by William Lewis for Nextstep descendants. 1999-01-27 17:53:11 +00:00
Barry Warsaw c80baa3365 err_input(): Nailed a small memory leak. If the error is E_INTR, the
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.
1999-01-27 16:39:40 +00:00
Barry Warsaw 54892c4b2c _PySys_Init(): Nailed small memory leak. The stringobject created for
sys.version was missing a Py_XDECREF().
1999-01-27 16:33:19 +00:00
Guido van Rossum 3dbba6ec3a Change rare occurrences of #if HAVE_LONG_LONG to #ifdef. 1999-01-25 21:48:56 +00:00
Guido van Rossum a71b5f4e1d Jim Ahlstrom patch: the module doc string is too long for 16-bit VC
1.5.  Omit the second part.
1999-01-14 19:07:00 +00:00
Guido van Rossum e23cde2f8d Avoid overflow if possible in calculations for range(); report
unavoidable overflow as OverflowError.
1999-01-12 05:07:47 +00:00
Guido van Rossum 2c1f6be38e Hack for Windows so that if (1) the exit status is nonzero and (2) we
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...
1999-01-08 15:56:28 +00:00
Guido van Rossum df69365f5f Ty Sarna writes:
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.
1999-01-07 21:50:41 +00:00
Guido van Rossum cad3d47f1e Chris Herborth writes:
Donn Cave tells me the PyImport_BeImageID() function isn't needed anymore.
1999-01-04 16:45:59 +00:00
Guido van Rossum e0d7dae3b8 Add sys.hexversion, which is an integer encoding the version in hexadecimal.
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?)
1999-01-03 12:55:39 +00:00
Guido van Rossum 6e0a3499ab Use PY_VERSION instead of PATCHLEVEL. 1999-01-03 12:41:50 +00:00
Guido van Rossum 47ae028071 Call PyInitFrozenExtensions() as requested by Mark Hammond (his patch). 1999-01-02 21:42:48 +00:00
Guido van Rossum c38e7d4c4b Oops, forgot a pair of {}'s. (Greg Couch) 1998-12-23 19:53:45 +00:00