Roll back the introduction of urlsplit() and urlunsplit() to
urlparse.py. These were new features in 2.2, and shouldn't be added
to 2.1 this late in the game. There was one use of urlsplit() in
httplib.py (the urlparse.py change was done as part of a backport of a
bugfix to httplib.py); this use is replaced with a call to urlparse()
without changing the effect (only the returned netloc is used).
Address SF bug #577530: del __builtins__ breaks out of rexec
Using the suggestion there: add_module() forces __builtin__ back; this
fixes r_exec, r_eval, r_execfile.
This does not mean that rexec is now considered safe! But for those
willing to take the risk, it's safer than before. (Note that a safety
analysis of the code module would be wise if you plan to use the
interactive console for real -- I've only ever used it to play with
restricted mode.)
The new execvpe code would sometimes do the wrong thing when a
non-executable file existed earlier in the path and an executable file
of the same name existed later in the path. This patch restores the
proper behavior (which is to execute the second file). When only a
non-executable file exists, the correct error is still reported.
Fred Drake [Tue, 27 Aug 2002 19:50:42 +0000 (19:50 +0000)]
Back-port the \ulink macro to the documentation package for Python 2.1.x
since a documentation patch included \ulink. Adding this here makes
back-porting further documentation patches easier than having to remove
\ulink from the patches.
Closes SF bug #598996.
Backport of SF patch 590294: os._execvpe security fix (Zack Weinberg).
1) Do not attempt to exec a file which does not exist
just to find out what error the operating system
returns. This is an exploitable race on all platforms
that support symbolic links.
2) Immediately re-raise the exception if we get an
error other than errno.ENOENT or errno.ENOTDIR. This
may need to be adapted for other platforms.
Jeremy Hylton [Fri, 12 Jul 2002 15:22:09 +0000 (15:22 +0000)]
Backport changes.
Change _begin() back to begin().
Fix for SF bug 579107.
Fix for SF bug #432621: httplib: multiple Set-Cookie headers
Fix SF bug #575360
Handle HTTP/0.9 responses.
Jeremy Hylton [Tue, 18 Jun 2002 16:53:42 +0000 (16:53 +0000)]
Add a special case code to deal with unexpected large files.
# On a Linux with large file support (LFS) using a Python without LFS,
# stat() will raise EOVERFLOW. This unambiguously indicates that the
# file exists because it only occurs when the size of the file can't
# find into the stat struct.
This change is only needed for Python 2.1, because LFS is
automatically configured starting with Python 2.2.
Fred Drake [Tue, 11 Jun 2002 02:58:26 +0000 (02:58 +0000)]
Completely revise markup for the list of list methods; the new markup matches
the semantics and presentation used in the library reference.
Added an explanation of the use of [...] to denote optional arguments, since
this is the only use of this in a signature line.
Closes SF bug #567127.
Neal Norwitz [Sat, 1 Jun 2002 18:27:34 +0000 (18:27 +0000)]
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.
Guido van Rossum [Fri, 31 May 2002 21:19:53 +0000 (21:19 +0000)]
Backport to 2.1.x:
SF bug 533625 (Armin Rigo). rexec: potential security hole
If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode. Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).
Neal Norwitz [Wed, 29 May 2002 01:29:38 +0000 (01:29 +0000)]
Backport fix by tismer for #210682
fixed an old buglet that caused bdb to be unable to
continue in the botframe, after a breakpoint was set.
the key idea is not to set botframe to the bottom level frame,
but its f_back, which actually might be None.
Additional changes: migrated old exception trick to use
sys._getframe(), which exists both in 2.1 and 2.2 .
Note: I believe Mark Hammond needs to look over his code now.
F5 correctly starts up in the debugger, but later on doesn't stop at a given
breakpoint any longer.
Fred Drake [Thu, 2 May 2002 05:59:15 +0000 (05:59 +0000)]
Add information on support for repietition & concatenation for buffer
and xrange objects, and generally present these in the same way that more
recent documentation releases present them (for ease of maintenance).
This closes SF bug #550555.
Anthony Baxter [Tue, 30 Apr 2002 04:01:21 +0000 (04:01 +0000)]
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
Anthony Baxter [Tue, 30 Apr 2002 03:58:47 +0000 (03:58 +0000)]
backport tim_one's patch:
[Re-did unicodeobject.c - it's changed a lot since 2.1 :) Pretty confident
that it's correct]
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/Objects/fileobject.c:2.161
python/dist/src/Objects/stringobject.c:2.161
python/dist/src/Objects/unicodeobject.c:2.147
Jeremy Hylton [Sat, 20 Apr 2002 18:21:29 +0000 (18:21 +0000)]
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__.
Anthony Baxter [Thu, 18 Apr 2002 05:09:06 +0000 (05:09 +0000)]
backport gvanrossum's patch:
Provisional fix for writefile() [SF bug # 541730].
The problem was that an exception can occur in the text.get() call or
in the write() call, when the text buffer contains non-ASCII
characters. This causes the previous contents of the file to be lost.
The provisional fix is to call str(self.text.get(...)) *before*
opening the file, so that if the exception occurs, we never open the
file.
Two orthogonal better solutions have to wait for policy decisions:
1. We could try to encode the data as Latin-1 or as UTF-8; but that
would require IDLE to grow a notion of file encoding which requires
more thought.
2. We could make backups before overwriting a file. This requires
more thought because it needs to be fast and cross-platform and
configurable.
Original patches were:
python/dist/src/Tools/idle/IOBinding.py:1.6
Tim Peters [Wed, 17 Apr 2002 04:36:16 +0000 (04:36 +0000)]
Windows installer: disabled Wise's "delete in-use files" uninstall
option. It was the cause of at least one way UNWISE.EXE could vanish
(install a python; uninstall it; install it again; reboot the machine;
abracadabra the uinstaller is gone).
Fred Drake [Wed, 17 Apr 2002 01:44:07 +0000 (01:44 +0000)]
Changed last two remaining uses of "./" to "index.html" when referring to the
index file for the top-level directory. This makes it easier to use an
unpacked version of the documentation via file: URLs.
This closes SF bug #541257.
Fred Drake [Thu, 4 Apr 2002 17:59:25 +0000 (17:59 +0000)]
Avoid creating circular references between the ExpatParser and the
ContentHandler. While GC will eventually clean up, it can take longer than
normal for applications that create a lot of strings (or other immutables)
rather without creating many containers.
This closes SF bug #535474.