Tim Peters [Sat, 10 Aug 2002 21:20:54 +0000 (21:20 +0000)]
If any trash happened to be sitting around waiting to get collected at
the time it's called, test_saveall() made it look a leak, triggering
bogus warnings from regrtest's -l (findleaks) mode.
Tim Peters [Sat, 10 Aug 2002 05:21:15 +0000 (05:21 +0000)]
1. Combined the base and length arrays into a single array of structs.
This is friendlier for caches.
2. Cut MIN_GALLOP to 7, but added a per-sort min_gallop vrbl that adapts
the "get into galloping mode" threshold higher when galloping isn't
paying, and lower when it is. There's no known case where this hurts.
It's (of course) neutral for /sort, \sort and =sort. It also happens
to be neutral for !sort. It cuts a tiny # of compares in 3sort and +sort.
For *sort, it reduces the # of compares to better than what this used to
do when MIN_GALLOP was hardcoded to 10 (it did about 0.1% more *sort
compares before, but given how close we are to the limit, this is "a
lot"!). %sort used to do about 1.5% more compares, and ~sort about
3.6% more. Here are exact counts:
i *sort 3sort +sort %sort ~sort !sort
15 449235 33019 33016 51328 188720 65534 before
448885 33016 33007 50426 182083 65534 after
0.08% 0.01% 0.03% 1.79% 3.65% 0.00% %ch from after
Tim Peters [Sat, 10 Aug 2002 03:04:33 +0000 (03:04 +0000)]
The samplesort-vs-mergesort #-of-comparisons comparisons were captured
before %sort was introduced. Redid them (the numbers change, but the
conclusions don't). Also did the samplesort counts with the released
2.2.1, as they're slightly different under the last CVS 2.3 samplesort
(some higher, some lower -- CVS had been changed to stop doing the
special-case business on recursive samplesort calls).
Fred Drake [Fri, 9 Aug 2002 20:20:50 +0000 (20:20 +0000)]
Lots of changes to the packaging of the documentation, all to keep
directories clean where the packages are unpacked. Each package now
contains a single directory, Python-Docs-<version>/, which contains the
files for that version of the documentation.
Tim Peters [Fri, 9 Aug 2002 18:13:51 +0000 (18:13 +0000)]
There's no distinction among 'user', 'group' and 'world' permissions
on Win32, so tests that assume there are such distinctions can't
pass. Fiddled them to work.
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg). This changes all uses of deprecated tempfile functions to
the recommended ones.
Check-in of the most essential parts of SF 589982 (tempfile.py
rewrite, by Zack Weinberg). This replaces most code in tempfile.py
(please review!!!) and adds extensive unit tests for it.
This will cause some warnings in the test suite; I'll check those in
soon, and also the docs.
Only call sq_repeat if the object does not have a nb_multiply slot. One
example of where this changes behavior is when a new-style instance
defines '__mul__' and '__rmul__' and is multiplied by an int. Before the
change the '__rmul__' method is never called, even if the int is the
left operand.
Steve Purcell [Fri, 9 Aug 2002 09:46:23 +0000 (09:46 +0000)]
Fix to ensure consistent 'repr' and 'str' results between Python
versions, since 'repr(new_style_class) != repr(classic_class)'.
Suggested by Jeremy Hylton.
Major speedup for new-style class creation. Turns out there was some
trampolining going on with the tp_new descriptor, where the inherited
PyType_GenericNew was overwritten with the much slower slot_tp_new
which would end up calling tp_new_wrapper which would eventually call
PyType_GenericNew. Add a special case for this to update_one_slot().
XXX Hope there isn't a loophole in this. I'll buy the first person to
point out a bug in the reasoning a beer.
Moved inplace add and multiply methods from UserString to MutableString.
Closes SF Bug #592573 where inplace add mutated a UserString.
Added unittests to verify the bug is cleared.
Moved special case for tuples from iterobject.c to
tupleobject.c. Makes the code in iterobject.c cleaner
and speeds-up the general case by not checking for
tuples everytime. SF Patch #592065.
Revised the test suite for 'contains' to use the test() function argument
rather than vereq(). While it was effectively testing regular strings, it
ignored the test() function argument when called by test_userstring.py.
Jack Jansen [Fri, 9 Aug 2002 00:18:21 +0000 (00:18 +0000)]
By popular demand the frameworkinstall target now installs everything:
the framework, the MacOSX apps and the unix tools.
Most of the hard work is done by Mac/OSX/Makefile.
Also, it should now be possible to install in a different directory,
such as /tmp/dist/Library/Frameworks, for building binary installers.
The fink crowd wanted this.
Significant speedup in new-style object creation: in slot_tp_new(),
intern the string "__new__" so we can call PyObject_GetAttr() rather
than PyObject_GetAttrString(). (Though it's a mystery why slot_tp_new
is being called when a class doesn't define __new__. I'll look into
that tomorrow.)
Jack Jansen [Thu, 8 Aug 2002 21:16:56 +0000 (21:16 +0000)]
Use hex escape for non-ascii chars, now that the parser wants that.
Good thing, too: some of the characters had been mangled by OS9->CVS->OSX
roundtrips.
A modest speedup of object deallocation. call_finalizer() did rather
a lot of work: it had to save and restore the current exception around
a call to lookup_maybe(), because that could fail in rare cases, and
most objects don't have a __del__ method, so the whole exercise was
usually a waste of time. Changed this to cache the __del__ method in
the type object just like all other special methods, in a new slot
tp_del. So now subtype_dealloc() can test whether tp_del is NULL and
skip the whole exercise if it is. The new slot doesn't need a new
flag bit: subtype_dealloc() is only called if the type was dynamically
allocated by type_new(), so it's guaranteed to have all current slots.
Types defined in C cannot fill in tp_del with a function of their own,
so there's no corresponding "wrapper". (That functionality is already
available through tp_dealloc.)
The other half of the patches added to SF patch 555085 by A I
MacIntyre. At least on OS/2, a subsequent connect() on a nonblocking
socket returns errno==EISCONN to indicate success. This seems
harmless on Unix.
Clean up some docstrings. Some docstrings didn't show their return
value; others were inconsistent in what to name the argument or return
value; a few module-global functions had "socket." in front of their
name, against convention.
testSendAll(): loop until all data is read; this was necessary at
least on OS/2 (see note on SF patch 555085 by A I MacIntyre) but
looks like the test *could* fail on any other platform too -- there's
no guarantee that recv() reads all data.
The _socketobject class has no need for a __del__ method: all it did was
to delete the reference to self._sock, and the regular destructor will
do that just fine. This made some hacks in close() unnecessary.
The _fileobject class still has a __del__ method, because it must flush.
Another refactoring of read() and readline(), this time based on the
observation that _rbuf could never have more than one string in it.
So make _rbuf a string. The code branches for size<0 and size>=0
are completely separate now, both in read() and in readline().
Another refactoring. Changed 'socket' from being a factory function
to being a new-style class, to be more similar to the socket class
in the _socket module; it is now the same as the _socketobject class.
Added __slots__. Added docstrings, copied from the real socket class
where possible.
The _fileobject class is now also a new-style class with __slots__
(though without docstrings). The mode, name, softspace, bufsize and
closed attributes are properly supported (closed as a property; name
as a class attributes; the softspace, mode and bufsize as slots).
Tim Peters [Thu, 8 Aug 2002 01:06:39 +0000 (01:06 +0000)]
PyList_Reverse(): This was leaking a reference to Py_None on every call.
I believe I introduced this bug when I refactored the reversal code so
that the mergesort could use it too. It's not a problem on the 2.2 branch.
Major restructuring of _fileobject. Hopefully several things now work
correctly (the test at least succeed, but they don't test everything yet).
Also fix a performance problem in read(-1): in unbuffered mode, this would
read 1 byte at a time. Since we're reading until EOF, that doesn't make
sense. Use the default buffer size if _rbufsize is <= 1.
Replace docstrings on test functions witrh comments -- then unittest
prints function and module names, which is more informative now that
we repeat some tests in slightly modified subclasses.
Add a test for read() until EOF.
Add test suites for line-buffered (bufsize==1) and a small custom
buffer size (bufsize==2).
Restructure testUnbufferedRead() somewhat to avoid a potentially
infinite loop.
Fix a subtle bug in the trashcan code I added yesterday to
subtype_dealloc().
When call_finalizer() failed, it would return without going through
the trashcan end macro, thereby unbalancing the trashcan nesting level
counter, and thereby defeating the test case (slottrash() in
test_descr.py). This in turn meant that the assert in the GC_UNTRACK
macro wasn't triggered by the slottrash() test despite a bug in the
code: _PyTrash_destroy_chain() calls the dealloc routine with an
object that's untracked, and the assert in the GC_UNTRACK macro would
fail on this; but because of an earlier test that resurrects an
object, causing call_finalizer() to fail and the trashcan nesting
level to be unbalanced, so _PyTrash_destroy_chain() was never called.
Calling the slottrash() test in isolation *did* trigger the assert,
however.
So the fix is twofold: (1) call the GC_UnTrack() function instead of
the GC_UNTRACK macro, because the function is safe when the object is
already untracked; (2) when call_finalizer() fails, jump to a label
that exits through the trashcan end macro, keeping the trashcan
nesting balanced.
Add -E and -tt options to the python invocations, as for the Unix tests.
The -tt means modules that mix tabs and spaces will be rejected.
The -E refuses to believe Python options in the environment.
Described responsibilty of weakly referenced extension types to initialize
the weakreflist to NULL in the constructor and to fill the tp_flags
slot with Py_TPFLAGS_HAVE_WEAKREFS. Closes SF bug 586583.
"Unbuffered" mode of class _fileobject wasn't actually unbuffered,
and this broke a Zope "pipelining" test which read multiple responses
from the same connection (this attaches a new file object to the
socket for each response). Added a test for this too.
(I want to do some code cleanup too, but I thought I'd first fix
the problem with as little code as possible, and add a unit test
for this case. So that's what this checkin is about.)
Jack Jansen [Wed, 7 Aug 2002 15:44:53 +0000 (15:44 +0000)]
- If an OSA identifier is a Python reserved word we now append an _
in stead of prepending it, which messes up "import * from".
- A few ascii()s added again.
- Changed the getbaseclasses a little, but it still isn't perfect.
Tim Peters [Tue, 6 Aug 2002 22:25:02 +0000 (22:25 +0000)]
internal_connect(): Windows. When sock_timeout > 0 and connect() yields
WSAEWOULDBLOCK, the second connect() attempt appears to yield WSAEISCONN
on Win98 but WSAEINVAL on Win2K. So accept either as meaning "yawn,
fine". This allows test_socket to succeed on my Win2K box (which it
already did on my Win98SE box).