At the PythonLabs meeting someone mentioned it would make Jim really
happy if one could delete the __dict__ attribute of an instance. I
love to make Jim happy, so here goes...
- New-style objects now support deleting their __dict__. This is for
all intents and purposes equivalent to assigning a brand new empty
dictionary, but saves space if the object is not used further.
Fred Drake [Wed, 5 Dec 2001 15:58:29 +0000 (15:58 +0000)]
Separate the script portion from the library portion; everything that
pertains to the script is now in the if __name__ == "__main__" block.
This is in response to a commenton python-dev from Neal Norwitz.
Tim Peters [Wed, 5 Dec 2001 06:05:07 +0000 (06:05 +0000)]
SF bug 482574: audioop.ratecv crashes.
Bugfix candidate.
A numerically naive computation of output buffer size caused crashes
and spurious MemoryErrors for reasonable arguments.
audioop_ratecv(): Avoid spurious overflow by careful reworking of the
buffer size computations, triggering MemoryError if and only if the
final buffer size can't be represented in a C int (although
PyString_FromStringAndSize may legitimately raise MemoryError even if
it does fit in a C int). All reasonable arguments should work as
intended now, and all unreasonable arguments should be cuaght.
Fred Drake [Wed, 5 Dec 2001 05:46:25 +0000 (05:46 +0000)]
Add a note to the description of the interaction between the softspace
attribute of file objects, the print statement, and other file operations.
This closes SF bug #484857.
Fred Drake [Wed, 5 Dec 2001 05:25:59 +0000 (05:25 +0000)]
Added documentation of the sendall() method, and a note to the send() method
that it does not guarantee that all data is sent.
This closes SF patch #474307.
Tim Peters [Tue, 4 Dec 2001 23:05:10 +0000 (23:05 +0000)]
SF bug #488480: integer multiply to return -max_int-1.
int_mul(): new and vastly simpler overflow checking. Whether it's
faster or slower will likely vary across platforms, favoring boxes
with fast floating point. OTOH, we no longer have to worry about
people shipping broken LONG_BIT definitions <0.9 wink>.
Tim Peters [Tue, 4 Dec 2001 20:06:11 +0000 (20:06 +0000)]
Stop defining NDEBUG in Python.h, because it can interfere with
extensions that #include Python.h. See (rejected) patch 487634 for
more detail. I'll open a new bug report for the rest needed here.
Fred Drake [Tue, 4 Dec 2001 19:47:46 +0000 (19:47 +0000)]
Include a warning that scripts should not have the same name as standard
modules, or the module cannot be properly imported. (Based on a suggestion
sent to python-docs.)
Update the displayed dir() of the sys and __builtin__ module with Python 2.2.
Fred Drake [Tue, 4 Dec 2001 19:20:43 +0000 (19:20 +0000)]
Talk about str() in the discussion of string representations of values, and
give examples for which str() and repr() yield different results.
This closes SF bug #485446.
Ka-Ping Yee [Tue, 4 Dec 2001 18:45:17 +0000 (18:45 +0000)]
Add "file" argument to Hook constructor.
By default, save sys.stdout in self.file when a Hook instance is created
(e.g. when cgitb.enable() is called).
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
There's now a new structmember code, T_OBJECT_EX, which is used for
all __slot__ variables (except __weakref__, which has special behavior
anyway). This new code raises AttributeError when the variable is
NULL rather than converting NULL to None.
Fred Drake [Tue, 4 Dec 2001 17:03:54 +0000 (17:03 +0000)]
Fix SF bug #479967: Appearantly I broke something that made the index
insertion work. This fix makes things at least somewhat more explicit, and
adds a little sanity checking (and verbosity!) to
add_bbl_and_idx_dummy_commands().
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
There's now a new structmember code, T_OBJECT_EX, which is used for
all __slot__ variables (except __weakref__, which has special behavior
anyway). This new code raises AttributeError when the variable is
NULL rather than converting NULL to None.
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.