[Patches] [ python-Patches-403666 ] Allow jython to use test_new

noreply@sourceforge.net noreply@sourceforge.net
Fri, 23 Mar 2001 08:07:41 -0800


Patches item #403666, was updated on 2001-02-07 12:25
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=403666&group_id=5470

Category: None
Group: None
Status: Open
Priority: 5
Submitted By: Finn Bock (bckfnn)
Assigned to: Barry Warsaw (bwarsaw)
Summary: Allow jython to use test_new

Initial Comment:
- Avoid the __builtins__ when jython.
- The codestr must have a "global c". Otherwise jython will make c a local. This is a definate difference between the two implementation, but I think it is ok.
- Skip the new.code() test which Jython never will implement.

----------------------------------------------------------------------

>Comment By: Barry Warsaw (bwarsaw)
Date: 2001-03-23 08:07

Message:
Logged In: YES 
user_id=12800

Here's a more portable alternative, which I plan to commit
for CPython 2.1b2.  I agree with the "global c" addition;
it's certainly not clear to me or Jeremy what c's binding
should be in a code object compiled at module scope but
bound to a new function.  Forcing it to global makes sense
(and btw, you might want to add a note to the CPython vs.
Jython differences page).

Further, while Jython doesn't have __builtins__, a more
portable way to test this is to import __builtin__ and bind
that to "__builtins__" in the g dict (I'm not sure why
CPython includes this in the test -- but w/ this change both
Jython and CPython pass).

Finally, instead of testing for sys.platform, test for
hasattr(new, 'code') for a more portable alternative (i.e.
other platforms like C# may -- although I don't know -- have
a similar restriction).

Attached is the new version of the patch.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=403666&group_id=5470