# pypy

committed 16ac40b Merge

hg merge default

# lib-python/modified-2.7/heapq.py

`+# -*- coding: latin-1 -*-`
`+`
`+"""Heap queue algorithm (a.k.a. priority queue).`
`+`
`+Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for`
`+all k, counting elements from 0.  For the sake of comparison,`
`+non-existing elements are considered to be infinite.  The interesting`
`+property of a heap is that a[0] is always its smallest element.`
`+`
`+Usage:`
`+`
`+heap = []            # creates an empty heap`
`+heappush(heap, item) # pushes a new item on the heap`
`+item = heappop(heap) # pops the smallest item from the heap`
`+item = heap[0]       # smallest item on the heap without popping it`
`+heapify(x)           # transforms list into a heap, in-place, in linear time`
`+item = heapreplace(heap, item) # pops and returns smallest item, and adds`
`+                               # new item; the heap size is unchanged`
`+`
`+Our API differs from textbook heap algorithms as follows:`
`+`
`+- We use 0-based indexing.  This makes the relationship between the`
`+  index for a node and the indexes for its children slightly less`
`+  obvious, but is more suitable since Python uses 0-based indexing.`
`+`
`+- Our heappop() method returns the smallest item, not the largest.`
`+`
`+These two make it possible to view the heap as a regular Python list`
`+without surprises: heap[0] is the smallest item, and heap.sort()`
`+maintains the heap invariant!`
`+"""`
`+`
`+# Original code by Kevin O'Connor, augmented by Tim Peters and Raymond Hettinger`
`+`
`+__about__ = """Heap queues`
`+`
`+[explanation by Fran�ois Pinard]`
`+`
`+Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for`
`+all k, counting elements from 0.  For the sake of comparison,`
`+non-existing elements are considered to be infinite.  The interesting`
`+property of a heap is that a[0] is always its smallest element.`
`+`
`+The strange invariant above is meant to be an efficient memory`
`+representation for a tournament.  The numbers below are `k', not a[k]:`
`+`
`+                                   0`
`+`
`+                  1                                 2`
`+`
`+          3               4                5               6`
`+`
`+      7       8       9       10      11      12      13      14`
`+`
`+    15 16   17 18   19 20   21 22   23 24   25 26   27 28   29 30`
`+`
`+`
`+In the tree above, each cell `k' is topping `2*k+1' and `2*k+2'.  In`
`+an usual binary tournament we see in sports, each cell is the winner`
`+over the two cells it tops, and we can trace the winner down the tree`
`+to see all opponents s/he had.  However, in many computer applications`
`+of such tournaments, we do not need to trace the history of a winner.`
`+To be more memory efficient, when a winner is promoted, we try to`
`+replace it by something else at a lower level, and the rule becomes`
`+that a cell and the two cells it tops contain three different items,`
`+but the top cell "wins" over the two topped cells.`
`+`
`+If this heap invariant is protected at all time, index 0 is clearly`
`+the overall winner.  The simplest algorithmic way to remove it and`
`+find the "next" winner is to move some loser (let's say cell 30 in the`
`+diagram above) into the 0 position, and then percolate this new 0 down`
`+the tree, exchanging values, until the invariant is re-established.`
`+This is clearly logarithmic on the total number of items in the tree.`
`+By iterating over all items, you get an O(n ln n) sort.`
`+`
`+A nice feature of this sort is that you can efficiently insert new`
`+items while the sort is going on, provided that the inserted items are`
`+not "better" than the last 0'th element you extracted.  This is`
`+especially useful in simulation contexts, where the tree holds all`
`+incoming events, and the "win" condition means the smallest scheduled`
`+time.  When an event schedule other events for execution, they are`
`+scheduled into the future, so they can easily go into the heap.  So, a`
`+heap is a good structure for implementing schedulers (this is what I`
`+used for my MIDI sequencer :-).`
`+`
`+Various structures for implementing schedulers have been extensively`
`+studied, and heaps are good for this, as they are reasonably speedy,`
`+the speed is almost constant, and the worst case is not much different`
`+than the average case.  However, there are other representations which`
`+are more efficient overall, yet the worst cases might be terrible.`
`+`
`+Heaps are also very useful in big disk sorts.  You most probably all`
`+know that a big sort implies producing "runs" (which are pre-sorted`
`+sequences, which size is usually related to the amount of CPU memory),`
`+followed by a merging passes for these runs, which merging is often`
`+very cleverly organised[1].  It is very important that the initial`
`+sort produces the longest runs possible.  Tournaments are a good way`
`+to that.  If, using all the memory available to hold a tournament, you`
`+replace and percolate items that happen to fit the current run, you'll`
`+produce runs which are twice the size of the memory for random input,`
`+and much better for input fuzzily ordered.`
`+`
`+Moreover, if you output the 0'th item on disk and get an input which`
`+may not fit in the current tournament (because the value "wins" over`
`+the last output value), it cannot fit in the heap, so the size of the`
`+heap decreases.  The freed memory could be cleverly reused immediately`
`+for progressively building a second heap, which grows at exactly the`
`+same rate the first heap is melting.  When the first heap completely`
`+vanishes, you switch heaps and start a new run.  Clever and quite`
`+effective!`
`+`
`+In a word, heaps are useful memory structures to know.  I use them in`
`+a few applications, and I think it is good to keep a `heap' module`
`+around. :-)`
`+`
`+--------------------`
`+[1] The disk balancing algorithms which are current, nowadays, are`
`+more annoying than clever, and this is a consequence of the seeking`
`+capabilities of the disks.  On devices which cannot seek, like big`
`+tape drives, the story was quite different, and one had to be very`
`+clever to ensure (far in advance) that each tape movement will be the`
`+most effective possible (that is, will best participate at`
`+"progressing" the merge).  Some tapes were even able to read`
`+backwards, and this was also used to avoid the rewinding time.`
`+Believe me, real good tape sorts were quite spectacular to watch!`
`+From all times, sorting has always been a Great Art! :-)`
`+"""`
`+`
`+__all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge',`
`+           'nlargest', 'nsmallest', 'heappushpop']`
`+`
`+from itertools import islice, repeat, count, imap, izip, tee, chain`
`+from operator import itemgetter`
`+import bisect`
`+`
`+def heappush(heap, item):`
`+    """Push item onto heap, maintaining the heap invariant."""`
`+    heap.append(item)`
`+    _siftdown(heap, 0, len(heap)-1)`
`+`
`+def heappop(heap):`
`+    """Pop the smallest item off the heap, maintaining the heap invariant."""`
`+    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty`
`+    if heap:`
`+        returnitem = heap[0]`
`+        heap[0] = lastelt`
`+        _siftup(heap, 0)`
`+    else:`
`+        returnitem = lastelt`
`+    return returnitem`
`+`
`+def heapreplace(heap, item):`
`+    """Pop and return the current smallest value, and add the new item.`
`+`
`+    This is more efficient than heappop() followed by heappush(), and can be`
`+    more appropriate when using a fixed-size heap.  Note that the value`
`+    returned may be larger than item!  That constrains reasonable uses of`
`+    this routine unless written as part of a conditional replacement:`
`+`
`+        if item > heap[0]:`
`+            item = heapreplace(heap, item)`
`+    """`
`+    returnitem = heap[0]    # raises appropriate IndexError if heap is empty`
`+    heap[0] = item`
`+    _siftup(heap, 0)`
`+    return returnitem`
`+`
`+def heappushpop(heap, item):`
`+    """Fast version of a heappush followed by a heappop."""`
`+    if heap and heap[0] < item:`
`+        item, heap[0] = heap[0], item`
`+        _siftup(heap, 0)`
`+    return item`
`+`
`+def heapify(x):`
`+    """Transform list into a heap, in-place, in O(len(heap)) time."""`
`+    n = len(x)`
`+    # Transform bottom-up.  The largest index there's any point to looking at`
`+    # is the largest with a child index in-range, so must have 2*i + 1 < n,`
`+    # or i < (n-1)/2.  If n is even = 2*j, this is (2*j-1)/2 = j-1/2 so`
`+    # j-1 is the largest, which is n//2 - 1.  If n is odd = 2*j+1, this is`
`+    # (2*j+1-1)/2 = j so j-1 is the largest, and that's again n//2-1.`
`+    for i in reversed(xrange(n//2)):`
`+        _siftup(x, i)`
`+`
`+def nlargest(n, iterable):`
`+    """Find the n largest elements in a dataset.`
`+`
`+    Equivalent to:  sorted(iterable, reverse=True)[:n]`
`+    """`
`+    if n < 0: # for consistency with the c impl`
`+        return []`
`+    it = iter(iterable)`
`+    result = list(islice(it, n))`
`+    if not result:`
`+        return result`
`+    heapify(result)`
`+    _heappushpop = heappushpop`
`+    for elem in it:`
`+        _heappushpop(result, elem)`
`+    result.sort(reverse=True)`
`+    return result`
`+`
`+def nsmallest(n, iterable):`
`+    """Find the n smallest elements in a dataset.`
`+`
`+    Equivalent to:  sorted(iterable)[:n]`
`+    """`
`+    if n < 0: # for consistency with the c impl`
`+        return []`
`+    if hasattr(iterable, '__len__') and n * 10 <= len(iterable):`
`+        # For smaller values of n, the bisect method is faster than a minheap.`
`+        # It is also memory efficient, consuming only n elements of space.`
`+        it = iter(iterable)`
`+        result = sorted(islice(it, 0, n))`
`+        if not result:`
`+            return result`
`+        insort = bisect.insort`
`+        pop = result.pop`
`+        los = result[-1]    # los --> Largest of the nsmallest`
`+        for elem in it:`
`+            if los <= elem:`
`+                continue`
`+            insort(result, elem)`
`+            pop()`
`+            los = result[-1]`
`+        return result`
`+    # An alternative approach manifests the whole iterable in memory but`
`+    # saves comparisons by heapifying all at once.  Also, saves time`
`+    # over bisect.insort() which has O(n) data movement time for every`
`+    # insertion.  Finding the n smallest of an m length iterable requires`
`+    #    O(m) + O(n log m) comparisons.`
`+    h = list(iterable)`
`+    heapify(h)`
`+    return map(heappop, repeat(h, min(n, len(h))))`
`+`
`+# 'heap' is a heap at all indices >= startpos, except possibly for pos.  pos`
`+# is the index of a leaf with a possibly out-of-order value.  Restore the`
`+# heap invariant.`
`+def _siftdown(heap, startpos, pos):`
`+    newitem = heap[pos]`
`+    # Follow the path to the root, moving parents down until finding a place`
`+    # newitem fits.`
`+    while pos > startpos:`
`+        parentpos = (pos - 1) >> 1`
`+        parent = heap[parentpos]`
`+        if newitem < parent:`
`+            heap[pos] = parent`
`+            pos = parentpos`
`+            continue`
`+        break`
`+    heap[pos] = newitem`
`+`
`+# The child indices of heap index pos are already heaps, and we want to make`
`+# a heap at index pos too.  We do this by bubbling the smaller child of`
`+# pos up (and so on with that child's children, etc) until hitting a leaf,`
`+# then using _siftdown to move the oddball originally at index pos into place.`
`+#`
`+# We *could* break out of the loop as soon as we find a pos where newitem <=`
`+# both its children, but turns out that's not a good idea, and despite that`
`+# many books write the algorithm that way.  During a heap pop, the last array`
`+# element is sifted in, and that tends to be large, so that comparing it`
`+# against values starting from the root usually doesn't pay (= usually doesn't`
`+# get us out of the loop early).  See Knuth, Volume 3, where this is`
`+# explained and quantified in an exercise.`
`+#`
`+# Cutting the # of comparisons is important, since these routines have no`
`+# way to extract "the priority" from an array element, so that intelligence`
`+# is likely to be hiding in custom __cmp__ methods, or in array elements`
`+# storing (priority, record) tuples.  Comparisons are thus potentially`
`+# expensive.`
`+#`
`+# On random arrays of length 1000, making this change cut the number of`
`+# comparisons made by heapify() a little, and those made by exhaustive`
`+# heappop() a lot, in accord with theory.  Here are typical results from 3`
`+# runs (3 just to demonstrate how small the variance is):`
`+#`
`+# Compares needed by heapify     Compares needed by 1000 heappops`
`+# --------------------------     --------------------------------`
`+# 1837 cut to 1663               14996 cut to 8680`
`+# 1855 cut to 1659               14966 cut to 8678`
`+# 1847 cut to 1660               15024 cut to 8703`
`+#`
`+# Building the heap by using heappush() 1000 times instead required`
`+# 2198, 2148, and 2219 compares:  heapify() is more efficient, when`
`+# you can use it.`
`+#`
`+# The total compares needed by list.sort() on the same lists were 8627,`
`+# 8627, and 8632 (this should be compared to the sum of heapify() and`
`+# heappop() compares):  list.sort() is (unsurprisingly!) more efficient`
`+# for sorting.`
`+`
`+def _siftup(heap, pos):`
`+    endpos = len(heap)`
`+    startpos = pos`
`+    newitem = heap[pos]`
`+    # Bubble up the smaller child until hitting a leaf.`
`+    childpos = 2*pos + 1    # leftmost child position`
`+    while childpos < endpos:`
`+        # Set childpos to index of smaller child.`
`+        rightpos = childpos + 1`
`+        if rightpos < endpos and not heap[childpos] < heap[rightpos]:`
`+            childpos = rightpos`
`+        # Move the smaller child up.`
`+        heap[pos] = heap[childpos]`
`+        pos = childpos`
`+        childpos = 2*pos + 1`
`+    # The leaf at pos is empty now.  Put newitem there, and bubble it up`
`+    # to its final resting place (by sifting its parents down).`
`+    heap[pos] = newitem`
`+    _siftdown(heap, startpos, pos)`
`+`
`+# If available, use C implementation`
`+try:`
`+    from _heapq import *`
`+except ImportError:`
`+    pass`
`+`
`+def merge(*iterables):`
`+    '''Merge multiple sorted inputs into a single sorted output.`
`+`
`+    Similar to sorted(itertools.chain(*iterables)) but returns a generator,`
`+    does not pull the data into memory all at once, and assumes that each of`
`+    the input streams is already sorted (smallest to largest).`
`+`
`+    >>> list(merge([1,3,5,7], [0,2,4,8], [5,10,15,20], [], [25]))`
`+    [0, 1, 2, 3, 4, 5, 5, 7, 8, 10, 15, 20, 25]`
`+`
`+    '''`
`+    _heappop, _heapreplace, _StopIteration = heappop, heapreplace, StopIteration`
`+`
`+    h = []`
`+    h_append = h.append`
`+    for itnum, it in enumerate(map(iter, iterables)):`
`+        try:`
`+            next = it.next`
`+            h_append([next(), itnum, next])`
`+        except _StopIteration:`
`+            pass`
`+    heapify(h)`
`+`
`+    while 1:`
`+        try:`
`+            while 1:`
`+                v, itnum, next = s = h[0]   # raises IndexError when h is empty`
`+                yield v`
`+                s[0] = next()               # raises StopIteration when exhausted`
`+                _heapreplace(h, s)          # restore heap condition`
`+        except _StopIteration:`
`+            _heappop(h)                     # remove empty iterator`
`+        except IndexError:`
`+            return`
`+`
`+# Extend the implementations of nsmallest and nlargest to use a key= argument`
`+_nsmallest = nsmallest`
`+def nsmallest(n, iterable, key=None):`
`+    """Find the n smallest elements in a dataset.`
`+`
`+    Equivalent to:  sorted(iterable, key=key)[:n]`
`+    """`
`+    # Short-cut for n==1 is to use min() when len(iterable)>0`
`+    if n == 1:`
`+        it = iter(iterable)`
`+        head = list(islice(it, 1))`
`+        if not head:`
`+            return []`
`+        if key is None:`
`+            return [min(chain(head, it))]`
`+        return [min(chain(head, it), key=key)]`
`+`
`+    # When n>=size, it's faster to use sort()`
`+    try:`
`+        size = len(iterable)`
`+    except (TypeError, AttributeError):`
`+        pass`
`+    else:`
`+        if n >= size:`
`+            return sorted(iterable, key=key)[:n]`
`+`
`+    # When key is none, use simpler decoration`
`+    if key is None:`
`+        it = izip(iterable, count())                        # decorate`
`+        result = _nsmallest(n, it)`
`+        return map(itemgetter(0), result)                   # undecorate`
`+`
`+    # General case, slowest method`
`+    in1, in2 = tee(iterable)`
`+    it = izip(imap(key, in1), count(), in2)                 # decorate`
`+    result = _nsmallest(n, it)`
`+    return map(itemgetter(2), result)                       # undecorate`
`+`
`+_nlargest = nlargest`
`+def nlargest(n, iterable, key=None):`
`+    """Find the n largest elements in a dataset.`
`+`
`+    Equivalent to:  sorted(iterable, key=key, reverse=True)[:n]`
`+    """`
`+`
`+    # Short-cut for n==1 is to use max() when len(iterable)>0`
`+    if n == 1:`
`+        it = iter(iterable)`
`+        head = list(islice(it, 1))`
`+        if not head:`
`+            return []`
`+        if key is None:`
`+            return [max(chain(head, it))]`
`+        return [max(chain(head, it), key=key)]`
`+`
`+    # When n>=size, it's faster to use sort()`
`+    try:`
`+        size = len(iterable)`
`+    except (TypeError, AttributeError):`
`+        pass`
`+    else:`
`+        if n >= size:`
`+            return sorted(iterable, key=key, reverse=True)[:n]`
`+`
`+    # When key is none, use simpler decoration`
`+    if key is None:`
`+        it = izip(iterable, count(0,-1))                    # decorate`
`+        result = _nlargest(n, it)`
`+        return map(itemgetter(0), result)                   # undecorate`
`+`
`+    # General case, slowest method`
`+    in1, in2 = tee(iterable)`
`+    it = izip(imap(key, in1), count(0,-1), in2)             # decorate`
`+    result = _nlargest(n, it)`
`+    return map(itemgetter(2), result)                       # undecorate`
`+`
`+if __name__ == "__main__":`
`+    # Simple sanity test`
`+    heap = []`
`+    data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]`
`+    for item in data:`
`+        heappush(heap, item)`
`+    sort = []`
`+    while heap:`
`+        sort.append(heappop(heap))`
`+    print sort`
`+`
`+    import doctest`
`+    doctest.testmod()`

# lib-python/modified-2.7/json/encoder.py

` """`
` import re`
` `
`-try:`
`-    from _json import encode_basestring_ascii as c_encode_basestring_ascii`
`-except ImportError:`
`-    c_encode_basestring_ascii = None`
`-try:`
`-    from _json import make_encoder as c_make_encoder`
`-except ImportError:`
`-    c_make_encoder = None`
`+from __pypy__.builders import StringBuilder, UnicodeBuilder`
` `
` ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]')`
` ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')`
`     '\t': '\\t',`
` }`
` for i in range(0x20):`
`-    ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))`
`-    #ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))`
`+    ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))`
` `
` # Assume this produces an infinity on all machines (probably not guaranteed)`
` INFINITY = float('1e66666')`
`     """`
`     def replace(match):`
`         return ESCAPE_DCT[match.group(0)]`
`-    return '"' + ESCAPE.sub(replace, s) + '"'`
`+    return ESCAPE.sub(replace, s)`
` `
`-`
`-def py_encode_basestring_ascii(s):`
`+def encode_basestring_ascii(s):`
`     """Return an ASCII-only JSON representation of a Python string`
` `
`     """`
`         except KeyError:`
`             n = ord(s)`
`             if n < 0x10000:`
`-                return '\\u{0:04x}'.format(n)`
`-                #return '\\u%04x' % (n,)`
`+                return '\\u%04x' % (n,)`
`             else:`
`                 # surrogate pair`
`                 n -= 0x10000`
`                 s1 = 0xd800 | ((n >> 10) & 0x3ff)`
`                 s2 = 0xdc00 | (n & 0x3ff)`
`-                return '\\u{0:04x}\\u{1:04x}'.format(s1, s2)`
`-                #return '\\u%04x\\u%04x' % (s1, s2)`
`-    return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'`
`-`
`-`
`-encode_basestring_ascii = (`
`-    c_encode_basestring_ascii or py_encode_basestring_ascii)`
`+                return '\\u%04x\\u%04x' % (s1, s2)`
`+    if ESCAPE_ASCII.search(s):`
`+        return str(ESCAPE_ASCII.sub(replace, s))`
`+    return s`
`+py_encode_basestring_ascii = lambda s: '"' + encode_basestring_ascii(s) + '"'`
`+c_encode_basestring_ascii = None`
` `
` class JSONEncoder(object):`
`     """Extensible JSON <http://json.org> encoder for Python data structures.`
` `
`         self.skipkeys = skipkeys`
`         self.ensure_ascii = ensure_ascii`
`+        if ensure_ascii:`
`+            self.encoder = encode_basestring_ascii`
`+        else:`
`+            self.encoder = encode_basestring`
`+        if encoding != 'utf-8':`
`+            orig_encoder = self.encoder`
`+            def encoder(o):`
`+                if isinstance(o, str):`
`+                    o = o.decode(encoding)`
`+                return orig_encoder(o)`
`+            self.encoder = encoder`
`         self.check_circular = check_circular`
`         self.allow_nan = allow_nan`
`         self.sort_keys = sort_keys`
`         '{"foo": ["bar", "baz"]}'`
` `
`         """`
`-        # This is for extremely simple cases and benchmarks.`
`+        if self.check_circular:`
`+            markers = {}`
`+        else:`
`+            markers = None`
`+        if self.ensure_ascii:`
`+            builder = StringBuilder()`
`+        else:`
`+            builder = UnicodeBuilder()`
`+        self._encode(o, markers, builder, 0)`
`+        return builder.build()`
`+`
`+    def _emit_indent(self, builder, _current_indent_level):`
`+        if self.indent is not None:`
`+            _current_indent_level += 1`
`+            newline_indent = '\n' + (' ' * (self.indent *`
`+                                            _current_indent_level))`
`+            separator = self.item_separator + newline_indent`
`+            builder.append(newline_indent)`
`+        else:`
`+            separator = self.item_separator`
`+        return separator, _current_indent_level`
`+`
`+    def _emit_unindent(self, builder, _current_indent_level):`
`+        if self.indent is not None:`
`+            builder.append('\n')`
`+            builder.append(' ' * (self.indent * (_current_indent_level - 1)))`
`+`
`+    def _encode(self, o, markers, builder, _current_indent_level):`
`         if isinstance(o, basestring):`
`-            if isinstance(o, str):`
`-                _encoding = self.encoding`
`-                if (_encoding is not None`
`-                        and not (_encoding == 'utf-8')):`
`-                    o = o.decode(_encoding)`
`-            if self.ensure_ascii:`
`-                return encode_basestring_ascii(o)`
`+            builder.append('"')`
`+            builder.append(self.encoder(o))`
`+            builder.append('"')`
`+        elif o is None:`
`+            builder.append('null')`
`+        elif o is True:`
`+            builder.append('true')`
`+        elif o is False:`
`+            builder.append('false')`
`+        elif isinstance(o, (int, long)):`
`+            builder.append(str(o))`
`+        elif isinstance(o, float):`
`+            builder.append(self._floatstr(o))`
`+        elif isinstance(o, (list, tuple)):`
`+            if not o:`
`+                builder.append('[]')`
`+                return`
`+            self._encode_list(o, markers, builder, _current_indent_level)`
`+        elif isinstance(o, dict):`
`+            if not o:`
`+                builder.append('{}')`
`+                return`
`+            self._encode_dict(o, markers, builder, _current_indent_level)`
`+        else:`
`+            self._mark_markers(markers, o)`
`+            res = self.default(o)`
`+            self._encode(res, markers, builder, _current_indent_level)`
`+            self._remove_markers(markers, o)`
`+            return res`
`+`
`+    def _encode_list(self, l, markers, builder, _current_indent_level):`
`+        self._mark_markers(markers, l)`
`+        builder.append('[')`
`+        first = True`
`+        separator, _current_indent_level = self._emit_indent(builder,`
`+                                                      _current_indent_level)`
`+        for elem in l:`
`+            if first:`
`+                first = False`
`             else:`
`-                return encode_basestring(o)`
`-        # This doesn't pass the iterator directly to ''.join() because the`
`-        # exceptions aren't as detailed.  The list call should be roughly`
`-        # equivalent to the PySequence_Fast that ''.join() would do.`
`-        chunks = self.iterencode(o, _one_shot=True)`
`-        if not isinstance(chunks, (list, tuple)):`
`-            chunks = list(chunks)`
`-        return ''.join(chunks)`
`+                builder.append(separator)`
`+            self._encode(elem, markers, builder, _current_indent_level)`
`+            del elem # XXX grumble`
`+        self._emit_unindent(builder, _current_indent_level)`
`+        builder.append(']')`
`+        self._remove_markers(markers, l)`
`+`
`+    def _encode_dict(self, d, markers, builder, _current_indent_level):`
`+        self._mark_markers(markers, d)`
`+        first = True`
`+        builder.append('{')`
`+        separator, _current_indent_level = self._emit_indent(builder,`
`+                                                         _current_indent_level)`
`+        if self.sort_keys:`
`+            items = sorted(d.items(), key=lambda kv: kv[0])`
`+        else:`
`+            items = d.iteritems()`
`+`
`+        for key, v in items:`
`+            if first:`
`+                first = False`
`+            else:`
`+                builder.append(separator)`
`+            if isinstance(key, basestring):`
`+                pass`
`+            # JavaScript is weakly typed for these, so it makes sense to`
`+            # also allow them.  Many encoders seem to do something like this.`
`+            elif isinstance(key, float):`
`+                key = self._floatstr(key)`
`+            elif key is True:`
`+                key = 'true'`
`+            elif key is False:`
`+                key = 'false'`
`+            elif key is None:`
`+                key = 'null'`
`+            elif isinstance(key, (int, long)):`
`+                key = str(key)`
`+            elif self.skipkeys:`
`+                continue`
`+            else:`
`+                raise TypeError("key " + repr(key) + " is not a string")`
`+            builder.append('"')`
`+            builder.append(self.encoder(key))`
`+            builder.append('"')`
`+            builder.append(self.key_separator)`
`+            self._encode(v, markers, builder, _current_indent_level)`
`+            del key`
`+            del v # XXX grumble`
`+        self._emit_unindent(builder, _current_indent_level)`
`+        builder.append('}')`
`+        self._remove_markers(markers, d)`
` `
`     def iterencode(self, o, _one_shot=False):`
`         """Encode the given object and yield each string`
`             markers = {}`
`         else:`
`             markers = None`
`-        if self.ensure_ascii:`
`-            _encoder = encode_basestring_ascii`
`+        return self._iterencode(o, markers, 0)`
`+`
`+    def _floatstr(self, o):`
`+        # Check for specials.  Note that this type of test is processor`
`+        # and/or platform-specific, so do tests which don't depend on the`
`+        # internals.`
`+`
`+        if o != o:`
`+            text = 'NaN'`
`+        elif o == INFINITY:`
`+            text = 'Infinity'`
`+        elif o == -INFINITY:`
`+            text = '-Infinity'`
`         else:`
`-            _encoder = encode_basestring`
`-        if self.encoding != 'utf-8':`
`-            def _encoder(o, _orig_encoder=_encoder, _encoding=self.encoding):`
`-                if isinstance(o, str):`
`-                    o = o.decode(_encoding)`
`-                return _orig_encoder(o)`
`+            return FLOAT_REPR(o)`
` `
`-        def floatstr(o, allow_nan=self.allow_nan,`
`-                _repr=FLOAT_REPR, _inf=INFINITY, _neginf=-INFINITY):`
`-            # Check for specials.  Note that this type of test is processor`
`-            # and/or platform-specific, so do tests which don't depend on the`
`-            # internals.`
`+        if not self.allow_nan:`
`+            raise ValueError(`
`+                "Out of range float values are not JSON compliant: " +`
`+                repr(o))`
` `
`-            if o != o:`
`-                text = 'NaN'`
`-            elif o == _inf:`
`-                text = 'Infinity'`
`-            elif o == _neginf:`
`-                text = '-Infinity'`
`-            else:`
`-                return _repr(o)`
`+        return text`
` `
`-            if not allow_nan:`
`-                raise ValueError(`
`-                    "Out of range float values are not JSON compliant: " +`
`-                    repr(o))`
`+    def _mark_markers(self, markers, o):`
`+        if markers is not None:`
`+            if id(o) in markers:`
`+                raise ValueError("Circular reference detected")`
`+            markers[id(o)] = None`
` `
`-            return text`
`+    def _remove_markers(self, markers, o):`
`+        if markers is not None:`
`+            del markers[id(o)]`
` `
`-`
`-        if (_one_shot and c_make_encoder is not None`
`-                and not self.indent and not self.sort_keys):`
`-            _iterencode = c_make_encoder(`
`-                markers, self.default, _encoder, self.indent,`
`-                self.key_separator, self.item_separator, self.sort_keys,`
`-                self.skipkeys, self.allow_nan)`
`-        else:`
`-            _iterencode = _make_iterencode(`
`-                markers, self.default, _encoder, self.indent, floatstr,`
`-                self.key_separator, self.item_separator, self.sort_keys,`
`-                self.skipkeys, _one_shot)`
`-        return _iterencode(o, 0)`
`-`
`-def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,`
`-        _key_separator, _item_separator, _sort_keys, _skipkeys, _one_shot,`
`-        ## HACK: hand-optimized bytecode; turn globals into locals`
`-        ValueError=ValueError,`
`-        basestring=basestring,`
`-        dict=dict,`
`-        float=float,`
`-        id=id,`
`-        int=int,`
`-        isinstance=isinstance,`
`-        list=list,`
`-        long=long,`
`-        str=str,`
`-        tuple=tuple,`
`-    ):`
`-`
`-    def _iterencode_list(lst, _current_indent_level):`
`+    def _iterencode_list(self, lst, markers, _current_indent_level):`
`         if not lst:`
`             yield '[]'`
`             return`
`-        if markers is not None:`
`-            markerid = id(lst)`
`-            if markerid in markers:`
`-                raise ValueError("Circular reference detected")`
`-            markers[markerid] = lst`
`+        self._mark_markers(markers, lst)`
`         buf = '['`
`-        if _indent is not None:`
`+        if self.indent is not None:`
`             _current_indent_level += 1`
`-            newline_indent = '\n' + (' ' * (_indent * _current_indent_level))`
`-            separator = _item_separator + newline_indent`
`+            newline_indent = '\n' + (' ' * (self.indent *`
`+                                            _current_indent_level))`
`+            separator = self.item_separator + newline_indent`
`             buf += newline_indent`
`         else:`
`             newline_indent = None`
`-            separator = _item_separator`
`+            separator = self.item_separator`
`         first = True`
`         for value in lst:`
`             if first:`
`             else:`
`                 buf = separator`
`             if isinstance(value, basestring):`
`-                yield buf + _encoder(value)`
`+                yield buf + '"' + self.encoder(value) + '"'`
`             elif value is None:`
`                 yield buf + 'null'`
`             elif value is True:`
`             elif isinstance(value, (int, long)):`
`                 yield buf + str(value)`
`             elif isinstance(value, float):`
`-                yield buf + _floatstr(value)`
`+                yield buf + self._floatstr(value)`
`             else:`
`                 yield buf`
`                 if isinstance(value, (list, tuple)):`
`-                    chunks = _iterencode_list(value, _current_indent_level)`
`+                    chunks = self._iterencode_list(value, markers,`
`+                                                   _current_indent_level)`
`                 elif isinstance(value, dict):`
`-                    chunks = _iterencode_dict(value, _current_indent_level)`
`+                    chunks = self._iterencode_dict(value, markers,`
`+                                                   _current_indent_level)`
`                 else:`
`-                    chunks = _iterencode(value, _current_indent_level)`
`+                    chunks = self._iterencode(value, markers,`
`+                                              _current_indent_level)`
`                 for chunk in chunks:`
`                     yield chunk`
`         if newline_indent is not None:`
`             _current_indent_level -= 1`
`-            yield '\n' + (' ' * (_indent * _current_indent_level))`
`+            yield '\n' + (' ' * (self.indent * _current_indent_level))`
`         yield ']'`
`-        if markers is not None:`
`-            del markers[markerid]`
`+        self._remove_markers(markers, lst)`
` `
`-    def _iterencode_dict(dct, _current_indent_level):`
`+    def _iterencode_dict(self, dct, markers, _current_indent_level):`
`         if not dct:`
`             yield '{}'`
`             return`
`-        if markers is not None:`
`-            markerid = id(dct)`
`-            if markerid in markers:`
`-                raise ValueError("Circular reference detected")`
`-            markers[markerid] = dct`
`+        self._mark_markers(markers, dct)`
`         yield '{'`
`-        if _indent is not None:`
`+        if self.indent is not None:`
`             _current_indent_level += 1`
`-            newline_indent = '\n' + (' ' * (_indent * _current_indent_level))`
`-            item_separator = _item_separator + newline_indent`
`+            newline_indent = '\n' + (' ' * (self.indent *`
`+                                            _current_indent_level))`
`+            item_separator = self.item_separator + newline_indent`
`             yield newline_indent`
`         else:`
`             newline_indent = None`
`-            item_separator = _item_separator`
`+            item_separator = self.item_separator`
`         first = True`
`-        if _sort_keys:`
`+        if self.sort_keys:`
`             items = sorted(dct.items(), key=lambda kv: kv[0])`
`         else:`
`             items = dct.iteritems()`
`             # JavaScript is weakly typed for these, so it makes sense to`
`             # also allow them.  Many encoders seem to do something like this.`
`             elif isinstance(key, float):`
`-                key = _floatstr(key)`
`+                key = self._floatstr(key)`
`             elif key is True:`
`                 key = 'true'`
`             elif key is False:`
`                 key = 'null'`
`             elif isinstance(key, (int, long)):`
`                 key = str(key)`
`-            elif _skipkeys:`
`+            elif self.skipkeys:`
`                 continue`
`             else:`
`                 raise TypeError("key " + repr(key) + " is not a string")`
`                 first = False`
`             else:`
`                 yield item_separator`
`-            yield _encoder(key)`
`-            yield _key_separator`
`+            yield '"' + self.encoder(key) + '"'`
`+            yield self.key_separator`
`             if isinstance(value, basestring):`
`-                yield _encoder(value)`
`+                yield '"' + self.encoder(value) + '"'`
`             elif value is None:`
`                 yield 'null'`
`             elif value is True:`
`             elif isinstance(value, (int, long)):`
`                 yield str(value)`
`             elif isinstance(value, float):`
`-                yield _floatstr(value)`
`+                yield self._floatstr(value)`
`             else:`
`                 if isinstance(value, (list, tuple)):`
`-                    chunks = _iterencode_list(value, _current_indent_level)`
`+                    chunks = self._iterencode_list(value, markers,`
`+                                                   _current_indent_level)`
`                 elif isinstance(value, dict):`
`-                    chunks = _iterencode_dict(value, _current_indent_level)`
`+                    chunks = self._iterencode_dict(value, markers,`
`+                                                   _current_indent_level)`
`                 else:`
`-                    chunks = _iterencode(value, _current_indent_level)`
`+                    chunks = self._iterencode(value, markers,`
`+                                              _current_indent_level)`
`                 for chunk in chunks:`
`                     yield chunk`
`         if newline_indent is not None:`
`             _current_indent_level -= 1`
`-            yield '\n' + (' ' * (_indent * _current_indent_level))`
`+            yield '\n' + (' ' * (self.indent * _current_indent_level))`
`         yield '}'`
`-        if markers is not None:`
`-            del markers[markerid]`
`+        self._remove_markers(markers, dct)`
` `
`-    def _iterencode(o, _current_indent_level):`
`+    def _iterencode(self, o, markers, _current_indent_level):`
`         if isinstance(o, basestring):`
`-            yield _encoder(o)`
`+            yield '"' + self.encoder(o) + '"'`
`         elif o is None:`
`             yield 'null'`
`         elif o is True:`
`         elif isinstance(o, (int, long)):`
`             yield str(o)`
`         elif isinstance(o, float):`
`-            yield _floatstr(o)`
`+            yield self._floatstr(o)`
`         elif isinstance(o, (list, tuple)):`
`-            for chunk in _iterencode_list(o, _current_indent_level):`
`+            for chunk in self._iterencode_list(o, markers,`
`+                                               _current_indent_level):`
`                 yield chunk`
`         elif isinstance(o, dict):`
`-            for chunk in _iterencode_dict(o, _current_indent_level):`
`+            for chunk in self._iterencode_dict(o, markers,`
`+                                               _current_indent_level):`
`                 yield chunk`
`         else:`
`-            if markers is not None:`
`-                markerid = id(o)`
`-                if markerid in markers:`
`-                    raise ValueError("Circular reference detected")`
`-                markers[markerid] = o`
`-            o = _default(o)`
`-            for chunk in _iterencode(o, _current_indent_level):`
`+            self._mark_markers(markers, o)`
`+            obj = self.default(o)`
`+            for chunk in self._iterencode(obj, markers,`
`+                                          _current_indent_level):`
`                 yield chunk`
`-            if markers is not None:`
`-                del markers[markerid]`
`-`
`-    return _iterencode`
`+            self._remove_markers(markers, o)`

# lib-python/modified-2.7/json/tests/test_unicode.py

`         self.assertEqual(type(json.loads(u'["a"]')[0]), unicode)`
`         # Issue 10038.`
`         self.assertEqual(type(json.loads('"foo"')), unicode)`
`+`
`+    def test_encode_not_utf_8(self):`
`+        self.assertEqual(json.dumps('\xb1\xe6', encoding='iso8859-2'),`
`+                         '"\\u0105\\u0107"')`
`+        self.assertEqual(json.dumps(['\xb1\xe6'], encoding='iso8859-2'),`
`+                         '["\\u0105\\u0107"]')`

# lib-python/modified-2.7/test/test_heapq.py

`         self.assertFalse(sys.modules['heapq'] is self.module)`
`         self.assertTrue(hasattr(self.module.heapify, 'func_code'))`
` `
`+    def test_islice_protection(self):`
`+        m = self.module`
`+        self.assertFalse(m.nsmallest(-1, [1]))`
`+        self.assertFalse(m.nlargest(-1, [1]))`
`+`
` `
` class TestHeapC(TestHeap):`
`     module = c_heapq`

# lib-python/modified-2.7/urllib2.py

`         meth_name = protocol+"_response"`
`         for processor in self.process_response.get(protocol, []):`
`             meth = getattr(processor, meth_name)`
`-            try:`
`-                response = meth(req, response)`
`-            except:`
`-                response.close()`
`-                raise`
`+            response = meth(req, response)`
` `
`         return response`
` `

# lib_pypy/_pypy_irc_topic.py

`-"""qvfgbcvna naq hgbcvna punvef`
`-qlfgbcvna naq hgbcvna punvef`
`-V'z fbeel, pbhyq lbh cyrnfr abg nterr jvgu gur png nf jryy?`
`-V'z fbeel, pbhyq lbh cyrnfr abg nterr jvgu gur punve nf jryy?`
`-jr cnffrq gur RH erivrj`
`-cbfg RhebClguba fcevag fgnegf 12.IVV.2007, 10nz`
`-RhebClguba raqrq`
`-n Pyrna Ragrecevfrf cebqhpgvba`
`-npnqrzl vf n pbzcyvpngrq ebyr tnzr`
`-npnqrzvn vf n pbzcyvpngrq ebyr tnzr`
`-jbexvat pbqr vf crn fbhc`
`-abg lbhe snhyg, zber yvxr vg'f n zbivat gnetrg`
`-guvf fragrapr vf snyfr`
`-abguvat vf gehr`
`-Yncfnat Fbhpubat`
`-Oenpunzhgnaqn`
`-fbeel, V'yy grnpu gur pnpghf ubj gb fjvz yngre`
`-Jul fb znal znal znal znal znal ivbyvaf?`
`-Jul fb znal znal znal znal znal bowrpgf?`
`-"eha njnl naq yvir ba n snez" nccebnpu gb fbsgjner qrirybczrag`
`-"va snpg, lbh zvtug xabj zber nobhg gur genafyngvba gbbypunva nsgre znfgrevat eclguba guna fbzr angvir fcrnxre xabjf nobhg uvf zbgure gbathr" - kbeNkNk`
`-"jurer qvq nyy gur ivbyvaf tb?"`
`-- ClCl fgnghf oybt: uggc://zberclcl.oybtfcbg.pbz/`
`-uggc://kxpq.pbz/353/`
`-pnfhnyvgl ivbyngvbaf naq sylvat`
`-wrgmg abpu fpubxbynqvtre`
`-R09 2X @PNN:85?`
`-vs lbh'er gelvat gb oybj hc fghss, jub pnerf?`
`-vs fghss oybjf hc, lbh pner`
`-2008 jvyy or gur lrne bs clcl ba gur qrfxgbc`
`-2008 jvyy or gur lrne bs gur qrfxgbc ba #clcl`
`-2008 jvyy or gur lrne bs gur qrfxgbc ba #clcl, Wnahnel jvyy or gur zbagu bs gur nyc gbcf`
`-lrf, ohg jung'g gur frafr bs 0 < "qhena qhena"`
`-eclguba: flagnk naq frznagvpf bs clguba, fcrrq bs p, erfgevpgvbaf bs wnin naq pbzcvyre reebe zrffntrf nf crargenoyr nf ZHZCF`
`+"""eclguba: flagnk naq frznagvpf bs clguba, fcrrq bs p, erfgevpgvbaf bs wnin naq pbzcvyre reebe zrffntrf nf crargenoyr nf ZHZCF`
` pglcrf unf n fcva bs 1/3`
` ' ' vf n fcnpr gbb`
`-2009 jvyy or gur lrne bs WVG ba gur qrfxgbc`
`-N ynathntr vf n qvnyrpg jvgu na nezl naq anil`
`-gbcvpf ner sbe gur srroyr zvaqrq`
`-2009 vf gur lrne bs ersyrpgvba ba gur qrfxgbc`
`-gur tybor vf bhe cbal, gur pbfzbf bhe erny ubefr`
`-jub nz V naq vs lrf, ubj znal?`
`-cebtenzzvat va orq vf n cresrpgyl svar npgvivgl`
`-zbber'f ynj vf n qeht jvgu gur jbefg pbzr qbja`
`-EClguba: jr hfr vg fb lbh qba'g unir gb`
`-Zbber'f ynj vf n qeht jvgu gur jbefg pbzr qbja. EClguba: haqrpvqrq.`
`-guvatf jvyy or avpr naq fghss`
`-qba'g cbfg yvaxf gb cngragf urer`
`-Abg lbhe hfhny nanylfrf.`
`-Gur Neg bs gur Punaary`
`-Clguba 300`
`-V fhccbfr ZO bs UGZY cre frpbaq vf abg gur hfhny fcrrq zrnfher crbcyr jbhyq rkcrpg sbe n wvg`
`-gur fha arire frgf ba gur ClCl rzcver`
`-ghegyrf ner snfgre guna lbh guvax`
`-cebtenzzvat vf na nrfgrguvp raqrnibhe`
`-P vf tbbq sbe fbzrguvat, whfg abg sbe jevgvat fbsgjner`
`-trezna vf tbbq sbe fbzrguvat, whfg abg sbe jevgvat fbsgjner`
`-trezna vf tbbq sbe artngvbaf, whfg abg sbe jevgvat fbsgjner`
`-# nffreg qvq abg penfu`
`-lbh fubhyq fgneg n cresrpg fbsgjner zbirzrag`
`-lbh fubhyq fgneg n cresrpg punaary gbcvp zbirzrag`
`-guvf vf n cresrpg punaary gbcvp`
`-guvf vf n frys-ersreragvny punaary gbcvp`
`-crrcubcr bcgvzvmngvbaf ner jung n Fhssvpvragyl Fzneg Pbzcvyre hfrf`
`-"crrcubcr" bcgvzvmngvbaf ner jung na bcgvzvfgvp Pbzcvyre hfrf`
`-pubbfr lbhe unpx`
`-gur 'fhcre' xrljbeq vf abg gung uhttnoyr`
`-wlguba cngpurf ner abg rabhtu sbe clcl`
`-- qb lbh xabj oreyva? - nyy bs vg? - jryy, whfg oreyva`
`-- ubj jvyy gur snpg gung gurl ner hfrq va bhe ercy punatr bhe gbcvpf?`
`-- ubj pna vg rire unir jbexrq?`
`-- jurer fubhyq gur unpx or fgberq?`
`-- Vg'f uneq gb fnl rknpgyl jung pbafgvghgrf erfrnepu va gur pbzchgre jbeyq, ohg nf n svefg nccebkvzngvba, vg'f fbsgjner gung qbrfa'g unir hfref.`
`-- Cebtenzzvat vf nyy nobhg xabjvat jura gb obvy gur benatr fcbatr qbaxrl npebff gur cuvyyvcvarf`
`-- Jul fb znal, znal, znal, znal, znal, znal qhpxyvatf?`
`-- ab qrgnvy vf bofpher rabhtu gb abg unir fbzr pbqr qrcraqvat ba vg.`
`-- jung V trarenyyl jnag vf serr fcrrqhcf`
`-- nyy bs ClCl vf kv-dhnyvgl`
`-"lbh pna nyjnlf xvyy -9 be bf._rkvg() vs lbh'er va n uheel"`
`-Ohernhpengf ohvyq npnqrzvp rzcverf juvpu puhea bhg zrnavatyrff fbyhgvbaf gb veeryrinag ceboyrzf.`
`-vg'f abg n unpx, vg'f n jbexnebhaq`
`-ClCl qbrfa'g unir pbcbylinevnqvp qrcraqragyl-zbabzbecurq ulcresyhknqf`
`-ClCl qbrfa'g punatr gur shaqnzragny culfvpf pbafgnagf`
`-Qnapr bs gur Fhtnecyhz Snvel`
`-Wnin vf whfg tbbq rabhtu gb or cenpgvpny, ohg abg tbbq rabhtu gb or hfnoyr.`
`-RhebClguba vf unccravat, qba'g rkcrpg nal dhvpx erfcbafr gvzrf.`
`-"V jbhyq yvxr gb fgnl njnl sebz ernyvgl gura"`
`-"gung'f jul gur 'be' vf ernyyl na 'naq' "`
`-jvgu nyy nccebcevngr pbagrkghnyvfngvbavat`
`-qba'g gevc ba gur cbjre pbeq`
`-vzcyrzragvat YBTB va YBTB: "ghegyrf nyy gur jnl qbja"`
`-gur ohooyrfbeg jbhyq or gur jebat jnl gb tb`
`-gur cevapvcyr bs pbafreingvba bs zrff`
`-gb fnir n gerr, rng n ornire`
`-Qre Ovore znpugf evpugvt: Antg nyyrf xnchgg.`
`-"Nal jbeyqivrj gung vfag jenpxrq ol frys-qbhog naq pbashfvba bire vgf bja vqragvgl vf abg n jbeyqivrj sbe zr." - Fpbgg Nnebafba`
`-jr oryvrir va cnapnxrf, znlor`
`-jr oryvrir va ghegyrf, znlor`
`-jr qrsvavgryl oryvrir va zrgn`
`-gur zngevk unf lbh`
`-"Yvsr vf uneq, gura lbh anc" - n png`
`-Vf Nezva ubzr jura gur havirefr prnfrf gb rkvfg?`
`-Qhrffryqbes fcevag fgnegrq`
`-frys.nobeeg("pnaabg ybnq negvpyrf")`
`-QRAGVFGEL FLZOBY YVTUG IREGVPNY NAQ JNIR`
`-"Gur UUH pnzchf vf n tbbq Dhnxr yriry" - Nezva`
`-"Gur UUH pnzchf jbhyq or n greevoyr dhnxr yriry - lbh'q arire unir n pyhr jurer lbh ner" - zvpunry`
`-N enqvbnpgvir png unf 18 unys-yvirf.`
`-<rfp> : j  [fvtu] <onpxfcnpr> <onpxfcnpr> <pgey>-f`
`-pbybe-pbqrq oyhrf`
`-"Neebtnapr va pbzchgre fpvrapr vf zrnfherq va anab-Qvwxfgenf."`
`-ClCl arrqf n Whfg-va-Gvzr WVG`
`-"Lbh pna'g gvzr geniry whfg ol frggvat lbhe pybpxf jebat"`
`-Gjb guernqf jnyx vagb n one. Gur onexrrcre ybbxf hc naq lryyf, "url, V jnag qba'g nal pbaqvgvbaf enpr yvxr gvzr ynfg!"`
` Clguba 2.k rfg cerfdhr zbeg, ivir Clguba!`
` Clguba 2.k vf abg qrnq`
` Riregvzr fbzrbar nethrf jvgu "Fznyygnyx unf nyjnlf qbar K", vg vf  nyjnlf n tbbq uvag gung fbzrguvat arrqf gb or punatrq snfg. - Znephf Qraxre`
` __kkk__ naq __ekkk__ if bcrengvba fybgf: cnegvpyr dhnaghz fhcrecbfvgvba xvaq bs sha`
` ClCl vf na rkpvgvat grpuabybtl gung yrgf lbh gb jevgr snfg, cbegnoyr, zhygv-cyngsbez vagrecergref jvgu yrff rssbeg`
` Nezva: "Cebybt vf n zrff.", PS: "Ab, vg'f irel pbby!", Nezva: "Vfa'g guvf jung V fnvq?"`
`-<nevtngb> tbbq, grfgf ner hfrshy fbzrgvzrf :-)`
` ClCl vf yvxr nofheq gurngre`
` jr unir ab nagv-vzcbffvoyr fgvpx gung znxrf fher gung nyy lbhe cebtenzf unyg`
` clcl vf n enpr orgjrra crbcyr funivat lnxf naq gur havirefr cebqhpvat zber orneqrq lnxf. Fb sne, gur havirefr vf jvaavat`
` ClCl 1.1.0orgn eryrnfrq: uggc://pbqrfcrnx.arg/clcl/qvfg/clcl/qbp/eryrnfr-1.1.0.ugzy`
` "gurer fubhyq or bar naq bayl bar boivbhf jnl gb qb vg". ClCl inevnag: "gurer pna or A unys-ohttl jnlf gb qb vg"`
` 1.1 svany eryrnfrq: uggc://pbqrfcrnx.arg/clcl/qvfg/clcl/qbp/eryrnfr-1.1.0.ugzy`
`-1.1 svany eryrnfrq | <svwny> nzq64 naq ccp ner bayl ninvynoyr va ragrecevfr irefvba`
`+<svwny> nzq64 naq ccp ner bayl ninvynoyr va ragrecevfr irefvba`
` Vf gurer n clcl gvzr? - vs lbh pna srry vg (?) gura gurer vf`
` <nevtngb> ab, abezny jbex vf fhpu zhpu yrff gvevat guna inpngvbaf`
` <nevtngb> ab, abezny jbex vf fb zhpu yrff gvevat guna inpngvbaf`
`-SVEFG gurl vtaber lbh, gura gurl ynhtu ng lbh, gura gurl svtug lbh, gura lbh jva.`
`+-SVEFG gurl vtaber lbh, gura gurl ynhtu ng lbh, gura gurl svtug lbh, gura lbh jva.-`
` vg'f Fhaqnl, znlor`
` vg'f Fhaqnl, ntnva`
`-"3 + 3 = 8"  Nagb va gur WVG gnyx`
`+"3 + 3 = 8" - Nagb va gur WVG gnyx`
` RPBBC vf unccravat`
` RPBBC vf svavfurq`
` cflpb rngf bar oenva cre vapu bs cebterff`
` "nu, whfg va gvzr qbphzragngvba" (__nc__)`
` ClCl vf abg n erny IZ: ab frtsnhyg unaqyref gb qb gur ener pnfrf`
` lbh pna'g unir obgu pbairavrapr naq fcrrq`
`-gur WVG qbrfa'g jbex ba BF/K (abi'09)`
`-ab fhccbeg sbe BF/K evtug abj! (abi'09)`
` fyvccref urvtug pna or zrnfherq va k86 ertvfgref`
` clcl vf n enpr orgjrra gur vaqhfgel gelvat gb ohvyq znpuvarf jvgu zber naq zber erfbheprf, naq gur clcl qrirybcref gelvat gb rng nyy bs gurz. Fb sne, gur jvaare vf fgvyy hapyrne`
`+"znl pbagnva ahgf naq/be lbhat cbvagref"`
`+vg'f nyy irel fvzcyr, yvxr gur ubyvqnlf`
`+unccl ClCl'f lrne 2010!`
`+fnzhryr fnlf gung jr ybfg n enmbe. fb jr pna'g funir lnxf`
`+"yrg'f abg or bofpher, hayrff jr ernyyl arrq gb"`
`+<nevtngb> (abg guernq-fnsr, ohg jryy, abguvat vf)`
`+clcl unf znal ceboyrzf, ohg rnpu bar unf znal fbyhgvbaf`
`+whfg nabgure vgrz (1.333...) ba bhe erny-ahzorerq gbqb yvfg`
`+ClCl vf Fuveg Bevtnzv erfrnepu`
`+<svwny> nafjrevat n dhrfgvba: "ab -- sbe ng yrnfg bar cbffvoyr vagrecergngvba bs lbhe fragrapr"`
`+eryrnfr 1.2 hcpbzvat`
`+ClCl 1.2 eryrnfrq - uggc://clcl.bet/`
`+AB IPF QVFPHFFVBAF`
`+EClguba vf n svar pnzry unve oehfu`
`+ClCl vf n npghnyyl n ivfhnyvmngvba cebwrpg, jr whfg ohvyq vagrecergref gb unir vagrerfgvat qngn gb ivfhnyvmr`
`+clcl vf yvxr fnhfntrf`
`+naq abj sbe fbzrguvat pbzcyrgryl qvssrerag`
`+n 10gu bs sberire vf 1u45`
`+pbeerpg pbqr qbrfag arrq nal grfgf <qhpx>`
`+cbfgfgehpghenyvfz rgp.`
`+clcl UVG trarengbe`
`+gur arj clcl fcbeg vf gb cnff clcl ohtf nf pclguba ohtf`
`+jr unir zhpu zber vagrecergref guna hfref`
`+ClCl 1.3 njnvgvat eryrnfr`
`+ClCl 1.3 eryrnfrq`
`+vg frrzf gb zr gung bapr lbh frggyr ba na rkrphgvba / bowrpg zbqry naq / be olgrpbqr sbezng, lbh'ir nyernql qrpvqrq jung ynathntrf (jurer gur 'f' frrzf fhcresyhbhf) fhccbeg vf tbvat gb or svefg pynff sbe`
`+"Nyy ceboyrzf va ClCl pna or fbyirq ol nabgure yriry bs vagrecergngvba"`
`+ClCl 1.3 eryrnfrq (jvaqbjf ovanevrf vapyhqrq)`
`+jul qvq lbh thlf unir gb znxr gur ohvygva sbeghar zber vagrerfgvat guna npghny jbex? v whfg pngpurq zlfrys erfgnegvat clcl 20 gvzrf`
`+"jr hfrq gb unir n zrff jvgu na bofpher vagresnpr, abj jr unir zrff urer naq bofpher vagresnpr gurer. cebterff" crqebavf ba n clcl fcevag`
`+"phcf bs pbssrr ner yvxr nanybtvrf va gung V'z znxvat bar evtug abj"`
`+"vg'f nyjnlf hc gb hf, va n jnl be gur bgure"`
`+ClCl vf infg, naq pbagnvaf zhygvghqrf`
`+qravny vf eneryl n tbbq qrohttvat grpuavdhr`
`+"Yrg'f tb." - "Jr pna'g" - "Jul abg?" - "Jr'er jnvgvat sbe n Genafyngvba." - (qrfcnvevatyl) "Nu!"`
`+'gung'f qrsvavgryl n pnfr bs "hu????"'`
`+va gurbel gurer vf gur Ybbc, va cenpgvpr gurer ner oevqtrf`
`+gur uneqqevir - pbafgnag qngn cvytevzntr`
`+ClCl vf n gbby gb xrrc bgurejvfr qnatrebhf zvaqf fnsryl bpphcvrq.`
`+jr ner n trareny senzrjbex ohvyg ba pbafvfgrag nccyvpngvba bs nqubp-arff`
`+gur jnl gb nibvq n jbexnebhaq vf gb vagebqhpr n fgebatre jbexnebhaq fbzrjurer ryfr`
`+pnyyvat gur genafyngvba gbby punva n 'fpevcg' vf xvaq bs bssrafvir`
`+ehaavat clcl-p genafyngr.cl vf n ovg yvxr jngpuvat n guevyyre zbivr, vg pbhyq pbafhzr nyy gur zrzbel ng nal gvzr`
`+ehaavat clcl-p genafyngr.cl vf n ovg yvxr jngpuvat n guevyyre zbivr, vg pbhyq qvr ng nal gvzr orpnhfr bs gur 32-ovg 4TO yvzvg bs ENZ`
`+Qh jvefg rora tranh qnf reervpura, jbena xrvare tynhog`
`+vs fjvgmreynaq jrer jurer terrpr vf (ba vfynaqf) jbhyq gurl nyy or pbaarpgrq ol oevqtrf?`
`+genafyngvat clcl jvgu pclguba vf fbbbbbb fybj`
`+ClCl 1.4 eryrnfrq!`
`+Jr ner abg urebrf, whfg irel cngvrag.`
`+QBAR zrnaf vg'f qbar`
`+jul gurer vf ab "ClCl 1.4 eryrnfrq" va gbcvp nal zber?`
`+fabj! fabj!`
`+svanyyl, zrephevny zvtengvba vf unccravat!`
`+Gur zvtengvba gb zrephevny vf pbzcyrgrq! uggc://ovgohpxrg.bet/clcl/clcl`
`+fabj! fabj! (gre)`
`+unccl arj lrne`
`+naq anaanaw gb lbh nf jryy`
`+Frrvat nf gur ynjf bs culfvpf ner ntnvafg lbh, lbh unir gb pnershyyl pbafvqre lbhe fpbcr fb gung lbhe tbnyf ner ernfbanoyr.`
`+nf hfhny va clcl, gur fbyhgvba nccrnef pbzcyrgryl qvfcebcbegvbangr gb gur ceboyrz naq vafgrnq jr'yy tb sbe n pbzcyrgryl qvssrerag fvzcyre nccebnpu gb gur bevtvany ceboyrz`
`+fabj, fabj!`
`+va clcl lbh ner nyjnlf ng gur jebat yriry, va bar jnl be gur bgure`
`+jryy, vg'f jebat ohg abg fb "irel jebat" nf vg ybbxrq`
`+<svwny> V ybir clcl`
`+ynmvarff vzcngvrapr naq uhoevf`
`+fabj, fabj`
`+EClguba: guvatf lbh jbhyqa'g qb va Clguba, naq pna'g qb va P.`
`+vg vf gur rkcrpgrq orunivbe, rkprcg jura lbh qba'g rkcrpg vg`
`+erqrsvavat lryybj frrzf yvxr n orggre vqrn`
`+"gung'f ubjrire whfg ratvarrevat" (svwny)`
`+"[vg] whfg fubjf ntnva gung eclguba vf bofpher" (psobym)`
`+"naljnl, clguba vf n infg ynathntr" (svwny)`
`+bhg-bs-yvr-thneqf`
`+"gurer ner qnlf ba juvpu lbh ybbx nebhaq naq abguvat fubhyq unir rire jbexrq" (svwny)`
`+clcl vf n orggre xvaq bs sbbyvfuarff - ynp`
`+ehaavat grfgf vf rffragvny sbe qrirybcvat clcl -- hu? qvq V oernx gur grfg? (svwny)`
`+V'ir tbg guvf sybbe jnk gung'f nyfb n TERNG qrffreg gbccvat!!`
`+rknexha: "gur cneg gung V gubhtug jnf tbvat gb or uneq jnf gevivny, fb abj V whfg unir guvf cneg gung V qvqa'g rira guvax bs gung vf uneq"`
`+V fhccbfr jr pna yvir jvgu gur bofphevgl, nf ybat nf gurer vf n pbzzrag znxvat vg yvtugre`
`+V nz n ovt oryvrire va ernfbaf. ohg gur nccnerag xvaq ner zl snibevgr.`
`+clcl: trg n WVG sbe serr (jryy gur svefg qnl lbh jba'g znantr naq vg jvyy or irel sehfgengvat)`
`+<Nyrk_Tnlabe> thgjbegu: bu, jr fubhyq znxr gur WVG zntvpnyyl orggre, jvgu qrpbengbef naq fghss`
`+vg'f n pbzcyrgr unpx, ohg n irel zvavzny bar (nevtngb)`
`+svefg gurl ynhtu ng lbh, gura gurl vtaber lbh, gura gurl svtug lbh, gura lbh jva`
`+ClCl vf snzvyl sevraqyl`
`+jr yvxr pbzcynvagf`
`+gbqnl jr'er snfgre guna lrfgreqnl (hfhnyyl)`
`+ClCl naq PClguba: gurl ner zbegny rarzvrf vagrag ba xvyyvat rnpu bgure`
`+nethnoyl, rirelguvat vf n avpur`
`+clcl unf ynlref yvxr bavbaf: crryvat gurz onpx jvyy znxr lbh pel`
`+EClguba zntvpnyyl znxrf lbh evpu naq snzbhf (fnlf fb ba gur gva)`
`+Vf evtbobg nebhaq jura gur havirefr prnfrf gb rkvfg?`
`+ClCl vf gbb pbby sbe dhrelfgevatf.`
`+< nevtngb> gura jung bpphef? < svwny> tbbq fghss V oryvrir`
`+ClCl 1.6 eryrnfrq!`
`+<psobym> jurer ner gur grfgf?`
`+uggc://gjvgcvp.pbz/52nr8s`
`+N enaqbz dhbgr`
`+Nyy rkprcgoybpxf frrz fnar.`
`+N cvax tyvggrel ebgngvat ynzoqn`
`+"vg'f yvxryl grzcbenel hagvy sberire" nevtb`
` """`
` `
` def some_topic():`

`         return ''.join(chars)`
` `
`     def _histline(self, line):`
`-        return unicode(line.rstrip('\n'), ENCODING)`
`+        line = line.rstrip('\n')`
`+        try:`
`+            return unicode(line, ENCODING)`
`+        except UnicodeDecodeError:   # bah, silently fall back...`
`+            return unicode(line, 'utf-8')`
` `
`     def get_history_length(self):`
`         return self.saved_history_length`
`         f = open(os.path.expanduser(filename), 'w')`
`         for entry in history:`
`             if isinstance(entry, unicode):`
`-                entry = entry.encode(ENCODING)`
`+                try:`
`+                    entry = entry.encode(ENCODING)`
`+                except UnicodeEncodeError:   # bah, silently fall back...`
`+                    entry = entry.encode('utf-8')`
`             entry = entry.replace('\n', '\r\n')   # multiline history support`
`             f.write(entry + '\n')`
`         f.close()`
Add a comment to this file

# pypy/annotation/builtin.py

File contents unchanged.

# pypy/config/pypyoption.py

` `
` module_import_dependencies = {`
`     # no _rawffi if importing pypy.rlib.clibffi raises ImportError`
`-    # or CompilationError`
`+    # or CompilationError or py.test.skip.Exception`
`     "_rawffi"   : ["pypy.rlib.clibffi"],`
`     "_ffi"      : ["pypy.rlib.clibffi"],`
` `
`             try:`
`                 for name in modlist:`
`                     __import__(name)`
`-            except (ImportError, CompilationError), e:`
`+            except (ImportError, CompilationError, py.test.skip.Exception), e:`
`                 errcls = e.__class__.__name__`
`                 config.add_warning(`
`                     "The module %r is disabled\n" % (modname,) +`

# pypy/doc/project-ideas.rst

` projects, or anything else in PyPy, pop up on IRC or write to us on the`
` `mailing list`_.`
` `
`+Make big integers faster`
`+-------------------------`
`+`
`+PyPy's implementation of the Python ``long`` type is slower than CPython's.`
`+Find out why and optimize them.`
`+`
` Numpy improvements`
` ------------------`
` `

# pypy/interpreter/astcompiler/ast.py

` from pypy.interpreter.baseobjspace import Wrappable`
` from pypy.interpreter import typedef`
` from pypy.interpreter.gateway import interp2app`
`-from pypy.interpreter.error import OperationError`
`+from pypy.interpreter.error import OperationError, operationerrfmt`
` from pypy.rlib.unroll import unrolling_iterable`
` from pypy.tool.pairtype import extendabletype`
` from pypy.tool.sourcetools import func_with_new_name`
` def Module_get_body(space, w_self):`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
` def Interactive_get_body(space, w_self):`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     return space.wrap(w_self.body)`
` `
` def Expression_set_body(space, w_self, w_new_value):`
` def Suite_get_body(space, w_self):`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
`             return w_obj`
`     if not w_self.initialization_state & w_self._lineno_mask:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'lineno'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')`
`     return space.wrap(w_self.lineno)`
` `
` def stmt_set_lineno(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & w_self._col_offset_mask:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'col_offset'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')`
`     return space.wrap(w_self.col_offset)`
` `
` def stmt_set_col_offset(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'name'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')`
`     return space.wrap(w_self.name)`
` `
` def FunctionDef_set_name(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'args'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')`
`     return space.wrap(w_self.args)`
` `
` def FunctionDef_set_args(space, w_self, w_new_value):`
` def FunctionDef_get_body(space, w_self):`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
` def FunctionDef_get_decorator_list(space, w_self):`
`     if not w_self.initialization_state & 8:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'decorator_list'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')`
`     if w_self.w_decorator_list is None:`
`         if w_self.decorator_list is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.decorator_list]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_decorator_list = w_list`
`     return w_self.w_decorator_list`
` `
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'name'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')`
`     return space.wrap(w_self.name)`
` `
` def ClassDef_set_name(space, w_self, w_new_value):`
` def ClassDef_get_bases(space, w_self):`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'bases'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'bases')`
`     if w_self.w_bases is None:`
`         if w_self.bases is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.bases]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_bases = w_list`
`     return w_self.w_bases`
` `
` def ClassDef_get_body(space, w_self):`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
` def ClassDef_get_decorator_list(space, w_self):`
`     if not w_self.initialization_state & 8:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'decorator_list'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')`
`     if w_self.w_decorator_list is None:`
`         if w_self.decorator_list is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.decorator_list]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_decorator_list = w_list`
`     return w_self.w_decorator_list`
` `
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')`
`     return space.wrap(w_self.value)`
` `
` def Return_set_value(space, w_self, w_new_value):`
` def Delete_get_targets(space, w_self):`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'targets'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')`
`     if w_self.w_targets is None:`
`         if w_self.targets is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.targets]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_targets = w_list`
`     return w_self.w_targets`
` `
` def Assign_get_targets(space, w_self):`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'targets'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')`
`     if w_self.w_targets is None:`
`         if w_self.targets is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.targets]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_targets = w_list`
`     return w_self.w_targets`
` `
`             return w_obj`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')`
`     return space.wrap(w_self.value)`
` `
` def Assign_set_value(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'target'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')`
`     return space.wrap(w_self.target)`
` `
` def AugAssign_set_target(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'op'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')`
`     return operator_to_class[w_self.op - 1]()`
` `
` def AugAssign_set_op(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')`
`     return space.wrap(w_self.value)`
` `
` def AugAssign_set_value(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'dest'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'dest')`
`     return space.wrap(w_self.dest)`
` `
` def Print_set_dest(space, w_self, w_new_value):`
` def Print_get_values(space, w_self):`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'values'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')`
`     if w_self.w_values is None:`
`         if w_self.values is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.values]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_values = w_list`
`     return w_self.w_values`
` `
`             return w_obj`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'nl'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'nl')`
`     return space.wrap(w_self.nl)`
` `
` def Print_set_nl(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'target'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')`
`     return space.wrap(w_self.target)`
` `
` def For_set_target(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'iter'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'iter')`
`     return space.wrap(w_self.iter)`
` `
` def For_set_iter(space, w_self, w_new_value):`
` def For_get_body(space, w_self):`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
` def For_get_orelse(space, w_self):`
`     if not w_self.initialization_state & 8:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')`
`     if w_self.w_orelse is None:`
`         if w_self.orelse is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.orelse]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_orelse = w_list`
`     return w_self.w_orelse`
` `
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'test'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')`
`     return space.wrap(w_self.test)`
` `
` def While_set_test(space, w_self, w_new_value):`
` def While_get_body(space, w_self):`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
` def While_get_orelse(space, w_self):`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')`
`     if w_self.w_orelse is None:`
`         if w_self.orelse is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.orelse]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_orelse = w_list`
`     return w_self.w_orelse`
` `
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'test'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')`
`     return space.wrap(w_self.test)`
` `
` def If_set_test(space, w_self, w_new_value):`
` def If_get_body(space, w_self):`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
` def If_get_orelse(space, w_self):`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')`
`     if w_self.w_orelse is None:`
`         if w_self.orelse is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.orelse]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_orelse = w_list`
`     return w_self.w_orelse`
` `
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'context_expr'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'context_expr')`
`     return space.wrap(w_self.context_expr)`
` `
` def With_set_context_expr(space, w_self, w_new_value):`
`             return w_obj`
`     if not w_self.initialization_state & 2:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'optional_vars'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'optional_vars')`
`     return space.wrap(w_self.optional_vars)`
` `
` def With_set_optional_vars(space, w_self, w_new_value):`
` def With_get_body(space, w_self):`
`     if not w_self.initialization_state & 4:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')`
`     if w_self.w_body is None:`
`         if w_self.body is None:`
`-            w_list = space.newlist([])`
`+            list_w = []`
`         else:`
`             list_w = [space.wrap(node) for node in w_self.body]`
`-            w_list = space.newlist(list_w)`
`+        w_list = space.newlist(list_w)`
`         w_self.w_body = w_list`
`     return w_self.w_body`
` `
`             return w_obj`
`     if not w_self.initialization_state & 1:`
`         typename = space.type(w_self).getname(space)`
`-        w_err = space.wrap("'%s' object has no attribute 'type'" % typename)`
`-        raise OperationError(space.w_AttributeError, w_err)`
`+        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'type')`
`     return space.wrap(w_self.type)`