Anonymous avatar Anonymous committed 211e94b Merge

commit

Comments (0)

Files changed (157)

 syntax: glob
 *.py[co]
 *~
+.*.swp
 
 syntax: regexp
 ^testresult$
 ^pypy/translator/benchmark/shootout_benchmarks$
 ^pypy/translator/goal/pypy-translation-snapshot$
 ^pypy/translator/goal/pypy-c
+^pypy/translator/goal/pypy-jvm
+^pypy/translator/goal/pypy-jvm.jar
 ^pypy/translator/goal/.+\.exe$
 ^pypy/translator/goal/.+\.dll$
 ^pypy/translator/goal/target.+-c$

lib-python/modified-2.7/distutils/cygwinccompiler.py

         elif msc_ver == '1500':
             # VS2008 / MSVC 9.0
             return ['msvcr90']
+        elif msc_ver == '1600':
+            # VS2010 / MSVC 10.0
+            return ['msvcr100']
         else:
             raise ValueError("Unknown MS Compiler version %s " % msc_ver)
 

lib-python/modified-2.7/opcode.py

 def_op('MAP_ADD', 147)
 
 # pypy modification, experimental bytecode
-def_op('CALL_LIKELY_BUILTIN', 200)    # #args + (#kwargs << 8)
 def_op('LOOKUP_METHOD', 201)          # Index in name list
 hasname.append(201)
 def_op('CALL_METHOD', 202)            # #args not including 'self'

lib-python/modified-2.7/pickle.py

 
 # Unpickling machinery
 
-class Unpickler:
+class Unpickler(object):
 
     def __init__(self, file):
         """This takes a file-like object for reading a pickle data stream.

lib-python/modified-2.7/test/test_descr.py

         self.assertTrue(l.__add__ != l.__mul__)
         self.assertTrue(l.__add__.__name__ == '__add__')
         self.assertTrue(l.__add__.__self__ is l)
-        self.assertTrue(l.__add__.__objclass__ is list)
+        if hasattr(l.__add__, '__objclass__'):   # CPython
+            self.assertTrue(l.__add__.__objclass__ is list)
+        else:                                    # PyPy
+            self.assertTrue(l.__add__.im_class is list)
         self.assertEqual(l.__add__.__doc__, list.__add__.__doc__)
         try:
             hash(l.__add__)

lib-python/modified-2.7/test/test_dis.py

-# Minimal tests for dis module
-
-from test.test_support import run_unittest
-import unittest
-import sys
-import dis
-import StringIO
-
-
-def _f(a):
-    print a
-    return 1
-
-dis_f = """\
- %-4d         0 LOAD_FAST                0 (a)
-              3 PRINT_ITEM
-              4 PRINT_NEWLINE
-
- %-4d         5 LOAD_CONST               1 (1)
-              8 RETURN_VALUE
-"""%(_f.func_code.co_firstlineno + 1,
-     _f.func_code.co_firstlineno + 2)
-
-
-# we "call" rangexxx() instead of range() to disable the
-# pypy optimization that turns it into CALL_LIKELY_BUILTIN.
-def bug708901():
-    for res in rangexxx(1,
-                        10):
-        pass
-
-dis_bug708901 = """\
- %-4d         0 SETUP_LOOP              23 (to 26)
-              3 LOAD_GLOBAL              0 (rangexxx)
-              6 LOAD_CONST               1 (1)
-
- %-4d         9 LOAD_CONST               2 (10)
-             12 CALL_FUNCTION            2
-             15 GET_ITER
-        >>   16 FOR_ITER                 6 (to 25)
-             19 STORE_FAST               0 (res)
-
- %-4d        22 JUMP_ABSOLUTE           16
-        >>   25 POP_BLOCK
-        >>   26 LOAD_CONST               0 (None)
-             29 RETURN_VALUE
-"""%(bug708901.func_code.co_firstlineno + 1,
-     bug708901.func_code.co_firstlineno + 2,
-     bug708901.func_code.co_firstlineno + 3)
-
-
-def bug1333982(x=[]):
-    assert 0, ([s for s in x] +
-              1)
-    pass
-
-dis_bug1333982 = """\
- %-4d         0 LOAD_CONST               1 (0)
-              3 POP_JUMP_IF_TRUE        38
-              6 LOAD_GLOBAL              0 (AssertionError)
-              9 BUILD_LIST               0
-             12 LOAD_FAST                0 (x)
-             15 GET_ITER
-        >>   16 FOR_ITER                12 (to 31)
-             19 STORE_FAST               1 (s)
-             22 LOAD_FAST                1 (s)
-             25 LIST_APPEND              2
-             28 JUMP_ABSOLUTE           16
-
- %-4d   >>   31 LOAD_CONST               2 (1)
-             34 BINARY_ADD
-             35 RAISE_VARARGS            2
-
- %-4d   >>   38 LOAD_CONST               0 (None)
-             41 RETURN_VALUE
-"""%(bug1333982.func_code.co_firstlineno + 1,
-     bug1333982.func_code.co_firstlineno + 2,
-     bug1333982.func_code.co_firstlineno + 3)
-
-_BIG_LINENO_FORMAT = """\
-%3d           0 LOAD_GLOBAL              0 (spam)
-              3 POP_TOP
-              4 LOAD_CONST               0 (None)
-              7 RETURN_VALUE
-"""
-
-class DisTests(unittest.TestCase):
-    def do_disassembly_test(self, func, expected):
-        s = StringIO.StringIO()
-        save_stdout = sys.stdout
-        sys.stdout = s
-        dis.dis(func)
-        sys.stdout = save_stdout
-        got = s.getvalue()
-        # Trim trailing blanks (if any).
-        lines = got.split('\n')
-        lines = [line.rstrip() for line in lines]
-        expected = expected.split("\n")
-        import difflib
-        if expected != lines:
-            self.fail(
-                "events did not match expectation:\n" +
-                "\n".join(difflib.ndiff(expected,
-                                        lines)))
-
-    def test_opmap(self):
-        self.assertEqual(dis.opmap["STOP_CODE"], 0)
-        self.assertIn(dis.opmap["LOAD_CONST"], dis.hasconst)
-        self.assertIn(dis.opmap["STORE_NAME"], dis.hasname)
-
-    def test_opname(self):
-        self.assertEqual(dis.opname[dis.opmap["LOAD_FAST"]], "LOAD_FAST")
-
-    def test_boundaries(self):
-        self.assertEqual(dis.opmap["EXTENDED_ARG"], dis.EXTENDED_ARG)
-        self.assertEqual(dis.opmap["STORE_NAME"], dis.HAVE_ARGUMENT)
-
-    def test_dis(self):
-        self.do_disassembly_test(_f, dis_f)
-
-    def test_bug_708901(self):
-        self.do_disassembly_test(bug708901, dis_bug708901)
-
-    def test_bug_1333982(self):
-        # This one is checking bytecodes generated for an `assert` statement,
-        # so fails if the tests are run with -O.  Skip this test then.
-        if __debug__:
-            self.do_disassembly_test(bug1333982, dis_bug1333982)
-
-    def test_big_linenos(self):
-        def func(count):
-            namespace = {}
-            func = "def foo():\n " + "".join(["\n "] * count + ["spam\n"])
-            exec func in namespace
-            return namespace['foo']
-
-        # Test all small ranges
-        for i in xrange(1, 300):
-            expected = _BIG_LINENO_FORMAT % (i + 2)
-            self.do_disassembly_test(func(i), expected)
-
-        # Test some larger ranges too
-        for i in xrange(300, 5000, 10):
-            expected = _BIG_LINENO_FORMAT % (i + 2)
-            self.do_disassembly_test(func(i), expected)
-
-def test_main():
-    run_unittest(DisTests)
-
-
-if __name__ == "__main__":
-    test_main()

lib-python/modified-2.7/test/test_sets.py

+#!/usr/bin/env python
+
+import unittest, operator, copy, pickle, random
+from test import test_support
+
+test_support.import_module("sets", deprecated=True)
+from sets import Set, ImmutableSet
+
+empty_set = Set()
+
+#==============================================================================
+
+class TestBasicOps(unittest.TestCase):
+
+    def test_repr(self):
+        if self.repr is not None:
+            self.assertEqual(repr(self.set), self.repr)
+
+    def test_length(self):
+        self.assertEqual(len(self.set), self.length)
+
+    def test_self_equality(self):
+        self.assertEqual(self.set, self.set)
+
+    def test_equivalent_equality(self):
+        self.assertEqual(self.set, self.dup)
+
+    def test_copy(self):
+        self.assertEqual(self.set.copy(), self.dup)
+
+    def test_self_union(self):
+        result = self.set | self.set
+        self.assertEqual(result, self.dup)
+
+    def test_empty_union(self):
+        result = self.set | empty_set
+        self.assertEqual(result, self.dup)
+
+    def test_union_empty(self):
+        result = empty_set | self.set
+        self.assertEqual(result, self.dup)
+
+    def test_self_intersection(self):
+        result = self.set & self.set
+        self.assertEqual(result, self.dup)
+
+    def test_empty_intersection(self):
+        result = self.set & empty_set
+        self.assertEqual(result, empty_set)
+
+    def test_intersection_empty(self):
+        result = empty_set & self.set
+        self.assertEqual(result, empty_set)
+
+    def test_self_symmetric_difference(self):
+        result = self.set ^ self.set
+        self.assertEqual(result, empty_set)
+
+    def checkempty_symmetric_difference(self):
+        result = self.set ^ empty_set
+        self.assertEqual(result, self.set)
+
+    def test_self_difference(self):
+        result = self.set - self.set
+        self.assertEqual(result, empty_set)
+
+    def test_empty_difference(self):
+        result = self.set - empty_set
+        self.assertEqual(result, self.dup)
+
+    def test_empty_difference_rev(self):
+        result = empty_set - self.set
+        self.assertEqual(result, empty_set)
+
+    def test_iteration(self):
+        for v in self.set:
+            self.assertIn(v, self.values)
+
+    def test_pickling(self):
+        p = pickle.dumps(self.set)
+        copy = pickle.loads(p)
+        self.assertEqual(self.set, copy,
+                         "%s != %s" % (self.set, copy))
+
+#------------------------------------------------------------------------------
+
+class TestBasicOpsEmpty(TestBasicOps):
+    def setUp(self):
+        self.case   = "empty set"
+        self.values = []
+        self.set    = Set(self.values)
+        self.dup    = Set(self.values)
+        self.length = 0
+        self.repr   = "Set([])"
+
+#------------------------------------------------------------------------------
+
+class TestBasicOpsSingleton(TestBasicOps):
+    def setUp(self):
+        self.case   = "unit set (number)"
+        self.values = [3]
+        self.set    = Set(self.values)
+        self.dup    = Set(self.values)
+        self.length = 1
+        self.repr   = "Set([3])"
+
+    def test_in(self):
+        self.assertTrue(3 in self.set)
+
+    def test_not_in(self):
+        self.assertTrue(2 not in self.set)
+
+#------------------------------------------------------------------------------
+
+class TestBasicOpsTuple(TestBasicOps):
+    def setUp(self):
+        self.case   = "unit set (tuple)"
+        self.values = [(0, "zero")]
+        self.set    = Set(self.values)
+        self.dup    = Set(self.values)
+        self.length = 1
+        self.repr   = "Set([(0, 'zero')])"
+
+    def test_in(self):
+        self.assertTrue((0, "zero") in self.set)
+
+    def test_not_in(self):
+        self.assertTrue(9 not in self.set)
+
+#------------------------------------------------------------------------------
+
+class TestBasicOpsTriple(TestBasicOps):
+    def setUp(self):
+        self.case   = "triple set"
+        self.values = [0, "zero", operator.add]
+        self.set    = Set(self.values)
+        self.dup    = Set(self.values)
+        self.length = 3
+        self.repr   = None
+
+#==============================================================================
+
+def baditer():
+    raise TypeError
+    yield True
+
+def gooditer():
+    yield True
+
+class TestExceptionPropagation(unittest.TestCase):
+    """SF 628246:  Set constructor should not trap iterator TypeErrors"""
+
+    def test_instanceWithException(self):
+        self.assertRaises(TypeError, Set, baditer())
+
+    def test_instancesWithoutException(self):
+        # All of these iterables should load without exception.
+        Set([1,2,3])
+        Set((1,2,3))
+        Set({'one':1, 'two':2, 'three':3})
+        Set(xrange(3))
+        Set('abc')
+        Set(gooditer())
+
+#==============================================================================
+
+class TestSetOfSets(unittest.TestCase):
+    def test_constructor(self):
+        inner = Set([1])
+        outer = Set([inner])
+        element = outer.pop()
+        self.assertEqual(type(element), ImmutableSet)
+        outer.add(inner)        # Rebuild set of sets with .add method
+        outer.remove(inner)
+        self.assertEqual(outer, Set())   # Verify that remove worked
+        outer.discard(inner)    # Absence of KeyError indicates working fine
+
+#==============================================================================
+
+class TestBinaryOps(unittest.TestCase):
+    def setUp(self):
+        self.set = Set((2, 4, 6))
+
+    def test_eq(self):              # SF bug 643115
+        self.assertEqual(self.set, Set({2:1,4:3,6:5}))
+
+    def test_union_subset(self):
+        result = self.set | Set([2])
+        self.assertEqual(result, Set((2, 4, 6)))
+
+    def test_union_superset(self):
+        result = self.set | Set([2, 4, 6, 8])
+        self.assertEqual(result, Set([2, 4, 6, 8]))
+
+    def test_union_overlap(self):
+        result = self.set | Set([3, 4, 5])
+        self.assertEqual(result, Set([2, 3, 4, 5, 6]))
+
+    def test_union_non_overlap(self):
+        result = self.set | Set([8])
+        self.assertEqual(result, Set([2, 4, 6, 8]))
+
+    def test_intersection_subset(self):
+        result = self.set & Set((2, 4))
+        self.assertEqual(result, Set((2, 4)))
+
+    def test_intersection_superset(self):
+        result = self.set & Set([2, 4, 6, 8])
+        self.assertEqual(result, Set([2, 4, 6]))
+
+    def test_intersection_overlap(self):
+        result = self.set & Set([3, 4, 5])
+        self.assertEqual(result, Set([4]))
+
+    def test_intersection_non_overlap(self):
+        result = self.set & Set([8])
+        self.assertEqual(result, empty_set)
+
+    def test_sym_difference_subset(self):
+        result = self.set ^ Set((2, 4))
+        self.assertEqual(result, Set([6]))
+
+    def test_sym_difference_superset(self):
+        result = self.set ^ Set((2, 4, 6, 8))
+        self.assertEqual(result, Set([8]))
+
+    def test_sym_difference_overlap(self):
+        result = self.set ^ Set((3, 4, 5))
+        self.assertEqual(result, Set([2, 3, 5, 6]))
+
+    def test_sym_difference_non_overlap(self):
+        result = self.set ^ Set([8])
+        self.assertEqual(result, Set([2, 4, 6, 8]))
+
+    def test_cmp(self):
+        a, b = Set('a'), Set('b')
+        self.assertRaises(TypeError, cmp, a, b)
+
+        # You can view this as a buglet:  cmp(a, a) does not raise TypeError,
+        # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True,
+        # which Python thinks is good enough to synthesize a cmp() result
+        # without calling __cmp__.
+        self.assertEqual(cmp(a, a), 0)
+
+        self.assertRaises(TypeError, cmp, a, 12)
+        self.assertRaises(TypeError, cmp, "abc", a)
+
+    def test_inplace_on_self(self):
+        t = self.set.copy()
+        t |= t
+        self.assertEqual(t, self.set)
+        t &= t
+        self.assertEqual(t, self.set)
+        t -= t
+        self.assertEqual(len(t), 0)
+        t = self.set.copy()
+        t ^= t
+        self.assertEqual(len(t), 0)
+
+
+#==============================================================================
+
+class TestUpdateOps(unittest.TestCase):
+    def setUp(self):
+        self.set = Set((2, 4, 6))
+
+    def test_union_subset(self):
+        self.set |= Set([2])
+        self.assertEqual(self.set, Set((2, 4, 6)))
+
+    def test_union_superset(self):
+        self.set |= Set([2, 4, 6, 8])
+        self.assertEqual(self.set, Set([2, 4, 6, 8]))
+
+    def test_union_overlap(self):
+        self.set |= Set([3, 4, 5])
+        self.assertEqual(self.set, Set([2, 3, 4, 5, 6]))
+
+    def test_union_non_overlap(self):
+        self.set |= Set([8])
+        self.assertEqual(self.set, Set([2, 4, 6, 8]))
+
+    def test_union_method_call(self):
+        self.set.union_update(Set([3, 4, 5]))
+        self.assertEqual(self.set, Set([2, 3, 4, 5, 6]))
+
+    def test_intersection_subset(self):
+        self.set &= Set((2, 4))
+        self.assertEqual(self.set, Set((2, 4)))
+
+    def test_intersection_superset(self):
+        self.set &= Set([2, 4, 6, 8])
+        self.assertEqual(self.set, Set([2, 4, 6]))
+
+    def test_intersection_overlap(self):
+        self.set &= Set([3, 4, 5])
+        self.assertEqual(self.set, Set([4]))
+
+    def test_intersection_non_overlap(self):
+        self.set &= Set([8])
+        self.assertEqual(self.set, empty_set)
+
+    def test_intersection_method_call(self):
+        self.set.intersection_update(Set([3, 4, 5]))
+        self.assertEqual(self.set, Set([4]))
+
+    def test_sym_difference_subset(self):
+        self.set ^= Set((2, 4))
+        self.assertEqual(self.set, Set([6]))
+
+    def test_sym_difference_superset(self):
+        self.set ^= Set((2, 4, 6, 8))
+        self.assertEqual(self.set, Set([8]))
+
+    def test_sym_difference_overlap(self):
+        self.set ^= Set((3, 4, 5))
+        self.assertEqual(self.set, Set([2, 3, 5, 6]))
+
+    def test_sym_difference_non_overlap(self):
+        self.set ^= Set([8])
+        self.assertEqual(self.set, Set([2, 4, 6, 8]))
+
+    def test_sym_difference_method_call(self):
+        self.set.symmetric_difference_update(Set([3, 4, 5]))
+        self.assertEqual(self.set, Set([2, 3, 5, 6]))
+
+    def test_difference_subset(self):
+        self.set -= Set((2, 4))
+        self.assertEqual(self.set, Set([6]))
+
+    def test_difference_superset(self):
+        self.set -= Set((2, 4, 6, 8))
+        self.assertEqual(self.set, Set([]))
+
+    def test_difference_overlap(self):
+        self.set -= Set((3, 4, 5))
+        self.assertEqual(self.set, Set([2, 6]))
+
+    def test_difference_non_overlap(self):
+        self.set -= Set([8])
+        self.assertEqual(self.set, Set([2, 4, 6]))
+
+    def test_difference_method_call(self):
+        self.set.difference_update(Set([3, 4, 5]))
+        self.assertEqual(self.set, Set([2, 6]))
+
+#==============================================================================
+
+class TestMutate(unittest.TestCase):
+    def setUp(self):
+        self.values = ["a", "b", "c"]
+        self.set = Set(self.values)
+
+    def test_add_present(self):
+        self.set.add("c")
+        self.assertEqual(self.set, Set("abc"))
+
+    def test_add_absent(self):
+        self.set.add("d")
+        self.assertEqual(self.set, Set("abcd"))
+
+    def test_add_until_full(self):
+        tmp = Set()
+        expected_len = 0
+        for v in self.values:
+            tmp.add(v)
+            expected_len += 1
+            self.assertEqual(len(tmp), expected_len)
+        self.assertEqual(tmp, self.set)
+
+    def test_remove_present(self):
+        self.set.remove("b")
+        self.assertEqual(self.set, Set("ac"))
+
+    def test_remove_absent(self):
+        try:
+            self.set.remove("d")
+            self.fail("Removing missing element should have raised LookupError")
+        except LookupError:
+            pass
+
+    def test_remove_until_empty(self):
+        expected_len = len(self.set)
+        for v in self.values:
+            self.set.remove(v)
+            expected_len -= 1
+            self.assertEqual(len(self.set), expected_len)
+
+    def test_discard_present(self):
+        self.set.discard("c")
+        self.assertEqual(self.set, Set("ab"))
+
+    def test_discard_absent(self):
+        self.set.discard("d")
+        self.assertEqual(self.set, Set("abc"))
+
+    def test_clear(self):
+        self.set.clear()
+        self.assertEqual(len(self.set), 0)
+
+    def test_pop(self):
+        popped = {}
+        while self.set:
+            popped[self.set.pop()] = None
+        self.assertEqual(len(popped), len(self.values))
+        for v in self.values:
+            self.assertIn(v, popped)
+
+    def test_update_empty_tuple(self):
+        self.set.union_update(())
+        self.assertEqual(self.set, Set(self.values))
+
+    def test_update_unit_tuple_overlap(self):
+        self.set.union_update(("a",))
+        self.assertEqual(self.set, Set(self.values))
+
+    def test_update_unit_tuple_non_overlap(self):
+        self.set.union_update(("a", "z"))
+        self.assertEqual(self.set, Set(self.values + ["z"]))
+
+#==============================================================================
+
+class TestSubsets(unittest.TestCase):
+
+    case2method = {"<=": "issubset",
+                   ">=": "issuperset",
+                  }
+
+    reverse = {"==": "==",
+               "!=": "!=",
+               "<":  ">",
+               ">":  "<",
+               "<=": ">=",
+               ">=": "<=",
+              }
+
+    def test_issubset(self):
+        x = self.left
+        y = self.right
+        for case in "!=", "==", "<", "<=", ">", ">=":
+            expected = case in self.cases
+            # Test the binary infix spelling.
+            result = eval("x" + case + "y", locals())
+            self.assertEqual(result, expected)
+            # Test the "friendly" method-name spelling, if one exists.
+            if case in TestSubsets.case2method:
+                method = getattr(x, TestSubsets.case2method[case])
+                result = method(y)
+                self.assertEqual(result, expected)
+
+            # Now do the same for the operands reversed.
+            rcase = TestSubsets.reverse[case]
+            result = eval("y" + rcase + "x", locals())
+            self.assertEqual(result, expected)
+            if rcase in TestSubsets.case2method:
+                method = getattr(y, TestSubsets.case2method[rcase])
+                result = method(x)
+                self.assertEqual(result, expected)
+#------------------------------------------------------------------------------
+
+class TestSubsetEqualEmpty(TestSubsets):
+    left  = Set()
+    right = Set()
+    name  = "both empty"
+    cases = "==", "<=", ">="
+
+#------------------------------------------------------------------------------
+
+class TestSubsetEqualNonEmpty(TestSubsets):
+    left  = Set([1, 2])
+    right = Set([1, 2])
+    name  = "equal pair"
+    cases = "==", "<=", ">="
+
+#------------------------------------------------------------------------------
+
+class TestSubsetEmptyNonEmpty(TestSubsets):
+    left  = Set()
+    right = Set([1, 2])
+    name  = "one empty, one non-empty"
+    cases = "!=", "<", "<="
+
+#------------------------------------------------------------------------------
+
+class TestSubsetPartial(TestSubsets):
+    left  = Set([1])
+    right = Set([1, 2])
+    name  = "one a non-empty proper subset of other"
+    cases = "!=", "<", "<="
+
+#------------------------------------------------------------------------------
+
+class TestSubsetNonOverlap(TestSubsets):
+    left  = Set([1])
+    right = Set([2])
+    name  = "neither empty, neither contains"
+    cases = "!="
+
+#==============================================================================
+
+class TestOnlySetsInBinaryOps(unittest.TestCase):
+
+    def test_eq_ne(self):
+        # Unlike the others, this is testing that == and != *are* allowed.
+        self.assertEqual(self.other == self.set, False)
+        self.assertEqual(self.set == self.other, False)
+        self.assertEqual(self.other != self.set, True)
+        self.assertEqual(self.set != self.other, True)
+
+    def test_ge_gt_le_lt(self):
+        self.assertRaises(TypeError, lambda: self.set < self.other)
+        self.assertRaises(TypeError, lambda: self.set <= self.other)
+        self.assertRaises(TypeError, lambda: self.set > self.other)
+        self.assertRaises(TypeError, lambda: self.set >= self.other)
+
+        self.assertRaises(TypeError, lambda: self.other < self.set)
+        self.assertRaises(TypeError, lambda: self.other <= self.set)
+        self.assertRaises(TypeError, lambda: self.other > self.set)
+        self.assertRaises(TypeError, lambda: self.other >= self.set)
+
+    def test_union_update_operator(self):
+        try:
+            self.set |= self.other
+        except TypeError:
+            pass
+        else:
+            self.fail("expected TypeError")
+
+    def test_union_update(self):
+        if self.otherIsIterable:
+            self.set.union_update(self.other)
+        else:
+            self.assertRaises(TypeError, self.set.union_update, self.other)
+
+    def test_union(self):
+        self.assertRaises(TypeError, lambda: self.set | self.other)
+        self.assertRaises(TypeError, lambda: self.other | self.set)
+        if self.otherIsIterable:
+            self.set.union(self.other)
+        else:
+            self.assertRaises(TypeError, self.set.union, self.other)
+
+    def test_intersection_update_operator(self):
+        try:
+            self.set &= self.other
+        except TypeError:
+            pass
+        else:
+            self.fail("expected TypeError")
+
+    def test_intersection_update(self):
+        if self.otherIsIterable:
+            self.set.intersection_update(self.other)
+        else:
+            self.assertRaises(TypeError,
+                              self.set.intersection_update,
+                              self.other)
+
+    def test_intersection(self):
+        self.assertRaises(TypeError, lambda: self.set & self.other)
+        self.assertRaises(TypeError, lambda: self.other & self.set)
+        if self.otherIsIterable:
+            self.set.intersection(self.other)
+        else:
+            self.assertRaises(TypeError, self.set.intersection, self.other)
+
+    def test_sym_difference_update_operator(self):
+        try:
+            self.set ^= self.other
+        except TypeError:
+            pass
+        else:
+            self.fail("expected TypeError")
+
+    def test_sym_difference_update(self):
+        if self.otherIsIterable:
+            self.set.symmetric_difference_update(self.other)
+        else:
+            self.assertRaises(TypeError,
+                              self.set.symmetric_difference_update,
+                              self.other)
+
+    def test_sym_difference(self):
+        self.assertRaises(TypeError, lambda: self.set ^ self.other)
+        self.assertRaises(TypeError, lambda: self.other ^ self.set)
+        if self.otherIsIterable:
+            self.set.symmetric_difference(self.other)
+        else:
+            self.assertRaises(TypeError, self.set.symmetric_difference, self.other)
+
+    def test_difference_update_operator(self):
+        try:
+            self.set -= self.other
+        except TypeError:
+            pass
+        else:
+            self.fail("expected TypeError")
+
+    def test_difference_update(self):
+        if self.otherIsIterable:
+            self.set.difference_update(self.other)
+        else:
+            self.assertRaises(TypeError,
+                              self.set.difference_update,
+                              self.other)
+
+    def test_difference(self):
+        self.assertRaises(TypeError, lambda: self.set - self.other)
+        self.assertRaises(TypeError, lambda: self.other - self.set)
+        if self.otherIsIterable:
+            self.set.difference(self.other)
+        else:
+            self.assertRaises(TypeError, self.set.difference, self.other)
+
+#------------------------------------------------------------------------------
+
+class TestOnlySetsNumeric(TestOnlySetsInBinaryOps):
+    def setUp(self):
+        self.set   = Set((1, 2, 3))
+        self.other = 19
+        self.otherIsIterable = False
+
+#------------------------------------------------------------------------------
+
+class TestOnlySetsDict(TestOnlySetsInBinaryOps):
+    def setUp(self):
+        self.set   = Set((1, 2, 3))
+        self.other = {1:2, 3:4}
+        self.otherIsIterable = True
+
+#------------------------------------------------------------------------------
+
+class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
+    def setUp(self):
+        self.set   = Set((1, 2, 3))
+        self.other = operator.add
+        self.otherIsIterable = False
+
+    def test_ge_gt_le_lt(self):
+        with test_support.check_py3k_warnings():
+            super(TestOnlySetsOperator, self).test_ge_gt_le_lt()
+
+#------------------------------------------------------------------------------
+
+class TestOnlySetsTuple(TestOnlySetsInBinaryOps):
+    def setUp(self):
+        self.set   = Set((1, 2, 3))
+        self.other = (2, 4, 6)
+        self.otherIsIterable = True
+
+#------------------------------------------------------------------------------
+
+class TestOnlySetsString(TestOnlySetsInBinaryOps):
+    def setUp(self):
+        self.set   = Set((1, 2, 3))
+        self.other = 'abc'
+        self.otherIsIterable = True
+
+#------------------------------------------------------------------------------
+
+class TestOnlySetsGenerator(TestOnlySetsInBinaryOps):
+    def setUp(self):
+        def gen():
+            for i in xrange(0, 10, 2):
+                yield i
+        self.set   = Set((1, 2, 3))
+        self.other = gen()
+        self.otherIsIterable = True
+
+#------------------------------------------------------------------------------
+
+class TestOnlySetsofSets(TestOnlySetsInBinaryOps):
+    def setUp(self):
+        self.set   = Set((1, 2, 3))
+        self.other = [Set('ab'), ImmutableSet('cd')]
+        self.otherIsIterable = True
+
+#==============================================================================
+
+class TestCopying(unittest.TestCase):
+
+    def test_copy(self):
+        dup = self.set.copy()
+        self.assertEqual(len(dup), len(self.set))
+        dup_list = sorted(dup)
+        set_list = sorted(self.set)
+        self.assertEqual(len(dup_list), len(set_list))
+        for i, el in enumerate(dup_list):
+            # Object identity is not guarnteed for immutable objects, so we
+            # can't use assertIs here.
+            self.assertEqual(el, set_list[i])
+
+    def test_deep_copy(self):
+        dup = copy.deepcopy(self.set)
+        self.assertSetEqual(dup, self.set)
+
+#------------------------------------------------------------------------------
+
+class TestCopyingEmpty(TestCopying):
+    def setUp(self):
+        self.set = Set()
+
+#------------------------------------------------------------------------------
+
+class TestCopyingSingleton(TestCopying):
+    def setUp(self):
+        self.set = Set(["hello"])
+
+#------------------------------------------------------------------------------
+
+class TestCopyingTriple(TestCopying):
+    def setUp(self):
+        self.set = Set(["zero", 0, None])
+
+    def test_copy(self):
+        with test_support.check_py3k_warnings():
+            super(TestCopyingTriple, self).test_copy()
+
+#------------------------------------------------------------------------------
+
+class TestCopyingTuple(TestCopying):
+    def setUp(self):
+        self.set = Set([(1, 2)])
+
+#------------------------------------------------------------------------------
+
+class TestCopyingNested(TestCopying):
+    def setUp(self):
+        self.set = Set([((1, 2), (3, 4))])
+
+#==============================================================================
+
+class TestIdentities(unittest.TestCase):
+    def setUp(self):
+        self.a = Set([random.randrange(100) for i in xrange(50)])
+        self.b = Set([random.randrange(100) for i in xrange(50)])
+
+    def test_binopsVsSubsets(self):
+        a, b = self.a, self.b
+        self.assertTrue(a - b <= a)
+        self.assertTrue(b - a <= b)
+        self.assertTrue(a & b <= a)
+        self.assertTrue(a & b <= b)
+        self.assertTrue(a | b >= a)
+        self.assertTrue(a | b >= b)
+        self.assertTrue(a ^ b <= a | b)
+
+    def test_commutativity(self):
+        a, b = self.a, self.b
+        self.assertEqual(a&b, b&a)
+        self.assertEqual(a|b, b|a)
+        self.assertEqual(a^b, b^a)
+        if a != b:
+            self.assertNotEqual(a-b, b-a)
+
+    def test_reflexsive_relations(self):
+        a, zero = self.a, Set()
+        self.assertEqual(a ^ a, zero)
+        self.assertEqual(a - a, zero)
+        self.assertEqual(a | a, a)
+        self.assertEqual(a & a, a)
+        self.assertTrue(a <= a)
+        self.assertTrue(a >= a)
+        self.assertTrue(a == a)
+
+    def test_summations(self):
+        # check that sums of parts equal the whole
+        a, b = self.a, self.b
+        self.assertEqual((a-b)|(a&b)|(b-a), a|b)
+        self.assertEqual((a&b)|(a^b), a|b)
+        self.assertEqual(a|(b-a), a|b)
+        self.assertEqual((a-b)|b, a|b)
+        self.assertEqual((a-b)|(a&b), a)
+        self.assertEqual((b-a)|(a&b), b)
+        self.assertEqual((a-b)|(b-a), a^b)
+
+    def test_exclusion(self):
+        # check that inverse operations do not overlap
+        a, b, zero = self.a, self.b, Set()
+        self.assertEqual((a-b)&b, zero)
+        self.assertEqual((b-a)&a, zero)
+        self.assertEqual((a&b)&(a^b), zero)
+
+    def test_cardinality_relations(self):
+        a, b = self.a, self.b
+        self.assertEqual(len(a), len(a-b) + len(a&b))
+        self.assertEqual(len(b), len(b-a) + len(a&b))
+        self.assertEqual(len(a^b), len(a-b) + len(b-a))
+        self.assertEqual(len(a|b), len(a-b) + len(a&b) + len(b-a))
+        self.assertEqual(len(a^b) + len(a&b), len(a|b))
+
+#==============================================================================
+
+libreftest = """
+Example from the Library Reference:  Doc/lib/libsets.tex
+
+>>> from sets import Set as Base  # override _repr to get sorted output
+>>> class Set(Base):
+...     def _repr(self):
+...         return Base._repr(self, sorted=True)
+>>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
+>>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
+>>> managers = Set(['Jane', 'Jack', 'Susan', 'Zack'])
+>>> employees = engineers | programmers | managers           # union
+>>> engineering_management = engineers & managers            # intersection
+>>> fulltime_management = managers - engineers - programmers # difference
+>>> engineers.add('Marvin')
+>>> print engineers
+Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
+>>> employees.issuperset(engineers)           # superset test
+False
+>>> employees.union_update(engineers)         # update from another set
+>>> employees.issuperset(engineers)
+True
+>>> for group in [engineers, programmers, managers, employees]:
+...     group.discard('Susan')                # unconditionally remove element
+...     print group
+...
+Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
+Set(['Jack', 'Janice', 'Sam'])
+Set(['Jack', 'Jane', 'Zack'])
+Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin', 'Sam', 'Zack'])
+"""
+
+#==============================================================================
+
+__test__ = {'libreftest' : libreftest}
+
+def test_main(verbose=None):
+    import doctest
+    from test import test_sets
+    test_support.run_unittest(
+        TestSetOfSets,
+        TestExceptionPropagation,
+        TestBasicOpsEmpty,
+        TestBasicOpsSingleton,
+        TestBasicOpsTuple,
+        TestBasicOpsTriple,
+        TestBinaryOps,
+        TestUpdateOps,
+        TestMutate,
+        TestSubsetEqualEmpty,
+        TestSubsetEqualNonEmpty,
+        TestSubsetEmptyNonEmpty,
+        TestSubsetPartial,
+        TestSubsetNonOverlap,
+        TestOnlySetsNumeric,
+        TestOnlySetsDict,
+        TestOnlySetsOperator,
+        TestOnlySetsTuple,
+        TestOnlySetsString,
+        TestOnlySetsGenerator,
+        TestOnlySetsofSets,
+        TestCopyingEmpty,
+        TestCopyingSingleton,
+        TestCopyingTriple,
+        TestCopyingTuple,
+        TestCopyingNested,
+        TestIdentities,
+        doctest.DocTestSuite(test_sets),
+    )
+
+if __name__ == "__main__":
+    test_main(verbose=True)

lib-python/modified-2.7/test/test_weakref.py

         self.assertTrue(len(weakdict) == 2)
         k, v = weakdict.popitem()
         self.assertTrue(len(weakdict) == 1)
-        if k is key1:
+        if k == key1:
             self.assertTrue(v is value1)
         else:
             self.assertTrue(v is value2)
         k, v = weakdict.popitem()
         self.assertTrue(len(weakdict) == 0)
-        if k is key1:
+        if k == key1:
             self.assertTrue(v is value1)
         else:
             self.assertTrue(v is value2)

lib_pypy/_ctypes/__init__.py

 if _os.name in ("nt", "ce"):
     from _rawffi import FormatError
     from _rawffi import check_HRESULT as _check_HRESULT
-    CopyComPointer = None # XXX
+
+    def CopyComPointer(src, dst):
+        from ctypes import c_void_p, cast
+        if src:
+            hr = src[0][0].AddRef(src)
+            if hr & 0x80000000:
+                return hr
+        dst[0] = cast(src, c_void_p).value
+        return 0
+
     LoadLibrary = dlopen
 
 from _rawffi import FUNCFLAG_STDCALL, FUNCFLAG_CDECL, FUNCFLAG_PYTHONAPI

lib_pypy/_ctypes/basics.py

         return buffer(self._buffer)
 
     def _get_b_base(self):
-        return self._base
+        try:
+            return self._base
+        except AttributeError:
+            return None
     _b_base_ = property(_get_b_base)
     _b_needsfree_ = False
 
     'z' : _ffi.types.void_p,
     'O' : _ffi.types.void_p,
     'Z' : _ffi.types.void_p,
+    'X' : _ffi.types.void_p,
+    'v' : _ffi.types.sshort,
     }
 

lib_pypy/_ctypes/function.py

                           RuntimeWarning, stacklevel=2)
 
         if self._com_index:
-            assert False, 'TODO2'
             from ctypes import cast, c_void_p, POINTER
             if not args:
                 raise ValueError(
                     "native COM method call without 'this' parameter"
                     )
-            thisarg = cast(args[0], POINTER(POINTER(c_void_p))).contents
-            argtypes = [c_void_p] + list(argtypes)
-            args = list(args)
-            args[0] = args[0].value
+            thisarg = cast(args[0], POINTER(POINTER(c_void_p)))
+            newargs, argtypes, outargs = self._convert_args(argtypes, args[1:], kwargs)
+            newargs.insert(0, args[0].value)
+            argtypes.insert(0, c_void_p)
         else:
             thisarg = None
-            
-        newargs, argtypes, outargs = self._convert_args(argtypes, args, kwargs)
+            newargs, argtypes, outargs = self._convert_args(argtypes, args, kwargs)
 
         funcptr = self._getfuncptr(argtypes, self._restype_, thisarg)
         result = self._call_funcptr(funcptr, *newargs)
 
         if not outargs:
             return result
+
+        simple_cdata = type(c_void_p()).__bases__[0]
+        outargs = [x.value if type(x).__bases__[0] is simple_cdata else x
+                   for x in outargs]
+
         if len(outargs) == 1:
             return outargs[0]
         return tuple(outargs)
             # extract the address from the object's virtual table
             if not thisarg:
                 raise ValueError("COM method call without VTable")
-            ptr = thisarg[self._com_index - 0x1000]
-            argshapes = [arg._ffiargshape for arg in argtypes]
-            resshape = restype._ffiargshape
-            return _rawffi.FuncPtr(ptr, argshapes, resshape, self._flags_)
+            ptr = thisarg[0][self._com_index - 0x1000]
+            ffiargs = [argtype.get_ffi_argtype() for argtype in argtypes]
+            ffires = restype.get_ffi_argtype()
+            return _ffi.FuncPtr.fromaddr(ptr, '', ffiargs, ffires)
         
         cdll = self.dll._handle
         try:
         newargtypes = []
         total = len(args)
         paramflags = self._paramflags
-
-        if self._com_index:
-            inargs_idx = 1
-        else:
-            inargs_idx = 0
+        inargs_idx = 0
 
         if not paramflags and total < len(argtypes):
             raise TypeError("not enough arguments")
 
         retval = None
 
-        if self._com_index:
-            if resbuffer[0] & 0x80000000:
-                raise get_com_error(resbuffer[0],
-                                    self._com_iid, argsandobjs[0])
-            else:
-                retval = int(resbuffer[0])
-        elif restype is not None:
+        if restype is not None:
             checker = getattr(self.restype, '_check_retval_', None)
             if checker:
                 val = restype(result)
                 # classes defining a new type, and their subclasses
                 if '_type_' in restype.__dict__:
                     val = val.value
-                retval = checker(val)
+                # XXX Raise a COMError when restype is HRESULT and
+                # checker(val) fails.  How to check for restype == HRESULT?
+                if self._com_index:
+                    if result & 0x80000000:
+                        raise get_com_error(result, None, None)
+                else:
+                    retval = checker(val)
             elif not isinstance(restype, _CDataMeta):
                 retval = restype(result)
             else:

lib_pypy/_ctypes/primitive.py

             result.value = property(_getvalue, _setvalue)
 
         elif tp == 'X':
-            from ctypes import windll
-            SysAllocStringLen = windll.oleaut32.SysAllocStringLen
-            SysStringLen = windll.oleaut32.SysStringLen
-            SysFreeString = windll.oleaut32.SysFreeString
+            from ctypes import WinDLL
+            # Use WinDLL("oleaut32") instead of windll.oleaut32
+            # because the latter is a shared (cached) object; and
+            # other code may set their own restypes. We need out own
+            # restype here.
+            oleaut32 = WinDLL("oleaut32")
+            SysAllocStringLen = oleaut32.SysAllocStringLen
+            SysStringLen = oleaut32.SysStringLen
+            SysFreeString = oleaut32.SysFreeString
             def _getvalue(self):
                 addr = self._buffer[0]
                 if addr == 0:

lib_pypy/binascii.py

         crc = crc_32_tab[(crc ^ long(ord(c))) & 0xffL] ^ (crc >> 8)
         #/* Note:  (crc >> 8) MUST zero fill on left
 
-        result = crc ^ 0xffffffffL
+    result = crc ^ 0xffffffffL
     
     if result > 2**31:
         result = ((result + 2**31) % 2**32) - 2**31
 
 from ctypes_support import standard_c_lib as libc
 from ctypes import Structure, POINTER, c_int, c_char_p, c_long
+from _structseq import structseqtype, structseqfield
 
 try: from __pypy__ import builtinify
 except ImportError: builtinify = lambda f: f
             yield self.pw_dir
             yield self.pw_shell
 
-class struct_passwd(tuple):
+class struct_passwd:
     """
     pwd.struct_passwd: Results from getpw*() routines.
 
       (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)
     or via the object attributes as named in the above tuple.
     """
-    def __init__(self, passwd):
-        self.pw_name = passwd.pw_name
-        self.pw_passwd = passwd.pw_passwd
-        self.pw_uid = passwd.pw_uid
-        self.pw_gid = passwd.pw_gid
-        self.pw_gecos = passwd.pw_gecos
-        self.pw_dir = passwd.pw_dir
-        self.pw_shell = passwd.pw_shell
-        tuple.__init__(self, passwd)
+    __metaclass__ = structseqtype
+    name = "pwd.struct_passwd"
+    pw_name = structseqfield(0)
+    pw_passwd = structseqfield(1)
+    pw_uid = structseqfield(2)
+    pw_gid = structseqfield(3)
+    pw_gecos = structseqfield(4)
+    pw_dir = structseqfield(5)
+    pw_shell = structseqfield(6)
 
 passwd_p = POINTER(passwd)
 

pypy/annotation/builtin.py

 def llmemory_cast_int_to_adr(s):
     return SomeAddress()
 
-
-##def rarith_ovfcheck(s_obj):
-##    if isinstance(s_obj, SomeInteger) and s_obj.unsigned:
-##        getbookkeeper().warning("ovfcheck on unsigned")
-##    return s_obj
-
-##def rarith_ovfcheck_lshift(s_obj1, s_obj2):
-##    if isinstance(s_obj1, SomeInteger) and s_obj1.unsigned:
-##        getbookkeeper().warning("ovfcheck_lshift with unsigned")
-##    return SomeInteger()
-
 def unicodedata_decimal(s_uchr):
     raise TypeError, "unicodedate.decimal() calls should not happen at interp-level"    
 
         original = getattr(__builtin__, name[8:])
         BUILTIN_ANALYZERS[original] = value
 
-##BUILTIN_ANALYZERS[pypy.rlib.rarithmetic.ovfcheck] = rarith_ovfcheck
-##BUILTIN_ANALYZERS[pypy.rlib.rarithmetic.ovfcheck_lshift] = rarith_ovfcheck_lshift
 BUILTIN_ANALYZERS[pypy.rlib.rarithmetic.intmask] = rarith_intmask
 BUILTIN_ANALYZERS[pypy.rlib.objectmodel.instantiate] = robjmodel_instantiate
 BUILTIN_ANALYZERS[pypy.rlib.objectmodel.we_are_translated] = (

pypy/config/pypyoption.py

                  cmdline='--objspace -o'),
 
     OptionDescription("opcodes", "opcodes to enable in the interpreter", [
-        BoolOption("CALL_LIKELY_BUILTIN", "emit a special bytecode for likely calls to builtin functions",
-                   default=False,
-                   requires=[("translation.stackless", False)]),
         BoolOption("CALL_METHOD", "emit a special bytecode for expr.name()",
                    default=False),
         ]),
         BoolOption("withcelldict",
                    "use dictionaries that are optimized for being used as module dicts",
                    default=False,
-                   requires=[("objspace.opcodes.CALL_LIKELY_BUILTIN", False),
-                             ("objspace.honor__builtins__", False)]),
-
-        BoolOption("withdictmeasurement",
-                   "create huge files with masses of information "
-                   "about dictionaries",
-                   default=False),
+                   requires=[("objspace.honor__builtins__", False)]),
 
         BoolOption("withmapdict",
                    "make instances really small but slow without the JIT",
     backend = config.translation.backend
 
     # all the good optimizations for PyPy should be listed here
-    if level in ['2', '3']:
-        config.objspace.opcodes.suggest(CALL_LIKELY_BUILTIN=True)
     if level in ['2', '3', 'jit']:
         config.objspace.opcodes.suggest(CALL_METHOD=True)
         config.objspace.std.suggest(withrangelist=True)

pypy/doc/config/objspace.opcodes.CALL_LIKELY_BUILTIN.txt

-Introduce a new opcode called ``CALL_LIKELY_BUILTIN``. It is used when something
-is called, that looks like a builtin function (but could in reality be shadowed
-by a name in the module globals). For all module globals dictionaries it is
-then tracked which builtin name is shadowed in this module. If the
-``CALL_LIKELY_BUILTIN`` opcode is executed, it is checked whether the builtin is
-shadowed. If not, the corresponding builtin is called. Otherwise the object that
-is shadowing it is called instead. If no shadowing is happening, this saves two
-dictionary lookups on calls to builtins.
-
-For more information, see the section in `Standard Interpreter Optimizations`_.
-
-.. _`Standard Interpreter Optimizations`: ../interpreter-optimizations.html#call-likely-builtin

pypy/doc/config/objspace.std.withdictmeasurement.txt

-Internal option.
-
-.. internal

pypy/doc/cpython_differences.rst

   その辞書はCPythonにはありません。
   ``__builtins__`` への割り当ては影響がありません。
 
+* object identity of immutable keys in dictionaries is not necessarily preserved.
+  Never compare immutable objects with ``is``.
+
 .. include:: _ref.txt
-

pypy/doc/getting-started.rst

 使用前に
 ==================================
 
-
 .. contents::
 
 .. _howtopypy: 
     an implementation of the Python_ programming language written in
     Python itself.  It is designed to be flexible and easy to experiment with.
 
-普通の言い方ではPYPYは2つの意味を持っています。
-1番目は、動的言語実装を生み出すフレームワークである `RPython translation toolchain`_ です。
-そして2番目は、このように生成された特定の実装( Python_ 自身で書かれたプログラミング言語Python)です。
+通俗的にPyPyは2つの意味を持っています。
+1つめは、動的言語実装を生み出すフレームワークである `RPython translation toolchain`_ です。
+そして2つめは、これによって生成された特定の実装( Python_ 自身で書かれたプログラミング言語Python)です。
 それは柔軟で簡単に実験しやすいように設計されています。
 
 ..
     documents, presentations, papers and videos will still have the old
     usage.  You are hereby warned.
 
-We target a large variety of platforms, small and large, by providing a
-compiler toolsuite that can produce custom Python versions.  Platform, memory
-and threading models, as well as the JIT compiler itself, are aspects of the
-translation process - as opposed to encoding low level details into the
-language implementation itself. `more...`_
+この2つの用法は、混乱をもたらすのは知られています。
+私たちはPyPyという名称をこの2つの意味で使うことからやめる試みをしています。
+これからは、私たちはPyPyという名称をPythonの実装だけに限定して使い、
+フレームワークを `RPython translation toolchain`_ と呼びます。
+いくつかの古い文書、プレゼンテーション、論文、動画はまだ古い用法のままです。
+注意してください。
+
+..
+  We target a large variety of platforms, small and large, by providing a
+  compiler toolsuite that can produce custom Python versions.  Platform, memory
+  and threading models, as well as the JIT compiler itself, are aspects of the
+  translation process - as opposed to encoding low level details into the
+  language implementation itself. `more...`_
+
+私たちはカスタムなPythonバージョンを生成するコンパイラのツール一式を提供することにより、
+小規模および大規模、様々なプラットフォームをターゲットにしています。
+プラットフォーム、メモリとスレッドモデルのみならず、JITコンパイラ自体も翻訳工程の側面です。
+- ということで、言語実装に対する低レベルな詳細情報の変換を認めていません。 `more...`_
 
 .. _Python: http://docs.python.org/reference/
 .. _`RPython translation toolchain`: translation.html
 .. _`more...`: architecture.html
 
-Just the facts 
-============== 
+..
+  Just the facts 
+  ============== 
 
-Download a pre-built PyPy
--------------------------
+もっともな事実
+===============
 
-The quickest way to start using PyPy is to download a prebuilt binary for your
-OS and architecture.  You can either use the `most recent release`_ or one of
-our `development nightly build`_.  Please note that the nightly builds are not
-guaranteed to be as stable as official releases, use them at your own risk.
+..
+  Download a pre-built PyPy
+  -------------------------
+
+プレビルドPyPyのダウンロード
+-----------------------------
+
+..
+  The quickest way to start using PyPy is to download a prebuilt binary for your
+  OS and architecture.  You can either use the `most recent release`_ or one of
+  our `development nightly build`_.  Please note that the nightly builds are not
+  guaranteed to be as stable as official releases, use them at your own risk.
+
+PyPyを使い始める最速な方法は、プレビルドバイナリをあなたのOSとアーキテクチャにダウンロードすることです。
+あなたは `most recent release`_ または、ある特定の `development nightly build`_ のいずれかを使うことができます。
+ナイトリービルドは安定したオフィシャルなリリースとしての保証をしていませんので、あなたの責任でそれらを使用して下さい。
 
 .. _`most recent release`: http://pypy.org/download.html
 .. _`development nightly build`: http://buildbot.pypy.org/nightly/trunk/
 
-Installing PyPy
----------------
+..
+  Installing PyPy
+  ---------------
 
-PyPy is ready to be executed as soon as you unpack the tarball or the zip
-file, with no need install it in any specific location::
+PyPyインストール
+----------------
 
+..
+  PyPy is ready to be executed as soon as you unpack the tarball or the zip
+  file, with no need to install it in any specific location::
+
+PyPyはどのような場所へのインストールであろうとも、すぐにtarballかzipファイルを解凍すると使うことができます::
+  
     $ tar xf pypy-1.5-linux.tar.bz2
 
     $ ./pypy-1.5-linux/bin/pypy
     "turtles all the way down"''
     >>>>
 
-If you want to make PyPy available system-wide, you can put a symlink to the
-``pypy`` executable in ``/usr/local/bin``.  It is important to put a symlink
-and not move the binary there, else PyPy would not be able to find its
-library.
+..
+  If you want to make PyPy available system-wide, you can put a symlink to the
+  ``pypy`` executable in ``/usr/local/bin``.  It is important to put a symlink
+  and not move the binary there, else PyPy would not be able to find its
+  library.
 
-If you want to install 3rd party libraries, the most convenient way is to
-install distribute_ and pip_:
+もしあなたがシステム全体でPyPyを使いたいのであれば、
+あなたは ``pypy`` のシンボリックリンクを ``/usr/local/bin`` に置くことができる。
+重要なこととして、シンボリックリンクを置くとバイナリを移動しないという他に、
+PyPyはPyPyのライブラリを見つけることができません。
+
+..
+  If you want to install 3rd party libraries, the most convenient way is to
+  install distribute_ and pip_:
+
+あなたがサードパーティのライブラリをインストールしたいのであれば、最も便利な方法は、
+distribute_ と pip_ をインストールすることです:
 
     $ curl -O http://python-distribute.org/distribute_setup.py
 
 
     $ ./pypy-1.5-linux/bin/pip install pygments  # for example
 
-3rd party libraries will be installed in ``pypy-1.5-linux/site-packages``, and
-the scripts in ``pypy-1.5-linux/bin``.
+..
+  3rd party libraries will be installed in ``pypy-1.5-linux/site-packages``, and
+  the scripts in ``pypy-1.5-linux/bin``.
 
-Installing using virtualenv
----------------------------
+サードパーティのライブラリは ``pypy-1.5-linux/site-packages`` にインストールされ
+スクリプトは ``pypy-1.5-linux/bin`` にあります。
 
-It is often convenient to run pypy inside a virtualenv.  To do this
-you need a recent version of virtualenv -- 1.6.1 or greater.  You can
-then install PyPy both from a precompiled tarball or from a mercurial
-checkout::
+..
+  Installing using virtualenv
+  ---------------------------
+
+virtualenvを使ったインストール
+------------------------------
+
+..
+  It is often convenient to run pypy inside a virtualenv.  To do this
+  you need a recent version of virtualenv -- 1.6.1 or greater.  You can
+  then install PyPy both from a precompiled tarball or from a mercurial
+  checkout::
+
+多くの場合、virtualenvでPyPyを実行すると便利です。
+これを行うには、virtualenvの最新のバージョンが必要です。 - 1.6.1か、それ以上の。
+あなたはプレコンパイルされたtarball、またはMercurialのチェックアウトからPyPyをインストールできます::
 
 	# from a tarball
 	$ virtualenv -p /opt/pypy-c-jit-41718-3fb486695f20-linux/bin/pypy my-pypy-env
 	# from the mercurial checkout
 	$ virtualenv -p /path/to/pypy/pypy/translator/goal/pypy-c my-pypy-env
 
-Note that bin/python is now a symlink to bin/pypy.
+..
+  Note that bin/python is now a symlink to bin/pypy.
+
+bin/pythonは/bin/pypyへの新たなシンボリックリンクであることに注意してください。
 
 .. _`distribute`: http://www.python-distribute.org/
 .. _`pip`: http://pypi.python.org/pypi/pip
 
 
-Clone the repository
---------------------
+..
+  Clone the repository
+  --------------------
 
-If you prefer to `compile PyPy by yourself`_, or if you want to modify it, you
-will need to obtain a copy of the sources.  This can be done either by
-`downloading them from the download page`_ or by checking them out from the
-repository using mercurial.  We suggest using mercurial if one wants to access
-the current development.
+リポジトリのクーロン
+---------------------
+
+..
+  If you prefer to `compile PyPy by yourself`_, or if you want to modify it, you
+  will need to obtain a copy of the sources.  This can be done either by
+  `downloading them from the download page`_ or by checking them out from the
+  repository using mercurial.  We suggest using mercurial if one wants to access
+  the current development.
+
+あなたが `compile PyPy by yourself`_ 場合、または自ら修正したい場合は、
+ソースをコピーして手に入れる必要があります。
+これは、 `downloading them from the download page`_ または、Mercurialを使ってリポジトリから
+ソースコードをチェックアウトすることによって行うことができます。
+
+現在の開発コードを利用したい場合は、Mercurialを使うことをお勧めします。
 
 .. _`downloading them from the download page`: http://pypy.org/download.html
 
-You must issue the following command on your
-command line, DOS box, or terminal::
+..
+  You must issue the following command on your
+  command line, DOS box, or terminal::
+
+コマンドライン、DOSボックス、ターミナルで次のコマンドを実行する必要があります::
 
     hg clone http://bitbucket.org/pypy/pypy pypy
 
-This will clone the repository and place it into a directory
-named ``pypy``, and will get you the PyPy source in
-``pypy/pypy`` and documentation files in ``pypy/pypy/doc``.
-We try to ensure that the tip is always stable, but it might
-occasionally be broken.  You may want to check out `our nightly tests:`_
-find a revision (12-chars alphanumeric string, e.g. "963e808156b3") 
-that passed at least the
-``{linux32}`` tests (corresponding to a ``+`` sign on the
-line ``success``) and then, in your cloned repository, switch to this revision
-using::
+..
+  This will clone the repository and place it into a directory
+  named ``pypy``, and will get you the PyPy source in
+  ``pypy/pypy`` and documentation files in ``pypy/pypy/doc``.
+  We try to ensure that the tip is always stable, but it might
+  occasionally be broken.  You may want to check out `our nightly tests:`_
+  find a revision (12-chars alphanumeric string, e.g. "963e808156b3") 
+  that passed at least the
+  ``{linux32}`` tests (corresponding to a ``+`` sign on the
+  line ``success``) and then, in your cloned repository, switch to this revision
+  using::
+
+これは、リポジトリをクローンし、 ``pypy`` という名前でディレクトリを配置します。
+またそれと、PyPyソースを ``pypy/pypy`` 、ドキュメントファイルを ``pypy/pypy/doc`` に取得します。
+私たちは、最新のコードが常に安定していることを保証しようとしていますが、
+時々壊れている可能性があります。
+`our nightly tests:`_ はリビジョンを入手しチェックアウトすることができます
+あなたは最新の ``{linux32}`` テストを通った( ``+`` 符号は ``success`` に相当する)
+ `our nightly tests:`_ のリビジョン(英数字の12文字、例: "963e808156b3")を見つけ、
+チェックアウトし入手することができます。
+あとで、複製されたリポジトリで使用してこのリビジョンに切り替えます::
 
     hg up -r XXXXX
 
-where XXXXX is the revision id.
-
+XXXXX はリビジョンIDです。
 
 .. _`compile PyPy by yourself`: getting-started-python.html
 .. _`our nightly tests:`: http://buildbot.pypy.org/summary?branch=<trunk>
 
-Where to go from here
+..
+  Where to go from here
+  ======================
+
+ここから先の話
 ======================
 
-After you successfully manage to get PyPy's source you can read more about:
+..
+  After you successfully manage to get PyPy's source you can read more about:
+
+首尾よくPyPyのソースを取得した後に、詳細を読むことができます。
 
  - `Building and using PyPy's Python interpreter`_
  - `Learning more about the RPython toolchain and how to develop (with) PyPy`_
 
 .. _setuptools: http://pypi.python.org/pypi/setuptools
 
-Understanding PyPy's architecture
+..
+  Understanding PyPy's architecture
+  ---------------------------------
+
+PyPyのアーキテクチャを理解する
 ---------------------------------
 
-For in-depth information about architecture and coding documentation 
-head over to the `documentation section`_ where you'll find lots of 
-interesting information.  Additionally, in true hacker spirit, you 
-may just `start reading sources`_ . 
+..
+  For in-depth information about architecture and coding documentation 
+  head over to the `documentation section`_ where you'll find lots of 
+  interesting information.  Additionally, in true hacker spirit, you 
+  may just `start reading sources`_ . 
+
+
+に上記のアーキテクチャおよび、コーディングマニュアルに関する詳細な情報については、
+`documentation section`_ へ進み興味深い情報を見つけることができます。
+さらに、真のハッカーの精神により、あなたは `start reading sources`_ ことができます。
 
 .. _`documentation section`: index.html#project-documentation
 .. _`start reading sources`: getting-started-dev.html#start-reading-sources
 
-Filing bugs or feature requests 
+..
+  Filing bugs or feature requests 
+  -------------------------------
+
+バグのファイルイングや機能要求
 -------------------------------
 
-You may file `bug reports`_ on our issue tracker which is
-also accessible through the 'issues' top menu of 
-the PyPy website.  `Using the development tracker`_ has 
-more detailed information on specific features of the tracker. 
+..
+  You may file `bug reports`_ on our issue tracker which is
+  also accessible through the 'issues' top menu of 
+  the PyPy website.  `Using the development tracker`_ has 
+  more detailed information on specific features of the tracker. 
+
+PyPyウェブサイトのトップメニューの 'issues' から
+私たちの課題トラッカーにアクセスでき、 `bug reports`_ を提出することができます。
 
 .. _`Using the development tracker`: coding-guide.html#using-development-tracker
 .. _bug reports:            https://codespeak.net/issue/pypy-dev/

pypy/doc/index.rst

     =============================================
 
 PyPyの世界へ...
+=============================================
 
 ..
-   * `Getting started`_: how to install and run the PyPy Python interpreter
+  * `Getting started`_: how to install and run the PyPy Python interpreter
 
-`Getting started`_: インストールとPyPy Pythonインタプリタの実行方法
+* `Getting started`_ : インストールとPyPy Pythonインタプリタの実行方法
 
 ..
-   * `FAQ`_: some frequently asked questions.
+  * `FAQ`_: some frequently asked questions.
 
- * `FAQ`_: 頻繁に聞かれる質問。
+* `FAQ`_ : 頻繁に聞かれる質問。
 
 ..
-   * `Release 1.5`_: the latest official release
+  * `Release 1.5`_: the latest official release
 
- * `Release 1.5`_: 最新の公式リリース
+* `Release 1.5`_: 最新の公式リリース
 
 ..
-   * `PyPy Blog`_: news and status info about PyPy 
+  * `PyPy Blog`_: news and status info about PyPy 
 
- * `PyPy Blog`_: PyPyについてのニュースと状況
+* `PyPy Blog`_: PyPyについてのニュースと状況
 
 ..
-   * `Papers`_: Academic papers, talks, and related projects
+  * `Papers`_: Academic papers, talks, and related projects
 
- * `Papers`_: 学術論文、話題、関連するプロジェクト
+* `Papers`_: 学術論文、話題、関連するプロジェクト
 
 .. 
-   * `Videos`_: Videos of PyPy talks and presentations
+  * `Videos`_: Videos of PyPy talks and presentations
 
- * `Videos`_: PyPyの語りとプレゼンテーションのビデオ
+* `Videos`_: PyPyの語りとプレゼンテーションのビデオ
 
 .. 
-   * `speed.pypy.org`_: Daily benchmarks of how fast PyPy is
+  * `speed.pypy.org`_: Daily benchmarks of how fast PyPy is
 
- * `speed.pypy.org`_: PyPyがどのくらいの速度なのか、毎日のベンチマークです。
+* `speed.pypy.org`_: PyPyがどのくらいの速度なのか、毎日のベンチマークです。
 
 ..
-   * `potential project ideas`_: In case you want to get your feet wet...
+  * `potential project ideas`_: In case you want to get your feet wet...
 
- * `potential project ideas`_: あなたがその世界に飛び込んでみたいなら...
+* `potential project ideas`_: あなたがその世界に飛び込んでみたいなら...
 
 
 ..

pypy/doc/interpreter-optimizations.rst

 A more advanced version of sharing dicts, called *map dicts,* is available
 with the :config:`objspace.std.withmapdict` option.
 
-Builtin-Shadowing
-+++++++++++++++++
-
-Usually the calling of builtins in Python requires two dictionary lookups: first
-to see whether the current global dictionary contains an object with the same
-name, then a lookup in the ``__builtin__`` dictionary. This is somehow
-circumvented by storing an often used builtin into a local variable to get
-the fast local lookup (which is a rather strange and ugly hack).
-
-The same problem is solved in a different way by "wary" dictionaries. They are
-another dictionary representation used together with multidicts. This
-representation is used only for module dictionaries. The representation checks on
-every setitem whether the key that is used is the name of a builtin. If this is
-the case, the dictionary is marked as shadowing that particular builtin.
-
-To identify calls to builtins easily, a new bytecode (``CALL_LIKELY_BUILTIN``)
-is introduced. Whenever it is executed, the globals dictionary is checked
-to see whether it masks the builtin (which is possible without a dictionary
-lookup).  Then the ``__builtin__`` dict is checked in the same way,
-to see whether somebody replaced the real builtin with something else. In the
-common case, the program didn't do any of these; the proper builtin can then
-be called without using any dictionary lookup at all.
-
-You can enable this feature with the
-:config:`objspace.opcodes.CALL_LIKELY_BUILTIN` option.
-
 
 List Optimizations
 ------------------
 You can enable this feature with the :config:`objspace.opcodes.CALL_METHOD`
 option.
 
-.. _`call likely builtin`:
-
-CALL_LIKELY_BUILTIN
-+++++++++++++++++++
-
-A often heard "tip" for speeding up Python programs is to give an often used
-builtin a local name, since local lookups are faster than lookups of builtins,
-which involve doing two dictionary lookups: one in the globals dictionary and
-one in the the builtins dictionary. PyPy approaches this problem at the
-implementation level, with the introduction of the new ``CALL_LIKELY_BUILTIN``
-bytecode. This bytecode is produced by the compiler for a call whose target is
-the name of a builtin.  Since such a syntactic construct is very often actually
-invoking the expected builtin at run-time, this information can be used to make
-the call to the builtin directly, without going through any dictionary lookup.
-
-However, it can occur that the name is shadowed by a global name from the
-current module.  To catch this case, a special dictionary implementation for
-multidicts is introduced, which is used for the dictionaries of modules. This