'Check for allowed op code in the calling frame'

def _is_allowed(self, frame):

    allowed = [dis.opmap['STORE_ATTR'], dis.opmap['LOAD_CONST'], dis.opmap.get('STOP_CODE', 0)]
    bytecode = frame.f_code.co_code
    instruction = bytecode[(frame.f_lasti + 3)]
    instruction = (ord(instruction) if PY2 else instruction)
    return (instruction in allowed)
