Commit Graph

26858 Commits

Author SHA1 Message Date
Anthony Baxter fda5e27ec9 extra punctuation removed 2003-04-09 03:03:46 +00:00
Fred Drake 567b0a6445 Add dependency information for the timeit module docs. 2003-04-09 02:41:36 +00:00
Skip Montanaro d6e9fe386a + libtimeit 2003-04-09 01:39:06 +00:00
Skip Montanaro ca652746ff doc for timeit module/script - mostly just a recast of Tim's docstring 2003-04-09 01:38:53 +00:00
Jeremy Hylton 400d8ee6fa Make staticmethods and classmethods participate in GC.
If a class was defined inside a function, used a static or class
method, and used super() inside the method body, it would be caught in
an uncollectable cycle.  (Simplified version: The static/class method
object would point to a function object with a closure that referred
to the class.)

Bugfix candidate.
2003-04-08 21:28:47 +00:00
Just van Rossum 547eb42d75 tentative fix for #712322: modification time stamp checking failed
when DST began.
2003-04-08 20:07:15 +00:00
Skip Montanaro f2f174f655 install timeit.py as a command line script 2003-04-08 19:50:02 +00:00
Skip Montanaro cfd55501bb add a #! line for unix weenies 2003-04-08 19:49:40 +00:00
Tim Peters 8805e66ec8 New tests identical to boom and boom2, except using new-style classes.
These never failed in 2.3, and the tests confirm it.  They still blow up
in the 2.2 branch, despite that all the gc-vs-__del__ fixes from 2.3
have been backported (and this is expected -- 2.2 needs more work than
2.3 needed).
2003-04-08 19:44:13 +00:00
Skip Montanaro fb2a6ccfc4 correct a couple docstring nits 2003-04-08 19:40:19 +00:00
Tim Peters f995cce4df Typo repair. 2003-04-08 18:47:21 +00:00
Fred Drake 2c2068c4d1 Added example of using positional and keyword args with atexit.register().
Based on a suggestion from a reader.
2003-04-08 17:46:53 +00:00
Fred Drake de7ad2caac Markup fix. 2003-04-08 17:37:47 +00:00
Tim Peters 730f5535ba s/referrents/referents/g. Gotta love that referrers remains rife with rs. 2003-04-08 17:17:17 +00:00
Tim Peters 0f81ab6d88 Finished implementing gc.get_referrents(): dealt with error and end
cases, wrote docs, added a test.
2003-04-08 16:39:48 +00:00
Tim Peters fb2ab4d5ae Comment repair; no semantic changes. 2003-04-07 22:41:24 +00:00
Tim Peters f6b8045ca5 Reworked has_finalizer() to use the new _PyObject_Lookup() instead
of PyObject_HasAttr(); the former promises never to execute
arbitrary Python code.  Undid many of the changes recently made to
worm around the worst consequences of that PyObject_HasAttr() could
execute arbitrary Python code.

Compatibility is hard to discuss, because the dangerous cases are
so perverse, and much of this appears to rely on implementation
accidents.

To start with, using hasattr() to check for __del__ wasn't only
dangerous, in some cases it was wrong:  if an instance of an old-
style class didn't have "__del__" in its instance dict or in any
base class dict, but a getattr hook said __del__ existed, then
hasattr() said "yes, this object has a __del__".  But
instance_dealloc() ignores the possibility of getattr hooks when
looking for a __del__, so while object.__del__ succeeds, no
__del__ method is called when the object is deleted.  gc was
therefore incorrect in believing that the object had a finalizer.

The new method doesn't suffer that problem (like instance_dealloc(),
_PyObject_Lookup() doesn't believe __del__ exists in that case), but
does suffer a somewhat opposite-- and even more obscure --oddity:
if an instance of an old-style class doesn't have "__del__" in its
instance dict, and a base class does have "__del__" in its dict,
and the first base class with a "__del__" associates it with a
descriptor (an object with a __get__ method), *and* if that
descriptor raises an exception when __get__ is called, then
(a) the current method believes the instance does have a __del__,
but (b) hasattr() does not believe the instance has a __del__.

While these disagree, I believe the new method is "more correct":
because the descriptor *will* be called when the object is
destructed, it can execute arbitrary Python code at the time the
object is destructed, and that's really what gc means by "has a
finalizer":  not specifically a __del__ method, but more generally
the possibility of executing arbitrary Python code at object
destruction time.  Code in a descriptor's __get__() executed at
destruction time can be just as problematic as code in a
__del__() executed then.

So I believe the new method is better on all counts.

Bugfix candidate, but it's unclear to me how all this differs in
the 2.2 branch (e.g., new-style and old-style classes already
took different gc paths in 2.3 before this last round of patches,
but don't in the 2.2 branch).
2003-04-07 19:21:15 +00:00
Tim Peters df875b99fc New private API function _PyInstance_Lookup. gc will use this to figure
out whether __del__ exists, without executing any Python-level code.
2003-04-07 17:51:59 +00:00
Anthony Baxter cb8ed53014 add note suggested by rhettinger about example. 2003-04-07 12:21:56 +00:00
Anthony Baxter b3303efec6 patch [ 698505 ] docs for hotshot module 2003-04-07 12:19:15 +00:00
Tim Peters 1155887a74 initgc(): Rewrote to use the PyModule_AddXYZ API; cuts code size. 2003-04-06 23:30:52 +00:00
Tim Peters 259272b7a0 handle_finalizers(): Rewrote to call append_objects() and gc_list_merge()
instead of looping.  Smaller and clearer.  Faster, too, when we're not
appending to gc.garbage:  gc_list_merge() takes constant time, regardless
of the lists' sizes.

append_objects():  Moved up to live with the other list manipulation
utilities.
2003-04-06 19:41:39 +00:00
Raymond Hettinger f394df47fd SF bug #699934: Obscure error message
mwh pointed out that the error message did not
make sense if obtained by rearranging the bases.
2003-04-06 19:13:41 +00:00
Raymond Hettinger ff41c48a77 SF patch #701494: more apply removals 2003-04-06 09:01:11 +00:00
Tim Peters 50c61d5a6c Switched from METH_VARARGS to METH_NOARGS for the 7 module functions that
take no arguments; cuts generated code size.
2003-04-06 01:50:50 +00:00
Tim Peters bf384c256e Reworked move_finalizer_reachable() to create two distinct lists:
externally unreachable objects with finalizers, and externally unreachable
objects without finalizers reachable from such objects.  This allows us
to call has_finalizer() at most once per object, and so limit the pain of
nasty getattr hooks.  This fixes the failing "boom 2" example Jeremy
posted (a non-printing variant of which is now part of test_gc), via never
triggering the nasty part of its __getattr__ method.
2003-04-06 00:11:39 +00:00
Tim Peters f6ae7a43eb move_finalizers(): Rewrote. It's not necessary for this routine
to special-case classic classes, or to worry about refcounts;
has_finalizer() deleted the current object iff the first entry in
the unreachable list has changed.  I don't believe it was correct
to check for ob_refcnt == 1, either:  the dealloc routine would get
called by Py_DECREF then, but there's nothing to stop the dealloc
routine from ressurecting the object, and then gc would remain at
the head of the unreachable list despite that its refcount temporarily
fell to 0 (and that would lead to an infinite loop in move_finalizers()).

I'm still worried about has_finalizer() resurrecting other objects
in the unreachable list:  what's to stop them from getting collected?
2003-04-05 18:40:50 +00:00
Tim Peters 2f74fddfc1 test_boom: More comments. Also check that len(gc.garbage) doesn't
change (it would be another kind of bug if the trash cycle weren't
reclaimed).
2003-04-05 17:46:04 +00:00
Tim Peters 86b993b6cf New comments. Rewrote has_finalizer() as a sequence of ifs instead of
squashed-together conditional operators; makes it much easier to step
thru in the debugger, and to set a breakpoint on the only dangerous
path.
2003-04-05 17:35:54 +00:00
Tim Peters 93ad66dea9 Fixed new seemingly random segfaults, by moving the initialization of
delstr from initgc() into collect().  initgc() isn't called unless the
user explicitly imports gc, so can be used only for initialization of
user-visible module features; delstr needs to be initialized for proper
internal operation, whether or not gc is explicitly imported.

Bugfix candidate?  I don't know whether the new bug was backported to
2.2 already.
2003-04-05 17:15:44 +00:00
Raymond Hettinger c377cbfdaf SF bug #715145: unittest.py still uses != in failUnlessEqual 2003-04-04 22:56:42 +00:00
Jeremy Hylton dee38ac7dd Add Tim's gc boom test to the test suite. 2003-04-04 20:00:04 +00:00
Jeremy Hylton ce136e985a Fix Tim's boom example.
move_finalizers() moves every object from unreachable to collectable
or finalizers, unless the object is deallocated first.
2003-04-04 19:59:06 +00:00
Greg Ward 76ffb1918d Use fcntl() to put the audio device *back* into blocking mode after
opening it in non-blocking mode.  Both Guido and David Hammerton have
reported that this fixes their problems with ossaudiodev -- hooray!
2003-04-04 01:47:42 +00:00
Jeremy Hylton 059b094e29 Add get_referrents() helper function. 2003-04-03 16:29:13 +00:00
Jeremy Hylton 5bd378bfca Add get_referrents() helper function. 2003-04-03 16:28:38 +00:00
Martin v. Löwis 7fb697b5d2 Revert Patch #670715: iconv support. 2003-04-03 04:49:12 +00:00
Walter Dörwald 1e469c5603 Fix description: u"%c" % 0xffffffff returned a ValueError not a TypeError. 2003-04-02 16:57:59 +00:00
Walter Dörwald 44f527fea4 Change formatchar(), so that u"%c" % 0xffffffff now raises
an OverflowError instead of a TypeError to be consistent
with "%c" % 256. See SF patch #710127.
2003-04-02 16:37:24 +00:00
Barry Warsaw 7ba256f039 Fix a comment 2003-04-02 04:51:33 +00:00
Jack Jansen a02b7a8f6d Added a note about scripting support and the IDE builtin help. 2003-04-01 22:33:37 +00:00
Jack Jansen b60352992f The minimal scripting example now actually works. 2003-04-01 22:30:23 +00:00
Jack Jansen 9dd78101d7 Sigh... The get() and set() commands are not declared in the aete for
the Standard_Suite, but various other suites do expect it (the Finder
implements get() without declaring it itself). It is probably another
case of OSA magic. Adding them to the global base class.
2003-04-01 22:27:18 +00:00
Jack Jansen 842273bcd7 Regenerated with property names with _Prop_ prepended. 2003-04-01 22:05:14 +00:00
Jack Jansen bc956056d4 Properties (like enums) are not in the global namespace but only valid
within a certain context. Give them an _Prop_ prefix, so they don't
accidentally obscure an element from another suite (as happened with
the Finder). Comparisons I'm not sure about, so I left them as global
names.

Also got rid of the lists if declarations, they serve no useful purpose.
2003-04-01 22:01:58 +00:00
Jack Jansen 3279cb0315 Turned the suite compiler into an object. 2003-04-01 14:25:49 +00:00
Jack Jansen 18c9b13959 - All messages are now dependent on the --verbose option.
- Added a --dump option that doesn't generate the module but dumps
  the pretty-printed aete resource(s) on stdout.
2003-04-01 13:32:17 +00:00
Barry Warsaw 1baa982c31 init_bsddb(): Added a few symbols that Greg forgot. 2003-03-31 19:51:29 +00:00
Walter Dörwald 56fbcb525b Remove duplicate test. 2003-03-31 18:18:41 +00:00
Walter Dörwald 43440a621e Fix PyString_Format() so that '%c' % u'a' returns u'a'
instead of raising a TypeError. (From SF patch #710127)

Add tests to verify this is fixed.

Add various tests for '%c' % int.
2003-03-31 18:07:50 +00:00