Jeremy Hylton [Tue, 16 Jul 2002 19:39:38 +0000 (19:39 +0000)]
The object returned by tp_new() may not have a tp_init.
If the object is an ExtensionClass, for example, the slot is not even
defined. So we must check that the type has the slot (implied by
HAVE_CLASS) before calling tp_init().
Tim Peters [Tue, 16 Jul 2002 19:30:59 +0000 (19:30 +0000)]
The atexit module effectively turned itself off if sys.exitfunc already
existed at the time atexit first got imported. That's a bug, and this
fixes it.
Also reworked test_atexit.py to test for this too, and to stop using
an "expected output" file, and to test what actually happens at exit
instead of just simulating what it thinks atexit will do at exit.
Bugfix candidate, but it's messy so I'll backport to 2.2 myself.
Barry Warsaw [Tue, 16 Jul 2002 16:04:13 +0000 (16:04 +0000)]
(py-imenu-create-index-function): Skip over stuff that looks like code
but which is in a comment or string. Closes SF bug # 572341 reported
by Adrian van den Dries.
Barry Warsaw [Mon, 15 Jul 2002 19:53:28 +0000 (19:53 +0000)]
Added the "weird" ccTLDs ac, gg, im, and je. These are not recognized
by ISO 3166 as country codes, but the are reserved by IANA
nonetheless. The commonly used uk ccTLD is part of this group, near
as I can tell.
Tim Peters [Mon, 15 Jul 2002 17:58:03 +0000 (17:58 +0000)]
XXXROUNDUP(): Turns out this fixed Andrew MacIntyre's memory-mgmt
disaster too, so this change is here to stay. Beefed up the comments
and added some stats Andrew reported. Also a small change to the
macro body, to make it obvious how XXXROUNDUP(0) ends up returning 0.
See SF patch 578297 for context.
Not a bugfix candidate, as the functional changes here have already
been backported to the 2.2 line (this patch just improves clarity).
Andrew MacIntyre [Mon, 15 Jul 2002 12:03:19 +0000 (12:03 +0000)]
Tim_one's change to aggressively overallocate nodes when adding child
nodes (in Parser/node.c) resolves the gross memory consumption
exhibited by the EMX runtime on OS/2, so the test should be exercised
on this platform.
Tim Peters [Mon, 15 Jul 2002 05:16:13 +0000 (05:16 +0000)]
docompare(): Another reasonable optimization from Jonathan Hogg for the
explicit comparison function case: use PyObject_Call instead of
PyEval_CallObject. Same thing in context, but gives a 2.4% overall
speedup when sorting a list of ints via list.sort(__builtin__.cmp).
Don't pass CREATE_NEW_CONSOLE to CreateProcess(), meaning our child process is in the same "console group" and therefore interrupted by the same Ctrl+C that interrupts the parent.
Mark Hammond [Sun, 14 Jul 2002 23:12:29 +0000 (23:12 +0000)]
Fix bug 439992 - [win32] KeyboardInterrupt Not Caught.
This gets us closer to consistent Ctrl+C behaviour on NT and Win9x. NT now reliably generates KeyboardInterrupt exceptions for NT when a file IO operation was aborted. Bugfix candidate
Tim Peters [Sun, 14 Jul 2002 22:14:19 +0000 (22:14 +0000)]
WINDOWS_LEAN_AND_MEAN: There is no such symbol, although a very few
MSDN sample programs use it, apparently in error. The correct name
is WIN32_LEAN_AND_MEAN. After switching to the correct name, in two
cases more was needed because the code actually relied on things that
disappear when WIN32_LEAN_AND_MEAN is defined.
Jeremy Hylton [Fri, 12 Jul 2002 15:54:37 +0000 (15:54 +0000)]
Remove httplib from tested modules.
The test of httplib makes it difficult to maintain httplib. There are
two many idioms that pyclbr doesn't seem to understand, and I don't
understand how to update these tests to make them work.
Tim Peters [Fri, 12 Jul 2002 05:01:20 +0000 (05:01 +0000)]
HAVE_LIMITS_H -- raise #error if not defined; limits.h is std C
ULONG_MAX -- removed; std C requires it in limits.h
LONGLONG_MAX -- removed; never used
ULONGLONGMAX -- removed; never used
Jeremy Hylton [Thu, 11 Jul 2002 22:01:40 +0000 (22:01 +0000)]
Do more robust test of whether global objects are accessible.
PyImport_ImportModule() is not guaranteed to return a module object.
When another type of object was returned, the PyModule_GetDict() call
return NULL and the subsequent GetItem() seg faulted.
Tim Peters [Thu, 11 Jul 2002 21:46:16 +0000 (21:46 +0000)]
docompare(): Use PyTuple_New instead of Py_BuildValue to build compare's
arg tuple. This was suggested on c.l.py but afraid I can't find the msg
again for proper attribution. For
list.sort(cmp)
where list is a list of random ints, and cmp is __builtin__.cmp, this
yields an overall 50-60% speedup on my Win2K box. Of course this is a
best case, because the overhead of calling cmp relative to the cost of
actually comparing two ints is at an extreme. Nevertheless it's huge
bang for the buck. An additionak 20-30% can be bought by making the arg
tuple an immortal static (avoiding all but "the first" PyTuple_New), but
that's tricky to make correct since docompare needs to be reentrant. So
this picks the cherry and leaves the pits for Fred <wink>.
Note that this makes no difference to the
list.sort()
case; an arg tuple gets built only if the user specifies an explicit
sort function.
Tim Peters [Thu, 11 Jul 2002 19:07:45 +0000 (19:07 +0000)]
test_trashcan() and supporting class Ouch(): Jeremy noted that this test
takes much longer to run in the context of the test suite than when run in
isolation. That's because it forces a large number of full collections,
which take time proportional to the total number of gc'ed objects in the
whole system.
But since the dangerous implementation trickery that caused this test to
fail in 2.0, 2.1 and 2.2 doesn't exist in 2.3 anymore (the trashcan
mechanism stopped doing evil things when the possibility for compiling
without cyclic gc was taken away), such an expensive test is no longer
justified. This checkin leaves the test intact, but fiddles the
constants to reduce the runtime by about a factor of 5.
Tim Peters [Thu, 11 Jul 2002 06:56:07 +0000 (06:56 +0000)]
Added a test that provokes the hypothesized (in my last checkin comment)
debug-build failure when an instance of a new-style class is resurrected
by a __del__ method -- we simply never had any code that tried this.
This is already fixed in 2.3 CVS. In 2.2.1, it blows up via
Fatal Python error: GC object already in linked list
Tim Peters [Thu, 11 Jul 2002 06:23:50 +0000 (06:23 +0000)]
object.h special-build macro minefield: renamed all the new lexical
helper macros to something saner, and used them appropriately in other
files too, to reduce #ifdef blocks.
classobject.c, instance_dealloc(): One of my worst Python Memories is
trying to fix this routine a few years ago when COUNT_ALLOCS was defined
but Py_TRACE_REFS wasn't. The special-build code here is way too
complicated. Now it's much simpler. Difference: in a Py_TRACE_REFS
build, the instance is no longer in the doubly-linked list of live
objects while its __del__ method is executing, and that may be visible
via sys.getobjects() called from a __del__ method. Tough -- the object
is presumed dead while its __del__ is executing anyway, and not calling
_Py_NewReference() at the start allows enormous code simplification.
typeobject.c, call_finalizer(): The special-build instance_dealloc()
pain apparently spread to here too via cut-'n-paste, and this is much
simpler now too. In addition, I didn't understand why this routine
was calling _PyObject_GC_TRACK() after a resurrection, since there's no
plausible way _PyObject_GC_UNTRACK() could have been called on the
object by this point. I suspect it was left over from pasting the
instance_delloc() code. Instead asserted that the object is still
tracked. Caution: I suspect we don't have a test that actually
exercises the subtype_dealloc() __del__-resurrected-me code.
Tim Peters [Wed, 10 Jul 2002 19:29:49 +0000 (19:29 +0000)]
Documented PYMALLOC_DEBUG. This completes primary coverage of all the
"special builds" I ever use. If you use others, document them here, or
don't be surprised if I rip out the code for them <0.5 wink>.
Tim Peters [Wed, 10 Jul 2002 06:34:15 +0000 (06:34 +0000)]
Uglified the new Py_REF_DEBUG (etc) lexical helper macro definitions so
that their uses can be prettier. I've come to despise the names I picked
for these things, though, and expect to change all of them -- I changed
a bunch of other files to use them (replacing #ifdef blocks), but the
names were so obscure out of context that I backed that all out again.
Jeremy Hylton [Tue, 9 Jul 2002 21:22:36 +0000 (21:22 +0000)]
Fix for SF bug 579107.
The recent SSL changes resulted in important, but subtle changes to
close() semantics. Since builtin socket makefile() is not called for
SSL connections, we don't get separately closeable fds for connection
and response. Comments in the code explain how to restore makefile
semantics.
Tim Peters [Tue, 9 Jul 2002 18:35:34 +0000 (18:35 +0000)]
New file to try to document the "special build" preprocessor symbols.
Incomplete. Add to it! Once it settles down, it would make a nice
appendix in the real docs.
Tim Peters [Tue, 9 Jul 2002 02:57:01 +0000 (02:57 +0000)]
The Py_REF_DEBUG/COUNT_ALLOCS/Py_TRACE_REFS macro minefield: added
more trivial lexical helper macros so that uses of these guys expand
to nothing at all when they're not enabled. This should help sub-
standard compilers that can't do a good job of optimizing away the
previous "(void)0" expressions.
Py_DECREF: There's only one definition of this now. Yay! That
was that last one in the family defined multiple times in an #ifdef
maze.
Py_FatalError(): Changed the char* signature to const char*.
_Py_NegativeRefcount(): New helper function for the Py_REF_DEBUG
expansion of Py_DECREF. Calling an external function cuts down on
the volume of generated code. The previous inline expansion of abort()
didn't work as intended on Windows (the program often kept going, and
the error msg scrolled off the screen unseen). _Py_NegativeRefcount
calls Py_FatalError instead, which captures our best knowledge of
how to abort effectively across platforms.
Barry Warsaw [Tue, 9 Jul 2002 02:50:02 +0000 (02:50 +0000)]
Anthony Baxter's patch for non-strict parsing. This adds a `strict'
argument to the constructor -- defaulting to true -- which is
different than Anthony's approach of using global state.
parse(), parsestr(): Grow a `headersonly' argument which stops parsing
once the header block has been seen, i.e. it does /not/ parse or even
read the body of the message. This is used for parsing message/rfc822
type messages.
We need test cases for the non-strict parsing. Anthony will supply
these.
_parsebody(): We can get rid of the isdigest end-of-line kludges,
although we still need to know if we're parsing a multipart/digest so
we can set the default type accordingly.
Barry Warsaw [Tue, 9 Jul 2002 02:46:12 +0000 (02:46 +0000)]
Add the concept of a "default type". Normally the default type is
text/plain but the RFCs state that inside a multipart/digest, the
default type is message/rfc822. To preserve idempotency, we need a
separate place to define the default type than the Content-Type:
header.
get_default_type(), set_default_type(): Accessor and mutator methods
for the default type.
Barry Warsaw [Tue, 9 Jul 2002 02:43:47 +0000 (02:43 +0000)]
clone(): A new method for creating a clone of this generator (for
recursive generation).
_dispatch(): If the message object doesn't have a Content-Type:
header, check its default type instead of assuming it's text/plain.
This makes for correct generation of message/rfc822 containers.
_handle_multipart(): We can get rid of the isdigest kludge. Just
print the message as normal and everything will work out correctly.
_handle_mulitpart_digest(): We don't need this anymore either.
Tim Peters [Mon, 8 Jul 2002 22:11:52 +0000 (22:11 +0000)]
SF bug 578752: COUNT_ALLOCS vs heap types
Repair segfaults and infinite loops in COUNT_ALLOCS builds in the
presence of new-style (heap-allocated) classes/types.
Bugfix candidate. I'll backport this to 2.2. It's irrelevant in 2.1.
Jack Jansen [Mon, 8 Jul 2002 21:39:36 +0000 (21:39 +0000)]
The readme file said that OSX Carbon modules were only built for
-enable-framework builds, but setup.py built them anyway. Fixed.
Also normalized whitespace.
Fred Drake [Mon, 8 Jul 2002 14:08:48 +0000 (14:08 +0000)]
Added font-setting line (and associated comments) to the A4 version of
this file; the lack of this was causing the A4 version of tutorial to
use really bad Type 3 fonts instead of Type 1 fonts, which also
bloated the file size substantially.
I thought there was a SourceForge bug for this, but couldn't find it.