[ python-Bugs-978308 ] Spurious errors taking bool of dead proxy
SourceForge.net
noreply at sourceforge.net
Thu Jul 8 03:22:40 CEST 2004
Bugs item #978308, was opened at 2004-06-23 11:48
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=978308&group_id=5470
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 6
Submitted By: Chris King (colander_man)
Assigned to: Neal Norwitz (nnorwitz)
Summary: Spurious errors taking bool of dead proxy
Initial Comment:
The following code will cause interesting errors:
from weakref import proxy
class a: pass
bool(proxy(a()))
Entered at a prompt, this will not cause a
ReferenceError until another statement is entered (and
will instead return True or 1) in both 2.3 and 2.2.
Run as a script, this will return True and cause a
fatal error in 2.3, but will return 1 and otherwise
exhibit no strange behaviour in 2.2 (even with
additional code accessing the return value).
The equivalent code written using ref rather than proxy
works as expected: bool(ref(a())()) returns False and
creates no errors.
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2004-07-07 21:22
Message:
Logged In: YES
user_id=33168
Checked in as:
* Objects/weakrefobject.c 1.18
* Lib/test/test_weakref.py 1.42
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2004-06-25 22:46
Message:
Logged In: YES
user_id=31435
Neal, FWIW, your fix is certainly correct.
----------------------------------------------------------------------
Comment By: Chris King (colander_man)
Date: 2004-06-25 09:47
Message:
Logged In: YES
user_id=573252
The fix works (plus gave me an excuse to download the 2.4
snapshot). Thanks!
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2004-06-24 22:57
Message:
Logged In: YES
user_id=33168
attaching patch w/test
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2004-06-24 22:46
Message:
Logged In: YES
user_id=33168
I believe the fix is in Objects/weakrefobject.c, line 358.
-1 should be returned, not 1 since an error occurred in
proxy_checkref(). I'll try to fix this. If anyone wants to
steal it, feel free. :-)
Chris, if you could test the fix and report your results,
that would be great.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-06-23 16:13
Message:
Logged In: YES
user_id=80475
Confirmed the script behavior in Py2.4.
The interactive prompt results are not consistent It
returned True the first time I ran it and raised a
ReferenceError in subsequent attempts.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=978308&group_id=5470
More information about the Python-bugs-list
mailing list