Barry Warsaw [Thu, 23 Jul 1998 16:05:56 +0000 (16:05 +0000)]
PyErr_SetFromErrnoWithFilename(): New function which supports setting
an exception from errno, with a supplied filename (primarily used by
IOError and OSError). If class exceptions are used then the exception
is instantiated with a 3-tuple: (errno, strerror, filename). For
backwards compatibility reasons, if string exceptions are used,
filename is ignored.
PyErr_SetFromErrno(): Implement in terms of
PyErr_SetFromErrnoWithFilename().
Barry Warsaw [Thu, 23 Jul 1998 16:03:46 +0000 (16:03 +0000)]
Added support for including the filename in IOErrors and OSErrors that
involve a filesystem path. To that end:
- Changed IOError to EnvironmentError and added a hack which checks
for arg of len 3. When constructed with a 3-tuple, the third item
is the filename and this is squirreled away in the `filename'
attribute. However, for in-place unpacking backwards
compatibility, self.args still only gets the first two items. Added
a __str__() which prints the filename if it is given.
- IOError now inherits from EnvironmentError
- New class OSError which also inherits from EnvironmentError and is
used by the posix module.
Barry Warsaw [Thu, 23 Jul 1998 15:59:57 +0000 (15:59 +0000)]
Added support for two new standard errors: EnvironmentError and
OSError. The EnvironmentError serves primarily as the (common
implementation) base class for IOError and OSError. OSError is used
by posixmodule.c
Also added tuple definition of EnvironmentError when using string
based exceptions.
Jack Jansen [Wed, 22 Jul 1998 13:37:37 +0000 (13:37 +0000)]
- Added a function MoviesTask, which is the same as the method but
with a null movie (giving time to all active movies)
- Made the graphics world parameter to SetMovieGWorld optional.
When comparing objects, always check that tp_compare is not NULL
before calling it. This check was there when the objects were of the
same type *before* coercion, but not if they initially differed but
became the same *after* coercion.
Added support for specifying a filename for a breakpoint, roughly
according to an idea by Harri Pasanen (but with different syntax).
This affects the 'break' and 'clear' commands and their help
functions. Also added a helper method lookupmodule().
Also:
- Try to import readline (important when pdb is used from/as a script).
- Get rid of reference to ancient __privileged__ magic variable.
- Moved all import out of functions to the top.
- When used as a script, check that the script file exists.
Get a 3- to 4-fold speedup for sub()/subn(), split() and findall() by
not calling self.search(); instead, call self.code.match() directly
and interpret the list of registers it returns directly. This saves
the overhead of instantiating a MatchObject for each hit, basically
inlining search() as well as group(). When a MatchObject is still
needed, one is allocated and reused for the duration of the scan.
Avoid using calloc(). This triggered an obscure bug on multiprocessor
Sparc Solaris 2.6 (fully patched!) that I don't want to dig into, but
which I suspect is a bug in the multithreaded malloc library that only
shows up when run on a multiprocessor. (The program wasn't using
threads, it was just using the multithreaded C library.)
Fred Drake [Wed, 15 Jul 1998 04:36:56 +0000 (04:36 +0000)]
Tk.__init__(): In computing baseName, add ".pyo" to list of dropped
extensions, and include the "." in ".pyc". Still need to get
_tkinter.c:Tkapp_New() to use baseName....
Temporarily get rid of the registration of Tcl_Finalize() as a
low-level Python exit handler. This can attempt to call Python code
at a point that the interpreter and thread state have already been
destroyed, causing a Bus Error. Given the intended use of
Py_AtExit(), I'm not convinced that it's a good idea to call it
earlier during Python's finalization sequence... (Although this is
the only use for it in the entire distribution.)
Jack Jansen [Mon, 13 Jul 1998 13:41:02 +0000 (13:41 +0000)]
Added a delete() method to menu entries. Only the last entry of a menu
can be deleted, but that's good enough for things like a "Windows"
menu with the dynamic list of open windows at the end of the menu.
Jack Jansen [Mon, 13 Jul 1998 13:38:29 +0000 (13:38 +0000)]
If the preference filename resource is empty don't try to open or
create the preferences file. This is so that frozen programs don't
interfere with an existing Python installation, or leave turds in the
Preferences folder.
Jack Jansen [Mon, 13 Jul 1998 13:37:12 +0000 (13:37 +0000)]
All import-related code has moved to macimport.c.
There's also new support for importing code fragments: if a file on
sys.path contains a PYD resource with resourcename equal to the name
of the module to be imported this PYD resource should contain a
(pascal) string with the name of a code fragment to load. This allows
freezing Python programs without access to source or a development
environment.
Add special case to PySequence_List() so that list() of a list is
faster (using PyList_GetSlice()). Also added a test for a NULL
argument, as with PySequence_Tuple(). (Hmm... Better names for these
two would be PyList_FromSequence() and PyTuple_FromSequence(). Oh well.)
Changed PySequence_List() and PySequence_Tuple() to support
"indefinite length" sequences. These should still have a length, but
the length is only used as a hint -- the actual length of the sequence
is determined by the item that raises IndexError, which may be either
smaller or larger than what len() returns. (This is a novelty; map(),
filter() and reduce() only allow the actual length to be larger than
what len() returns, not shorter. I'll fix that shortly.)
Jack Jansen [Fri, 10 Jul 1998 15:47:48 +0000 (15:47 +0000)]
Added a function SetUserItemHandler: this takes a function(dialog,
item) as parameter and returns a handle suitable for passing to
SetDialogItem as a user-item redraw routine. Note that you can
only make one of these, for now.
(1) Added a sys.exc_info() emulation. (It returns None for the traceback.)
(2) Made the test script a bit fancier -- you can now use it to run
arbitrary scripts in restricted mode, and it will do the right thing.
(The interactive mode is still pretty lame; should integrate this with
code.interact().)
Fred Drake [Wed, 8 Jul 1998 21:37:25 +0000 (21:37 +0000)]
Fix suggested by Lorenzo M. Catucci <lorenzo@argon.roma2.infn.it> to keep the
large letter at the top of each index section with at least the first entry
for that letter.
Fix some problems that a picky SGI compiler reported. Two were benign
(unreachable break after a return) but one was a real bug:
ReadFrames() was getting a bogus framecount because of a missing '&'.
Sigh. The hack to enable special treatment for errno on SGI machines
must be enabled here, otherwise the errno we set on overflows is not
the errno that's being read by compile.c. Wonder how many other files
that do their own "#include config.h" need this too :-(
(Because of the structure of autoconf, it's not so simple to get this
into config.h...)
(1) reorder the tests for -Olimit 1500 and -OPT:Olimit=0 so that the
latter test is performed first, and if it works, the former test is
skipped. This should get rid of the problem that the new SGI
compilers accept both but emit a warning about -Olimit 1500.
(2) The DGUX hack was somehow split in two by the Olimit tests,
probably as the result of a non-context diff. Moved this back
together again, after the Olimit tests.
Barry Warsaw [Tue, 7 Jul 1998 17:45:38 +0000 (17:45 +0000)]
(py-beginning-of-def-or-class, py-end-of-def-or-class,
py-mark-def-or-class): Integrated Michael Ernst latest patches.
Primarily, it allows functions that search or mark defs/classes based
on programmatic specification, to take an 'either flag value which
allows searching for both classes and defs (stopping at the nearest
construct).
Barry Warsaw [Tue, 7 Jul 1998 15:11:24 +0000 (15:11 +0000)]
(py-comment-indent-function): A replacement for
comment-indent-function's default lambda value (in simple.el), this
version finally kills this nit: auto-filling a comment that starts in
column zero with filladapt turned off would cascade the #'s to the
right.
Now auto-filling seems to work with or without filladapt, and with the
comment starting in any column.
Added back the description of the exec statement. It appears that I
accidentally cut it out when removing the access statement! Added a
paragraph on __builtins__ and other possible manipulations of the key
space of the dictionaries. Added some index entries.
On Windows, put the select file descriptor arrays on the heap.
This is because they are huge and the stack is limited on Windows.
Other platforms keep declaring it on the stack.
Barry Warsaw [Wed, 1 Jul 1998 20:41:12 +0000 (20:41 +0000)]
Several changes:
1. Convert to using re module
2. Added two new exception classes
a. MissingSectionHeaderError which signals an early parsing
exception when options appear in the file before any section
header. Previously a bogus TypeError was thrown deeper down.
b. ParsingError which collates any non-fatal parsing errors.
ConfigParser.read() will raise this after the entire file was
parsed if any errors occurred during parsing (client could just
catch the exception and continue, because the ConfigParser
instance would still be initialized with the valid data).
(small note: Error.__msg => Error._msg)
3. ConfigParser.__read() now uses re which has the following minor
semantic change: underscore is now allowed in section header and
option name. Also, because of the old regexps, theoretically.
Fixed continuation line bug reported by F. Lundh.
4. It seemed that the old ConfigParser automatically added the option
`name' to every section, which contained the name of the section.
This seemed bogus to me so I took it out.
Added a section to the chapter on modules, describing the package system.
The text is almost completely from GvR's essay on packages; some
introductory paragraphs have been removed, and everything after the
'Details' section in the HTML has been dropped (seems too technical). A
paragraph has been added after the sample package layout stating that there
must be a file called__init__.py in a directory to make it a package.