Make sure that tp_free frees the int the same way as tp_dealloc would.
This fixes the problem that Barry reported on python-dev:
>>> 23000 .__class__ = bool
crashes in the deallocator. This was because int inherited tp_free
from object, which uses the default allocator.
Barry Warsaw [Thu, 25 Apr 2002 21:31:47 +0000 (21:31 +0000)]
SF patch #510288 by Kevin J. Butler, mod'd by Barry. This provides
better auto-recognition of a Jython file vs. a CPython (or agnostic)
file by looking at the #! line more closely, and inspecting the import
statements in the first 20000 bytes (configurable). Specifically,
(py-import-check-point-max): New variable, controlling how far into
the buffer it will search for import statements.
(py-jpython-packages): List of package names that are Jython-ish.
(py-shell-alist): List of #! line programs and the modes associated
with them.
(jpython-mode-hook): Extra hook that runs when entering jpython-mode
(what about Jython mode? <20k wink>).
(py-choose-shell-by-shebang, py-choose-shell-by-import,
py-choose-shell): New functions.
(python-mode): Use py-choose-shell.
(jpython-mode): New command.
(py-execute-region): Don't use my previous hacky attempt at doing
this, use the new py-choose-shell function.
One other thing this file now does: it attempts to add the proper
hooks to interpreter-mode-alist and auto-mode-alist if they aren't
already there. Might help with Emacs users since that editor doesn't
come with python-mode by default.
Barry Warsaw [Thu, 25 Apr 2002 19:17:42 +0000 (19:17 +0000)]
(py-execute-region): Alexander Schmolck points out that leading
whitespace can hose the needs-if test. So just skip all blank lines
at the start of the region right off the bat.
Thomas Heller [Thu, 25 Apr 2002 17:26:37 +0000 (17:26 +0000)]
Append the PC specific include 'PC' and library 'PCBuild' directories
under NT - this allows distutils to work with the CVS version or the
source distribution.
Barry Warsaw [Thu, 25 Apr 2002 16:26:38 +0000 (16:26 +0000)]
(py-comint-output-filter-function): Add a pop-to-buffer call so you
always get to see the result of e.g. a py-execute-region. Funny, this
bugged both me /and/ Guido!
Tim Peters [Tue, 23 Apr 2002 23:07:28 +0000 (23:07 +0000)]
test_mmap started breaking on Windows, only when run after test_bsddb.
On Win2K it thought 'foo' started at byte offset 0 instead of at the
pagesize, and on Win98 it thought 'foo' didn't exist at all. Somehow
or other this is related to the new "in memory file" gimmicks in
bsddb, but the old bsddb we use on Windows sucks so bad anyway I don't
want to bother digging deeper. Flushing the file in test_mmap after
writing to it makes the problem go away, so good enough.
Barry Warsaw [Tue, 23 Apr 2002 22:48:42 +0000 (22:48 +0000)]
Unit tests for the changes in abstract.c version 2.101. The debug
build's "undetected error" problems were originally detected with
extension types, but we can whitebox test the same situations with
new-style classes.
Barry Warsaw [Tue, 23 Apr 2002 22:45:44 +0000 (22:45 +0000)]
abstract_get_bases(): Clarify exactly what the return values and
states can be for this function, and ensure that only AttributeErrors
are masked. Any other exception raised via the equivalent of
getattr(cls, '__bases__') should be propagated up.
abstract_issubclass(): If abstract_get_bases() returns NULL, we must
call PyErr_Occurred() to see if an exception is being propagated, and
return -1 or 0 as appropriate. This is the specific fix for a problem
whereby if getattr(derived, '__bases__') raised an exception, an
"undetected error" would occur (under a debug build). This nasty
situation was uncovered when writing a security proxy extension type
for the Zope3 project, where the security proxy raised a Forbidden
exception on getattr of __bases__.
PyObject_IsInstance(), PyObject_IsSubclass(): After both calls to
abstract_get_bases(), where we're setting the TypeError if the return
value is NULL, we must first check to see if an exception occurred,
and /not/ mask an existing exception.
Neil Schemenauer should double check that these changes don't break
his ExtensionClass examples (there aren't any test cases for those
examples and abstract_get_bases() was added by him in response to
problems with ExtensionClass). Neil, please add test cases if
possible!
I belive this is a bug fix candidate for Python 2.2.2.
Barry Warsaw [Tue, 23 Apr 2002 21:39:00 +0000 (21:39 +0000)]
Rewrote the PyUnit description so that it now recommends to use
run_suite() instead of run_unittest(). Best practice is to plan for
multiple test classes.
Jack Jansen [Tue, 23 Apr 2002 21:03:21 +0000 (21:03 +0000)]
First part of fix for #493826: if 'errn' key exists in return value this doesn't necesarily signal an error, only if the value is non-zero it does. This
does not correspond with my reading of the documentation, but the OSX Finder can return 'errn'=0, and it knows better than me:-)
Jeremy Hylton [Tue, 23 Apr 2002 20:31:01 +0000 (20:31 +0000)]
Ignore SIGXFSZ.
The SIGXFSZ signal is sent when the maximum file size limit is
exceeded (RLIMIT_FSIZE). Apparently, it is also sent when the 2GB
file limit is reached on platforms without large file support.
The default action for SIGXFSZ is to terminate the process and dump
core. When it is ignored, the system call that caused the limit to be
exceeded returns an error and sets errno to EFBIG. Python
always checks errno on I/O syscalls, so there is nothing to do with
the signal.
Jeremy Hylton [Tue, 23 Apr 2002 20:21:22 +0000 (20:21 +0000)]
Add tests for the recent resource module change.
Also add a test that Python doesn't die with SIGXFSZ if it exceeds the
file rlimit. (Assuming this will also test the behavior when the 2GB
limit is exceed on a platform that doesn't have large file support.)
Barry Warsaw [Mon, 22 Apr 2002 22:05:49 +0000 (22:05 +0000)]
Merge in Skip's last few updates w.r.t. py-help-at-point:
(py-mode-map): Bind py-help-at-point to f1 as well as C-c C-h
(py-help-at-point): Make sure the symbol is quoted so things like
pydoc.help('sys.platform') work correctly. Also, leave the *Python
Output* buffer in help-mode; this may be a bit more controversial.
Barry Warsaw [Mon, 22 Apr 2002 21:48:20 +0000 (21:48 +0000)]
Some contributions and ideas by Alexander Schmolck: add a keybinding
to call pychecker on the current file, add a face for pseudo
keywords self, None, True, False, and Ellipsis. Specifically,
(py-pychecker-command, py-pychecker-command-args): New variables.
(py-pseudo-keyword-face): New face variable, defaulting to a copy of
font-lock-keyword-face.
(python-font-lock-keywords): Add an entry for self, None, True, False,
Ellipsis to be rendered in py-pseudo-keyword-face.
Tim Peters [Mon, 22 Apr 2002 19:00:10 +0000 (19:00 +0000)]
unicode_memchr(): Squashed gratuitous int-vs-size_t mismatch (which
gives a compiler wng under MSVC because of the resulting signed-vs-
unsigned comparison).
Tim Peters [Mon, 22 Apr 2002 18:43:49 +0000 (18:43 +0000)]
SF bug 546078: IDLE calltips cause application error.
Assorted crashes on Windows and Linux when trying to display a very
long calltip, most likely a Tk bug. Wormed around by clamping the
calltip display to a maximum of 79 characters (why 79? why not ...).
Walter Dörwald [Mon, 22 Apr 2002 17:42:37 +0000 (17:42 +0000)]
Apply patch diff.txt from SF feature request
http://www.python.org/sf/444708
This adds the optional argument for str.strip
to unicode.strip too and makes it possible
to call str.strip with a unicode argument
and unicode.strip with a str argument.
Barry Warsaw [Mon, 22 Apr 2002 17:15:19 +0000 (17:15 +0000)]
Skip Montanaro's contribution (slightly mod'd by Barry) to provide a
"help-on-symbol-at-point" feature which uses pydoc to provide help on
the symbol under point, if available.
Mods include some name changes, a port to Emacs, binding the command
to C-c C-h, and providing a more informative error message if the
symbol's help can't be found (through use of a nasty bare except).
Note also that py-describe-mode has been moved off of C-c C-h m; it's
now just available on C-c ?
Barry Warsaw [Mon, 22 Apr 2002 16:23:29 +0000 (16:23 +0000)]
(py-execute-region): If the line at the beginning of the region is a
#! line, use the command on that line as the shell command to use to
execute the region. I.e. if the region looks like
Barry Warsaw [Mon, 22 Apr 2002 15:29:27 +0000 (15:29 +0000)]
(py-execute-region): If you ran this without having visited a
python-mode file, py-which-shell would have been nil and the command
to use would not get set correctly. This changes things so that 1)
the temporary file has a .py extension, 2) the temporary file is put
into python-mode, and 3) the temporary file's py-which-shell is
captured in a local `shell' variable, which is used to calculate the
command to use. Closes SF bug #545436.
(py-parse-state): Rip out the XEmacs-specific calls to
buffer-syntactic-context, which can get quite confused if there's an
open paren in column zero say, embedded in a triple quoted string.
This was always a performance hack anyway, and computers are fast
enough now that we should be able to get away with the slower, more
portable, full-parse branch. Closes SF bug #451841.
Jack Jansen [Mon, 22 Apr 2002 13:55:43 +0000 (13:55 +0000)]
Fixes based on ideas from Christopher Smith:
- islink() now returns true for alias files
- walk() no longer follows aliases while traversing
- realpath() implemented, returning an alias-free pathname.
As this could conceivably break existing code I think it isn't a bugfix candidate.
Tim Peters [Mon, 22 Apr 2002 02:33:27 +0000 (02:33 +0000)]
Moving pymalloc along.
+ Redirect PyMem_{Del, DEL} to the object allocator's free() when
pymalloc is enabled. Needed so old extensions can continue to
mix PyObject_New with PyMem_DEL.
+ This implies that pgen needs to be able to see the PyObject_XYZ
declarations too. pgenheaders.h now includes Python.h. An
implication is that I expect obmalloc.o needs to get linked into
pgen on non-Windows boxes.
+ When PYMALLOC_DEBUG is defined, *all* Py memory API functions
now funnel through the debug allocator wrapper around pymalloc.
This is the default in a debug build.
+ That caused compile.c to fail: it indirectly mixed PyMem_Malloc
with raw platform free() in one place. This is verbotten.
Tim Peters [Sun, 21 Apr 2002 07:29:14 +0000 (07:29 +0000)]
Py_UniversalNewlineFread(): Many changes.
+ Continued looping until n bytes in the buffer have been filled, not
just when n bytes have been read from the file. This repairs the
bug that f.readlines() only sucked up the first 8192 bytes of the file
on Windows when universal newlines was enabled and f was opened in
U mode (see Python-Dev -- this was the ultimate cause of the
test_inspect.py failure).
+ Changed prototye to take a char* buffer (void* doesn't make much sense).
+ Squashed size_t vs int mismatches (in particular, besides the unsigned
vs signed distinction, size_t may be larger than int).
+ Gets out under all error conditions now (it's possible for fread() to
suffer an error even if it returns a number larger than 0 -- any
"short read" is an error or EOF condition).
Tim Peters [Sun, 21 Apr 2002 06:12:02 +0000 (06:12 +0000)]
Assorted code cleanups for readability. Greatly boosted the size of the
test data: this test fails on WIndows now if universal newlines are
enabled (which they aren't yet, by default). I don't know whether the
test will also fail on Linux now.
Tim Peters [Sun, 21 Apr 2002 04:44:11 +0000 (04:44 +0000)]
Hack around the "2.1.6 Blank lines" bug in a way that the TOC still
displays a recognizable section title (there are extra blanks at the
end of it now, due to the nested anchor, but that's fine).
Tim Peters [Sun, 21 Apr 2002 03:26:37 +0000 (03:26 +0000)]
PyUnicode_EncodeUTF8: squash compiler wng. The difference of two
pointers is a signed type. Changing "allocated" to a signed int makes
undetected overflow more likely, but there was no overflow detection
before either.
Tim Peters [Sun, 21 Apr 2002 02:01:01 +0000 (02:01 +0000)]
Give the Help viewer a font-size button. This isn't documented by MS,
but is documented by others on the web, and the defn of the magic flag
needed appears in MS's htmlhelp.h header file.
Tim Peters [Sat, 20 Apr 2002 21:34:34 +0000 (21:34 +0000)]
Move "everything left one": the TOC now shows each doc directory as a
distinct top-level node. Before they were all nested under an artificial
top-level node, uselessly chewing up horizontal space, and ensuring that
the only thing the user saw in the TOC upon opening the file was a single
collapsed top-level folder.
Tim Peters [Sat, 20 Apr 2002 20:26:26 +0000 (20:26 +0000)]
Stopped all warnings from the HTML Help Compiler, by generating proper
HTML (or, at least, proper in its view). The TOC file is now identical
to what the HTML compiler itself generates, except for whitespace and
a glitch identified below. The pretty-printing done by prechm.py is
pretty much destroyed for now; if you need it pretty-printed, just make
the Help Compiler save the files (it's got its own idea of pretty-
printing anyway).
Glitch: The title of Ref Man "2.1.6 Blank lines" shows up as a blank
for now. This is because the relevant entry in ref/index.html contains
nested anchors, and pychm really has no idea what to do with that. I
hacked it for now to avoid any error messages or worse insanity, and
filed a bug report against the docs.
Tim Peters [Sat, 20 Apr 2002 08:36:42 +0000 (08:36 +0000)]
Widespread: Used classes in a more natural way. Added convenience
methods to squash code duplication. Simplified several overly complex
chunks of logic. Built output strings more with string interpolation
instead of infix '+'. Added comments. Exploited recent Python features
(chiefly bool and augmented assignment).
Jeremy Hylton [Sat, 20 Apr 2002 04:46:55 +0000 (04:46 +0000)]
Fix SF bug #505315: Make free and cell vars show up consistently in locals().
PyFrame_FastToLocals() and PyFrame_LocalsToFast() had a return if
f_nlocals was 0. I think this was a holdover from the pre 2.1 days
when regular locals were the only kind of local variables.
The change makes it possible to use a free variable in eval or exec if
it the variable is also used elsewhere in the same block, which is
what the documentation says.
Tim Peters [Sat, 20 Apr 2002 03:25:02 +0000 (03:25 +0000)]
Replaced the fiddly 5-tuples with a new Book convenience class, allowing
to reference fields via names instead of meaningless little integers.
This turned up one case where the wrong little integer was being used,
in informative progress output. Fixed that too.
Jeremy Hylton [Fri, 19 Apr 2002 22:56:37 +0000 (22:56 +0000)]
Fix com_arglist() and update grammar fragment.
SF bug #522264 reported by Evelyn Mitchell.
The code included a comment about "STAR STAR" which was translated
into the code as the bogus attribute token.STARSTAR. This name never
caused an attribute error because it was never retrieved. The code
was based on an old version of the grammar that specified kwargs as
two tokens ('*' '*'). I checked as far back as 2.1 and didn't find
this production.
The fix is simple, because token.DOUBLESTAR is the only token
allowed. Also update the grammar fragment in com_arglist().
XXX I'll bet lots of other grammar fragments in comments are out of
date, probably in this module and in compile.c.
Tim Peters [Fri, 19 Apr 2002 18:41:46 +0000 (18:41 +0000)]
Added a stop-list to reduce the size of the full text search index. Fred,
populate the "stop_list" triple-quoted string with your favorite handful
of stop words.
Tim Peters [Fri, 19 Apr 2002 16:46:43 +0000 (16:46 +0000)]
+ Changed TOC to folder-tree style.
+ Increased size of the window the user sees the first time.
+ Arranged for the display to remember its last size and position.
+ Added a Favorites (bookmarks) tab.
+ Added the "Advanced Search" decorations.
Tim Peters [Fri, 19 Apr 2002 16:09:26 +0000 (16:09 +0000)]
Generates inputs to the Microsoft Help Compiler, which creates compiled
HTML help files (.chm). Obtained from Robin Dunn's packaging of the
2.2 docs at <http://alldunn.com/python/>, obtained in turn from
Hernán Martínez Foffani's original work at
<http://www.orgmf.com.ar/condor/pytstuff.html>.
Jack Jansen [Fri, 19 Apr 2002 14:29:47 +0000 (14:29 +0000)]
Oops: we used PyMem_DEL() to clean up objects, and that's a problem since
pymalloc, apparently. Fixed, but this means all bgen-generated modules will
have to be re-generated.
I hope (and expect) that the pymalloc fixes aren't bugfix candidates, because
if they are this is one too.
Fred Drake [Fri, 19 Apr 2002 04:04:57 +0000 (04:04 +0000)]
Clean up the use of version numbers in filenames; always use an "abstract"
version number, and explain what it is at the top of the chapter.
This closes SF bug #225003.
Tim Peters [Thu, 18 Apr 2002 22:25:03 +0000 (22:25 +0000)]
_PyObject_DebugMallocStats(): Added some potentially expensive internal
consistency checks, enabled only in a debug (Py_DEBUG) build. Note that
this never gets called automatically unless PYMALLOC_DEBUG is #define'd
too, and the envar PYTHONMALLOCSTATS exists.