[ python-Bugs-978308 ] Spurious errors taking bool of dead proxy

SourceForge.net noreply at sourceforge.net
Fri Jun 25 09:47:03 EDT 2004


Bugs item #978308, was opened at 2004-06-23 11:48
Message generated for change (Comment added) made by colander_man
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: Open
Resolution: None
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: 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