Issue #2225 duplicate

PyPy3k settrace/_trace messes up scoping

Geoffrey Sneddon
created an issue

With the below:

import sys

class Tracer(object):
    def start(self):
        sys.settrace(self._trace)

    def _trace(self, frame, event, arg_unused):
        return self._trace

tracer = Tracer()
tracer.start()

def getExtraClass():
    def hidden():
        pass

    class ExtraClass():
        def hidden(self):
            return hidden()

    return ExtraClass

extraClass = getExtraClass()
obj = extraClass()
output = obj.hidden()

PyPy3k gives:

Traceback (most recent call last):
  File "html5lib/tests/tree_construction.py", line 25, in <module>
    output = obj.hidden()
  File "html5lib/tests/tree_construction.py", line 19, in hidden
    return hidden()
TypeError: hidden() takes exactly 1 argument (0 given)

CPython 2.7.11, CPython 3.5.1, and PyPy 4.0.1 all manage to run the above code without problem. Only PyPy3k (2.4.0) fails.