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.
Jack Jansen [Mon, 8 Sep 1997 13:19:42 +0000 (13:19 +0000)]
Major overhaul: this is now little more than a user interface, the
preference handling code is in modules pythonprefs and preferences.
This should finally make it easier for someone (Just?) to write a
decent interface to preference setting, and it'll allow setting
initial sys.path and such from ConfigurePython.
Initialize self.__tempfiles to [] in the constructor (else it remains
a shared class variable -- but each instance will attempt to clean it
up entirely ob cleanup).
*Semantic change*: when unpickling the instance variables of an
instance, use inst.__dict__.update(value) instead of a for loop with
setattr() over the value.keys(). This is more consistent (the
pickling doesn't use getattr() either but pickles inst.__dict__) and
avoids problems with instances that have a __setattr__ hook.
But it *is* a semantic change (because the setattr hook is no longer
used). So beware!
Change the names of the subdirectories tkinter and stdwin to
lib-tk and lib-stdwin. (BTW this was also done in the previous
checkin of (toplevel)/Makefile.in, though not noted in the checkin
message.)
Look for uuencoded test files in the directory containing this module, too.
(This is necessary because when imported as test.test_rgbimg, the test
directory is not on sys.path.)
Look for uuencoded test files in the directory containing this module, too.
(This is necessary because when imported as test.test_rgbimg, the test
directory is not on sys.path.)
Reverse the order in which Setup and Setup.local are passed to the
makesetup script. (Sorry Sjoerd -- I know you proposed this a while
ago and I didn't think it would work then. I looked again and it
does work.)
Fix details in the test:
- traceback should go to stdout!
- don't import ni, import t1!
- nicer support for command line options, only if run as __main__
Significant speedup -- when a submodule imports a global module, add a
dummy entry to sys.modules, marking the absence of a submodule by the
same name.
Thus, if module foo.bar executes the statement "import time",
sys.modules['foo.time'] will be set to None, once the absence of a
module foo.time is confirmed (by looking for it in foo's path).
The next time when foo.bar (or any other submodule of foo) executes
"import time", no I/O is necessary to determine that there is no
module foo.time.
(Justification: It may seem strange to pollute sys.modules. However,
since we're doing the lookup anyway it's definitely the fastest
solution. This is the same convention that 'ni' uses and I haven't
heard any complaints.)
Phase two of package import. "import a.b.c" and all variants now do the
right thing.
Still to do:
- Make reload() of a submodule work.
- Performance tweaks -- currently, a submodule that tries to import a
global module *always* searches the package directory first, even if
the global module was already imported. Not sure how to solve this
one; probably need to record misses per package.
Fixed some details of printing the str() of an exception. This fixes
a core dump when __str__() returns a non-string, and plugs a memory
leak as well: the result of PyObject_Str() was never DECREFed.
This doesn't yet support "import a.b.c" or "from a.b.c import x", but
it does recognize directories. When importing a directory, it
initializes __path__ to a list containing the directory name, and
loads the __init__ module if found.
The (internal) find_module() and load_module() functions are
restructured so that they both also handle built-in and frozen modules
and Mac resources (and directories of course). The imp module's
find_module() and (new) load_module() also have this functionality.
Moreover, imp unconditionally defines constants for all module types,
and has two more new functions: find_module_in_package() and
find_module_in_directory().
There's also a new API function, PyImport_ImportModuleEx(), which
takes all four __import__ arguments (name, globals, locals, fromlist).
The last three may be NULL. This is currently the same as
PyImport_ImportModule() but in the future it will be able to do
relative dotted-path imports.
Other changes:
- bltinmodule.c: in __import__, call PyImport_ImportModuleEx().
- ceval.c: always pass the fromlist to __import__, even if it is a C
function, so PyImport_ImportModuleEx() is useful.
- getmtime.c: the function has a second argument, the FILE*, on which
it applies fstat(). According to Sjoerd this is much faster. The
first (pathname) argument is ignored, but remains for backward
compatibility (so the Mac version still works without changes).
By cleverly combining the new imp functionality, the full support for
dotted names in Python (mini.py, not checked in) is now about 7K,
lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly
commented).
Added PyImport_ImportModuleEx(name, globals, locals, fromlist); this
is like PyImport_ImporModule(name) but receives the globals and locals
dict and the fromlist arguments as well. (The name is a char*; the
others are PyObject*s).