Commit Graph

20018 Commits

Author SHA1 Message Date
Guido van Rossum 1c45073aba Keep track of a type's subclasses (subtypes), in tp_subclasses, which
is a list of weak references to types (new-style classes).  Make this
accessible to Python as the function __subclasses__ which returns a
list of types -- we don't want Python programmers to be able to
manipulate the raw list.

In order to make this possible, I also had to add weak reference
support to type objects.

This will eventually be used together with a trap on attribute
assignment for dynamic classes for a major speed-up without losing the
dynamic properties of types: when a __foo__ method is added to a
class, the class and all its subclasses will get an appropriate tp_foo
slot function.
2001-10-08 15:18:27 +00:00
Jack Jansen 4c398fde5c Mac OS X build instructions talked about --without-toolbox-glue, but
the configure option is really called --disable-toolbox-glue.
2001-10-08 13:21:15 +00:00
Martin v. Löwis 2f20dab9c1 Do not add -shared to linker_so. Any necessary options should already be
in LDSHARED.
2001-10-08 13:18:37 +00:00
Martin v. Löwis 8158b5ad09 Provide explicit program when trying to link pthread_create.
Contributed by Albert Chin in discussion of bug #210665.
2001-10-08 13:17:28 +00:00
Jack Jansen b58f1c0c03 Added declarations for PyMac_SetConsoleHandler, PyMan_DUmmyReadHandler
and PyMac_DummyWriteHandler.
2001-10-08 13:16:39 +00:00
Jack Jansen 144d387c85 Added weakrefobject.c and regenerated .exp files. 2001-10-08 13:01:05 +00:00
Tim Peters 281084f798 Put the deprecated .ignore() method back where it was. 2001-10-08 06:28:18 +00:00
Tim Peters 7d01685738 Widespread random code cleanup.
Most of this code was old enough to vote.  Examples of cleanups:

+ Backslashes were used for line continuation even inside unclosed
  bracket structures, from back in the days that was still needed.

+ There was no use of % formats, and e.g. the old fpformat module was
  still used to format floats "by hand" in conjunction with rjust().

+ There was even use of a do-nothing .ignore() method to tack on to the
  end of a chain of method calls, else way back when Python would print
  the non-None result (as it does now in an interactive session -- it
  *used* to do that in batch mode too).

+ Perhaps controversial (although I can't imagine why for real <wink>),
  used augmented assignment where helpful.  Stuff like

      self.total_calls = self.total_calls + other.total_calls

  is just plain harder to follow than

      self.total_calls += other.total_calls
2001-10-08 06:13:19 +00:00
Guido van Rossum 03290ecbf1 Implement isinstance(x, (A, B, ...)). Note that we only allow tuples,
not other sequences (then we'd have to except strings, and we'd still
be susceptible to recursive attacks).
2001-10-07 20:54:12 +00:00
Steven M. Gava 1f733baa04 merged port binding error message patch 2001-10-07 11:44:49 +00:00
Steven M. Gava 4eb286874f merged win spawn patch 2001-10-07 11:26:48 +00:00
Steven M. Gava 898a365c27 merged status bar packing patch 2001-10-07 11:10:44 +00:00
Martin v. Löwis 322c0d187d Only close sockets if they have been created. Reported by Blake Winton. 2001-10-07 08:53:32 +00:00
Tim Peters fb163784ab Typo repair in comment. 2001-10-07 08:49:02 +00:00
Martin v. Löwis 25ae43b184 Support OpenUNIX like UnixWare. 2001-10-07 08:39:18 +00:00
Tim Peters 8d061ed75b Guido points out that the comments for self.cur[2] were subtly but
seriously wrong.  This started out by just fixing the docs, but then it
occurred to me that the doc confusion propagated into misleading vrbl names
too, so I also renamed those to match reality.  As a result, INO the time
computations are much easier to understand now (within the limitations of
vast quantities of 3-character names <wink>).
2001-10-07 08:35:44 +00:00
Martin v. Löwis 260aecc83d Use AC_TRY_RUN for checking for -Kpthread. 2001-10-07 08:14:41 +00:00
Tim Peters db1ed2aec3 At Guido's request, changed the code that's conceptually asserting stuff
to use assert stmts (was raising unexpected kinds of exceptions).
2001-10-07 04:30:53 +00:00
Tim Peters 6e22149cb6 Repair some longstanding comment errors:
+ The last index in the timing tuple is 4, not 5 (noted by Guido).

+ The poorly named trace_dispatch_i works with float return values too.
2001-10-07 04:02:36 +00:00
Tim Peters f2a67daca2 Guido suggests, and I agree, to insist that SIZEOF_VOID_P be a power of 2.
This simplifies the rounding in _PyObject_VAR_SIZE, allows to restore the
pre-rounding calling sequence, and allows some nice little simplifications
in its callers.  I'm still making it return a size_t, though.
2001-10-07 03:54:51 +00:00
Tim Peters 0a1fc4e389 Remove code and docs for the OldProfile and HotProfile classes: code
hasn't worked in years, docs were wrong, and they aren't interesting
anymore regardless.
2001-10-07 03:12:08 +00:00
Tim Peters 6d483d3477 _PyObject_VAR_SIZE: always round up to a multiple-of-pointer-size value.
As Guido suggested, this makes the new subclassing code substantially
simpler.  But the mechanics of doing it w/ C macro semantics are a mess,
and _PyObject_VAR_SIZE has a new calling sequence now.

Question:  The PyObject_NEW_VAR macro appears to be part of the public API.
Regardless of what it expands to, the notion that it has to round up the
memory it allocates is new, and extensions containing the old
PyObject_NEW_VAR macro expansion (which was embedded in the
PyObject_NEW_VAR expansion) won't do this rounding.  But the rounding
isn't actually *needed* except for new-style instances with dict pointers
after a variable-length blob of embedded data.  So my guess is that we do
not need to bump the API version for this (as the rounding isn't needed
for anything an extension can do unless it's recompiled anyway).  What's
your guess?
2001-10-06 21:27:34 +00:00
Tim Peters 406fe3b1c0 Repaired the debug Windows deaths in test_descr, by allocating enough
pad memory to properly align the __dict__ pointer in all cases.

gcmodule.c/objimpl.h, _PyObject_GC_Malloc:
+ Added a "padding" argument so that this flavor of malloc can allocate
  enough bytes for alignment padding (it can't know this is needed, but
  its callers do).

typeobject.c, PyType_GenericAlloc:
+ Allocated enough bytes to align the __dict__ pointer.
+ Sped and simplified the round-up-to-PTRSIZE logic.
+ Added blank lines so I could parse the if/else blocks <0.7 wink>.
2001-10-06 19:04:01 +00:00
Tim Peters 7254e5a3ed _PyObject_GetDictPtr():
+ Use the _PyObject_VAR_SIZE macro to compute object size.
+ Break the computation into lines convenient for debugger inspection.
+ Speed the round-up-to-pointer-size computation.
2001-10-06 17:45:17 +00:00
Tim Peters 8c18f25850 _PyObject_GC_Malloc(): split a complicated line in two. As is, there was
no way to talk the debugger into showing me how many bytes were being
allocated.
2001-10-06 08:03:20 +00:00
Fred Drake 8c2c3d301b Update the documentation to reflect the changes to ReferenceError. 2001-10-06 06:10:54 +00:00
Tim Peters df5cfd884d The fix to profile semantics broke the miserable but advertised way to
derive Profile subclasses.  This patch repairs that, restoring
negative tuple indices.  Yuck?  You bet.
2001-10-05 23:15:10 +00:00
Tim Peters 23d192e652 Teach Windows how to build the new weakref module. 2001-10-05 22:14:45 +00:00
Fred Drake 335244c710 Remove bogus declaration. 2001-10-05 22:06:45 +00:00
Fred Drake bf88b68f38 Add documentation for the public API for weak reference objects. 2001-10-05 22:03:58 +00:00
Fred Drake f7f8cad548 Adjust the _weakref module to use the public API for the weak reference
objects.  This is now simply a shim to give weakref.py access to the
underlying implementation.
2001-10-05 22:00:24 +00:00
Fred Drake b3f0d349b6 PyObject_ClearWeakRefs() is now a real function instead of a function pointer;
the implementation is in Objects/weakrefobject.c.
2001-10-05 21:58:11 +00:00
Fred Drake 502ed82125 Add dependencies for the weakref object. 2001-10-05 21:56:02 +00:00
Fred Drake 19bc578a09 Include the weakref object interface. 2001-10-05 21:55:19 +00:00
Fred Drake e029242d5c ReferenceError is now built-in, so pick it up from the right place.
It still needs to be here to preserve the API.
2001-10-05 21:54:09 +00:00
Fred Drake 8844d5264f The weak reference implementation, separated from the weakref module. 2001-10-05 21:52:26 +00:00
Fred Drake bb9fa21cfe weakref.ReferenceError becomes a built-in exception now that weak ref objects
are moving into the core; with these changes, it will be possible for the
exception to be raised without the weakref module ever being imported.
2001-10-05 21:50:08 +00:00
Guido van Rossum 39c785108f Martijn Pieters convinced me that when readline() strips the trailing
newline from a multifile part, it should also strip a trailing \r\n.
2001-10-05 21:22:21 +00:00
Guido van Rossum 9475a2310d Enable GC for new-style instances. This touches lots of files, since
many types were subclassable but had a xxx_dealloc function that
called PyObject_DEL(self) directly instead of deferring to
self->ob_type->tp_free(self).  It is permissible to set tp_free in the
type object directly to _PyObject_Del, for non-GC types, or to
_PyObject_GC_Del, for GC types.  Still, PyObject_DEL was a tad faster,
so I'm fearing that our pystone rating is going down again.  I'm not
sure if doing something like

void xxx_dealloc(PyObject *self)
{
	if (PyXxxCheckExact(self))
		PyObject_DEL(self);
	else
		self->ob_type->tp_free(self);
}

is any faster than always calling the else branch, so I haven't
attempted that -- however those types whose own dealloc is fancier
(int, float, unicode) do use this pattern.
2001-10-05 20:51:39 +00:00
Thomas Heller be63884d50 With Andrew's blessing: distutils version number is now 1.0.3. 2001-10-05 20:43:09 +00:00
Tim Peters b1c469843f Introduced the oddly-missing PyList_CheckExact(), and used it to replace
a hard-coded type check.
2001-10-05 20:41:38 +00:00
Thomas Heller e138f369e6 Explicitely list the metadata attributes to show
in the gui.
Updated to include the new exe-file.
2001-10-05 20:40:48 +00:00
Tim Peters c1e6d969ba Get rid of unique local ISSTRICTINT macro in favor of std PyInt_CheckExact. 2001-10-05 20:21:03 +00:00
Tim Peters 9835206268 A regexp example was rendered as
foo\d
when it was clearly intended to render as
    foo$
Fred, is this a right way to fix it?  If not, the earlier place in the
same paragraph that does render as
    foo$
is also wrong.
2001-10-05 20:06:47 +00:00
Barry Warsaw 4a8e9f4e42 SMTPServer.__init__(): Print the start information on the DEBUGSTREAM
so that it can be suppressed.
2001-10-05 17:10:31 +00:00
Guido van Rossum ef67ded6c7 Remove false statement about running make in the Modules directory. 2001-10-05 17:04:42 +00:00
Fred Drake e8f47bb93a Remove some long-unsupported Mac OS modules.
This closes SF patch #460737.
2001-10-05 16:49:31 +00:00
Fred Drake 645a7e08b3 Frankly, I'd like my "L." as well! 2001-10-05 14:12:23 +00:00
Guido van Rossum 261f57cc30 Another contributor.
Give Fred his Jr.
2001-10-05 14:06:27 +00:00
Andrew M. Kuchling 38300c631a Fix typo in docstring 2001-10-05 12:24:15 +00:00