Fred Drake [Fri, 25 Jun 1999 17:52:17 +0000 (17:52 +0000)]
Update to Sjoerd's documentation of the chunk module, with some
additions from Moshe's version. Used my table for describing the
chunk format, and added some markup and index entries.
Guido van Rossum [Fri, 25 Jun 1999 16:06:29 +0000 (16:06 +0000)]
Add _close() method that does the actual cleanup (close() asks the
user what they want first if there's unsaved stuff, and may cancel).
It closes more than before.
Add unload_extensions() method to unload all extensions; called from
_close(). It calls an extension's close() method if it has one.
Guido van Rossum [Thu, 24 Jun 1999 17:58:44 +0000 (17:58 +0000)]
Clarify the example by explicitly importing the fcntl module -- this
avoid being fooled into thinking that fcntl and FCNTL are the same
thing -- they aren't! (fcntl is the extension, FCNTL.py is h2py
output that defines all the constants).
(XXX The example is still weird -- I think there's a more portable way
to do locking now. That's for someone else to fix...)
Guido van Rossum [Thu, 24 Jun 1999 15:27:36 +0000 (15:27 +0000)]
Sjoerd Mullender writes:
Urllib makes the URL of the opened file available through the geturl
method of the returned object. For local files, this consists of
file: plus the name of the file. This results in an invalid URL if
the file name was relative. This patch fixes this so that the
returned URL is just a relative URL in that case. When the file name
is absolute, the URL returned is of the form file:///absolute/path.
[I guess that a URL of the form "file:foo.html" is illegal... GvR]
Guido van Rossum [Wed, 23 Jun 1999 21:37:57 +0000 (21:37 +0000)]
Simplified version of a patch by Chih-Hao Huang, who wrote:
"""
When there are additional Setup files, specified by -e option of freeze,
checkextenstions.py assumes that *.o, *.a, -Lpath, and -Rpath are all
relative to where the Setup file is. select() inserts the path to the
Setup file to make them absolute. However, the assumption is not true.
There are cases that absolute paths are specified for them. The inserted
prefix, by select(), results in error.
The following fix check for absolute paths. The assumption is: an
absolute path begins with either '/' or '$'. In the latter case, it is
from the environmental variable. (Variables defined locally in the Setup
file have already been handled by expandvars())
"""
My version of the patch has been verified by Charles Waldman (a
colleague of Chih-Hao).
Guido van Rossum [Tue, 22 Jun 1999 14:47:32 +0000 (14:47 +0000)]
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.]
Guido van Rossum [Mon, 21 Jun 1999 22:36:53 +0000 (22:36 +0000)]
Patch submitted by Toby Dickenson and approved by Mark Hammond.
Toby writes:
winmakemakefile.py tries to allow for spaces in the python install
path, by adding quotes around the appropriate filenames. It doesn't
quite get this correct; sometimes the quotes end up in the middle of
the path.
Microsoft's NMAKE version 6.0 is happy with this (!!!!) unless there
is also a space in the name. I guess most users of freeze on windows
do not use the same path as the binary distribution.
I've tested the following changes on systems with and without a space
in the path.
Guido van Rossum [Fri, 18 Jun 1999 14:22:24 +0000 (14:22 +0000)]
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.
Fred Drake [Thu, 17 Jun 1999 18:49:18 +0000 (18:49 +0000)]
When looking for things that might be modules, include *module.c from
the Modules/ directory. Most of the remaining undocumented modules
seem to be living there.
Guido van Rossum [Thu, 17 Jun 1999 18:41:42 +0000 (18:41 +0000)]
Patch suggested (and partially provided) by Lars Damerow: instead of
always lowercasing the option name, call a method optionxform() which
can be overridden. Also make the regexps SECTRE and OPTRE non-private
variables so they can also be overridden.
Guido van Rossum [Wed, 16 Jun 1999 17:28:37 +0000 (17:28 +0000)]
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 ;).
Guido van Rossum [Tue, 15 Jun 1999 22:25:32 +0000 (22:25 +0000)]
Laurence Tratt notes that the accept() call in get_request() can fail,
and suggests putting a try/except around the get_request() call in
handle_request(). (All in class TCPServer.)