1316 Commits

Author SHA1 Message Date
Fred Drake
78c4095d52 PyModule_AddObject(): Added missing exceptions.
Closes SF bug #523473.
2002-06-17 17:16:11 +00:00
Neal Norwitz
63ab3e2bca Fix SF #561858 Assertion with very long lists
if co_stacksize was > 32767 (the maximum value
which can be stored in 16 bits (signed)),
the PyCodeObject would be written wrong.
So on the second import (reading the .pyc)
would cause a crash.

Since we can't change the PYC magic, we
go on (silently), but don't write the file.
This means everything will work, but
a .pyc will not be written and the file will need
to be parsed on each import.
2002-06-01 18:27:34 +00:00
Anthony Baxter
34d316c21c backport tim_one's patch:
Repair widespread misuse of _PyString_Resize.  Since it's clear people
don't understand how this function works, also beefed up the docs.  The
most common usage error is of this form (often spread out across gotos):

	if (_PyString_Resize(&s, n) < 0) {
		Py_DECREF(s);
		s = NULL;
		goto outtahere;
	}

The error is that if _PyString_Resize runs out of memory, it automatically
decrefs the input string object s (which also deallocates it, since its
refcount must be 1 upon entry), and sets s to NULL.  So if the "if"
branch ever triggers, it's an error to call Py_DECREF(s):  s is already
NULL!  A correct way to write the above is the simpler (and intended)

	if (_PyString_Resize(&s, n) < 0)
		goto outtahere;

Bugfix candidate.

Original patch(es):
python/dist/src/Python/bltinmodule.c:2.253
2002-04-30 04:01:21 +00:00
Jeremy Hylton
f599b7424d Backport fixes for two nested scopes bugs.
frameobject.c: make sure free and cell vars make it into locals, which
    makes eval work.

bltinmodule.c & ceval.c: make sure a code object with free variables
    that is passed to exec or eval raises an exception.

Also duplicate the current trunk test suite in the 2.1 branch, except
for certain necessary changes: different warnings raised by 2.1, need
for __future__.
2002-04-20 18:21:29 +00:00
Guido van Rossum
ded18d634f Backport for 2.1.3 (if we ever release it; we may have to because
this is what Zope 2 will be using in the foreseeable future).

Fix an issue that was reported in but unrelated to the main problem of
SF bug 535905 (Evil Trashcan and GC interaction).

The SETLOCAL() macro should not DECREF the local variable in-place and
then store the new value; it should copy the old value to a temporary
value, then store the new value, and then DECREF the temporary value.
This is because it is possible that during the DECREF the frame is
accessed by other code (e.g. a __del__ method or gc.collect()) and the
variable would be pointing to already-freed memory.

BUGFIX CANDIDATE!
2002-03-28 20:21:21 +00:00
Guido van Rossum
a472771dad Backport revision 2.69.
SF patch #471839: Bug when extensions import extensions (Shane Hathaway)

    When an extension imports another extension in its
    initXXX() function, the variable _Py_PackageContext is
    prematurely reset to NULL. If the outer extension then
    calls Py_InitModule(), the extension is installed in
    sys.modules without its package name. The
    manifestation of this bug is a "SystemError:
    _PyImport_FixupExtension: module <package>.<extension>
    not loaded".

    To fix this, importdl.c just needs to retain the old
    value of _Py_PackageContext and restore it after the
    initXXX() method is called. The attached patch does this.

    This patch applies to Python 2.1.1 and the current CVS.
2002-01-15 21:14:38 +00:00
Tim Peters
a03453d944 Attempted to update all the copyright notices (we're releasing this in
2002!).  Does anyone know of a copyright blurb I missed?
2002-01-10 22:49:58 +00:00
Anthony Baxter
f226f40864 cosmetic change to add a commit message for the last commit, accidently
sent with empty message.

sheesh. Lucky I decided it was worth doing last minute complete compile
tests. cvs merge stupid on my part fixed that made solaris builds totally
fail.
2002-01-10 11:12:20 +00:00
Anthony Baxter
ca1512cd83 thread_pthread.h 2002-01-10 11:10:18 +00:00
Anthony Baxter
64d8547dbc backport of solaris thread patch, adding PTHREAD_SCOPE_SYSTEM support:
Improve threading on Solaris, according to SF patch #460269, submitted
  by bbrox@bbrox.org / lionel.ulmer@free.fr.

  This adds a configure check and if all goes well turns on the
  PTHREAD_SCOPE_SYSTEM thread attribute for new threads.

  This should remove the need to add tiny sleeps at the start of threads
  to allow other threads to be scheduled.

This is a semi-feature, but makes such a huge difference to the
performance of Zope on Solaris that it's worthwhile (well, imho).
2001-12-23 04:07:25 +00:00
Anthony Baxter
ba5a3f2ebb backport 2.35:
SF bug 485175:  buffer overflow in
 traceback.c.  Bugfix candidate.  tb_displayline():  the sprintf
 format was choking off the file name, but used plain %s for the
 function name (which can be arbitrarily long).  Limit both to 500
 chars max.
2001-12-21 03:49:31 +00:00
Anthony Baxter
8d0b5adf15 backport 2.153:
Missing DECREFs when exception is raised in sys.excepthook.
2001-12-21 03:46:12 +00:00
Anthony Baxter
047f687cec backport 2.9:
PySymtableEntry_New():  I'm not sure what this
 routine is doing, but it was obviously leaking an int object when
 whatever the heck it's looking for was found.  Repaired that.  This
 accounts for why entering function and class definitions at an
 interactive prompt leaked a reference to the integer 1 each time.
2001-12-21 03:45:15 +00:00
Anthony Baxter
f3f6cfe161 backport 2.144:
Py_Initialize(): Apply patch by Jürgen Hermann to call
    _PyImport_FixupExtension() on the exceptions module.  Now
    reload(exceptions) acts just like reload(sys) instead of raising
    an ImportError.

    This closes SF bug #422004.
2001-12-21 03:29:12 +00:00
Jeremy Hylton
f7adf24280 Backport rev 2.301 to the 2.1 maintenance branch.
Add checks for stack underflow and overflow.
2001-12-20 02:07:36 +00:00
Anthony Baxter
55aa02bb43 backport of jeremy's 2.227:
Fix for SF bug [ #471928 ] global made w/nested list comprehensions

. Initially I was going to just rip out the bits of this that fixed this
  bug, but the rest of the code looks (after a fair amount of staring at
  it) like it's ok - variable renames, that sort of thing.
  flames and "hey, no way!" to me, or to python-dev.
  It felt safer to just go with the full patch, rather than butchering
  it.
2001-11-21 06:21:18 +00:00
Anthony Baxter
d2d88aedce backport of tim's 2.66:
. SF bug [#467265] Compile errors on SuSe Linux on IBM/s390.
  - errors.c, PyErr_Format:  add a va_end() to balance the va_start().
2001-11-21 05:41:03 +00:00
Anthony Baxter
b104606d4c backport of 2.8, after checking with MarkH
. Always pass a full path name to LoadLibraryEx().  Fixes some Windows 9x
  problems.  As discussed on python-dev
2001-11-21 05:37:32 +00:00
Anthony Baxter
a700e18600 backport of patches 2.10, 2.11, 2.12, by MvL.
. Patch #455231: Support ELF properly on OpenBSD.
. Patch to bug #472202: Correctly recognize NetBSD before 199712.
. Move dlfcn.h block out of NetBSD block, assuming that NetBSD before
  199712 didn't have dlfcn.h, or that it wouldn't conflict with the other
  stuff defined.
2001-11-21 05:01:44 +00:00
Anthony Baxter
057a2e70b1 backport of 2.8 by jack:
Patch by Jonathan Wight (slightly reformatted) to forestall loading the
same module twice, which apparently crashes Python. I could not test the
error condition, but in normal life it seems to have no adverse effects.

Also removed an unsued variable, and corrected 2 glaring errors (missing
'case' in front of a label).
2001-11-21 04:58:37 +00:00
Anthony Baxter
b78e593e49 backport of 2.242:
improved error message-- names the type of the unexpected object
2001-11-21 04:49:19 +00:00
Anthony Baxter
1534ab50b8 backport of 2.90:
Patch number #422106 by Greg Ball, to fix segmentation
fault in sys.displayhook.
2001-11-21 03:51:20 +00:00
Anthony Baxter
dc009f3237 Backport fix from 2.277 - incorrectly swapped arguments to PyFrame_BlockSetup.
Fixes very obscure and nasty bug.
2001-10-21 05:57:28 +00:00
Thomas Wouters
d4a75dc44c Backport of Tim's checkin 2.178:
SF bug #438295: [Windows] __init__.py cause strange behavior

Probable fix (the bug report doesn't have enough info to say for sure).
find_init_module():  Insist on a case-sensitive match for __init__ files.
Given __INIT__.PY instead, find_init_module() thought that was fine, but
the later attempt to do find_module("__INIT__.PY") didn't and its caller
silently suppressed the resulting ImportError.  Now find_init_module()
refuses to accept __INIT__.PY to begin with.
2001-07-11 12:03:44 +00:00
Thomas Wouters
44c3679296 Backport Tim's checkin 2.247:
SF bug 433228:  repr(list) woes when len(list) big
call_object:  If the object isn't callable, display its type in the error
msg rather than its repr.
2001-06-27 14:13:32 +00:00