There was actually a test that ensured that raising an exception A
with an instance of a derived class B would really raise an A, not a
B. Since Barry fixed this anomalous behaviour, I though I might as
well fix the test! (Hmm, Barry, did you not run the tests or did you
miss that test_opcodes failed?)
(1) Use PyErr_NewException("module.class", NULL, NULL) to create the
exception object.
(2) Remove all calls to Py_FatalError(); instead, return or
ignore the errors -- the import code now checks PyErr_Occurred()
after calling a module's init function, so it's no longer a
fatal error for the initialization to fail.
Also did some small cleanups, e.g. removed unnecessary test for
"already initialized" from initfpectl(), and unified
initposix()/initnt().
I haven't checked this very thoroughly, so while the changes are
pretty trivial -- beware of untested code!
Change PyEval_SaveThread() and PyEval_RestoreThread() to always do the
tstate swapping. Only the acquiring and releasing of the lock is
conditional (twice, under ``#ifdef WITH_THREAD'' and inside ``if
(interpreter_lock)'').
Barry Warsaw [Tue, 30 Sep 1997 15:00:18 +0000 (15:00 +0000)]
PyErr_NormalizeException(): If the exception's type is a class and the
instance's class is a subclass of this, then use the instance's class
as the exception type.
Add optional bufsize argument to various calls so we can make the
os.fdopen() calls unbuffered. I presume that it's enough if we can
make all three of them (for stdin, stdout, and stderr) unbuffered and
don't need to specify different buffer sizes per file -- that would
complicate the interface more than I care for.
Add an optional hack for threads in Tkinter.
This one works! However it requires using a modified version of
tclNotify.c (provided), which requires access to the Tcl source
to compile it. In order to enable this hack, add the following
to the Setup line for _tkinter:
tclNotify.c -DHAVE_PYTCL_WAITUNTILEVENT -I$(TCL)/generic
where TCL points to the source tree of Tcl 8.0. Other versions
of Tcl are not supported.
The tclNotify.c file is copyrighted by Sun Microsystems; the
licensing terms are in the file license.terms. According to this
file, no further permission to distribute this is required,
provided the file license.terms is included. Hence, I am checking
that in, too.
Changes submitted by Marc-Andre Lemburg to add two tables: errorcode
maps errno numbers to errno names (e.g. EINTR), and errorcode maps
them to message strings. (The latter is redundant because
the new call posix.strerror() now does the same, but alla...)
Use Marc Lemburg's tb_lineno() to calculate the correct line number.
Apparently the traceback object doesn't contains the right linenumber
when -O is used. Rather than guessing whether -O is on or off, use
tb_lineno() unconditionally.
Word completion for the new readline.set_completer() function.
When completing a simple identifier, it completes keywords, built-ins
and globals in __main__; when completing NAME.NAME..., it evaluates
(!) the expression up to the last dot and completes its attributes.
It's very cool to do "import string" type "string.", hit the
completion key (twice), and see the list of names defined by the
string module!
Tip: to use the tab key as the completion key, call
The first is the most exciting feature: with an appropriate Python
completer function, it can do dynamic completion based on the contents
of your namespace!
Barry Warsaw [Thu, 18 Sep 1997 16:42:02 +0000 (16:42 +0000)]
Py_Initialize(): move the call to _PyImport_FixupExtension() to after
the phase 2 init of the __builtin__ module, so that multiple
interpreters will get the right exceptions.
Barry Warsaw [Thu, 18 Sep 1997 03:44:38 +0000 (03:44 +0000)]
initerrors(): Eliminate circular reference which was causing a small
but annoying memory leak. This was introduced when PyExc_Exception
was added; the loop above populating the PyExc_StandardError exception
tuple started at index 1 in bltin_exc, but PyExc_Exception was added
at index 0, so PyExc_StandardError was getting inserted in itself!
How else can a tuple include itself?!
Barry Warsaw [Tue, 16 Sep 1997 21:42:03 +0000 (21:42 +0000)]
PyErr_Print(): When printing a class exception, try to dig out the
__module__ string and if found, print <module>.<class>, unless
<module> == "exceptions".
Patch by Case Roole <cjr@bound.xs4all.nl> to fail with a more
explanatory message when the manual directories aren't found.
(I have to say I'm surprised that it actually still works!)
When creating a class, set its __module__ attribute to the module
whose name is in the current globals' __name__ variable. If __name__
is not set, ignore this.
As Paul Prescod pointed out, metaprogramming is really something
different (programs that write programs). We are dealing with
metaclasses here. So change the words slightly.
Update the description and the example to the new functionality, which
is mostly concentrated in a generalized find_module() and the new
load_module(). Added the new module type constants. Declare that
SEARCH_ERROR and a whole bunch of module-type-specific functions are
obsolete.
Crrected a flow control error that caused the wrong error message when
load-module() didn't find a built-in or frozen module. Also got rid
of is_frozen(), which duplicated the functionality of
find_frozen()!=NULL.
Patch submitted by Brad Howes (with one bug fixed by me): allow
arbitrary nested parens in a %(...)X style format.
#Also folded two lines and added more detail to the error message for
#unsupported format character.