Jack Jansen [Tue, 4 Dec 2001 13:30:29 +0000 (13:30 +0000)]
Patch by Jason Harper to allow IDE to work again under MacOS 8.1. Plus appearance support for Wlist frames and focussing. Plus commented-out appearance support for the same for Wtext, which still needs some work.
Jeremy Hylton [Tue, 4 Dec 2001 02:41:46 +0000 (02:41 +0000)]
SF bug #488687 reported by Neal Norwitz
The error for assignment to __debug__ used ste->ste_opt_lineno instead
of n->n_lineno. The latter was at best incorrect; often the slot was
uninitialized. Two fixes here: Use the correct lineno for the error.
Initialize ste_opt_lineno in PySymtable_New(); while there are no
current cases where it is referenced unless it has already been
assigned to, there is no harm in initializing it.
Fred Drake [Mon, 3 Dec 2001 22:15:56 +0000 (22:15 +0000)]
Slightly improved indexing for the string-% operator, thanks to comments
from Skip Montanaro. There is one weirdness in the final index for HTML, but
that is low priority.
Fix the final two issues in Armin Rigo's SF bug #488477: apply_slice()
and assign_slice() weren't properly DECREF'ing the temporary slice
object they created. (Shame on me. :-)
unpack_iterable(): Add a missing DECREF in an error case. Reported by
Armin Rigo (SF bug #488477). Added a testcase to test_unpack_iter()
in test_iter.py.
Barry Warsaw [Mon, 3 Dec 2001 19:26:40 +0000 (19:26 +0000)]
decode(), encode(): Accepting the minor optimizations from SF patch
#486375, but not the rest of it, since that changes the documented
semantics of encode().
Fred Drake [Mon, 3 Dec 2001 18:27:22 +0000 (18:27 +0000)]
Re-word the intro slightly to avoid reader misunderstanding: strings are not
mutable! We do not want to shock anyone.
This closes SF bug #483805.
Re-factor so that the description of the "access" keyword parameter is not
repeated in both the descriptions of mmap(). Also, only make sure the first
description of mmap() appears in the index. The the index link is followed,
the first is now used to locate the page on the screen; chances are really good
both will be visible. This avoids the problem that the index entry for the
second is selected and the first version is not visible, making the reader
consider that mmap() is not available on Windows.
Fred Drake [Mon, 3 Dec 2001 17:32:27 +0000 (17:32 +0000)]
Remove most references to __members__ and __methods__, leaving only one pair
of references that now state that these attributes have been removed,
directing the reader to the dir() function.
This closes SF bug #456420.
Fred Drake [Mon, 3 Dec 2001 17:09:50 +0000 (17:09 +0000)]
Convert to using string methods instead of the string module.
In goahead(), use a bound version of rawdata.startswith() since we use the
same method all the time and never change the value of rawdata. This can
save a lot of bound method creation.
Fix of SF bug #475877 (Mutable subtype instances are hashable).
Rather than tweaking the inheritance of type object slots (which turns
out to be too messy to try), this fix adds a __hash__ to the list and
dict types (the only mutable types I'm aware of) that explicitly
raises an error. This has the advantage that list.__hash__([]) also
raises an error (previously, this would invoke object.__hash__([]),
returning the argument's address); ditto for dict.__hash__.
The disadvantage for this fix is that 3rd party mutable types aren't
automatically fixed. This should be added to the rules for creating
subclassable extension types: if you don't want your object to be
hashable, add a tp_hash function that raises an exception.
Also, it's possible that I've forgotten about other mutable types for
which this should be done.
Address SF patch #480716 as well as related issues.
SF patch #480716 by Greg Chapman fixes the problem that super's
__get__ method always returns an instance of super, even when the
instance whose __get__ method is called is an instance of a subclass
of super.
Other issues fixed:
- super(C, C()).__class__ would return the __class__ attribute of C()
rather than the __class__ attribute of the super object. This is
confusing. To fix this, I decided to change the semantics of super
so that it only applies to code attributes, not to data attributes.
After all, overriding data attributes is not supported anyway.
- While super(C, x) carefully checked that x is an instance of C,
super(C).__get__(x) made no such check, allowing for a loophole.
This is now fixed.
slot_tp_descr_set(): When deleting an attribute described by a
descriptor implemented in Python, the descriptor's __del__ method is
called by the slot_tp_descr_set dispatch function. This is bogus --
__del__ already has a different meaning. Renaming this use of __del__
is renamed to __delete__.
Tim Peters [Mon, 3 Dec 2001 00:43:33 +0000 (00:43 +0000)]
mysnprintf.c: Massive rewrite of PyOS_snprintf and PyOS_vsnprintf, to
use wrappers on all platforms, to make this as consistent as possible x-
platform (in particular, make sure there's at least one \0 byte in
the output buffer). Also document more of the truth about what these do.
getargs.c, seterror(): Three computations of remaining buffer size were
backwards, thus telling PyOS_snprintf the buffer is larger than it
actually is. This matters a lot now that PyOS_snprintf ensures there's a
trailing \0 byte (because it didn't get the truth about the buffer size,
it was storing \0 beyond the true end of the buffer).
sysmodule.c, mywrite(): Simplify, now that PyOS_vsnprintf guarantees to
produce a \0 byte.
Jack Jansen [Mon, 3 Dec 2001 00:11:35 +0000 (00:11 +0000)]
A system() lookalike that sends commands to ToolServer, by Daniel Brotsky. The semantics aren't enough like system() to add this to the main Lib folder, but it is pretty useful nonetheless for selected people.
slot_tp_descr_set(): When deleting an attribute described by a
descriptor implemented in Python, the descriptor's __del__ method is
called by the slot_tp_descr_set dispatch function. This is bogus --
__del__ already has a different meaning. Renaming this use of __del__
is renamed to __delete__.
Jack Jansen [Sun, 2 Dec 2001 23:56:28 +0000 (23:56 +0000)]
Changed logic for finding python home in Mac OS X framework Pythons.
Now sys.executable points to the executable again, in stead of to
the shared library. The latter is used only for locating the python
home.
Fred Drake [Sun, 2 Dec 2001 15:10:46 +0000 (15:10 +0000)]
Add reference to the "String Methods" section to make that information
easier to find. Based on the comment from Steve Alexander on the
zope-coders mailing list.
When the number of bytes written to the malloc'ed buffer is larger
than the argument string size, copy as many bytes as will fit
(including a terminating '\0'), rather than not copying anything.
This to make it satisfy the C99 spec.
Tim Peters [Sat, 1 Dec 2001 02:52:56 +0000 (02:52 +0000)]
SF bug #487743: test_builtin fails on 64 bit platform.
Bugfix candidate.
int_repr(): we've never had a buffer big enough to hold the largest
possible result on a 64-bit box. Now that we're using snprintf instead
of sprintf, this can lead to nonsense results instead of random stack
corruption.
Fred Drake [Fri, 30 Nov 2001 18:09:54 +0000 (18:09 +0000)]
Add a new environment in the Python docs markup: seealso*. This is similar
to seealso, but does not add the "See also:" header or put the content in a
box in the HTML version.
Updated the description of \seeurl to better indicate when it should be used;
the old description was written before we had \seetitle.
Fred Drake [Thu, 29 Nov 2001 04:30:46 +0000 (04:30 +0000)]
A few small changes:
- Change PREFIX to PREFIXES, which contains a sequence of prefix strings.
This is useful since we want to look for both Py and PY.
- Wrap a long line.
- Collect struct tags as well as typedef names. Since we generally only
use one of the other, that improves coverage.
- Make the script executable on Unix.
This could use a better approach to determine if a symbol is documented,
and could easily avoid keeping the massive string in memory. That would
take time to actually write more code, though, so we'll bail on that
for now.
Tim Peters [Thu, 29 Nov 2001 03:26:37 +0000 (03:26 +0000)]
SF bug 486278 SystemError: Python/getargs.c:1086: bad.
vgetargskeywords(): Now that this routine is checking for bad input
(rather than dump core in some cases), some bad calls are raising errors
that previously "worked". This patch makes the error strings more
revealing, and changes the exceptions from SystemError to RuntimeError
(under the theory that SystemError is more of a "can't happen!" assert-
like thing, and so inappropriate for bad arguments to a public C API
function).
Guido van Rossum [Thu, 29 Nov 2001 02:50:15 +0000 (02:50 +0000)]
canonic(): don't use abspath() for filenames looking like <...>; this
fixes the problem reported in SF bug #477023 (Jonathan Mark): "pdb:
unexpected path confuses Emacs".
Tim Peters [Wed, 28 Nov 2001 23:16:40 +0000 (23:16 +0000)]
SF bug 486480: zipfile __del__ is broken
ZipFile.__del__(): call ZipFile.close(), like its docstring says it does.
ZipFile.close(): allow calling more than once (as all file-like objects
in Python should support).
Tim Peters [Wed, 28 Nov 2001 22:43:45 +0000 (22:43 +0000)]
PyFloat_AsStringEx(): This function takes an output char* but doesn't
pass the buffer length. Stop using it. It should be deprecated, but too
late in the release cycle to do that now.
New static format_float() does the same thing but requires passing the
buffer length too. Use it instead.
Tim Peters [Wed, 28 Nov 2001 22:13:25 +0000 (22:13 +0000)]
PyFile_WriteString(): change prototype so that the string arg is
const char* instead of char*. The change is conceptually correct, and
indirectly fixes a compiler wng introduced when somebody else innocently
passed a const char* to this function.
Jeremy Hylton [Wed, 28 Nov 2001 21:46:59 +0000 (21:46 +0000)]
Use PyOS_snprintf() at some cost even though it was correct before.
seterror() uses a char array and a pointer to the current position in
that array. Use snprintf() and compute the amount of space left in
the buffer based on the current pointer position.
Jeremy Hylton [Wed, 28 Nov 2001 21:44:53 +0000 (21:44 +0000)]
Use PyOS_vsnprintf() and check its return value.
If it returns -1 (which indicates overflow on old Linux platforms and
perhaps on Windows) or size greater than buffer, write a message
indicating that the previous message was truncated.