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.)
Guido van Rossum [Fri, 11 Jun 1999 18:26:09 +0000 (18:26 +0000)]
After more discussion with Jim, change the behavior so that only a
*missing* content-type at the outer level of a POST defaults to
urlencoded. In all other circumstances, the default is read_singe().
Guido van Rossum [Fri, 11 Jun 1999 15:03:00 +0000 (15:03 +0000)]
Tim Peters smart.patch:
EditorWindow.py:
+ Added get_tabwidth & set_tabwidth "virtual text" methods, that get/set the
widget's view of what a tab means.
+ Moved TK_TABWIDTH_DEFAULT here from AutoIndent.
+ Renamed Mark's get_selection_index to get_selection_indices (sorry, Mark,
but the name was plain wrong <wink>).
FormatParagraph.py: renamed use of get_selection_index.
AutoIndent.py:
+ Moved TK_TABWIDTH_DEFAULT to EditorWindow.
+ Rewrote set_indentation_params to use new VTW get/set_tabwidth methods.
+ Changed smart_backspace_event to delete whitespace back to closest
preceding virtual tab stop or real character (note that this may require
inserting characters if backspacing over a tab!).
+ Nuked almost references to the selection tag, in favor of using
get_selection_indices. The sole exception is in set_region, for which no
"set_selection" abstraction has yet been agreed upon.
+ Had too much fun using the spiffy new features of the format-paragraph
cmd.
Fred Drake [Fri, 11 Jun 1999 14:25:45 +0000 (14:25 +0000)]
Last night's scribbles:
- Revise abstract based on Guido's comments from way back.
- Point out that LaTeX is a structured system & we're using it that
way.
- Add a small section on marking up code examples.
Guido van Rossum [Thu, 10 Jun 1999 15:19:14 +0000 (15:19 +0000)]
Adapt to the new pyclbr's support of listing top-level functions. If
this functionality is not present (e.g. when used with a vintage
Python 1.5.2 installation) top-level functions are not listed.
(Hmm... Any distribution of IDLE 0.5 should probably include a copy
of the new pyclbr.py!)
Guido van Rossum [Thu, 10 Jun 1999 14:44:48 +0000 (14:44 +0000)]
Fix off-by-one error in Tim's recent change to comment_region(): the
list of lines returned by get_region() contains an empty line at the
end representing the start of the next line, and this shouldn't be
commented out!
Guido van Rossum [Thu, 10 Jun 1999 14:39:39 +0000 (14:39 +0000)]
Co-production with Tim Peters, implementing a suggestion by Mark
Hammond: record top-level functions (as Function instances, a simple
subclass of Class). You must use the new interface readmodule_ex() to
get these, though.
Guido van Rossum [Thu, 10 Jun 1999 14:20:26 +0000 (14:20 +0000)]
Mark Hammond writes: Here is another change that allows it to work for
class creation - tries to locate an __init__ function. Also updated
the test code to reflect your new "***" change.
Guido van Rossum [Thu, 10 Jun 1999 14:19:46 +0000 (14:19 +0000)]
Mark Hammond writes: Tim's suggestion of copying the font for the
CallTipWindow from the text control makes sense, and actually makes
the control look better IMO.