]> granicus.if.org Git - python/log
python
22 years agoMove the call to _Py_PrintReferences() a bit further down. This
Guido van Rossum [Tue, 15 Apr 2003 14:10:09 +0000 (14:10 +0000)]
Move the call to _Py_PrintReferences() a bit further down.  This
prevents it from showing stuff (like codec state) that is cleared when
the interpreter state is cleared.

22 years agoSome errors from range() should be TypeError, not ValueError.
Guido van Rossum [Tue, 15 Apr 2003 12:43:26 +0000 (12:43 +0000)]
Some errors from range() should be TypeError, not ValueError.

22 years agoPort test_pwd.py to PyUnit. Check that getpwall() and
Walter Dörwald [Tue, 15 Apr 2003 11:10:33 +0000 (11:10 +0000)]
Port test_pwd.py to PyUnit. Check that getpwall() and
getpwnam()/getpwuid() return consistent data.

Change test_grp to check that getgrall() and
getgrnam()/getgrgid() return consistent data.
Add error checks similar to test_pwd.py.

Port test___all__.py to PyUnit.

From SF patch #662807.

22 years agoExtend SF patch #707257: Improve code generation
Raymond Hettinger [Tue, 15 Apr 2003 10:35:07 +0000 (10:35 +0000)]
Extend SF patch #707257: Improve code generation
to cover the case for:  "x,y,z=1,2,3".  Gives a 30% speed-up.

Also, added FOR_ITER to the list of opcodes that can jump.

22 years agoThe date class is now properly subclassable. (SF bug #720908)
Guido van Rossum [Mon, 14 Apr 2003 22:01:58 +0000 (22:01 +0000)]
The date class is now properly subclassable.  (SF bug #720908)

(This is only the tip of the iceberg; the time and datetime classes
need the same treatment.)

22 years agoClose off the "Verre Carlo hack" as discussed on python-dev.
Guido van Rossum [Mon, 14 Apr 2003 21:46:03 +0000 (21:46 +0000)]
Close off the "Verre Carlo hack" as discussed on python-dev.

22 years agosuper_getattro(): kill some dead code; explain a mystery.
Guido van Rossum [Mon, 14 Apr 2003 21:20:26 +0000 (21:20 +0000)]
super_getattro(): kill some dead code; explain a mystery.

22 years ago- list.insert(i, x) now interprets negative i as it would be
Guido van Rossum [Mon, 14 Apr 2003 20:58:14 +0000 (20:58 +0000)]
- list.insert(i, x) now interprets negative i as it would be
  interpreted by slicing, so negative values count from the end of the
  list.  This was the only place where such an interpretation was not
  placed on a list index.

22 years agoAdd a name
Andrew M. Kuchling [Mon, 14 Apr 2003 18:47:28 +0000 (18:47 +0000)]
Add a name

22 years agoPrompted by Tim's comment, when handle_range_longs() sees an
Guido van Rossum [Mon, 14 Apr 2003 18:25:04 +0000 (18:25 +0000)]
Prompted by Tim's comment, when handle_range_longs() sees an
unexpected type, report the actual type rather than 'float'.  (It's
hard to even reach this code with a float. :-)

22 years agoSF patch #720991 by Gary Herron:
Guido van Rossum [Mon, 14 Apr 2003 17:59:34 +0000 (17:59 +0000)]
SF patch #720991 by Gary Herron:
A small fix for bug #545855 and Greg Chapman's
addition of op code SRE_OP_MIN_REPEAT_ONE for
eliminating recursion on simple uses of pattern '*?' on a
long string.

22 years agoTypo fix
Andrew M. Kuchling [Mon, 14 Apr 2003 15:32:18 +0000 (15:32 +0000)]
Typo fix

22 years agoFix docstring typo
Andrew M. Kuchling [Mon, 14 Apr 2003 15:31:27 +0000 (15:31 +0000)]
Fix docstring typo

22 years agoPatch #709178: remove -static option from cygwinccompiler
Jason Tishler [Mon, 14 Apr 2003 12:51:26 +0000 (12:51 +0000)]
Patch #709178: remove -static option from cygwinccompiler

After some more reflection (and no negative feedback), I am reverting the
original patch and applying my version, cygwinccompiler.py-shared.diff,
instead.

My reasons are the following:

1. support for older toolchains is retained
2. support for new toolchains (i.e., ld -shared) is added

The goal of my approach is to avoid breaking older toolchains while adding
better support for newer ones.

22 years agoMake readers and writers participate in garbage collection.
Jeremy Hylton [Mon, 14 Apr 2003 02:20:55 +0000 (02:20 +0000)]
Make readers and writers participate in garbage collection.
Fix memory leak in dialect_init().

22 years agoGet test working if gzip support is not available
Neal Norwitz [Mon, 14 Apr 2003 01:18:32 +0000 (01:18 +0000)]
Get test working if gzip support is not available

22 years agohandle_range_longs(): refcount handling is very delicate here, and
Tim Peters [Sun, 13 Apr 2003 22:13:08 +0000 (22:13 +0000)]
handle_range_longs():  refcount handling is very delicate here, and
the code erroneously decrefed the istep argument in an error case.  This
caused a co_consts tuple to lose a float constant prematurely, which
eventually caused gc to try executing static data in floatobject.c (don't
ask <wink>).  So reworked this extensively to ensure refcount correctness.

22 years agoMention timeit module
Andrew M. Kuchling [Sun, 13 Apr 2003 21:44:28 +0000 (21:44 +0000)]
Mention timeit module
Fix error in description of logging package's 'propagate'
Mention default arg to dict.pop()
Link to more module docs
   (I wonder if I should adopt some convention such as linking the first
    mention of all new modules to the LibRef?)
Various text changes
Bump version number and Python version

22 years agoUse simpler import
Andrew M. Kuchling [Sun, 13 Apr 2003 21:13:02 +0000 (21:13 +0000)]
Use simpler import

22 years agoMust declare vrbls at the tops of blocks in C89 (wouldn't compile).
Tim Peters [Sun, 13 Apr 2003 03:25:15 +0000 (03:25 +0000)]
Must declare vrbls at the tops of blocks in C89 (wouldn't compile).

22 years agoOops, _propdeclarations and friends are needed: gensuitemodule uses them
Jack Jansen [Sat, 12 Apr 2003 22:27:11 +0000 (22:27 +0000)]
Oops, _propdeclarations and friends are needed: gensuitemodule uses them
to lookup properties declared in base classes. Looking at it I'm not sure
what the official scope if the property codes is, maybe it is only the
(OSA) class in which they are used. But giving them global scope hasn't been
a problem so far.

Regenerated the standard suites, which are now also space-indented.

22 years agouse PyModule_Add{Int,String}Constant() where appropriate
Skip Montanaro [Sat, 12 Apr 2003 19:23:46 +0000 (19:23 +0000)]
use PyModule_Add{Int,String}Constant() where appropriate
(thanks to Neal Norwitz for the code review, BTW)

22 years agotighten up string checks
Skip Montanaro [Sat, 12 Apr 2003 19:17:14 +0000 (19:17 +0000)]
tighten up string checks
make csv_{get,unregister}_dialect METH_O functions to avoid PyArg_ParseTuple

22 years agoadd writerows docstring
Skip Montanaro [Sat, 12 Apr 2003 18:57:52 +0000 (18:57 +0000)]
add writerows docstring
conditionally exclude Unicode functions

22 years agotypo
Skip Montanaro [Fri, 11 Apr 2003 23:10:13 +0000 (23:10 +0000)]
typo

22 years agotypo
Skip Montanaro [Fri, 11 Apr 2003 21:40:01 +0000 (21:40 +0000)]
typo

22 years agoBack out of setting the default charset to iso-8859-1.
Barry Warsaw [Fri, 11 Apr 2003 21:28:10 +0000 (21:28 +0000)]
Back out of setting the default charset to iso-8859-1.

22 years agoNullTranslations.__init__(): Back out of setting the default charset
Barry Warsaw [Fri, 11 Apr 2003 20:26:47 +0000 (20:26 +0000)]
NullTranslations.__init__(): Back out of setting the default charset
to iso-8859-1.

GNUTranslations._parse(): Back out the addition of a test for
Project-ID-Version in the metadata.  This was deliberately removed in
response to SF patch #700839.

Also, re-organize the code in _parse() so we parse the metadata header
containing the charset parameter before we try to decode any strings
using charset.

22 years agozap commented out bit of code
Skip Montanaro [Fri, 11 Apr 2003 19:33:55 +0000 (19:33 +0000)]
zap commented out bit of code

22 years agoFix markup
Neal Norwitz [Fri, 11 Apr 2003 18:48:03 +0000 (18:48 +0000)]
Fix markup

22 years agoPatch by Chad Netzer (with significant change):
Guido van Rossum [Fri, 11 Apr 2003 18:43:06 +0000 (18:43 +0000)]
Patch by Chad Netzer (with significant change):
- range() now works even if the arguments are longs with magnitude
  larger than sys.maxint, as long as the total length of the sequence
  fits.  E.g., range(2**100, 2**101, 2**100) is the following list:
  [1267650600228229401496703205376L].  (SF patch #707427.)

22 years agoFrom http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw [Fri, 11 Apr 2003 18:36:43 +0000 (18:36 +0000)]
From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html

- Expose NullTranslations and GNUTranslations to __all__

- Set the default charset to iso-8859-1.  It used to be None, which
would cause problems with .ugettext() if the file had no charset
parameter.  Arguably, the po/mo file would be broken, but I still think
iso-8859-1 is a reasonable default.

- Add a "coerce" default argument to GNUTranslations's constructor.  The
reason for this is that in Zope, we want all msgids and msgstrs to be
Unicode.  For the latter, we could use .ugettext() but there isn't
currently a mechanism for Unicode-ifying msgids.

The plan then is that the charset parameter specifies the encoding for
both the msgids and msgstrs, and both are decoded to Unicode when read.
For example, we might encode po files with utf-8. I think the GNU
gettext tools don't care.

Since this could potentially break code [*] that wants to use the
encoded interface .gettext(), the constructor flag is added, defaulting
to False.  Most code I suspect will want to set this to True and use
.ugettext().

- A few other minor changes from the Zope project, including asserting
that a zero-length msgid must have a Project-ID-Version header for it to
be counted as the metadata record.

22 years agoAdded a note that the Mac OSA modules are documented.
Jack Jansen [Fri, 11 Apr 2003 15:37:20 +0000 (15:37 +0000)]
Added a note that the Mac OSA modules are documented.

22 years agoSF patch #706707, time.tzset standards compliance update by Stuart Bishop
Neal Norwitz [Fri, 11 Apr 2003 15:35:53 +0000 (15:35 +0000)]
SF patch #706707, time.tzset standards compliance update by Stuart Bishop

Update configure and test to use proper timezone specifications

22 years agoMoved all the scripting stuff to a separate section, added all the
Jack Jansen [Fri, 11 Apr 2003 15:35:28 +0000 (15:35 +0000)]
Moved all the scripting stuff to a separate section, added all the
missing bits (well, all the bits I could think of) and updated the
rest.

22 years agoAvoid creating one of the TestSuite objects.
Fred Drake [Fri, 11 Apr 2003 15:14:05 +0000 (15:14 +0000)]
Avoid creating one of the TestSuite objects.

22 years agoFix test_tarfile failure when gzip is not available
Neal Norwitz [Fri, 11 Apr 2003 03:05:56 +0000 (03:05 +0000)]
Fix test_tarfile failure when gzip is not available
The module would exist, but be empty if already imported.
This change ensures we have gzip available.

22 years agoAttempt to make all the various string *strip methods the same.
Neal Norwitz [Thu, 10 Apr 2003 22:35:32 +0000 (22:35 +0000)]
Attempt to make all the various string *strip methods the same.
 * Doc - add doc for when functions were added
 * UserString
 * string object methods
 * string module functions
'chars' is used for the last parameter everywhere.

These changes will be backported, since part of the changes
have already been made, but they were inconsistent.

22 years agoMove declaration of enc to scope where it is used
Neal Norwitz [Thu, 10 Apr 2003 21:53:14 +0000 (21:53 +0000)]
Move declaration of enc to scope where it is used

22 years agoAdd a space after expression to be consistent
Neal Norwitz [Thu, 10 Apr 2003 21:51:29 +0000 (21:51 +0000)]
Add a space after expression to be consistent

22 years agoPyErr_NormalizeException(): in the type==NULL test, we should simply
Guido van Rossum [Thu, 10 Apr 2003 20:29:48 +0000 (20:29 +0000)]
PyErr_NormalizeException(): in the type==NULL test, we should simply
return.  Setting an exception can mess with the exception state, and
continuing is definitely wrong (since type is dereferenced later on).
Some code that calls this seems to be prepared for a NULL exception
type, so let's be safe rather than sorry and simply assume there's
nothing to normalize in this case.

22 years agohoist contents of csv submodule up to the package level
Skip Montanaro [Thu, 10 Apr 2003 17:16:15 +0000 (17:16 +0000)]
hoist contents of csv submodule up to the package level

22 years agoSF patch #718867: Fix reference leak for time.strptime
Raymond Hettinger [Thu, 10 Apr 2003 16:03:22 +0000 (16:03 +0000)]
SF patch #718867:  Fix reference leak for time.strptime
(contributed by Brett Cannon)

22 years agoMake Unpickler objects colletable.
Jeremy Hylton [Wed, 9 Apr 2003 21:25:30 +0000 (21:25 +0000)]
Make Unpickler objects colletable.

Bugfix candidate.

22 years agoMake Picklers collectable.
Jeremy Hylton [Wed, 9 Apr 2003 21:05:12 +0000 (21:05 +0000)]
Make Picklers collectable.

Bug fix candidate.

22 years agoMissing DECREF.
Jeremy Hylton [Wed, 9 Apr 2003 21:01:42 +0000 (21:01 +0000)]
Missing DECREF.

22 years agoPatch #718551: cygwinccompiler.get_versions() patch
Jason Tishler [Wed, 9 Apr 2003 20:13:59 +0000 (20:13 +0000)]
Patch #718551: cygwinccompiler.get_versions() patch

The cygwinccompiler.get_versions() function only handles versions numbers of
the form "x.y.z".  The attached patch enhances get_versions() to handle "x.y"
too (i.e., the ".z" is optional).

This change causes the unnecessary "--entry _DllMain@12" link option to be
suppressed for recent Cygwin and Mingw toolchains. Additionally, it directs
recent Mingw toolchains to use gcc instead of dllwrap during linking.

22 years agoAdd test for MessageBeep()
Guido van Rossum [Wed, 9 Apr 2003 19:57:06 +0000 (19:57 +0000)]
Add test for MessageBeep()

22 years ago- New function winsound.MessageBeep() wraps the Win32 API
Guido van Rossum [Wed, 9 Apr 2003 19:39:06 +0000 (19:39 +0000)]
- New function winsound.MessageBeep() wraps the Win32 API
  MessageBeep().

22 years agoAdd MessageBeep() API.
Guido van Rossum [Wed, 9 Apr 2003 19:38:08 +0000 (19:38 +0000)]
Add MessageBeep() API.

22 years agoDetabified.
Guido van Rossum [Wed, 9 Apr 2003 19:36:34 +0000 (19:36 +0000)]
Detabified.
Removed dead code.

22 years agoMake it possible to call instancemethod() with 2 arguments.
Guido van Rossum [Wed, 9 Apr 2003 19:35:08 +0000 (19:35 +0000)]
Make it possible to call instancemethod() with 2 arguments.

22 years agoReformat a few docstrings that caused line wraps in help() output.
Guido van Rossum [Wed, 9 Apr 2003 19:32:45 +0000 (19:32 +0000)]
Reformat a few docstrings that caused line wraps in help() output.

22 years agoFix two crashes on Windows:
Guido van Rossum [Wed, 9 Apr 2003 19:31:02 +0000 (19:31 +0000)]
Fix two crashes on Windows:
- CHECK_VALID() was checking the wrong value for a closed fd
- fseek(&_iob[fileno], ...) doesn't work for fileno >= 20

22 years agoVarious improvements to the way the table is formatted, to deal with
Guido van Rossum [Wed, 9 Apr 2003 19:10:46 +0000 (19:10 +0000)]
Various improvements to the way the table is formatted, to deal with
exceptionally large totals etc.

22 years ago- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum [Wed, 9 Apr 2003 19:06:21 +0000 (19:06 +0000)]
- New function sys.call_tracing() allows pdb to debug code
  recursively.
- pdb has a new command, "debug", which lets you step through
  arbitrary code from the debugger's (pdb) prompt.

22 years agoMinor markup adjustments.
Fred Drake [Wed, 9 Apr 2003 18:15:57 +0000 (18:15 +0000)]
Minor markup adjustments.

22 years agoTry to discourage use of PyObject_Type().
Guido van Rossum [Wed, 9 Apr 2003 18:02:23 +0000 (18:02 +0000)]
Try to discourage use of PyObject_Type().

22 years agoDon't use (PyObject *)PyObject_Type(x). It is a leaky and verbose way
Guido van Rossum [Wed, 9 Apr 2003 17:53:22 +0000 (17:53 +0000)]
Don't use (PyObject *)PyObject_Type(x).  It is a leaky and verbose way
of saying x->ob_type.

22 years agoRe-indent example; fix typo
Andrew M. Kuchling [Wed, 9 Apr 2003 17:26:38 +0000 (17:26 +0000)]
Re-indent example; fix typo

22 years agoproperty_traverse() should also traverse into prop_doc -- there's no
Guido van Rossum [Wed, 9 Apr 2003 17:05:33 +0000 (17:05 +0000)]
property_traverse() should also traverse into prop_doc -- there's no
typecheck that guarantees it's a string, and BTW string subclasses
could hide references.

22 years agoPatch #709178: remove -static option from cygwinccompiler
Jason Tishler [Wed, 9 Apr 2003 16:03:57 +0000 (16:03 +0000)]
Patch #709178: remove -static option from cygwinccompiler

Currently, the cygwinccompiler.py compiler handling in
distutils is invoking the cygwin and mingw compilers
with the -static option.

Logically, this means that the linker should choose to
link to static libraries instead of shared/dynamically
linked libraries.

Current win32 binutils expect import libraries to have
a .dll.a suffix and static libraries to have .a suffix.
If -static is passed, it will skip the .dll.a
libraries. This is pain if one has a tree with both
static and dynamic libraries using this naming
convention, and wish to use the dynamic libraries.

The -static option being passed in distutils is to get
around a bug in old versions of binutils where it would
get confused when it found the DLLs themselves.

The decision to use static or shared libraries is site
or package specific, and should be left to the setup
script or to command line options.

22 years agoCreated a minimal MacOSX section.
Jack Jansen [Wed, 9 Apr 2003 15:12:38 +0000 (15:12 +0000)]
Created a minimal MacOSX section.

22 years agoDetabbed.
Jack Jansen [Wed, 9 Apr 2003 13:25:43 +0000 (13:25 +0000)]
Detabbed.

22 years agoRemove the --verify option in favor of the standard -n/--dry-run option
Andrew M. Kuchling [Wed, 9 Apr 2003 12:35:51 +0000 (12:35 +0000)]
Remove the --verify option in favor of the standard -n/--dry-run option

22 years agoLots of small markup adjustments.
Fred Drake [Wed, 9 Apr 2003 04:06:37 +0000 (04:06 +0000)]
Lots of small markup adjustments.

22 years agoAdd dependency information for the hotshot package docs.
Fred Drake [Wed, 9 Apr 2003 03:25:07 +0000 (03:25 +0000)]
Add dependency information for the hotshot package docs.

22 years agoextra punctuation removed
Anthony Baxter [Wed, 9 Apr 2003 03:03:46 +0000 (03:03 +0000)]
extra punctuation removed

22 years agoAdd dependency information for the timeit module docs.
Fred Drake [Wed, 9 Apr 2003 02:41:36 +0000 (02:41 +0000)]
Add dependency information for the timeit module docs.

22 years ago+ libtimeit
Skip Montanaro [Wed, 9 Apr 2003 01:39:06 +0000 (01:39 +0000)]
+ libtimeit

22 years agodoc for timeit module/script - mostly just a recast of Tim's docstring
Skip Montanaro [Wed, 9 Apr 2003 01:38:53 +0000 (01:38 +0000)]
doc for timeit module/script - mostly just a recast of Tim's docstring

22 years agoMake staticmethods and classmethods participate in GC.
Jeremy Hylton [Tue, 8 Apr 2003 21:28:47 +0000 (21:28 +0000)]
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.

22 years agotentative fix for #712322: modification time stamp checking failed
Just van Rossum [Tue, 8 Apr 2003 20:07:15 +0000 (20:07 +0000)]
tentative fix for #712322: modification time stamp checking failed
when DST began.

22 years agoinstall timeit.py as a command line script
Skip Montanaro [Tue, 8 Apr 2003 19:50:02 +0000 (19:50 +0000)]
install timeit.py as a command line script

22 years agoadd a #! line for unix weenies
Skip Montanaro [Tue, 8 Apr 2003 19:49:40 +0000 (19:49 +0000)]
add a #! line for unix weenies

22 years agoNew tests identical to boom and boom2, except using new-style classes.
Tim Peters [Tue, 8 Apr 2003 19:44:13 +0000 (19:44 +0000)]
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).

22 years agocorrect a couple docstring nits
Skip Montanaro [Tue, 8 Apr 2003 19:40:19 +0000 (19:40 +0000)]
correct a couple docstring nits

22 years agoTypo repair.
Tim Peters [Tue, 8 Apr 2003 18:47:21 +0000 (18:47 +0000)]
Typo repair.

22 years agoAdded example of using positional and keyword args with atexit.register().
Fred Drake [Tue, 8 Apr 2003 17:46:53 +0000 (17:46 +0000)]
Added example of using positional and keyword args with atexit.register().
Based on a suggestion from a reader.

22 years agoMarkup fix.
Fred Drake [Tue, 8 Apr 2003 17:37:47 +0000 (17:37 +0000)]
Markup fix.

22 years agos/referrents/referents/g. Gotta love that referrers remains rife with rs.
Tim Peters [Tue, 8 Apr 2003 17:17:17 +0000 (17:17 +0000)]
s/referrents/referents/g.  Gotta love that referrers remains rife with rs.

22 years agoFinished implementing gc.get_referrents(): dealt with error and end
Tim Peters [Tue, 8 Apr 2003 16:39:48 +0000 (16:39 +0000)]
Finished implementing gc.get_referrents():  dealt with error and end
cases, wrote docs, added a test.

22 years agoComment repair; no semantic changes.
Tim Peters [Mon, 7 Apr 2003 22:41:24 +0000 (22:41 +0000)]
Comment repair; no semantic changes.

22 years agoReworked has_finalizer() to use the new _PyObject_Lookup() instead
Tim Peters [Mon, 7 Apr 2003 19:21:15 +0000 (19:21 +0000)]
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).

22 years agoNew private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters [Mon, 7 Apr 2003 17:51:59 +0000 (17:51 +0000)]
New private API function _PyInstance_Lookup.  gc will use this to figure
out whether __del__ exists, without executing any Python-level code.

22 years agoadd note suggested by rhettinger about example.
Anthony Baxter [Mon, 7 Apr 2003 12:21:56 +0000 (12:21 +0000)]
add note suggested by rhettinger about example.

22 years agopatch [ 698505 ] docs for hotshot module
Anthony Baxter [Mon, 7 Apr 2003 12:19:15 +0000 (12:19 +0000)]
patch [ 698505 ] docs for hotshot module

22 years agoinitgc(): Rewrote to use the PyModule_AddXYZ API; cuts code size.
Tim Peters [Sun, 6 Apr 2003 23:30:52 +0000 (23:30 +0000)]
initgc():  Rewrote to use the PyModule_AddXYZ API; cuts code size.

22 years agohandle_finalizers(): Rewrote to call append_objects() and gc_list_merge()
Tim Peters [Sun, 6 Apr 2003 19:41:39 +0000 (19:41 +0000)]
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.

22 years agoSF bug #699934: Obscure error message
Raymond Hettinger [Sun, 6 Apr 2003 19:13:41 +0000 (19:13 +0000)]
SF bug #699934:  Obscure error message

mwh pointed out that the error message did not
make sense if obtained by rearranging the bases.

22 years agoSF patch #701494: more apply removals
Raymond Hettinger [Sun, 6 Apr 2003 09:01:11 +0000 (09:01 +0000)]
SF patch #701494:  more apply removals

22 years agoSwitched from METH_VARARGS to METH_NOARGS for the 7 module functions that
Tim Peters [Sun, 6 Apr 2003 01:50:50 +0000 (01:50 +0000)]
Switched from METH_VARARGS to METH_NOARGS for the 7 module functions that
take no arguments; cuts generated code size.

22 years agoReworked move_finalizer_reachable() to create two distinct lists:
Tim Peters [Sun, 6 Apr 2003 00:11:39 +0000 (00:11 +0000)]
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.

22 years agomove_finalizers(): Rewrote. It's not necessary for this routine
Tim Peters [Sat, 5 Apr 2003 18:40:50 +0000 (18:40 +0000)]
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?

22 years agotest_boom: More comments. Also check that len(gc.garbage) doesn't
Tim Peters [Sat, 5 Apr 2003 17:46:04 +0000 (17:46 +0000)]
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).

22 years agoNew comments. Rewrote has_finalizer() as a sequence of ifs instead of
Tim Peters [Sat, 5 Apr 2003 17:35:54 +0000 (17:35 +0000)]
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.

22 years agoFixed new seemingly random segfaults, by moving the initialization of
Tim Peters [Sat, 5 Apr 2003 17:15:44 +0000 (17:15 +0000)]
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.

22 years agoSF bug #715145: unittest.py still uses != in failUnlessEqual
Raymond Hettinger [Fri, 4 Apr 2003 22:56:42 +0000 (22:56 +0000)]
SF bug #715145: unittest.py still uses != in failUnlessEqual

22 years agoAdd Tim's gc boom test to the test suite.
Jeremy Hylton [Fri, 4 Apr 2003 20:00:04 +0000 (20:00 +0000)]
Add Tim's gc boom test to the test suite.

22 years agoFix Tim's boom example.
Jeremy Hylton [Fri, 4 Apr 2003 19:59:06 +0000 (19:59 +0000)]
Fix Tim's boom example.

move_finalizers() moves every object from unreachable to collectable
or finalizers, unless the object is deallocated first.