[pypy-svn] r26180 - in pypy/dist/pypy: objspace/std translator/goal
stephan at codespeak.net
stephan at codespeak.net
Sun Apr 23 13:52:49 CEST 2006
Author: stephan
Date: Sun Apr 23 13:52:47 2006
New Revision: 26180
Added:
pypy/dist/pypy/translator/goal/targetrdicttest2.py
Modified:
pypy/dist/pypy/objspace/std/setobject.py
pypy/dist/pypy/translator/goal/targetrdicttest.py
Log:
current set implementation (enable model.WITHSET if using).
This version shows different behaviour for inplace_update in py.py and pypy-c.
targetrdicttest2 shows that the problem seems to be NOT related to rdict.update behaviour.
Modified: pypy/dist/pypy/objspace/std/setobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/setobject.py (original)
+++ pypy/dist/pypy/objspace/std/setobject.py Sun Apr 23 13:52:47 2006
@@ -454,7 +454,7 @@
return space.w_None
def inplace_and__Set_Set(space, w_left, w_other):
- set_intersection_update__Set_ANY(space, w_left, w_other)
+ set_intersection_update__Set_Set(space, w_left, w_other)
return w_left
inplace_and__Set_Frozenset = inplace_and__Set_Set
Modified: pypy/dist/pypy/translator/goal/targetrdicttest.py
==============================================================================
--- pypy/dist/pypy/translator/goal/targetrdicttest.py (original)
+++ pypy/dist/pypy/translator/goal/targetrdicttest.py Sun Apr 23 13:52:47 2006
@@ -28,30 +28,27 @@
os.write(1,'test 1: hashing an unhashable object\n')
try:
myhash(uhobj)
- except KeyError:
- os.write(1,'\tKeyError\n')
- except TypeError:
- os.write(1,'\tTypeError\n')
+ except KeyError,e:
+ os.write(1,'\tKeyError\t')
+ os.write(1,str(e) + '\n')
+ except TypeError,e:
+ os.write(1,'\tTypeError\t')
+ os.write(1,str(e) + '\n')
else:
os.write(1,'\tno exception\n')
os.write(1,'test 2: getitem with unhashable key:\n')
try:
mydict[uhobj]
- except KeyError:
- os.write(1,'\tKeyError\n')
- except TypeError:
- os.write(1,'\tTypeError\n')
+ except KeyError,e:
+ os.write(1,'\tKeyError\t')
+ os.write(1,str(e) + '\n')
+ except TypeError,e:
+ os.write(1,'\tTypeError\t')
+ os.write(1,str(e) + '\n')
else:
os.write(1,'\tno exception\n')
- os.write(1,'test 3: getitem with unhashable key: (and catching general Exception)\n')
- try:
- mydict[uhobj]
- except Exception, e:
- os.write(1,'\t' + str(e) + '\n')
- else:
- os.write(1,'\tno exception\n')
# The Following can't be translated (for reasons I don't understand:
# it has to do with the assignment.
#
Added: pypy/dist/pypy/translator/goal/targetrdicttest2.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/goal/targetrdicttest2.py Sun Apr 23 13:52:47 2006
@@ -0,0 +1,47 @@
+from pypy.rpython.objectmodel import r_dict
+import os, sys
+import operator
+
+# __________ Entry point __________
+
+def eq(arg1, arg2):
+ return arg1 == arg2
+
+def myhash(arg):
+ return arg.__hash__()
+
+class number(object):
+ def __init__(self,arg):
+ self.num = arg
+ def __hash__(self):
+ return self.num
+
+ def __eq__(self,other):
+ return self.num == other.num
+
+def entry_point(argv):
+ dict_one = r_dict(eq,myhash)
+ dict_two = r_dict(eq,myhash)
+ os.write(1,'test for rdict.update\n')
+ one = number(1)
+ two = number(2)
+ three = number(3)
+ four = number(4)
+
+ dict_one[one] = None
+ dict_one[four] = None
+
+ dict_two[two] = None
+ dict_two[three] = None
+
+ dict_one.update(dict_two)
+ for key in dict_one.iterkeys():
+ os.write(1,'found %s\n' % key.num)
+
+ return 0
+
+# _____ Define and setup target ___
+
+def target(*args):
+ return entry_point, None
+
More information about the Pypy-commit
mailing list