file_path
stringlengths
21
207
content
stringlengths
5
1.02M
size
int64
5
1.02M
lang
stringclasses
9 values
avg_line_length
float64
1.33
100
max_line_length
int64
4
993
alphanum_fraction
float64
0.27
0.93
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/pydev_run_in_console.py
''' Entry point module to run a file in the interactive console. ''' import os import sys import traceback from pydevconsole import InterpreterInterface, process_exec_queue, start_console_server, init_mpl_in_console from _pydev_bundle._pydev_saved_modules import threading, _queue from _pydev_bundle import pydev_imports from _pydevd_bundle.pydevd_utils import save_main_module from _pydev_bundle.pydev_console_utils import StdIn from pydevd_file_utils import get_fullname def run_file(file, globals=None, locals=None, is_module=False): module_name = None entry_point_fn = None if is_module: file, _, entry_point_fn = file.partition(':') module_name = file filename = get_fullname(file) if filename is None: sys.stderr.write("No module named %s\n" % file) return else: file = filename if os.path.isdir(file): new_target = os.path.join(file, '__main__.py') if os.path.isfile(new_target): file = new_target if globals is None: m = save_main_module(file, 'pydev_run_in_console') globals = m.__dict__ try: globals['__builtins__'] = __builtins__ except NameError: pass # Not there on Jython... if locals is None: locals = globals if not is_module: sys.path.insert(0, os.path.split(file)[0]) print('Running %s' % file) try: if not is_module: pydev_imports.execfile(file, globals, locals) # execute the script else: # treat ':' as a seperator between module and entry point function # if there is no entry point we run we same as with -m switch. Otherwise we perform # an import and execute the entry point if entry_point_fn: mod = __import__(module_name, level=0, fromlist=[entry_point_fn], globals=globals, locals=locals) func = getattr(mod, entry_point_fn) func() else: # Run with the -m switch from _pydevd_bundle import pydevd_runpy pydevd_runpy._run_module_as_main(module_name) except: traceback.print_exc() return globals def skip_successful_exit(*args): """ System exit in file shouldn't kill interpreter (i.e. in `timeit`)""" if len(args) == 1 and args[0] in (0, None): pass else: raise SystemExit(*args) def process_args(argv): setup_args = {'file': '', 'module': False} setup_args['port'] = argv[1] del argv[1] setup_args['client_port'] = argv[1] del argv[1] module_flag = "--module" if module_flag in argv: i = argv.index(module_flag) if i != -1: setup_args['module'] = True setup_args['file'] = argv[i + 1] del sys.argv[i] else: setup_args['file'] = argv[1] del argv[0] return setup_args #======================================================================================================================= # main #======================================================================================================================= if __name__ == '__main__': setup = process_args(sys.argv) port = setup['port'] client_port = setup['client_port'] file = setup['file'] is_module = setup['module'] from _pydev_bundle import pydev_localhost if int(port) == 0 and int(client_port) == 0: (h, p) = pydev_localhost.get_socket_name() client_port = p host = pydev_localhost.get_localhost() # replace exit (see comments on method) # note that this does not work in jython!!! (sys method can't be replaced). sys.exit = skip_successful_exit connect_status_queue = _queue.Queue() interpreter = InterpreterInterface(host, int(client_port), threading.current_thread(), connect_status_queue=connect_status_queue) server_thread = threading.Thread(target=start_console_server, name='ServerThread', args=(host, int(port), interpreter)) server_thread.daemon = True server_thread.start() sys.stdin = StdIn(interpreter, host, client_port, sys.stdin) init_mpl_in_console(interpreter) try: success = connect_status_queue.get(True, 60) if not success: raise ValueError() except: sys.stderr.write("Console server didn't start\n") sys.stderr.flush() sys.exit(1) globals = run_file(file, None, None, is_module) interpreter.get_namespace().update(globals) interpreter.ShowConsole() process_exec_queue(interpreter)
4,709
Python
29.584415
133
0.568061
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/pydev_coverage.py
''' Entry point module to run code-coverage. ''' def is_valid_py_file(path): ''' Checks whether the file can be read by the coverage module. This is especially needed for .pyx files and .py files with syntax errors. ''' import os is_valid = False if os.path.isfile(path) and not os.path.splitext(path)[1] == '.pyx': try: with open(path, 'rb') as f: compile(f.read(), path, 'exec') is_valid = True except: pass return is_valid def execute(): import os import sys files = None if 'combine' not in sys.argv: if '--pydev-analyze' in sys.argv: # Ok, what we want here is having the files passed through stdin (because # there may be too many files for passing in the command line -- we could # just pass a dir and make the find files here, but as that's already # given in the java side, let's just gather that info here). sys.argv.remove('--pydev-analyze') s = input() s = s.replace('\r', '') s = s.replace('\n', '') files = [] invalid_files = [] for v in s.split('|'): if is_valid_py_file(v): files.append(v) else: invalid_files.append(v) if invalid_files: sys.stderr.write('Invalid files not passed to coverage: %s\n' % ', '.join(invalid_files)) # Note that in this case we'll already be in the working dir with the coverage files, # so, the coverage file location is not passed. else: # For all commands, the coverage file is configured in pydev, and passed as the first # argument in the command line, so, let's make sure this gets to the coverage module. os.environ['COVERAGE_FILE'] = sys.argv[1] del sys.argv[1] try: import coverage # @UnresolvedImport except: sys.stderr.write('Error: coverage module could not be imported\n') sys.stderr.write('Please make sure that the coverage module ' '(http://nedbatchelder.com/code/coverage/)\n') sys.stderr.write('is properly installed in your interpreter: %s\n' % (sys.executable,)) import traceback;traceback.print_exc() return if hasattr(coverage, '__version__'): version = tuple(map(int, coverage.__version__.split('.')[:2])) if version < (4, 3): sys.stderr.write('Error: minimum supported coverage version is 4.3.' '\nFound: %s\nLocation: %s\n' % ('.'.join(str(x) for x in version), coverage.__file__)) sys.exit(1) else: sys.stderr.write('Warning: Could not determine version of python module coverage.' '\nEnsure coverage version is >= 4.3\n') from coverage.cmdline import main # @UnresolvedImport if files is not None: sys.argv.append('xml') sys.argv += files main() if __name__ == '__main__': execute()
3,200
Python
32.694736
97
0.545312
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_parallel.py
import unittest from _pydev_bundle._pydev_saved_modules import thread import queue as Queue from _pydev_runfiles import pydev_runfiles_xml_rpc import time import os import threading import sys #======================================================================================================================= # flatten_test_suite #======================================================================================================================= def flatten_test_suite(test_suite, ret): if isinstance(test_suite, unittest.TestSuite): for t in test_suite._tests: flatten_test_suite(t, ret) elif isinstance(test_suite, unittest.TestCase): ret.append(test_suite) #======================================================================================================================= # execute_tests_in_parallel #======================================================================================================================= def execute_tests_in_parallel(tests, jobs, split, verbosity, coverage_files, coverage_include): ''' @param tests: list(PydevTestSuite) A list with the suites to be run @param split: str Either 'module' or the number of tests that should be run in each batch @param coverage_files: list(file) A list with the files that should be used for giving coverage information (if empty, coverage information should not be gathered). @param coverage_include: str The pattern that should be included in the coverage. @return: bool Returns True if the tests were actually executed in parallel. If the tests were not executed because only 1 should be used (e.g.: 2 jobs were requested for running 1 test), False will be returned and no tests will be run. It may also return False if in debug mode (in which case, multi-processes are not accepted) ''' try: from _pydevd_bundle.pydevd_comm import get_global_debugger if get_global_debugger() is not None: return False except: pass # Ignore any error here. # This queue will receive the tests to be run. Each entry in a queue is a list with the tests to be run together When # split == 'tests', each list will have a single element, when split == 'module', each list will have all the tests # from a given module. tests_queue = [] queue_elements = [] if split == 'module': module_to_tests = {} for test in tests: lst = [] flatten_test_suite(test, lst) for test in lst: key = (test.__pydev_pyfile__, test.__pydev_module_name__) module_to_tests.setdefault(key, []).append(test) for key, tests in module_to_tests.items(): queue_elements.append(tests) if len(queue_elements) < jobs: # Don't create jobs we will never use. jobs = len(queue_elements) elif split == 'tests': for test in tests: lst = [] flatten_test_suite(test, lst) for test in lst: queue_elements.append([test]) if len(queue_elements) < jobs: # Don't create jobs we will never use. jobs = len(queue_elements) else: raise AssertionError('Do not know how to handle: %s' % (split,)) for test_cases in queue_elements: test_queue_elements = [] for test_case in test_cases: try: test_name = test_case.__class__.__name__ + "." + test_case._testMethodName except AttributeError: # Support for jython 2.1 (__testMethodName is pseudo-private in the test case) test_name = test_case.__class__.__name__ + "." + test_case._TestCase__testMethodName test_queue_elements.append(test_case.__pydev_pyfile__ + '|' + test_name) tests_queue.append(test_queue_elements) if jobs < 2: return False sys.stdout.write('Running tests in parallel with: %s jobs.\n' % (jobs,)) queue = Queue.Queue() for item in tests_queue: queue.put(item, block=False) providers = [] clients = [] for i in range(jobs): test_cases_provider = CommunicationThread(queue) providers.append(test_cases_provider) test_cases_provider.start() port = test_cases_provider.port if coverage_files: clients.append(ClientThread(i, port, verbosity, coverage_files.pop(0), coverage_include)) else: clients.append(ClientThread(i, port, verbosity)) for client in clients: client.start() client_alive = True while client_alive: client_alive = False for client in clients: # Wait for all the clients to exit. if not client.finished: client_alive = True time.sleep(.2) break for provider in providers: provider.shutdown() return True #======================================================================================================================= # CommunicationThread #======================================================================================================================= class CommunicationThread(threading.Thread): def __init__(self, tests_queue): threading.Thread.__init__(self) self.daemon = True self.queue = tests_queue self.finished = False from _pydev_bundle.pydev_imports import SimpleXMLRPCServer from _pydev_bundle import pydev_localhost # Create server server = SimpleXMLRPCServer((pydev_localhost.get_localhost(), 0), logRequests=False) server.register_function(self.GetTestsToRun) server.register_function(self.notifyStartTest) server.register_function(self.notifyTest) server.register_function(self.notifyCommands) self.port = server.socket.getsockname()[1] self.server = server def GetTestsToRun(self, job_id): ''' @param job_id: @return: list(str) Each entry is a string in the format: filename|Test.testName ''' try: ret = self.queue.get(block=False) return ret except: # Any exception getting from the queue (empty or not) means we finished our work on providing the tests. self.finished = True return [] def notifyCommands(self, job_id, commands): # Batch notification. for command in commands: getattr(self, command[0])(job_id, *command[1], **command[2]) return True def notifyStartTest(self, job_id, *args, **kwargs): pydev_runfiles_xml_rpc.notifyStartTest(*args, **kwargs) return True def notifyTest(self, job_id, *args, **kwargs): pydev_runfiles_xml_rpc.notifyTest(*args, **kwargs) return True def shutdown(self): if hasattr(self.server, 'shutdown'): self.server.shutdown() else: self._shutdown = True def run(self): if hasattr(self.server, 'shutdown'): self.server.serve_forever() else: self._shutdown = False while not self._shutdown: self.server.handle_request() #======================================================================================================================= # Client #======================================================================================================================= class ClientThread(threading.Thread): def __init__(self, job_id, port, verbosity, coverage_output_file=None, coverage_include=None): threading.Thread.__init__(self) self.daemon = True self.port = port self.job_id = job_id self.verbosity = verbosity self.finished = False self.coverage_output_file = coverage_output_file self.coverage_include = coverage_include def _reader_thread(self, pipe, target): while True: target.write(pipe.read(1)) def run(self): try: from _pydev_runfiles import pydev_runfiles_parallel_client # TODO: Support Jython: # # For jython, instead of using sys.executable, we should use: # r'D:\bin\jdk_1_5_09\bin\java.exe', # '-classpath', # 'D:/bin/jython-2.2.1/jython.jar', # 'org.python.util.jython', args = [ sys.executable, pydev_runfiles_parallel_client.__file__, str(self.job_id), str(self.port), str(self.verbosity), ] if self.coverage_output_file and self.coverage_include: args.append(self.coverage_output_file) args.append(self.coverage_include) import subprocess if False: proc = subprocess.Popen(args, env=os.environ, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) thread.start_new_thread(self._reader_thread, (proc.stdout, sys.stdout)) thread.start_new_thread(target=self._reader_thread, args=(proc.stderr, sys.stderr)) else: proc = subprocess.Popen(args, env=os.environ, shell=False) proc.wait() finally: self.finished = True
9,472
Python
34.347015
122
0.537162
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_xml_rpc.py
import sys import threading import traceback import warnings from _pydev_bundle._pydev_filesystem_encoding import getfilesystemencoding from _pydev_bundle.pydev_imports import xmlrpclib, _queue from _pydevd_bundle.pydevd_constants import Null Queue = _queue.Queue # This may happen in IronPython (in Python it shouldn't happen as there are # 'fast' replacements that are used in xmlrpclib.py) warnings.filterwarnings( 'ignore', 'The xmllib module is obsolete.*', DeprecationWarning) file_system_encoding = getfilesystemencoding() #======================================================================================================================= # _ServerHolder #======================================================================================================================= class _ServerHolder: ''' Helper so that we don't have to use a global here. ''' SERVER = None #======================================================================================================================= # set_server #======================================================================================================================= def set_server(server): _ServerHolder.SERVER = server #======================================================================================================================= # ParallelNotification #======================================================================================================================= class ParallelNotification(object): def __init__(self, method, args): self.method = method self.args = args def to_tuple(self): return self.method, self.args #======================================================================================================================= # KillServer #======================================================================================================================= class KillServer(object): pass #======================================================================================================================= # ServerFacade #======================================================================================================================= class ServerFacade(object): def __init__(self, notifications_queue): self.notifications_queue = notifications_queue def notifyTestsCollected(self, *args): self.notifications_queue.put_nowait(ParallelNotification('notifyTestsCollected', args)) def notifyConnected(self, *args): self.notifications_queue.put_nowait(ParallelNotification('notifyConnected', args)) def notifyTestRunFinished(self, *args): self.notifications_queue.put_nowait(ParallelNotification('notifyTestRunFinished', args)) def notifyStartTest(self, *args): self.notifications_queue.put_nowait(ParallelNotification('notifyStartTest', args)) def notifyTest(self, *args): new_args = [] for arg in args: new_args.append(_encode_if_needed(arg)) args = tuple(new_args) self.notifications_queue.put_nowait(ParallelNotification('notifyTest', args)) #======================================================================================================================= # ServerComm #======================================================================================================================= class ServerComm(threading.Thread): def __init__(self, notifications_queue, port, daemon=False): threading.Thread.__init__(self) self.setDaemon(daemon) # If False, wait for all the notifications to be passed before exiting! self.finished = False self.notifications_queue = notifications_queue from _pydev_bundle import pydev_localhost # It is necessary to specify an encoding, that matches # the encoding of all bytes-strings passed into an # XMLRPC call: "All 8-bit strings in the data structure are assumed to use the # packet encoding. Unicode strings are automatically converted, # where necessary." # Byte strings most likely come from file names. encoding = file_system_encoding if encoding == "mbcs": # Windos symbolic name for the system encoding CP_ACP. # We need to convert it into a encoding that is recognized by Java. # Unfortunately this is not always possible. You could use # GetCPInfoEx and get a name similar to "windows-1251". Then # you need a table to translate on a best effort basis. Much to complicated. # ISO-8859-1 is good enough. encoding = "ISO-8859-1" self.server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), port), encoding=encoding) def run(self): while True: kill_found = False commands = [] command = self.notifications_queue.get(block=True) if isinstance(command, KillServer): kill_found = True else: assert isinstance(command, ParallelNotification) commands.append(command.to_tuple()) try: while True: command = self.notifications_queue.get(block=False) # No block to create a batch. if isinstance(command, KillServer): kill_found = True else: assert isinstance(command, ParallelNotification) commands.append(command.to_tuple()) except: pass # That's OK, we're getting it until it becomes empty so that we notify multiple at once. if commands: try: self.server.notifyCommands(commands) except: traceback.print_exc() if kill_found: self.finished = True return #======================================================================================================================= # initialize_server #======================================================================================================================= def initialize_server(port, daemon=False): if _ServerHolder.SERVER is None: if port is not None: notifications_queue = Queue() _ServerHolder.SERVER = ServerFacade(notifications_queue) _ServerHolder.SERVER_COMM = ServerComm(notifications_queue, port, daemon) _ServerHolder.SERVER_COMM.start() else: # Create a null server, so that we keep the interface even without any connection. _ServerHolder.SERVER = Null() _ServerHolder.SERVER_COMM = Null() try: _ServerHolder.SERVER.notifyConnected() except: traceback.print_exc() #======================================================================================================================= # notifyTest #======================================================================================================================= def notifyTestsCollected(tests_count): assert tests_count is not None try: _ServerHolder.SERVER.notifyTestsCollected(tests_count) except: traceback.print_exc() #======================================================================================================================= # notifyStartTest #======================================================================================================================= def notifyStartTest(file, test): ''' @param file: the tests file (c:/temp/test.py) @param test: the test ran (i.e.: TestCase.test1) ''' assert file is not None if test is None: test = '' # Could happen if we have an import error importing module. try: _ServerHolder.SERVER.notifyStartTest(file, test) except: traceback.print_exc() def _encode_if_needed(obj): # In the java side we expect strings to be ISO-8859-1 (org.python.pydev.debug.pyunit.PyUnitServer.initializeDispatches().new Dispatch() {...}.getAsStr(Object)) if isinstance(obj, str): # Unicode in py3 return xmlrpclib.Binary(obj.encode('ISO-8859-1', 'xmlcharrefreplace')) elif isinstance(obj, bytes): try: return xmlrpclib.Binary(obj.decode(sys.stdin.encoding).encode('ISO-8859-1', 'xmlcharrefreplace')) except: return xmlrpclib.Binary(obj) # bytes already return obj #======================================================================================================================= # notifyTest #======================================================================================================================= def notifyTest(cond, captured_output, error_contents, file, test, time): ''' @param cond: ok, fail, error @param captured_output: output captured from stdout @param captured_output: output captured from stderr @param file: the tests file (c:/temp/test.py) @param test: the test ran (i.e.: TestCase.test1) @param time: float with the number of seconds elapsed ''' assert cond is not None assert captured_output is not None assert error_contents is not None assert file is not None if test is None: test = '' # Could happen if we have an import error importing module. assert time is not None try: captured_output = _encode_if_needed(captured_output) error_contents = _encode_if_needed(error_contents) _ServerHolder.SERVER.notifyTest(cond, captured_output, error_contents, file, test, time) except: traceback.print_exc() #======================================================================================================================= # notifyTestRunFinished #======================================================================================================================= def notifyTestRunFinished(total_time): assert total_time is not None try: _ServerHolder.SERVER.notifyTestRunFinished(total_time) except: traceback.print_exc() #======================================================================================================================= # force_server_kill #======================================================================================================================= def force_server_kill(): _ServerHolder.SERVER_COMM.notifications_queue.put_nowait(KillServer())
10,594
Python
40.065891
163
0.46885
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles.py
from __future__ import nested_scopes import fnmatch import os.path from _pydev_runfiles.pydev_runfiles_coverage import start_coverage_support from _pydevd_bundle.pydevd_constants import * # @UnusedWildImport import re import time #======================================================================================================================= # Configuration #======================================================================================================================= class Configuration: def __init__( self, files_or_dirs='', verbosity=2, include_tests=None, tests=None, port=None, files_to_tests=None, jobs=1, split_jobs='tests', coverage_output_dir=None, coverage_include=None, coverage_output_file=None, exclude_files=None, exclude_tests=None, include_files=None, django=False, ): self.files_or_dirs = files_or_dirs self.verbosity = verbosity self.include_tests = include_tests self.tests = tests self.port = port self.files_to_tests = files_to_tests self.jobs = jobs self.split_jobs = split_jobs self.django = django if include_tests: assert isinstance(include_tests, (list, tuple)) if exclude_files: assert isinstance(exclude_files, (list, tuple)) if exclude_tests: assert isinstance(exclude_tests, (list, tuple)) self.exclude_files = exclude_files self.include_files = include_files self.exclude_tests = exclude_tests self.coverage_output_dir = coverage_output_dir self.coverage_include = coverage_include self.coverage_output_file = coverage_output_file def __str__(self): return '''Configuration - files_or_dirs: %s - verbosity: %s - tests: %s - port: %s - files_to_tests: %s - jobs: %s - split_jobs: %s - include_files: %s - include_tests: %s - exclude_files: %s - exclude_tests: %s - coverage_output_dir: %s - coverage_include_dir: %s - coverage_output_file: %s - django: %s ''' % ( self.files_or_dirs, self.verbosity, self.tests, self.port, self.files_to_tests, self.jobs, self.split_jobs, self.include_files, self.include_tests, self.exclude_files, self.exclude_tests, self.coverage_output_dir, self.coverage_include, self.coverage_output_file, self.django, ) #======================================================================================================================= # parse_cmdline #======================================================================================================================= def parse_cmdline(argv=None): """ Parses command line and returns test directories, verbosity, test filter and test suites usage: runfiles.py -v|--verbosity <level> -t|--tests <Test.test1,Test2> dirs|files Multiprocessing options: jobs=number (with the number of jobs to be used to run the tests) split_jobs='module'|'tests' if == module, a given job will always receive all the tests from a module if == tests, the tests will be split independently of their originating module (default) --exclude_files = comma-separated list of patterns with files to exclude (fnmatch style) --include_files = comma-separated list of patterns with files to include (fnmatch style) --exclude_tests = comma-separated list of patterns with test names to exclude (fnmatch style) Note: if --tests is given, --exclude_files, --include_files and --exclude_tests are ignored! """ if argv is None: argv = sys.argv verbosity = 2 include_tests = None tests = None port = None jobs = 1 split_jobs = 'tests' files_to_tests = {} coverage_output_dir = None coverage_include = None exclude_files = None exclude_tests = None include_files = None django = False from _pydev_bundle._pydev_getopt import gnu_getopt optlist, dirs = gnu_getopt( argv[1:], "", [ "verbosity=", "tests=", "port=", "config_file=", "jobs=", "split_jobs=", "include_tests=", "include_files=", "exclude_files=", "exclude_tests=", "coverage_output_dir=", "coverage_include=", "django=" ] ) for opt, value in optlist: if opt in ("-v", "--verbosity"): verbosity = value elif opt in ("-p", "--port"): port = int(value) elif opt in ("-j", "--jobs"): jobs = int(value) elif opt in ("-s", "--split_jobs"): split_jobs = value if split_jobs not in ('module', 'tests'): raise AssertionError('Expected split to be either "module" or "tests". Was :%s' % (split_jobs,)) elif opt in ("-d", "--coverage_output_dir",): coverage_output_dir = value.strip() elif opt in ("-i", "--coverage_include",): coverage_include = value.strip() elif opt in ("-I", "--include_tests"): include_tests = value.split(',') elif opt in ("-E", "--exclude_files"): exclude_files = value.split(',') elif opt in ("-F", "--include_files"): include_files = value.split(',') elif opt in ("-e", "--exclude_tests"): exclude_tests = value.split(',') elif opt in ("-t", "--tests"): tests = value.split(',') elif opt in ("--django",): django = value.strip() in ['true', 'True', '1'] elif opt in ("-c", "--config_file"): config_file = value.strip() if os.path.exists(config_file): f = open(config_file, 'r') try: config_file_contents = f.read() finally: f.close() if config_file_contents: config_file_contents = config_file_contents.strip() if config_file_contents: for line in config_file_contents.splitlines(): file_and_test = line.split('|') if len(file_and_test) == 2: file, test = file_and_test if file in files_to_tests: files_to_tests[file].append(test) else: files_to_tests[file] = [test] else: sys.stderr.write('Could not find config file: %s\n' % (config_file,)) if type([]) != type(dirs): dirs = [dirs] ret_dirs = [] for d in dirs: if '|' in d: # paths may come from the ide separated by | ret_dirs.extend(d.split('|')) else: ret_dirs.append(d) verbosity = int(verbosity) if tests: if verbosity > 4: sys.stdout.write('--tests provided. Ignoring --exclude_files, --exclude_tests and --include_files\n') exclude_files = exclude_tests = include_files = None config = Configuration( ret_dirs, verbosity, include_tests, tests, port, files_to_tests, jobs, split_jobs, coverage_output_dir, coverage_include, exclude_files=exclude_files, exclude_tests=exclude_tests, include_files=include_files, django=django, ) if verbosity > 5: sys.stdout.write(str(config) + '\n') return config #======================================================================================================================= # PydevTestRunner #======================================================================================================================= class PydevTestRunner(object): """ finds and runs a file or directory of files as a unit test """ __py_extensions = ["*.py", "*.pyw"] __exclude_files = ["__init__.*"] # Just to check that only this attributes will be written to this file __slots__ = [ 'verbosity', # Always used 'files_to_tests', # If this one is given, the ones below are not used 'files_or_dirs', # Files or directories received in the command line 'include_tests', # The filter used to collect the tests 'tests', # Strings with the tests to be run 'jobs', # Integer with the number of jobs that should be used to run the test cases 'split_jobs', # String with 'tests' or 'module' (how should the jobs be split) 'configuration', 'coverage', ] def __init__(self, configuration): self.verbosity = configuration.verbosity self.jobs = configuration.jobs self.split_jobs = configuration.split_jobs files_to_tests = configuration.files_to_tests if files_to_tests: self.files_to_tests = files_to_tests self.files_or_dirs = list(files_to_tests.keys()) self.tests = None else: self.files_to_tests = {} self.files_or_dirs = configuration.files_or_dirs self.tests = configuration.tests self.configuration = configuration self.__adjust_path() def __adjust_path(self): """ add the current file or directory to the python path """ path_to_append = None for n in range(len(self.files_or_dirs)): dir_name = self.__unixify(self.files_or_dirs[n]) if os.path.isdir(dir_name): if not dir_name.endswith("/"): self.files_or_dirs[n] = dir_name + "/" path_to_append = os.path.normpath(dir_name) elif os.path.isfile(dir_name): path_to_append = os.path.dirname(dir_name) else: if not os.path.exists(dir_name): block_line = '*' * 120 sys.stderr.write('\n%s\n* PyDev test runner error: %s does not exist.\n%s\n' % (block_line, dir_name, block_line)) return msg = ("unknown type. \n%s\nshould be file or a directory.\n" % (dir_name)) raise RuntimeError(msg) if path_to_append is not None: # Add it as the last one (so, first things are resolved against the default dirs and # if none resolves, then we try a relative import). sys.path.append(path_to_append) def __is_valid_py_file(self, fname): """ tests that a particular file contains the proper file extension and is not in the list of files to exclude """ is_valid_fname = 0 for invalid_fname in self.__class__.__exclude_files: is_valid_fname += int(not fnmatch.fnmatch(fname, invalid_fname)) if_valid_ext = 0 for ext in self.__class__.__py_extensions: if_valid_ext += int(fnmatch.fnmatch(fname, ext)) return is_valid_fname > 0 and if_valid_ext > 0 def __unixify(self, s): """ stupid windows. converts the backslash to forwardslash for consistency """ return os.path.normpath(s).replace(os.sep, "/") def __importify(self, s, dir=False): """ turns directory separators into dots and removes the ".py*" extension so the string can be used as import statement """ if not dir: dirname, fname = os.path.split(s) if fname.count('.') > 1: # if there's a file named xxx.xx.py, it is not a valid module, so, let's not load it... return imp_stmt_pieces = [dirname.replace("\\", "/").replace("/", "."), os.path.splitext(fname)[0]] if len(imp_stmt_pieces[0]) == 0: imp_stmt_pieces = imp_stmt_pieces[1:] return ".".join(imp_stmt_pieces) else: # handle dir return s.replace("\\", "/").replace("/", ".") def __add_files(self, pyfiles, root, files): """ if files match, appends them to pyfiles. used by os.path.walk fcn """ for fname in files: if self.__is_valid_py_file(fname): name_without_base_dir = self.__unixify(os.path.join(root, fname)) pyfiles.append(name_without_base_dir) def find_import_files(self): """ return a list of files to import """ if self.files_to_tests: pyfiles = self.files_to_tests.keys() else: pyfiles = [] for base_dir in self.files_or_dirs: if os.path.isdir(base_dir): for root, dirs, files in os.walk(base_dir): # Note: handling directories that should be excluded from the search because # they don't have __init__.py exclude = {} for d in dirs: for init in ['__init__.py', '__init__.pyo', '__init__.pyc', '__init__.pyw', '__init__$py.class']: if os.path.exists(os.path.join(root, d, init).replace('\\', '/')): break else: exclude[d] = 1 if exclude: new = [] for d in dirs: if d not in exclude: new.append(d) dirs[:] = new self.__add_files(pyfiles, root, files) elif os.path.isfile(base_dir): pyfiles.append(base_dir) if self.configuration.exclude_files or self.configuration.include_files: ret = [] for f in pyfiles: add = True basename = os.path.basename(f) if self.configuration.include_files: add = False for pat in self.configuration.include_files: if fnmatch.fnmatchcase(basename, pat): add = True break if not add: if self.verbosity > 3: sys.stdout.write('Skipped file: %s (did not match any include_files pattern: %s)\n' % (f, self.configuration.include_files)) elif self.configuration.exclude_files: for pat in self.configuration.exclude_files: if fnmatch.fnmatchcase(basename, pat): if self.verbosity > 3: sys.stdout.write('Skipped file: %s (matched exclude_files pattern: %s)\n' % (f, pat)) elif self.verbosity > 2: sys.stdout.write('Skipped file: %s\n' % (f,)) add = False break if add: if self.verbosity > 3: sys.stdout.write('Adding file: %s for test discovery.\n' % (f,)) ret.append(f) pyfiles = ret return pyfiles def __get_module_from_str(self, modname, print_exception, pyfile): """ Import the module in the given import path. * Returns the "final" module, so importing "coilib40.subject.visu" returns the "visu" module, not the "coilib40" as returned by __import__ """ try: mod = __import__(modname) for part in modname.split('.')[1:]: mod = getattr(mod, part) return mod except: if print_exception: from _pydev_runfiles import pydev_runfiles_xml_rpc from _pydevd_bundle import pydevd_io buf_err = pydevd_io.start_redirect(keep_original_redirection=True, std='stderr') buf_out = pydevd_io.start_redirect(keep_original_redirection=True, std='stdout') try: import traceback;traceback.print_exc() sys.stderr.write('ERROR: Module: %s could not be imported (file: %s).\n' % (modname, pyfile)) finally: pydevd_io.end_redirect('stderr') pydevd_io.end_redirect('stdout') pydev_runfiles_xml_rpc.notifyTest( 'error', buf_out.getvalue(), buf_err.getvalue(), pyfile, modname, 0) return None def remove_duplicates_keeping_order(self, seq): seen = set() seen_add = seen.add return [x for x in seq if not (x in seen or seen_add(x))] def find_modules_from_files(self, pyfiles): """ returns a list of modules given a list of files """ # let's make sure that the paths we want are in the pythonpath... imports = [(s, self.__importify(s)) for s in pyfiles] sys_path = [os.path.normpath(path) for path in sys.path] sys_path = self.remove_duplicates_keeping_order(sys_path) system_paths = [] for s in sys_path: system_paths.append(self.__importify(s, True)) ret = [] for pyfile, imp in imports: if imp is None: continue # can happen if a file is not a valid module choices = [] for s in system_paths: if imp.startswith(s): add = imp[len(s) + 1:] if add: choices.append(add) # sys.stdout.write(' ' + add + ' ') if not choices: sys.stdout.write('PYTHONPATH not found for file: %s\n' % imp) else: for i, import_str in enumerate(choices): print_exception = i == len(choices) - 1 mod = self.__get_module_from_str(import_str, print_exception, pyfile) if mod is not None: ret.append((pyfile, mod, import_str)) break return ret #=================================================================================================================== # GetTestCaseNames #=================================================================================================================== class GetTestCaseNames: """Yes, we need a class for that (cannot use outer context on jython 2.1)""" def __init__(self, accepted_classes, accepted_methods): self.accepted_classes = accepted_classes self.accepted_methods = accepted_methods def __call__(self, testCaseClass): """Return a sorted sequence of method names found within testCaseClass""" testFnNames = [] className = testCaseClass.__name__ if className in self.accepted_classes: for attrname in dir(testCaseClass): # If a class is chosen, we select all the 'test' methods' if attrname.startswith('test') and hasattr(getattr(testCaseClass, attrname), '__call__'): testFnNames.append(attrname) else: for attrname in dir(testCaseClass): # If we have the class+method name, we must do a full check and have an exact match. if className + '.' + attrname in self.accepted_methods: if hasattr(getattr(testCaseClass, attrname), '__call__'): testFnNames.append(attrname) # sorted() is not available in jython 2.1 testFnNames.sort() return testFnNames def _decorate_test_suite(self, suite, pyfile, module_name): import unittest if isinstance(suite, unittest.TestSuite): add = False suite.__pydev_pyfile__ = pyfile suite.__pydev_module_name__ = module_name for t in suite._tests: t.__pydev_pyfile__ = pyfile t.__pydev_module_name__ = module_name if self._decorate_test_suite(t, pyfile, module_name): add = True return add elif isinstance(suite, unittest.TestCase): return True else: return False def find_tests_from_modules(self, file_and_modules_and_module_name): """ returns the unittests given a list of modules """ # Use our own suite! from _pydev_runfiles import pydev_runfiles_unittest import unittest unittest.TestLoader.suiteClass = pydev_runfiles_unittest.PydevTestSuite loader = unittest.TestLoader() ret = [] if self.files_to_tests: for pyfile, m, module_name in file_and_modules_and_module_name: accepted_classes = {} accepted_methods = {} tests = self.files_to_tests[pyfile] for t in tests: accepted_methods[t] = t loader.getTestCaseNames = self.GetTestCaseNames(accepted_classes, accepted_methods) suite = loader.loadTestsFromModule(m) if self._decorate_test_suite(suite, pyfile, module_name): ret.append(suite) return ret if self.tests: accepted_classes = {} accepted_methods = {} for t in self.tests: splitted = t.split('.') if len(splitted) == 1: accepted_classes[t] = t elif len(splitted) == 2: accepted_methods[t] = t loader.getTestCaseNames = self.GetTestCaseNames(accepted_classes, accepted_methods) for pyfile, m, module_name in file_and_modules_and_module_name: suite = loader.loadTestsFromModule(m) if self._decorate_test_suite(suite, pyfile, module_name): ret.append(suite) return ret def filter_tests(self, test_objs, internal_call=False): """ based on a filter name, only return those tests that have the test case names that match """ import unittest if not internal_call: if not self.configuration.include_tests and not self.tests and not self.configuration.exclude_tests: # No need to filter if we have nothing to filter! return test_objs if self.verbosity > 1: if self.configuration.include_tests: sys.stdout.write('Tests to include: %s\n' % (self.configuration.include_tests,)) if self.tests: sys.stdout.write('Tests to run: %s\n' % (self.tests,)) if self.configuration.exclude_tests: sys.stdout.write('Tests to exclude: %s\n' % (self.configuration.exclude_tests,)) test_suite = [] for test_obj in test_objs: if isinstance(test_obj, unittest.TestSuite): # Note: keep the suites as they are and just 'fix' the tests (so, don't use the iter_tests). if test_obj._tests: test_obj._tests = self.filter_tests(test_obj._tests, True) if test_obj._tests: # Only add the suite if we still have tests there. test_suite.append(test_obj) elif isinstance(test_obj, unittest.TestCase): try: testMethodName = test_obj._TestCase__testMethodName except AttributeError: # changed in python 2.5 testMethodName = test_obj._testMethodName add = True if self.configuration.exclude_tests: for pat in self.configuration.exclude_tests: if fnmatch.fnmatchcase(testMethodName, pat): if self.verbosity > 3: sys.stdout.write('Skipped test: %s (matched exclude_tests pattern: %s)\n' % (testMethodName, pat)) elif self.verbosity > 2: sys.stdout.write('Skipped test: %s\n' % (testMethodName,)) add = False break if add: if self.__match_tests(self.tests, test_obj, testMethodName): include = True if self.configuration.include_tests: include = False for pat in self.configuration.include_tests: if fnmatch.fnmatchcase(testMethodName, pat): include = True break if include: test_suite.append(test_obj) else: if self.verbosity > 3: sys.stdout.write('Skipped test: %s (did not match any include_tests pattern %s)\n' % ( testMethodName, self.configuration.include_tests,)) return test_suite def iter_tests(self, test_objs): # Note: not using yield because of Jython 2.1. import unittest tests = [] for test_obj in test_objs: if isinstance(test_obj, unittest.TestSuite): tests.extend(self.iter_tests(test_obj._tests)) elif isinstance(test_obj, unittest.TestCase): tests.append(test_obj) return tests def list_test_names(self, test_objs): names = [] for tc in self.iter_tests(test_objs): try: testMethodName = tc._TestCase__testMethodName except AttributeError: # changed in python 2.5 testMethodName = tc._testMethodName names.append(testMethodName) return names def __match_tests(self, tests, test_case, test_method_name): if not tests: return 1 for t in tests: class_and_method = t.split('.') if len(class_and_method) == 1: # only class name if class_and_method[0] == test_case.__class__.__name__: return 1 elif len(class_and_method) == 2: if class_and_method[0] == test_case.__class__.__name__ and class_and_method[1] == test_method_name: return 1 return 0 def __match(self, filter_list, name): """ returns whether a test name matches the test filter """ if filter_list is None: return 1 for f in filter_list: if re.match(f, name): return 1 return 0 def run_tests(self, handle_coverage=True): """ runs all tests """ sys.stdout.write("Finding files... ") files = self.find_import_files() if self.verbosity > 3: sys.stdout.write('%s ... done.\n' % (self.files_or_dirs)) else: sys.stdout.write('done.\n') sys.stdout.write("Importing test modules ... ") if handle_coverage: coverage_files, coverage = start_coverage_support(self.configuration) file_and_modules_and_module_name = self.find_modules_from_files(files) sys.stdout.write("done.\n") all_tests = self.find_tests_from_modules(file_and_modules_and_module_name) all_tests = self.filter_tests(all_tests) from _pydev_runfiles import pydev_runfiles_unittest test_suite = pydev_runfiles_unittest.PydevTestSuite(all_tests) from _pydev_runfiles import pydev_runfiles_xml_rpc pydev_runfiles_xml_rpc.notifyTestsCollected(test_suite.countTestCases()) start_time = time.time() def run_tests(): executed_in_parallel = False if self.jobs > 1: from _pydev_runfiles import pydev_runfiles_parallel # What may happen is that the number of jobs needed is lower than the number of jobs requested # (e.g.: 2 jobs were requested for running 1 test) -- in which case execute_tests_in_parallel will # return False and won't run any tests. executed_in_parallel = pydev_runfiles_parallel.execute_tests_in_parallel( all_tests, self.jobs, self.split_jobs, self.verbosity, coverage_files, self.configuration.coverage_include) if not executed_in_parallel: # If in coverage, we don't need to pass anything here (coverage is already enabled for this execution). runner = pydev_runfiles_unittest.PydevTextTestRunner(stream=sys.stdout, descriptions=1, verbosity=self.verbosity) sys.stdout.write('\n') runner.run(test_suite) if self.configuration.django: get_django_test_suite_runner()(run_tests).run_tests([]) else: run_tests() if handle_coverage: coverage.stop() coverage.save() total_time = 'Finished in: %.2f secs.' % (time.time() - start_time,) pydev_runfiles_xml_rpc.notifyTestRunFinished(total_time) DJANGO_TEST_SUITE_RUNNER = None def get_django_test_suite_runner(): global DJANGO_TEST_SUITE_RUNNER if DJANGO_TEST_SUITE_RUNNER: return DJANGO_TEST_SUITE_RUNNER try: # django >= 1.8 import django from django.test.runner import DiscoverRunner class MyDjangoTestSuiteRunner(DiscoverRunner): def __init__(self, on_run_suite): django.setup() DiscoverRunner.__init__(self) self.on_run_suite = on_run_suite def build_suite(self, *args, **kwargs): pass def suite_result(self, *args, **kwargs): pass def run_suite(self, *args, **kwargs): self.on_run_suite() except: # django < 1.8 try: from django.test.simple import DjangoTestSuiteRunner except: class DjangoTestSuiteRunner: def __init__(self): pass def run_tests(self, *args, **kwargs): raise AssertionError("Unable to run suite with django.test.runner.DiscoverRunner nor django.test.simple.DjangoTestSuiteRunner because it couldn't be imported.") class MyDjangoTestSuiteRunner(DjangoTestSuiteRunner): def __init__(self, on_run_suite): DjangoTestSuiteRunner.__init__(self) self.on_run_suite = on_run_suite def build_suite(self, *args, **kwargs): pass def suite_result(self, *args, **kwargs): pass def run_suite(self, *args, **kwargs): self.on_run_suite() DJANGO_TEST_SUITE_RUNNER = MyDjangoTestSuiteRunner return DJANGO_TEST_SUITE_RUNNER #======================================================================================================================= # main #======================================================================================================================= def main(configuration): PydevTestRunner(configuration).run_tests()
31,550
Python
35.772727
180
0.513217
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_coverage.py
import os.path import sys from _pydevd_bundle.pydevd_constants import Null #======================================================================================================================= # get_coverage_files #======================================================================================================================= def get_coverage_files(coverage_output_dir, number_of_files): base_dir = coverage_output_dir ret = [] i = 0 while len(ret) < number_of_files: while True: f = os.path.join(base_dir, '.coverage.%s' % i) i += 1 if not os.path.exists(f): ret.append(f) break #Break only inner for. return ret #======================================================================================================================= # start_coverage_support #======================================================================================================================= def start_coverage_support(configuration): return start_coverage_support_from_params( configuration.coverage_output_dir, configuration.coverage_output_file, configuration.jobs, configuration.coverage_include, ) #======================================================================================================================= # start_coverage_support_from_params #======================================================================================================================= def start_coverage_support_from_params(coverage_output_dir, coverage_output_file, jobs, coverage_include): coverage_files = [] coverage_instance = Null() if coverage_output_dir or coverage_output_file: try: import coverage #@UnresolvedImport except: sys.stderr.write('Error: coverage module could not be imported\n') sys.stderr.write('Please make sure that the coverage module (http://nedbatchelder.com/code/coverage/)\n') sys.stderr.write('is properly installed in your interpreter: %s\n' % (sys.executable,)) import traceback;traceback.print_exc() else: if coverage_output_dir: if not os.path.exists(coverage_output_dir): sys.stderr.write('Error: directory for coverage output (%s) does not exist.\n' % (coverage_output_dir,)) elif not os.path.isdir(coverage_output_dir): sys.stderr.write('Error: expected (%s) to be a directory.\n' % (coverage_output_dir,)) else: n = jobs if n <= 0: n += 1 n += 1 #Add 1 more for the current process (which will do the initial import). coverage_files = get_coverage_files(coverage_output_dir, n) os.environ['COVERAGE_FILE'] = coverage_files.pop(0) coverage_instance = coverage.coverage(source=[coverage_include]) coverage_instance.start() elif coverage_output_file: #Client of parallel run. os.environ['COVERAGE_FILE'] = coverage_output_file coverage_instance = coverage.coverage(source=[coverage_include]) coverage_instance.start() return coverage_files, coverage_instance
3,499
Python
44.454545
124
0.452415
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_parallel_client.py
from _pydev_bundle.pydev_imports import xmlrpclib, _queue Queue = _queue.Queue import traceback import sys from _pydev_runfiles.pydev_runfiles_coverage import start_coverage_support_from_params import threading #======================================================================================================================= # ParallelNotification #======================================================================================================================= class ParallelNotification(object): def __init__(self, method, args, kwargs): self.method = method self.args = args self.kwargs = kwargs def to_tuple(self): return self.method, self.args, self.kwargs #======================================================================================================================= # KillServer #======================================================================================================================= class KillServer(object): pass #======================================================================================================================= # ServerComm #======================================================================================================================= class ServerComm(threading.Thread): def __init__(self, job_id, server): self.notifications_queue = Queue() threading.Thread.__init__(self) self.setDaemon(False) #Wait for all the notifications to be passed before exiting! assert job_id is not None assert port is not None self.job_id = job_id self.finished = False self.server = server def run(self): while True: kill_found = False commands = [] command = self.notifications_queue.get(block=True) if isinstance(command, KillServer): kill_found = True else: assert isinstance(command, ParallelNotification) commands.append(command.to_tuple()) try: while True: command = self.notifications_queue.get(block=False) #No block to create a batch. if isinstance(command, KillServer): kill_found = True else: assert isinstance(command, ParallelNotification) commands.append(command.to_tuple()) except: pass #That's OK, we're getting it until it becomes empty so that we notify multiple at once. if commands: try: #Batch notification. self.server.lock.acquire() try: self.server.notifyCommands(self.job_id, commands) finally: self.server.lock.release() except: traceback.print_exc() if kill_found: self.finished = True return #======================================================================================================================= # ServerFacade #======================================================================================================================= class ServerFacade(object): def __init__(self, notifications_queue): self.notifications_queue = notifications_queue def notifyTestsCollected(self, *args, **kwargs): pass #This notification won't be passed def notifyTestRunFinished(self, *args, **kwargs): pass #This notification won't be passed def notifyStartTest(self, *args, **kwargs): self.notifications_queue.put_nowait(ParallelNotification('notifyStartTest', args, kwargs)) def notifyTest(self, *args, **kwargs): self.notifications_queue.put_nowait(ParallelNotification('notifyTest', args, kwargs)) #======================================================================================================================= # run_client #======================================================================================================================= def run_client(job_id, port, verbosity, coverage_output_file, coverage_include): job_id = int(job_id) from _pydev_bundle import pydev_localhost server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), port)) server.lock = threading.Lock() server_comm = ServerComm(job_id, server) server_comm.start() try: server_facade = ServerFacade(server_comm.notifications_queue) from _pydev_runfiles import pydev_runfiles from _pydev_runfiles import pydev_runfiles_xml_rpc pydev_runfiles_xml_rpc.set_server(server_facade) #Starts None and when the 1st test is gotten, it's started (because a server may be initiated and terminated #before receiving any test -- which would mean a different process got all the tests to run). coverage = None try: tests_to_run = [1] while tests_to_run: #Investigate: is it dangerous to use the same xmlrpclib server from different threads? #It seems it should be, as it creates a new connection for each request... server.lock.acquire() try: tests_to_run = server.GetTestsToRun(job_id) finally: server.lock.release() if not tests_to_run: break if coverage is None: _coverage_files, coverage = start_coverage_support_from_params( None, coverage_output_file, 1, coverage_include) files_to_tests = {} for test in tests_to_run: filename_and_test = test.split('|') if len(filename_and_test) == 2: files_to_tests.setdefault(filename_and_test[0], []).append(filename_and_test[1]) configuration = pydev_runfiles.Configuration( '', verbosity, None, None, None, files_to_tests, 1, #Always single job here None, #The coverage is handled in this loop. coverage_output_file=None, coverage_include=None, ) test_runner = pydev_runfiles.PydevTestRunner(configuration) sys.stdout.flush() test_runner.run_tests(handle_coverage=False) finally: if coverage is not None: coverage.stop() coverage.save() except: traceback.print_exc() server_comm.notifications_queue.put_nowait(KillServer()) #======================================================================================================================= # main #======================================================================================================================= if __name__ == '__main__': if len(sys.argv) -1 == 3: job_id, port, verbosity = sys.argv[1:] coverage_output_file, coverage_include = None, None elif len(sys.argv) -1 == 5: job_id, port, verbosity, coverage_output_file, coverage_include = sys.argv[1:] else: raise AssertionError('Could not find out how to handle the parameters: '+sys.argv[1:]) job_id = int(job_id) port = int(port) verbosity = int(verbosity) run_client(job_id, port, verbosity, coverage_output_file, coverage_include)
7,722
Python
34.92093
120
0.460891
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_pytest2.py
from _pydev_runfiles import pydev_runfiles_xml_rpc import pickle import zlib import base64 import os from pydevd_file_utils import canonical_normalized_path import pytest import sys import time from pathlib import Path #========================================================================= # Load filters with tests we should skip #========================================================================= py_test_accept_filter = None def _load_filters(): global py_test_accept_filter if py_test_accept_filter is None: py_test_accept_filter = os.environ.get('PYDEV_PYTEST_SKIP') if py_test_accept_filter: py_test_accept_filter = pickle.loads( zlib.decompress(base64.b64decode(py_test_accept_filter))) # Newer versions of pytest resolve symlinks, so, we # may need to filter with a resolved path too. new_dct = {} for filename, value in py_test_accept_filter.items(): new_dct[canonical_normalized_path(str(Path(filename).resolve()))] = value py_test_accept_filter.update(new_dct) else: py_test_accept_filter = {} def is_in_xdist_node(): main_pid = os.environ.get('PYDEV_MAIN_PID') if main_pid and main_pid != str(os.getpid()): return True return False connected = False def connect_to_server_for_communication_to_xml_rpc_on_xdist(): global connected if connected: return connected = True if is_in_xdist_node(): port = os.environ.get('PYDEV_PYTEST_SERVER') if not port: sys.stderr.write( 'Error: no PYDEV_PYTEST_SERVER environment variable defined.\n') else: pydev_runfiles_xml_rpc.initialize_server(int(port), daemon=True) PY2 = sys.version_info[0] <= 2 PY3 = not PY2 class State: start_time = time.time() buf_err = None buf_out = None def start_redirect(): if State.buf_out is not None: return from _pydevd_bundle import pydevd_io State.buf_err = pydevd_io.start_redirect(keep_original_redirection=True, std='stderr') State.buf_out = pydevd_io.start_redirect(keep_original_redirection=True, std='stdout') def get_curr_output(): buf_out = State.buf_out buf_err = State.buf_err return buf_out.getvalue() if buf_out is not None else '', buf_err.getvalue() if buf_err is not None else '' def pytest_unconfigure(): if is_in_xdist_node(): return # Only report that it finished when on the main node (we don't want to report # the finish on each separate node). pydev_runfiles_xml_rpc.notifyTestRunFinished( 'Finished in: %.2f secs.' % (time.time() - State.start_time,)) def pytest_collection_modifyitems(session, config, items): # A note: in xdist, this is not called on the main process, only in the # secondary nodes, so, we'll actually make the filter and report it multiple # times. connect_to_server_for_communication_to_xml_rpc_on_xdist() _load_filters() if not py_test_accept_filter: pydev_runfiles_xml_rpc.notifyTestsCollected(len(items)) return # Keep on going (nothing to filter) new_items = [] for item in items: f = canonical_normalized_path(str(item.parent.fspath)) name = item.name if f not in py_test_accept_filter: # print('Skip file: %s' % (f,)) continue # Skip the file i = name.find('[') name_without_parametrize = None if i > 0: name_without_parametrize = name[:i] accept_tests = py_test_accept_filter[f] if item.cls is not None: class_name = item.cls.__name__ else: class_name = None for test in accept_tests: if test == name: # Direct match of the test (just go on with the default # loading) new_items.append(item) break if name_without_parametrize is not None and test == name_without_parametrize: # This happens when parameterizing pytest tests on older versions # of pytest where the test name doesn't include the fixture name # in it. new_items.append(item) break if class_name is not None: if test == class_name + '.' + name: new_items.append(item) break if name_without_parametrize is not None and test == class_name + '.' + name_without_parametrize: new_items.append(item) break if class_name == test: new_items.append(item) break else: pass # print('Skip test: %s.%s. Accept: %s' % (class_name, name, accept_tests)) # Modify the original list items[:] = new_items pydev_runfiles_xml_rpc.notifyTestsCollected(len(items)) try: """ pytest > 5.4 uses own version of TerminalWriter based on py.io.TerminalWriter and assumes there is a specific method TerminalWriter._write_source so try load pytest version first or fallback to default one """ from _pytest._io import TerminalWriter except ImportError: from py.io import TerminalWriter def _get_error_contents_from_report(report): if report.longrepr is not None: try: tw = TerminalWriter(stringio=True) stringio = tw.stringio except TypeError: import io stringio = io.StringIO() tw = TerminalWriter(file=stringio) tw.hasmarkup = False report.toterminal(tw) exc = stringio.getvalue() s = exc.strip() if s: return s return '' def pytest_collectreport(report): error_contents = _get_error_contents_from_report(report) if error_contents: report_test('fail', '<collect errors>', '<collect errors>', '', error_contents, 0.0) def append_strings(s1, s2): if s1.__class__ == s2.__class__: return s1 + s2 # Prefer str if isinstance(s1, bytes): s1 = s1.decode('utf-8', 'replace') if isinstance(s2, bytes): s2 = s2.decode('utf-8', 'replace') return s1 + s2 def pytest_runtest_logreport(report): if is_in_xdist_node(): # When running with xdist, we don't want the report to be called from the node, only # from the main process. return report_duration = report.duration report_when = report.when report_outcome = report.outcome if hasattr(report, 'wasxfail'): if report_outcome != 'skipped': report_outcome = 'passed' if report_outcome == 'passed': # passed on setup/teardown: no need to report if in setup or teardown # (only on the actual test if it passed). if report_when in ('setup', 'teardown'): return status = 'ok' elif report_outcome == 'skipped': status = 'skip' else: # It has only passed, skipped and failed (no error), so, let's consider # error if not on call. if report_when in ('setup', 'teardown'): status = 'error' else: # any error in the call (not in setup or teardown) is considered a # regular failure. status = 'fail' # This will work if pytest is not capturing it, if it is, nothing will # come from here... captured_output, error_contents = getattr(report, 'pydev_captured_output', ''), getattr(report, 'pydev_error_contents', '') for type_section, value in report.sections: if value: if type_section in ('err', 'stderr', 'Captured stderr call'): error_contents = append_strings(error_contents, value) else: captured_output = append_strings(error_contents, value) filename = getattr(report, 'pydev_fspath_strpath', '<unable to get>') test = report.location[2] if report_outcome != 'skipped': # On skipped, we'll have a traceback for the skip, which is not what we # want. exc = _get_error_contents_from_report(report) if exc: if error_contents: error_contents = append_strings(error_contents, '----------------------------- Exceptions -----------------------------\n') error_contents = append_strings(error_contents, exc) report_test(status, filename, test, captured_output, error_contents, report_duration) def report_test(status, filename, test, captured_output, error_contents, duration): ''' @param filename: 'D:\\src\\mod1\\hello.py' @param test: 'TestCase.testMet1' @param status: fail, error, ok ''' time_str = '%.2f' % (duration,) pydev_runfiles_xml_rpc.notifyTest( status, captured_output, error_contents, filename, test, time_str) if not hasattr(pytest, 'hookimpl'): raise AssertionError('Please upgrade pytest (the current version of pytest: %s is unsupported)' % (pytest.__version__,)) @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() report.pydev_fspath_strpath = item.fspath.strpath report.pydev_captured_output, report.pydev_error_contents = get_curr_output() @pytest.mark.tryfirst def pytest_runtest_setup(item): ''' Note: with xdist will be on a secondary process. ''' # We have our own redirection: if xdist does its redirection, we'll have # nothing in our contents (which is OK), but if it does, we'll get nothing # from pytest but will get our own here. start_redirect() filename = item.fspath.strpath test = item.location[2] pydev_runfiles_xml_rpc.notifyStartTest(filename, test)
9,845
Python
31.071661
139
0.600914
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_unittest.py
import unittest as python_unittest from _pydev_runfiles import pydev_runfiles_xml_rpc import time from _pydevd_bundle import pydevd_io import traceback from _pydevd_bundle.pydevd_constants import * # @UnusedWildImport from io import StringIO #======================================================================================================================= # PydevTextTestRunner #======================================================================================================================= class PydevTextTestRunner(python_unittest.TextTestRunner): def _makeResult(self): return PydevTestResult(self.stream, self.descriptions, self.verbosity) _PythonTextTestResult = python_unittest.TextTestRunner()._makeResult().__class__ #======================================================================================================================= # PydevTestResult #======================================================================================================================= class PydevTestResult(_PythonTextTestResult): def addSubTest(self, test, subtest, err): """Called at the end of a subtest. 'err' is None if the subtest ended successfully, otherwise it's a tuple of values as returned by sys.exc_info(). """ _PythonTextTestResult.addSubTest(self, test, subtest, err) if err is not None: subdesc = subtest._subDescription() error = (test, self._exc_info_to_string(err, test)) self._reportErrors([error], [], '', '%s %s' % (self.get_test_name(test), subdesc)) def startTest(self, test): _PythonTextTestResult.startTest(self, test) self.buf = pydevd_io.start_redirect(keep_original_redirection=True, std='both') self.start_time = time.time() self._current_errors_stack = [] self._current_failures_stack = [] try: test_name = test.__class__.__name__ + "." + test._testMethodName except AttributeError: # Support for jython 2.1 (__testMethodName is pseudo-private in the test case) test_name = test.__class__.__name__ + "." + test._TestCase__testMethodName pydev_runfiles_xml_rpc.notifyStartTest( test.__pydev_pyfile__, test_name) def get_test_name(self, test): try: try: test_name = test.__class__.__name__ + "." + test._testMethodName except AttributeError: # Support for jython 2.1 (__testMethodName is pseudo-private in the test case) try: test_name = test.__class__.__name__ + "." + test._TestCase__testMethodName # Support for class/module exceptions (test is instance of _ErrorHolder) except: test_name = test.description.split()[1][1:-1] + ' <' + test.description.split()[0] + '>' except: traceback.print_exc() return '<unable to get test name>' return test_name def stopTest(self, test): end_time = time.time() pydevd_io.end_redirect(std='both') _PythonTextTestResult.stopTest(self, test) captured_output = self.buf.getvalue() del self.buf error_contents = '' test_name = self.get_test_name(test) diff_time = '%.2f' % (end_time - self.start_time) skipped = False outcome = getattr(test, '_outcome', None) if outcome is not None: skipped = bool(getattr(outcome, 'skipped', None)) if skipped: pydev_runfiles_xml_rpc.notifyTest( 'skip', captured_output, error_contents, test.__pydev_pyfile__, test_name, diff_time) elif not self._current_errors_stack and not self._current_failures_stack: pydev_runfiles_xml_rpc.notifyTest( 'ok', captured_output, error_contents, test.__pydev_pyfile__, test_name, diff_time) else: self._reportErrors(self._current_errors_stack, self._current_failures_stack, captured_output, test_name) def _reportErrors(self, errors, failures, captured_output, test_name, diff_time=''): error_contents = [] for test, s in errors + failures: if type(s) == type((1,)): # If it's a tuple (for jython 2.1) sio = StringIO() traceback.print_exception(s[0], s[1], s[2], file=sio) s = sio.getvalue() error_contents.append(s) sep = '\n' + self.separator1 error_contents = sep.join(error_contents) if errors and not failures: try: pydev_runfiles_xml_rpc.notifyTest( 'error', captured_output, error_contents, test.__pydev_pyfile__, test_name, diff_time) except: file_start = error_contents.find('File "') file_end = error_contents.find('", ', file_start) if file_start != -1 and file_end != -1: file = error_contents[file_start + 6:file_end] else: file = '<unable to get file>' pydev_runfiles_xml_rpc.notifyTest( 'error', captured_output, error_contents, file, test_name, diff_time) elif failures and not errors: pydev_runfiles_xml_rpc.notifyTest( 'fail', captured_output, error_contents, test.__pydev_pyfile__, test_name, diff_time) else: # Ok, we got both, errors and failures. Let's mark it as an error in the end. pydev_runfiles_xml_rpc.notifyTest( 'error', captured_output, error_contents, test.__pydev_pyfile__, test_name, diff_time) def addError(self, test, err): _PythonTextTestResult.addError(self, test, err) # Support for class/module exceptions (test is instance of _ErrorHolder) if not hasattr(self, '_current_errors_stack') or test.__class__.__name__ == '_ErrorHolder': # Not in start...end, so, report error now (i.e.: django pre/post-setup) self._reportErrors([self.errors[-1]], [], '', self.get_test_name(test)) else: self._current_errors_stack.append(self.errors[-1]) def addFailure(self, test, err): _PythonTextTestResult.addFailure(self, test, err) if not hasattr(self, '_current_failures_stack'): # Not in start...end, so, report error now (i.e.: django pre/post-setup) self._reportErrors([], [self.failures[-1]], '', self.get_test_name(test)) else: self._current_failures_stack.append(self.failures[-1]) class PydevTestSuite(python_unittest.TestSuite): pass
6,685
Python
43.278145
120
0.551832
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_nose.py
from nose.plugins.multiprocess import MultiProcessTestRunner # @UnresolvedImport from nose.plugins.base import Plugin # @UnresolvedImport import sys from _pydev_runfiles import pydev_runfiles_xml_rpc import time from _pydev_runfiles.pydev_runfiles_coverage import start_coverage_support from contextlib import contextmanager from io import StringIO import traceback #======================================================================================================================= # PydevPlugin #======================================================================================================================= class PydevPlugin(Plugin): def __init__(self, configuration): self.configuration = configuration Plugin.__init__(self) def begin(self): # Called before any test is run (it's always called, with multiprocess or not) self.start_time = time.time() self.coverage_files, self.coverage = start_coverage_support(self.configuration) def finalize(self, result): # Called after all tests are run (it's always called, with multiprocess or not) self.coverage.stop() self.coverage.save() pydev_runfiles_xml_rpc.notifyTestRunFinished('Finished in: %.2f secs.' % (time.time() - self.start_time,)) #=================================================================================================================== # Methods below are not called with multiprocess (so, we monkey-patch MultiProcessTestRunner.consolidate # so that they're called, but unfortunately we loose some info -- i.e.: the time for each test in this # process). #=================================================================================================================== class Sentinel(object): pass @contextmanager def _without_user_address(self, test): # #PyDev-1095: Conflict between address in test and test.address() in PydevPlugin().report_cond() user_test_instance = test.test user_address = self.Sentinel user_class_address = self.Sentinel try: if 'address' in user_test_instance.__dict__: user_address = user_test_instance.__dict__.pop('address') except: # Just ignore anything here. pass try: user_class_address = user_test_instance.__class__.address del user_test_instance.__class__.address except: # Just ignore anything here. pass try: yield finally: if user_address is not self.Sentinel: user_test_instance.__dict__['address'] = user_address if user_class_address is not self.Sentinel: user_test_instance.__class__.address = user_class_address def _get_test_address(self, test): try: if hasattr(test, 'address'): with self._without_user_address(test): address = test.address() # test.address() is something as: # ('D:\\workspaces\\temp\\test_workspace\\pytesting1\\src\\mod1\\hello.py', 'mod1.hello', 'TestCase.testMet1') # # and we must pass: location, test # E.g.: ['D:\\src\\mod1\\hello.py', 'TestCase.testMet1'] address = address[0], address[2] else: # multiprocess try: address = test[0], test[1] except TypeError: # It may be an error at setup, in which case it's not really a test, but a Context object. f = test.context.__file__ if f.endswith('.pyc'): f = f[:-1] elif f.endswith('$py.class'): f = f[:-len('$py.class')] + '.py' address = f, '?' except: sys.stderr.write("PyDev: Internal pydev error getting test address. Please report at the pydev bug tracker\n") traceback.print_exc() sys.stderr.write("\n\n\n") address = '?', '?' return address def report_cond(self, cond, test, captured_output, error=''): ''' @param cond: fail, error, ok ''' address = self._get_test_address(test) error_contents = self.get_io_from_error(error) try: time_str = '%.2f' % (time.time() - test._pydev_start_time) except: time_str = '?' pydev_runfiles_xml_rpc.notifyTest(cond, captured_output, error_contents, address[0], address[1], time_str) def startTest(self, test): test._pydev_start_time = time.time() file, test = self._get_test_address(test) pydev_runfiles_xml_rpc.notifyStartTest(file, test) def get_io_from_error(self, err): if type(err) == type(()): if len(err) != 3: if len(err) == 2: return err[1] # multiprocess s = StringIO() etype, value, tb = err if isinstance(value, str): return value traceback.print_exception(etype, value, tb, file=s) return s.getvalue() return err def get_captured_output(self, test): if hasattr(test, 'capturedOutput') and test.capturedOutput: return test.capturedOutput return '' def addError(self, test, err): self.report_cond( 'error', test, self.get_captured_output(test), err, ) def addFailure(self, test, err): self.report_cond( 'fail', test, self.get_captured_output(test), err, ) def addSuccess(self, test): self.report_cond( 'ok', test, self.get_captured_output(test), '', ) PYDEV_NOSE_PLUGIN_SINGLETON = None def start_pydev_nose_plugin_singleton(configuration): global PYDEV_NOSE_PLUGIN_SINGLETON PYDEV_NOSE_PLUGIN_SINGLETON = PydevPlugin(configuration) return PYDEV_NOSE_PLUGIN_SINGLETON original = MultiProcessTestRunner.consolidate #======================================================================================================================= # new_consolidate #======================================================================================================================= def new_consolidate(self, result, batch_result): ''' Used so that it can work with the multiprocess plugin. Monkeypatched because nose seems a bit unsupported at this time (ideally the plugin would have this support by default). ''' ret = original(self, result, batch_result) parent_frame = sys._getframe().f_back # addr is something as D:\pytesting1\src\mod1\hello.py:TestCase.testMet4 # so, convert it to what report_cond expects addr = parent_frame.f_locals['addr'] i = addr.rindex(':') addr = [addr[:i], addr[i + 1:]] output, testsRun, failures, errors, errorClasses = batch_result if failures or errors: for failure in failures: PYDEV_NOSE_PLUGIN_SINGLETON.report_cond('fail', addr, output, failure) for error in errors: PYDEV_NOSE_PLUGIN_SINGLETON.report_cond('error', addr, output, error) else: PYDEV_NOSE_PLUGIN_SINGLETON.report_cond('ok', addr, output) return ret MultiProcessTestRunner.consolidate = new_consolidate
7,549
Python
35.298077
126
0.527355
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_override.py
def overrides(method): ''' Meant to be used as class B: @overrides(A.m1) def m1(self): pass ''' def wrapper(func): if func.__name__ != method.__name__: msg = "Wrong @override: %r expected, but overwriting %r." msg = msg % (func.__name__, method.__name__) raise AssertionError(msg) if func.__doc__ is None: func.__doc__ = method.__doc__ return func return wrapper def implements(method): def wrapper(func): if func.__name__ != method.__name__: msg = "Wrong @implements: %r expected, but implementing %r." msg = msg % (func.__name__, method.__name__) raise AssertionError(msg) if func.__doc__ is None: func.__doc__ = method.__doc__ return func return wrapper
872
Python
23.942856
72
0.497706
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_umd.py
""" The UserModuleDeleter and runfile methods are copied from Spyder and carry their own license agreement. http://code.google.com/p/spyderlib/source/browse/spyderlib/widgets/externalshell/sitecustomize.py Spyder License Agreement (MIT License) -------------------------------------- Copyright (c) 2009-2012 Pierre Raybaut Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import sys import os from _pydev_bundle._pydev_execfile import execfile # The following classes and functions are mainly intended to be used from # an interactive Python session class UserModuleDeleter: """ User Module Deleter (UMD) aims at deleting user modules to force Python to deeply reload them during import pathlist [list]: ignore list in terms of module path namelist [list]: ignore list in terms of module name """ def __init__(self, namelist=None, pathlist=None): if namelist is None: namelist = [] self.namelist = namelist if pathlist is None: pathlist = [] self.pathlist = pathlist try: # ignore all files in org.python.pydev/pysrc import pydev_pysrc, inspect self.pathlist.append(os.path.dirname(pydev_pysrc.__file__)) except: pass self.previous_modules = list(sys.modules.keys()) def is_module_ignored(self, modname, modpath): for path in [sys.prefix] + self.pathlist: if modpath.startswith(path): return True else: return set(modname.split('.')) & set(self.namelist) def run(self, verbose=False): """ Del user modules to force Python to deeply reload them Do not del modules which are considered as system modules, i.e. modules installed in subdirectories of Python interpreter's binary Do not del C modules """ log = [] modules_copy = dict(sys.modules) for modname, module in modules_copy.items(): if modname == 'aaaaa': print(modname, module) print(self.previous_modules) if modname not in self.previous_modules: modpath = getattr(module, '__file__', None) if modpath is None: # *module* is a C module that is statically linked into the # interpreter. There is no way to know its path, so we # choose to ignore it. continue if not self.is_module_ignored(modname, modpath): log.append(modname) del sys.modules[modname] if verbose and log: print("\x1b[4;33m%s\x1b[24m%s\x1b[0m" % ("UMD has deleted", ": " + ", ".join(log))) __umd__ = None _get_globals_callback = None def _set_globals_function(get_globals): global _get_globals_callback _get_globals_callback = get_globals def _get_globals(): """Return current Python interpreter globals namespace""" if _get_globals_callback is not None: return _get_globals_callback() else: try: from __main__ import __dict__ as namespace except ImportError: try: # The import fails on IronPython import __main__ namespace = __main__.__dict__ except: namespace shell = namespace.get('__ipythonshell__') if shell is not None and hasattr(shell, 'user_ns'): # IPython 0.12+ kernel return shell.user_ns else: # Python interpreter return namespace return namespace def runfile(filename, args=None, wdir=None, namespace=None): """ Run filename args: command line arguments (string) wdir: working directory """ try: if hasattr(filename, 'decode'): filename = filename.decode('utf-8') except (UnicodeError, TypeError): pass global __umd__ if os.environ.get("PYDEV_UMD_ENABLED", "").lower() == "true": if __umd__ is None: namelist = os.environ.get("PYDEV_UMD_NAMELIST", None) if namelist is not None: namelist = namelist.split(',') __umd__ = UserModuleDeleter(namelist=namelist) else: verbose = os.environ.get("PYDEV_UMD_VERBOSE", "").lower() == "true" __umd__.run(verbose=verbose) if args is not None and not isinstance(args, (bytes, str)): raise TypeError("expected a character buffer object") if namespace is None: namespace = _get_globals() if '__file__' in namespace: old_file = namespace['__file__'] else: old_file = None namespace['__file__'] = filename sys.argv = [filename] if args is not None: for arg in args.split(): sys.argv.append(arg) if wdir is not None: try: if hasattr(wdir, 'decode'): wdir = wdir.decode('utf-8') except (UnicodeError, TypeError): pass os.chdir(wdir) execfile(filename, namespace) sys.argv = [''] if old_file is None: del namespace['__file__'] else: namespace['__file__'] = old_file
6,279
Python
33.696132
97
0.607262
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_import_hook.py
import sys import traceback from types import ModuleType from _pydevd_bundle.pydevd_constants import DebugInfoHolder import builtins class ImportHookManager(ModuleType): def __init__(self, name, system_import): ModuleType.__init__(self, name) self._system_import = system_import self._modules_to_patch = {} def add_module_name(self, module_name, activate_function): self._modules_to_patch[module_name] = activate_function def do_import(self, name, *args, **kwargs): module = self._system_import(name, *args, **kwargs) try: activate_func = self._modules_to_patch.pop(name, None) if activate_func: activate_func() # call activate function except: if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 2: traceback.print_exc() # Restore normal system importer to reduce performance impact # of calling this method every time an import statement is invoked if not self._modules_to_patch: builtins.__import__ = self._system_import return module import_hook_manager = ImportHookManager(__name__ + '.import_hook', builtins.__import__) builtins.__import__ = import_hook_manager.do_import sys.modules[import_hook_manager.__name__] = import_hook_manager
1,322
Python
31.268292
87
0.652799
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_localhost.py
from _pydev_bundle._pydev_saved_modules import socket import sys IS_JYTHON = sys.platform.find('java') != -1 _cache = None def get_localhost(): ''' Should return 127.0.0.1 in ipv4 and ::1 in ipv6 localhost is not used because on windows vista/windows 7, there can be issues where the resolving doesn't work properly and takes a lot of time (had this issue on the pyunit server). Using the IP directly solves the problem. ''' # TODO: Needs better investigation! global _cache if _cache is None: try: for addr_info in socket.getaddrinfo("localhost", 80, 0, 0, socket.SOL_TCP): config = addr_info[4] if config[0] == '127.0.0.1': _cache = '127.0.0.1' return _cache except: # Ok, some versions of Python don't have getaddrinfo or SOL_TCP... Just consider it 127.0.0.1 in this case. _cache = '127.0.0.1' else: _cache = 'localhost' return _cache def get_socket_names(n_sockets, close=False): socket_names = [] sockets = [] for _ in range(n_sockets): if IS_JYTHON: # Although the option which would be pure java *should* work for Jython, the socket being returned is still 0 # (i.e.: it doesn't give the local port bound, only the original port, which was 0). from java.net import ServerSocket sock = ServerSocket(0) socket_name = get_localhost(), sock.getLocalPort() else: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((get_localhost(), 0)) socket_name = sock.getsockname() sockets.append(sock) socket_names.append(socket_name) if close: for s in sockets: s.close() return socket_names def get_socket_name(close=False): return get_socket_names(1, close)[0] if __name__ == '__main__': print(get_socket_name())
2,070
Python
29.455882
121
0.591304
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_is_thread_alive.py
from _pydev_bundle._pydev_saved_modules import threading # Hack for https://www.brainwy.com/tracker/PyDev/363 (i.e.: calling is_alive() can throw AssertionError under some # circumstances). # It is required to debug threads started by start_new_thread in Python 3.4 _temp = threading.Thread() if hasattr(_temp, '_is_stopped'): # Python 3.x has this def is_thread_alive(t): return not t._is_stopped elif hasattr(_temp, '_Thread__stopped'): # Python 2.x has this def is_thread_alive(t): return not t._Thread__stopped else: # Jython wraps a native java thread and thus only obeys the public API. def is_thread_alive(t): return t.is_alive() del _temp
696
Python
28.041665
114
0.688218
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_tipper_common.py
import inspect import re def do_find(f, mod): import linecache if inspect.ismodule(mod): return f, 0, 0 lines = linecache.getlines(f) if inspect.isclass(mod): name = mod.__name__ pat = re.compile(r'^\s*class\s*' + name + r'\b') for i in range(len(lines)): if pat.match(lines[i]): return f, i, 0 return f, 0, 0 if inspect.ismethod(mod): mod = mod.im_func if inspect.isfunction(mod): try: mod = mod.func_code except AttributeError: mod = mod.__code__ # python 3k if inspect.istraceback(mod): mod = mod.tb_frame if inspect.isframe(mod): mod = mod.f_code if inspect.iscode(mod): if not hasattr(mod, 'co_filename'): return None, 0, 0 if not hasattr(mod, 'co_firstlineno'): return mod.co_filename, 0, 0 lnum = mod.co_firstlineno pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)') while lnum > 0: if pat.match(lines[lnum]): break lnum -= 1 return f, lnum, 0 raise RuntimeError('Do not know about: ' + f + ' ' + str(mod))
1,227
Python
22.169811
72
0.509372
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py
import sys import os def find_in_pythonpath(module_name): # Check all the occurrences where we could match the given module/package in the PYTHONPATH. # # This is a simplistic approach, but probably covers most of the cases we're interested in # (i.e.: this may fail in more elaborate cases of import customization or .zip imports, but # this should be rare in general). found_at = [] parts = module_name.split('.') # split because we need to convert mod.name to mod/name for path in sys.path: target = os.path.join(path, *parts) target_py = target + '.py' if os.path.isdir(target): found_at.append(target) if os.path.exists(target_py): found_at.append(target_py) return found_at class DebuggerInitializationError(Exception): pass class VerifyShadowedImport(object): def __init__(self, import_name): self.import_name = import_name def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): if exc_type is not None: if exc_type == DebuggerInitializationError: return False # It's already an error we generated. # We couldn't even import it... found_at = find_in_pythonpath(self.import_name) if len(found_at) <= 1: # It wasn't found anywhere or there was just 1 occurrence. # Let's just return to show the original error. return False # We found more than 1 occurrence of the same module in the PYTHONPATH # (the user module and the standard library module). # Let's notify the user as it seems that the module was shadowed. msg = self._generate_shadowed_import_message(found_at) raise DebuggerInitializationError(msg) def _generate_shadowed_import_message(self, found_at): msg = '''It was not possible to initialize the debugger due to a module name conflict. i.e.: the module "%(import_name)s" could not be imported because it is shadowed by: %(found_at)s Please rename this file/folder so that the original module from the standard library can be imported.''' % { 'import_name': self.import_name, 'found_at': found_at[0]} return msg def check(self, module, expected_attributes): msg = '' for expected_attribute in expected_attributes: try: getattr(module, expected_attribute) except: msg = self._generate_shadowed_import_message([module.__file__]) break if msg: raise DebuggerInitializationError(msg) with VerifyShadowedImport('threading') as verify_shadowed: import threading; verify_shadowed.check(threading, ['Thread', 'settrace', 'setprofile', 'Lock', 'RLock', 'current_thread']) with VerifyShadowedImport('time') as verify_shadowed: import time; verify_shadowed.check(time, ['sleep', 'time', 'mktime']) with VerifyShadowedImport('socket') as verify_shadowed: import socket; verify_shadowed.check(socket, ['socket', 'gethostname', 'getaddrinfo']) with VerifyShadowedImport('select') as verify_shadowed: import select; verify_shadowed.check(select, ['select']) with VerifyShadowedImport('code') as verify_shadowed: import code as _code; verify_shadowed.check(_code, ['compile_command', 'InteractiveInterpreter']) with VerifyShadowedImport('_thread') as verify_shadowed: import _thread as thread; verify_shadowed.check(thread, ['start_new_thread', 'start_new', 'allocate_lock']) with VerifyShadowedImport('queue') as verify_shadowed: import queue as _queue; verify_shadowed.check(_queue, ['Queue', 'LifoQueue', 'Empty', 'Full', 'deque']) with VerifyShadowedImport('xmlrpclib') as verify_shadowed: import xmlrpc.client as xmlrpclib; verify_shadowed.check(xmlrpclib, ['ServerProxy', 'Marshaller', 'Server']) with VerifyShadowedImport('xmlrpc.server') as verify_shadowed: import xmlrpc.server as xmlrpcserver; verify_shadowed.check(xmlrpcserver, ['SimpleXMLRPCServer']) with VerifyShadowedImport('http.server') as verify_shadowed: import http.server as BaseHTTPServer; verify_shadowed.check(BaseHTTPServer, ['BaseHTTPRequestHandler']) # If set, this is a version of the threading.enumerate that doesn't have the patching to remove the pydevd threads. # Note: as it can't be set during execution, don't import the name (import the module and access it through its name). pydevd_saved_threading_enumerate = None
4,573
Python
40.207207
130
0.674393
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey_qt.py
from __future__ import nested_scopes from _pydev_bundle._pydev_saved_modules import threading import os from _pydev_bundle import pydev_log def set_trace_in_qt(): from _pydevd_bundle.pydevd_comm import get_global_debugger py_db = get_global_debugger() if py_db is not None: threading.current_thread() # Create the dummy thread for qt. py_db.enable_tracing() _patched_qt = False def patch_qt(qt_support_mode): ''' This method patches qt (PySide2, PySide, PyQt4, PyQt5) so that we have hooks to set the tracing for QThread. ''' if not qt_support_mode: return if qt_support_mode is True or qt_support_mode == 'True': # do not break backward compatibility qt_support_mode = 'auto' if qt_support_mode == 'auto': qt_support_mode = os.getenv('PYDEVD_PYQT_MODE', 'auto') # Avoid patching more than once global _patched_qt if _patched_qt: return pydev_log.debug('Qt support mode: %s', qt_support_mode) _patched_qt = True if qt_support_mode == 'auto': patch_qt_on_import = None try: import PySide2 # @UnresolvedImport @UnusedImport qt_support_mode = 'pyside2' except: try: import Pyside # @UnresolvedImport @UnusedImport qt_support_mode = 'pyside' except: try: import PyQt5 # @UnresolvedImport @UnusedImport qt_support_mode = 'pyqt5' except: try: import PyQt4 # @UnresolvedImport @UnusedImport qt_support_mode = 'pyqt4' except: return if qt_support_mode == 'pyside2': try: import PySide2.QtCore # @UnresolvedImport _internal_patch_qt(PySide2.QtCore, qt_support_mode) except: return elif qt_support_mode == 'pyside': try: import PySide.QtCore # @UnresolvedImport _internal_patch_qt(PySide.QtCore, qt_support_mode) except: return elif qt_support_mode == 'pyqt5': try: import PyQt5.QtCore # @UnresolvedImport _internal_patch_qt(PyQt5.QtCore) except: return elif qt_support_mode == 'pyqt4': # Ok, we have an issue here: # PyDev-452: Selecting PyQT API version using sip.setapi fails in debug mode # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html # Mostly, if the user uses a different API version (i.e.: v2 instead of v1), # that has to be done before importing PyQt4 modules (PySide/PyQt5 don't have this issue # as they only implements v2). patch_qt_on_import = 'PyQt4' def get_qt_core_module(): import PyQt4.QtCore # @UnresolvedImport return PyQt4.QtCore _patch_import_to_patch_pyqt_on_import(patch_qt_on_import, get_qt_core_module) else: raise ValueError('Unexpected qt support mode: %s' % (qt_support_mode,)) def _patch_import_to_patch_pyqt_on_import(patch_qt_on_import, get_qt_core_module): # I don't like this approach very much as we have to patch __import__, but I like even less # asking the user to configure something in the client side... # So, our approach is to patch PyQt4 right before the user tries to import it (at which # point he should've set the sip api version properly already anyways). pydev_log.debug('Setting up Qt post-import monkeypatch.') dotted = patch_qt_on_import + '.' original_import = __import__ from _pydev_bundle._pydev_sys_patch import patch_sys_module, patch_reload, cancel_patches_in_sys_module patch_sys_module() patch_reload() def patched_import(name, *args, **kwargs): if patch_qt_on_import == name or name.startswith(dotted): builtins.__import__ = original_import cancel_patches_in_sys_module() _internal_patch_qt(get_qt_core_module()) # Patch it only when the user would import the qt module return original_import(name, *args, **kwargs) import builtins # Py3 builtins.__import__ = patched_import def _internal_patch_qt(QtCore, qt_support_mode='auto'): pydev_log.debug('Patching Qt: %s', QtCore) _original_thread_init = QtCore.QThread.__init__ _original_runnable_init = QtCore.QRunnable.__init__ _original_QThread = QtCore.QThread class FuncWrapper: def __init__(self, original): self._original = original def __call__(self, *args, **kwargs): set_trace_in_qt() return self._original(*args, **kwargs) class StartedSignalWrapper(QtCore.QObject): # Wrapper for the QThread.started signal try: _signal = QtCore.Signal() # @UndefinedVariable except: _signal = QtCore.pyqtSignal() # @UndefinedVariable def __init__(self, thread, original_started): QtCore.QObject.__init__(self) self.thread = thread self.original_started = original_started if qt_support_mode in ('pyside', 'pyside2'): self._signal = original_started else: self._signal.connect(self._on_call) self.original_started.connect(self._signal) def connect(self, func, *args, **kwargs): if qt_support_mode in ('pyside', 'pyside2'): return self._signal.connect(FuncWrapper(func), *args, **kwargs) else: return self._signal.connect(func, *args, **kwargs) def disconnect(self, *args, **kwargs): return self._signal.disconnect(*args, **kwargs) def emit(self, *args, **kwargs): return self._signal.emit(*args, **kwargs) def _on_call(self, *args, **kwargs): set_trace_in_qt() class ThreadWrapper(QtCore.QThread): # Wrapper for QThread def __init__(self, *args, **kwargs): _original_thread_init(self, *args, **kwargs) # In PyQt5 the program hangs when we try to call original run method of QThread class. # So we need to distinguish instances of QThread class and instances of QThread inheritors. if self.__class__.run == _original_QThread.run: self.run = self._exec_run else: self._original_run = self.run self.run = self._new_run self._original_started = self.started self.started = StartedSignalWrapper(self, self.started) def _exec_run(self): set_trace_in_qt() self.exec_() return None def _new_run(self): set_trace_in_qt() return self._original_run() class RunnableWrapper(QtCore.QRunnable): # Wrapper for QRunnable def __init__(self, *args, **kwargs): _original_runnable_init(self, *args, **kwargs) self._original_run = self.run self.run = self._new_run def _new_run(self): set_trace_in_qt() return self._original_run() QtCore.QThread = ThreadWrapper QtCore.QRunnable = RunnableWrapper
7,306
Python
32.672811
112
0.588968
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_log.py
from _pydevd_bundle.pydevd_constants import DebugInfoHolder, SHOW_COMPILE_CYTHON_COMMAND_LINE, NULL, LOG_TIME from contextlib import contextmanager import traceback import os import sys class _LoggingGlobals(object): _warn_once_map = {} _debug_stream_filename = None _debug_stream = sys.stderr _debug_stream_initialized = False def initialize_debug_stream(reinitialize=False): ''' :param bool reinitialize: Reinitialize is used to update the debug stream after a fork (thus, if it wasn't initialized, we don't need to do anything). ''' if reinitialize: if not _LoggingGlobals._debug_stream_initialized: return else: if _LoggingGlobals._debug_stream_initialized: return _LoggingGlobals._debug_stream_initialized = True # Note: we cannot initialize with sys.stderr because when forking we may end up logging things in 'os' calls. _LoggingGlobals._debug_stream = NULL _LoggingGlobals._debug_stream_filename = None if not DebugInfoHolder.PYDEVD_DEBUG_FILE: _LoggingGlobals._debug_stream = sys.stderr else: # Add pid to the filename. try: dirname = os.path.dirname(DebugInfoHolder.PYDEVD_DEBUG_FILE) basename = os.path.basename(DebugInfoHolder.PYDEVD_DEBUG_FILE) try: os.makedirs(dirname) except: pass # Ignore error if it already exists. name, ext = os.path.splitext(basename) debug_file = os.path.join(dirname, name + '.' + str(os.getpid()) + ext) _LoggingGlobals._debug_stream = open(debug_file, 'w') _LoggingGlobals._debug_stream_filename = debug_file except: _LoggingGlobals._debug_stream = sys.stderr # Don't fail when trying to setup logging, just show the exception. traceback.print_exc() def list_log_files(pydevd_debug_file): log_files = [] dirname = os.path.dirname(pydevd_debug_file) basename = os.path.basename(pydevd_debug_file) if os.path.isdir(dirname): name, ext = os.path.splitext(basename) for f in os.listdir(dirname): if f.startswith(name) and f.endswith(ext): log_files.append(os.path.join(dirname, f)) return log_files @contextmanager def log_context(trace_level, stream): ''' To be used to temporarily change the logging settings. ''' original_trace_level = DebugInfoHolder.DEBUG_TRACE_LEVEL original_debug_stream = _LoggingGlobals._debug_stream original_pydevd_debug_file = DebugInfoHolder.PYDEVD_DEBUG_FILE original_debug_stream_filename = _LoggingGlobals._debug_stream_filename original_initialized = _LoggingGlobals._debug_stream_initialized DebugInfoHolder.DEBUG_TRACE_LEVEL = trace_level _LoggingGlobals._debug_stream = stream _LoggingGlobals._debug_stream_initialized = True try: yield finally: DebugInfoHolder.DEBUG_TRACE_LEVEL = original_trace_level _LoggingGlobals._debug_stream = original_debug_stream DebugInfoHolder.PYDEVD_DEBUG_FILE = original_pydevd_debug_file _LoggingGlobals._debug_stream_filename = original_debug_stream_filename _LoggingGlobals._debug_stream_initialized = original_initialized import time _last_log_time = time.time() def _pydevd_log(level, msg, *args): ''' Levels are: 0 most serious warnings/errors (always printed) 1 warnings/significant events 2 informational trace 3 verbose mode ''' if level <= DebugInfoHolder.DEBUG_TRACE_LEVEL: # yes, we can have errors printing if the console of the program has been finished (and we're still trying to print something) try: try: if args: msg = msg % args except: msg = '%s - %s' % (msg, args) if LOG_TIME: global _last_log_time new_log_time = time.time() time_diff = new_log_time - _last_log_time _last_log_time = new_log_time msg = '%.2fs - %s\n' % (time_diff, msg,) else: msg = '%s\n' % (msg,) try: try: initialize_debug_stream() # Do it as late as possible _LoggingGlobals._debug_stream.write(msg) except TypeError: if isinstance(msg, bytes): # Depending on the StringIO flavor, it may only accept unicode. msg = msg.decode('utf-8', 'replace') _LoggingGlobals._debug_stream.write(msg) except UnicodeEncodeError: # When writing to the stream it's possible that the string can't be represented # in the encoding expected (in this case, convert it to the stream encoding # or ascii if we can't find one suitable using a suitable replace). encoding = getattr(_LoggingGlobals._debug_stream, 'encoding', 'ascii') msg = msg.encode(encoding, 'backslashreplace') msg = msg.decode(encoding) _LoggingGlobals._debug_stream.write(msg) _LoggingGlobals._debug_stream.flush() except: pass return True def _pydevd_log_exception(msg='', *args): if msg or args: _pydevd_log(0, msg, *args) try: initialize_debug_stream() # Do it as late as possible traceback.print_exc(file=_LoggingGlobals._debug_stream) _LoggingGlobals._debug_stream.flush() except: raise def verbose(msg, *args): if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 3: _pydevd_log(3, msg, *args) def debug(msg, *args): if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 2: _pydevd_log(2, msg, *args) def info(msg, *args): if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1: _pydevd_log(1, msg, *args) warn = info def critical(msg, *args): _pydevd_log(0, msg, *args) def exception(msg='', *args): try: _pydevd_log_exception(msg, *args) except: pass # Should never fail (even at interpreter shutdown). error = exception def error_once(msg, *args): try: if args: message = msg % args else: message = str(msg) except: message = '%s - %s' % (msg, args) if message not in _LoggingGlobals._warn_once_map: _LoggingGlobals._warn_once_map[message] = True critical(message) def exception_once(msg, *args): try: if args: message = msg % args else: message = str(msg) except: message = '%s - %s' % (msg, args) if message not in _LoggingGlobals._warn_once_map: _LoggingGlobals._warn_once_map[message] = True exception(message) def debug_once(msg, *args): if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 3: error_once(msg, *args) def show_compile_cython_command_line(): if SHOW_COMPILE_CYTHON_COMMAND_LINE: dirname = os.path.dirname(os.path.dirname(__file__)) error_once("warning: Debugger speedups using cython not found. Run '\"%s\" \"%s\" build_ext --inplace' to build.", sys.executable, os.path.join(dirname, 'setup_pydevd_cython.py'))
7,359
Python
31.139738
134
0.608507
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_versioncheck.py
import sys def versionok_for_gui(): ''' Return True if running Python is suitable for GUI Event Integration and deeper IPython integration ''' # We require Python 2.6+ ... if sys.hexversion < 0x02060000: return False # Or Python 3.2+ if sys.hexversion >= 0x03000000 and sys.hexversion < 0x03020000: return False # Not supported under Jython nor IronPython if sys.platform.startswith("java") or sys.platform.startswith('cli'): return False return True
510
Python
29.058822
110
0.678431
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_completer.py
from collections import namedtuple from string import ascii_letters, digits from _pydevd_bundle import pydevd_xml import pydevconsole import builtins as __builtin__ # Py3 try: import java.lang # @UnusedImport from _pydev_bundle import _pydev_jy_imports_tipper _pydev_imports_tipper = _pydev_jy_imports_tipper except ImportError: IS_JYTHON = False from _pydev_bundle import _pydev_imports_tipper dir2 = _pydev_imports_tipper.generate_imports_tip_for_module #======================================================================================================================= # _StartsWithFilter #======================================================================================================================= class _StartsWithFilter: ''' Used because we can't create a lambda that'll use an outer scope in jython 2.1 ''' def __init__(self, start_with): self.start_with = start_with.lower() def __call__(self, name): return name.lower().startswith(self.start_with) #======================================================================================================================= # Completer # # This class was gotten from IPython.completer (dir2 was replaced with the completer already in pydev) #======================================================================================================================= class Completer: def __init__(self, namespace=None, global_namespace=None): """Create a new completer for the command line. Completer([namespace,global_namespace]) -> completer instance. If unspecified, the default namespace where completions are performed is __main__ (technically, __main__.__dict__). Namespaces should be given as dictionaries. An optional second namespace can be given. This allows the completer to handle cases where both the local and global scopes need to be distinguished. Completer instances should be used as the completion mechanism of readline via the set_completer() call: readline.set_completer(Completer(my_namespace).complete) """ # Don't bind to namespace quite yet, but flag whether the user wants a # specific namespace or to use __main__.__dict__. This will allow us # to bind to __main__.__dict__ at completion time, not now. if namespace is None: self.use_main_ns = 1 else: self.use_main_ns = 0 self.namespace = namespace # The global namespace, if given, can be bound directly if global_namespace is None: self.global_namespace = {} else: self.global_namespace = global_namespace def complete(self, text): """Return the next possible completion for 'text'. This is called successively with state == 0, 1, 2, ... until it returns None. The completion should begin with 'text'. """ if self.use_main_ns: # In pydev this option should never be used raise RuntimeError('Namespace must be provided!') self.namespace = __main__.__dict__ # @UndefinedVariable if "." in text: return self.attr_matches(text) else: return self.global_matches(text) def global_matches(self, text): """Compute matches when text is a simple name. Return a list of all keywords, built-in functions and names currently defined in self.namespace or self.global_namespace that match. """ def get_item(obj, attr): return obj[attr] a = {} for dict_with_comps in [__builtin__.__dict__, self.namespace, self.global_namespace]: # @UndefinedVariable a.update(dict_with_comps) filter = _StartsWithFilter(text) return dir2(a, a.keys(), get_item, filter) def attr_matches(self, text): """Compute matches when text contains a dot. Assuming the text is of the form NAME.NAME....[NAME], and is evaluatable in self.namespace or self.global_namespace, it will be evaluated and its attributes (as revealed by dir()) are used as possible completions. (For class instances, class members are are also considered.) WARNING: this can still invoke arbitrary C code, if an object with a __getattr__ hook is evaluated. """ import re # Another option, seems to work great. Catches things like ''.<tab> m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text) # @UndefinedVariable if not m: return [] expr, attr = m.group(1, 3) try: obj = eval(expr, self.namespace) except: try: obj = eval(expr, self.global_namespace) except: return [] filter = _StartsWithFilter(attr) words = dir2(obj, filter=filter) return words def generate_completions(frame, act_tok): ''' :return list(tuple(method_name, docstring, parameters, completion_type)) method_name: str docstring: str parameters: str -- i.e.: "(a, b)" completion_type is an int See: _pydev_bundle._pydev_imports_tipper for TYPE_ constants ''' if frame is None: return [] # Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329 # (Names not resolved in generator expression in method) # See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html updated_globals = {} updated_globals.update(frame.f_globals) updated_globals.update(frame.f_locals) # locals later because it has precedence over the actual globals if pydevconsole.IPYTHON: completions = pydevconsole.get_completions(act_tok, act_tok, updated_globals, frame.f_locals) else: completer = Completer(updated_globals, None) # list(tuple(name, descr, parameters, type)) completions = completer.complete(act_tok) return completions def generate_completions_as_xml(frame, act_tok): completions = generate_completions(frame, act_tok) return completions_to_xml(completions) def completions_to_xml(completions): valid_xml = pydevd_xml.make_valid_xml_value quote = pydevd_xml.quote msg = ["<xml>"] for comp in completions: msg.append('<comp p0="') msg.append(valid_xml(quote(comp[0], '/>_= \t'))) msg.append('" p1="') msg.append(valid_xml(quote(comp[1], '/>_= \t'))) msg.append('" p2="') msg.append(valid_xml(quote(comp[2], '/>_= \t'))) msg.append('" p3="') msg.append(valid_xml(quote(comp[3], '/>_= \t'))) msg.append('"/>') msg.append("</xml>") return ''.join(msg) identifier_start = ascii_letters + '_' identifier_part = ascii_letters + '_' + digits identifier_start = set(identifier_start) identifier_part = set(identifier_part) def isidentifier(s): return s.isidentifier() TokenAndQualifier = namedtuple('TokenAndQualifier', 'token, qualifier') def extract_token_and_qualifier(text, line=0, column=0): ''' Extracts the token a qualifier from the text given the line/colum (see test_extract_token_and_qualifier for examples). :param unicode text: :param int line: 0-based :param int column: 0-based ''' # Note: not using the tokenize module because text should be unicode and # line/column refer to the unicode text (otherwise we'd have to know # those ranges after converted to bytes). if line < 0: line = 0 if column < 0: column = 0 if isinstance(text, bytes): text = text.decode('utf-8') lines = text.splitlines() try: text = lines[line] except IndexError: return TokenAndQualifier(u'', u'') if column >= len(text): column = len(text) text = text[:column] token = u'' qualifier = u'' temp_token = [] for i in range(column - 1, -1, -1): c = text[i] if c in identifier_part or isidentifier(c) or c == u'.': temp_token.append(c) else: break temp_token = u''.join(reversed(temp_token)) if u'.' in temp_token: temp_token = temp_token.split(u'.') token = u'.'.join(temp_token[:-1]) qualifier = temp_token[-1] else: qualifier = temp_token return TokenAndQualifier(token, qualifier)
8,544
Python
30.884328
127
0.587196
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_filesystem_encoding.py
import sys def __getfilesystemencoding(): ''' Note: there's a copy of this method in interpreterInfo.py ''' try: ret = sys.getfilesystemencoding() if not ret: raise RuntimeError('Unable to get encoding.') return ret except: try: #Handle Jython from java.lang import System # @UnresolvedImport env = System.getProperty("os.name").lower() if env.find('win') != -1: return 'ISO-8859-1' #mbcs does not work on Jython, so, use a (hopefully) suitable replacement return 'utf-8' except: pass #Only available from 2.3 onwards. if sys.platform == 'win32': return 'mbcs' return 'utf-8' def getfilesystemencoding(): try: ret = __getfilesystemencoding() #Check if the encoding is actually there to be used! if hasattr('', 'encode'): ''.encode(ret) if hasattr('', 'decode'): ''.decode(ret) return ret except: return 'utf-8'
1,095
Python
25.095237
110
0.536073
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_imports_tipper.py
import inspect import os.path import sys from _pydev_bundle._pydev_tipper_common import do_find from _pydevd_bundle.pydevd_utils import hasattr_checked, dir_checked from inspect import getfullargspec def getargspec(*args, **kwargs): arg_spec = getfullargspec(*args, **kwargs) return arg_spec.args, arg_spec.varargs, arg_spec.varkw, arg_spec.defaults, arg_spec.kwonlyargs or [], arg_spec.kwonlydefaults or {} # completion types. TYPE_IMPORT = '0' TYPE_CLASS = '1' TYPE_FUNCTION = '2' TYPE_ATTR = '3' TYPE_BUILTIN = '4' TYPE_PARAM = '5' def _imp(name, log=None): try: return __import__(name) except: if '.' in name: sub = name[0:name.rfind('.')] if log is not None: log.add_content('Unable to import', name, 'trying with', sub) log.add_exception() return _imp(sub, log) else: s = 'Unable to import module: %s - sys.path: %s' % (str(name), sys.path) if log is not None: log.add_content(s) log.add_exception() raise ImportError(s) IS_IPY = False if sys.platform == 'cli': IS_IPY = True _old_imp = _imp def _imp(name, log=None): # We must add a reference in clr for .Net import clr # @UnresolvedImport initial_name = name while '.' in name: try: clr.AddReference(name) break # If it worked, that's OK. except: name = name[0:name.rfind('.')] else: try: clr.AddReference(name) except: pass # That's OK (not dot net module). return _old_imp(initial_name, log) def get_file(mod): f = None try: f = inspect.getsourcefile(mod) or inspect.getfile(mod) except: try: f = getattr(mod, '__file__', None) except: f = None if f and f.lower(f[-4:]) in ['.pyc', '.pyo']: filename = f[:-4] + '.py' if os.path.exists(filename): f = filename return f def Find(name, log=None): f = None mod = _imp(name, log) parent = mod foundAs = '' if inspect.ismodule(mod): f = get_file(mod) components = name.split('.') old_comp = None for comp in components[1:]: try: # this happens in the following case: # we have mx.DateTime.mxDateTime.mxDateTime.pyd # but after importing it, mx.DateTime.mxDateTime shadows access to mxDateTime.pyd mod = getattr(mod, comp) except AttributeError: if old_comp != comp: raise if inspect.ismodule(mod): f = get_file(mod) else: if len(foundAs) > 0: foundAs = foundAs + '.' foundAs = foundAs + comp old_comp = comp return f, mod, parent, foundAs def search_definition(data): '''@return file, line, col ''' data = data.replace('\n', '') if data.endswith('.'): data = data.rstrip('.') f, mod, parent, foundAs = Find(data) try: return do_find(f, mod), foundAs except: return do_find(f, parent), foundAs def generate_tip(data, log=None): data = data.replace('\n', '') if data.endswith('.'): data = data.rstrip('.') f, mod, parent, foundAs = Find(data, log) # print_ >> open('temp.txt', 'w'), f tips = generate_imports_tip_for_module(mod) return f, tips def check_char(c): if c == '-' or c == '.': return '_' return c _SENTINEL = object() def generate_imports_tip_for_module(obj_to_complete, dir_comps=None, getattr=getattr, filter=lambda name:True): ''' @param obj_to_complete: the object from where we should get the completions @param dir_comps: if passed, we should not 'dir' the object and should just iterate those passed as kwonly_arg parameter @param getattr: the way to get kwonly_arg given object from the obj_to_complete (used for the completer) @param filter: kwonly_arg callable that receives the name and decides if it should be appended or not to the results @return: list of tuples, so that each tuple represents kwonly_arg completion with: name, doc, args, type (from the TYPE_* constants) ''' ret = [] if dir_comps is None: dir_comps = dir_checked(obj_to_complete) if hasattr_checked(obj_to_complete, '__dict__'): dir_comps.append('__dict__') if hasattr_checked(obj_to_complete, '__class__'): dir_comps.append('__class__') get_complete_info = True if len(dir_comps) > 1000: # ok, we don't want to let our users wait forever... # no complete info for you... get_complete_info = False dontGetDocsOn = (float, int, str, tuple, list, dict) dontGetattrOn = (dict, list, set, tuple) for d in dir_comps: if d is None: continue if not filter(d): continue args = '' try: try: if isinstance(obj_to_complete, dontGetattrOn): raise Exception('Since python 3.9, e.g. "dict[str]" will return' " a dict that's only supposed to take strings. " 'Interestingly, e.g. dict["val"] is also valid ' 'and presumably represents a dict that only takes ' 'keys that are "val". This breaks our check for ' 'class attributes.') obj = getattr(obj_to_complete.__class__, d) except: obj = getattr(obj_to_complete, d) except: # just ignore and get it without additional info ret.append((d, '', args, TYPE_BUILTIN)) else: if get_complete_info: try: retType = TYPE_BUILTIN # check if we have to get docs getDoc = True for class_ in dontGetDocsOn: if isinstance(obj, class_): getDoc = False break doc = '' if getDoc: # no need to get this info... too many constants are defined and # makes things much slower (passing all that through sockets takes quite some time) try: doc = inspect.getdoc(obj) if doc is None: doc = '' except: # may happen on jython when checking java classes (so, just ignore it) doc = '' if inspect.ismethod(obj) or inspect.isbuiltin(obj) or inspect.isfunction(obj) or inspect.isroutine(obj): try: args, vargs, kwargs, defaults, kwonly_args, kwonly_defaults = getargspec(obj) args = args[:] for kwonly_arg in kwonly_args: default = kwonly_defaults.get(kwonly_arg, _SENTINEL) if default is not _SENTINEL: args.append('%s=%s' % (kwonly_arg, default)) else: args.append(str(kwonly_arg)) args = '(%s)' % (', '.join(args)) except TypeError: # ok, let's see if we can get the arguments from the doc args, doc = signature_from_docstring(doc, getattr(obj, '__name__', None)) retType = TYPE_FUNCTION elif inspect.isclass(obj): retType = TYPE_CLASS elif inspect.ismodule(obj): retType = TYPE_IMPORT else: retType = TYPE_ATTR # add token and doc to return - assure only strings. ret.append((d, doc, args, retType)) except: # just ignore and get it without aditional info ret.append((d, '', args, TYPE_BUILTIN)) else: # get_complete_info == False if inspect.ismethod(obj) or inspect.isbuiltin(obj) or inspect.isfunction(obj) or inspect.isroutine(obj): retType = TYPE_FUNCTION elif inspect.isclass(obj): retType = TYPE_CLASS elif inspect.ismodule(obj): retType = TYPE_IMPORT else: retType = TYPE_ATTR # ok, no complete info, let's try to do this as fast and clean as possible # so, no docs for this kind of information, only the signatures ret.append((d, '', str(args), retType)) return ret def signature_from_docstring(doc, obj_name): args = '()' try: found = False if len(doc) > 0: if IS_IPY: # Handle case where we have the situation below # sort(self, object cmp, object key) # sort(self, object cmp, object key, bool reverse) # sort(self) # sort(self, object cmp) # Or: sort(self: list, cmp: object, key: object) # sort(self: list, cmp: object, key: object, reverse: bool) # sort(self: list) # sort(self: list, cmp: object) if obj_name: name = obj_name + '(' # Fix issue where it was appearing sort(aa)sort(bb)sort(cc) in the same line. lines = doc.splitlines() if len(lines) == 1: c = doc.count(name) if c > 1: doc = ('\n' + name).join(doc.split(name)) major = '' for line in doc.splitlines(): if line.startswith(name) and line.endswith(')'): if len(line) > len(major): major = line if major: args = major[major.index('('):] found = True if not found: i = doc.find('->') if i < 0: i = doc.find('--') if i < 0: i = doc.find('\n') if i < 0: i = doc.find('\r') if i > 0: s = doc[0:i] s = s.strip() # let's see if we have a docstring in the first line if s[-1] == ')': start = s.find('(') if start >= 0: end = s.find('[') if end <= 0: end = s.find(')') if end <= 0: end = len(s) args = s[start:end] if not args[-1] == ')': args = args + ')' # now, get rid of unwanted chars l = len(args) - 1 r = [] for i in range(len(args)): if i == 0 or i == l: r.append(args[i]) else: r.append(check_char(args[i])) args = ''.join(r) if IS_IPY: if args.startswith('(self:'): i = args.find(',') if i >= 0: args = '(self' + args[i:] else: args = '(self)' i = args.find(')') if i > 0: args = args[:i + 1] except: pass return args, doc
12,350
Python
32.024064
135
0.453279
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_imports.py
from _pydev_bundle._pydev_saved_modules import xmlrpclib from _pydev_bundle._pydev_saved_modules import xmlrpcserver SimpleXMLRPCServer = xmlrpcserver.SimpleXMLRPCServer from _pydev_bundle._pydev_execfile import execfile from _pydev_bundle._pydev_saved_modules import _queue from _pydevd_bundle.pydevd_exec2 import Exec from urllib.parse import quote, quote_plus, unquote_plus # @UnresolvedImport
404
Python
27.928569
77
0.814356
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_log.py
import traceback import sys from io import StringIO class Log: def __init__(self): self._contents = [] def add_content(self, *content): self._contents.append(' '.join(content)) def add_exception(self): s = StringIO() exc_info = sys.exc_info() traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file=s) self._contents.append(s.getvalue()) def get_contents(self): return '\n'.join(self._contents) def clear_log(self): del self._contents[:]
555
Python
21.239999
92
0.598198
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_calltip_util.py
''' License: Apache 2.0 Author: Yuli Fitterman ''' import types from _pydevd_bundle.pydevd_constants import IS_JYTHON try: import inspect except: import traceback; traceback.print_exc() # Ok, no inspect available (search will not work) from _pydev_bundle._pydev_imports_tipper import signature_from_docstring def is_bound_method(obj): if isinstance(obj, types.MethodType): return getattr(obj, '__self__', getattr(obj, 'im_self', None)) is not None else: return False def get_class_name(instance): return getattr(getattr(instance, "__class__", None), "__name__", None) def get_bound_class_name(obj): my_self = getattr(obj, '__self__', getattr(obj, 'im_self', None)) if my_self is None: return None return get_class_name(my_self) def get_description(obj): try: ob_call = obj.__call__ except: ob_call = None if isinstance(obj, type) or type(obj).__name__ == 'classobj': fob = getattr(obj, '__init__', lambda: None) if not isinstance(fob, (types.FunctionType, types.MethodType)): fob = obj elif is_bound_method(ob_call): fob = ob_call else: fob = obj argspec = "" fn_name = None fn_class = None if isinstance(fob, (types.FunctionType, types.MethodType)): spec_info = inspect.getfullargspec(fob) argspec = inspect.formatargspec(*spec_info) fn_name = getattr(fob, '__name__', None) if isinstance(obj, type) or type(obj).__name__ == 'classobj': fn_name = "__init__" fn_class = getattr(obj, "__name__", "UnknownClass") elif is_bound_method(obj) or is_bound_method(ob_call): fn_class = get_bound_class_name(obj) or "UnknownClass" else: fn_name = getattr(fob, '__name__', None) fn_self = getattr(fob, '__self__', None) if fn_self is not None and not isinstance(fn_self, types.ModuleType): fn_class = get_class_name(fn_self) doc_string = get_docstring(ob_call) if is_bound_method(ob_call) else get_docstring(obj) return create_method_stub(fn_name, fn_class, argspec, doc_string) def create_method_stub(fn_name, fn_class, argspec, doc_string): if fn_name and argspec: doc_string = "" if doc_string is None else doc_string fn_stub = create_function_stub(fn_name, argspec, doc_string, indent=1 if fn_class else 0) if fn_class: expr = fn_class if fn_name == '__init__' else fn_class + '().' + fn_name return create_class_stub(fn_class, fn_stub) + "\n" + expr else: expr = fn_name return fn_stub + "\n" + expr elif doc_string: if fn_name: restored_signature, _ = signature_from_docstring(doc_string, fn_name) if restored_signature: return create_method_stub(fn_name, fn_class, restored_signature, doc_string) return create_function_stub('unknown', '(*args, **kwargs)', doc_string) + '\nunknown' else: return '' def get_docstring(obj): if obj is not None: try: if IS_JYTHON: # Jython doc = obj.__doc__ if doc is not None: return doc from _pydev_bundle import _pydev_jy_imports_tipper is_method, infos = _pydev_jy_imports_tipper.ismethod(obj) ret = '' if is_method: for info in infos: ret += info.get_as_doc() return ret else: doc = inspect.getdoc(obj) if doc is not None: return doc except: pass else: return '' try: # if no attempt succeeded, try to return repr()... return repr(obj) except: try: # otherwise the class return str(obj.__class__) except: # if all fails, go to an empty string return '' def create_class_stub(class_name, contents): return "class %s(object):\n%s" % (class_name, contents) def create_function_stub(fn_name, fn_argspec, fn_docstring, indent=0): def shift_right(string, prefix): return ''.join(prefix + line for line in string.splitlines(True)) fn_docstring = shift_right(inspect.cleandoc(fn_docstring), " " * (indent + 1)) ret = ''' def %s%s: """%s""" pass ''' % (fn_name, fn_argspec, fn_docstring) ret = ret[1:] # remove first /n ret = ret.replace('\t', " ") if indent: prefix = " " * indent ret = shift_right(ret, prefix) return ret
4,687
Python
29.051282
97
0.56326
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_console_utils.py
import os import sys import traceback from _pydev_bundle.pydev_imports import xmlrpclib, _queue, Exec from _pydev_bundle._pydev_calltip_util import get_description from _pydevd_bundle import pydevd_vars from _pydevd_bundle import pydevd_xml from _pydevd_bundle.pydevd_constants import (IS_JYTHON, NEXT_VALUE_SEPARATOR, get_global_debugger, silence_warnings_decorator) from contextlib import contextmanager from _pydev_bundle import pydev_log from _pydevd_bundle.pydevd_utils import interrupt_main_thread from io import StringIO # ======================================================================================================================= # BaseStdIn # ======================================================================================================================= class BaseStdIn: def __init__(self, original_stdin=sys.stdin, *args, **kwargs): try: self.encoding = sys.stdin.encoding except: # Not sure if it's available in all Python versions... pass self.original_stdin = original_stdin try: self.errors = sys.stdin.errors # Who knew? sys streams have an errors attribute! except: # Not sure if it's available in all Python versions... pass def readline(self, *args, **kwargs): # sys.stderr.write('Cannot readline out of the console evaluation\n') -- don't show anything # This could happen if the user had done input('enter number).<-- upon entering this, that message would appear, # which is not something we want. return '\n' def write(self, *args, **kwargs): pass # not available StdIn (but it can be expected to be in the stream interface) def flush(self, *args, **kwargs): pass # not available StdIn (but it can be expected to be in the stream interface) def read(self, *args, **kwargs): # in the interactive interpreter, a read and a readline are the same. return self.readline() def close(self, *args, **kwargs): pass # expected in StdIn def __iter__(self): # BaseStdIn would not be considered as Iterable in Python 3 without explicit `__iter__` implementation return self.original_stdin.__iter__() def __getattr__(self, item): # it's called if the attribute wasn't found if hasattr(self.original_stdin, item): return getattr(self.original_stdin, item) raise AttributeError("%s has no attribute %s" % (self.original_stdin, item)) # ======================================================================================================================= # StdIn # ======================================================================================================================= class StdIn(BaseStdIn): ''' Object to be added to stdin (to emulate it as non-blocking while the next line arrives) ''' def __init__(self, interpreter, host, client_port, original_stdin=sys.stdin): BaseStdIn.__init__(self, original_stdin) self.interpreter = interpreter self.client_port = client_port self.host = host def readline(self, *args, **kwargs): # Ok, callback into the client to get the new input try: server = xmlrpclib.Server('http://%s:%s' % (self.host, self.client_port)) requested_input = server.RequestInput() if not requested_input: return '\n' # Yes, a readline must return something (otherwise we can get an EOFError on the input() call). else: # readline should end with '\n' (not doing so makes IPython 5 remove the last *valid* character). requested_input += '\n' return requested_input except KeyboardInterrupt: raise # Let KeyboardInterrupt go through -- #PyDev-816: Interrupting infinite loop in the Interactive Console except: return '\n' def close(self, *args, **kwargs): pass # expected in StdIn #======================================================================================================================= # DebugConsoleStdIn #======================================================================================================================= class DebugConsoleStdIn(BaseStdIn): ''' Object to be added to stdin (to emulate it as non-blocking while the next line arrives) ''' def __init__(self, py_db, original_stdin): ''' :param py_db: If None, get_global_debugger() is used. ''' BaseStdIn.__init__(self, original_stdin) self._py_db = py_db self._in_notification = 0 def __send_input_requested_message(self, is_started): try: py_db = self._py_db if py_db is None: py_db = get_global_debugger() if py_db is None: return cmd = py_db.cmd_factory.make_input_requested_message(is_started) py_db.writer.add_command(cmd) except Exception: pydev_log.exception() @contextmanager def notify_input_requested(self): self._in_notification += 1 if self._in_notification == 1: self.__send_input_requested_message(True) try: yield finally: self._in_notification -= 1 if self._in_notification == 0: self.__send_input_requested_message(False) def readline(self, *args, **kwargs): with self.notify_input_requested(): return self.original_stdin.readline(*args, **kwargs) def read(self, *args, **kwargs): with self.notify_input_requested(): return self.original_stdin.read(*args, **kwargs) class CodeFragment: def __init__(self, text, is_single_line=True): self.text = text self.is_single_line = is_single_line def append(self, code_fragment): self.text = self.text + "\n" + code_fragment.text if not code_fragment.is_single_line: self.is_single_line = False # ======================================================================================================================= # BaseInterpreterInterface # ======================================================================================================================= class BaseInterpreterInterface: def __init__(self, mainThread, connect_status_queue=None): self.mainThread = mainThread self.interruptable = False self.exec_queue = _queue.Queue(0) self.buffer = None self.banner_shown = False self.connect_status_queue = connect_status_queue self.mpl_modules_for_patching = {} self.init_mpl_modules_for_patching() def build_banner(self): return 'print({0})\n'.format(repr(self.get_greeting_msg())) def get_greeting_msg(self): return 'PyDev console: starting.\n' def init_mpl_modules_for_patching(self): from pydev_ipython.matplotlibtools import activate_matplotlib, activate_pylab, activate_pyplot self.mpl_modules_for_patching = { "matplotlib": lambda: activate_matplotlib(self.enableGui), "matplotlib.pyplot": activate_pyplot, "pylab": activate_pylab } def need_more_for_code(self, source): # PyDev-502: PyDev 3.9 F2 doesn't support backslash continuations # Strangely even the IPython console is_complete said it was complete # even with a continuation char at the end. if source.endswith('\\'): return True if hasattr(self.interpreter, 'is_complete'): return not self.interpreter.is_complete(source) try: # At this point, it should always be single. # If we don't do this, things as: # # for i in range(10): print(i) # # (in a single line) don't work. # Note that it won't give an error and code will be None (so, it'll # use execMultipleLines in the next call in this case). symbol = 'single' code = self.interpreter.compile(source, '<input>', symbol) except (OverflowError, SyntaxError, ValueError): # Case 1 return False if code is None: # Case 2 return True # Case 3 return False def need_more(self, code_fragment): if self.buffer is None: self.buffer = code_fragment else: self.buffer.append(code_fragment) return self.need_more_for_code(self.buffer.text) def create_std_in(self, debugger=None, original_std_in=None): if debugger is None: return StdIn(self, self.host, self.client_port, original_stdin=original_std_in) else: return DebugConsoleStdIn(py_db=debugger, original_stdin=original_std_in) def add_exec(self, code_fragment, debugger=None): # In case sys.excepthook called, use original excepthook #PyDev-877: Debug console freezes with Python 3.5+ # (showtraceback does it on python 3.5 onwards) sys.excepthook = sys.__excepthook__ try: original_in = sys.stdin try: help = None if 'pydoc' in sys.modules: pydoc = sys.modules['pydoc'] # Don't import it if it still is not there. if hasattr(pydoc, 'help'): # You never know how will the API be changed, so, let's code defensively here help = pydoc.help if not hasattr(help, 'input'): help = None except: # Just ignore any error here pass more = False try: sys.stdin = self.create_std_in(debugger, original_in) try: if help is not None: # This will enable the help() function to work. try: try: help.input = sys.stdin except AttributeError: help._input = sys.stdin except: help = None if not self._input_error_printed: self._input_error_printed = True sys.stderr.write('\nError when trying to update pydoc.help.input\n') sys.stderr.write('(help() may not work -- please report this as a bug in the pydev bugtracker).\n\n') traceback.print_exc() try: self.start_exec() if hasattr(self, 'debugger'): self.debugger.enable_tracing() more = self.do_add_exec(code_fragment) if hasattr(self, 'debugger'): self.debugger.disable_tracing() self.finish_exec(more) finally: if help is not None: try: try: help.input = original_in except AttributeError: help._input = original_in except: pass finally: sys.stdin = original_in except SystemExit: raise except: traceback.print_exc() finally: sys.__excepthook__ = sys.excepthook return more def do_add_exec(self, codeFragment): ''' Subclasses should override. @return: more (True if more input is needed to complete the statement and False if the statement is complete). ''' raise NotImplementedError() def get_namespace(self): ''' Subclasses should override. @return: dict with namespace. ''' raise NotImplementedError() def __resolve_reference__(self, text): """ :type text: str """ obj = None if '.' not in text: try: obj = self.get_namespace()[text] except KeyError: pass if obj is None: try: obj = self.get_namespace()['__builtins__'][text] except: pass if obj is None: try: obj = getattr(self.get_namespace()['__builtins__'], text, None) except: pass else: try: last_dot = text.rindex('.') parent_context = text[0:last_dot] res = pydevd_vars.eval_in_context(parent_context, self.get_namespace(), self.get_namespace()) obj = getattr(res, text[last_dot + 1:]) except: pass return obj def getDescription(self, text): try: obj = self.__resolve_reference__(text) if obj is None: return '' return get_description(obj) except: return '' def do_exec_code(self, code, is_single_line): try: code_fragment = CodeFragment(code, is_single_line) more = self.need_more(code_fragment) if not more: code_fragment = self.buffer self.buffer = None self.exec_queue.put(code_fragment) return more except: traceback.print_exc() return False def execLine(self, line): return self.do_exec_code(line, True) def execMultipleLines(self, lines): if IS_JYTHON: more = False for line in lines.split('\n'): more = self.do_exec_code(line, True) return more else: return self.do_exec_code(lines, False) def interrupt(self): self.buffer = None # Also clear the buffer when it's interrupted. try: if self.interruptable: # Fix for #PyDev-500: Console interrupt can't interrupt on sleep interrupt_main_thread(self.mainThread) self.finish_exec(False) return True except: traceback.print_exc() return False def close(self): sys.exit(0) def start_exec(self): self.interruptable = True def get_server(self): if getattr(self, 'host', None) is not None: return xmlrpclib.Server('http://%s:%s' % (self.host, self.client_port)) else: return None server = property(get_server) def ShowConsole(self): server = self.get_server() if server is not None: server.ShowConsole() def finish_exec(self, more): self.interruptable = False server = self.get_server() if server is not None: return server.NotifyFinished(more) else: return True def getFrame(self): xml = StringIO() hidden_ns = self.get_ipython_hidden_vars_dict() xml.write("<xml>") xml.write(pydevd_xml.frame_vars_to_xml(self.get_namespace(), hidden_ns)) xml.write("</xml>") return xml.getvalue() @silence_warnings_decorator def getVariable(self, attributes): xml = StringIO() xml.write("<xml>") val_dict = pydevd_vars.resolve_compound_var_object_fields(self.get_namespace(), attributes) if val_dict is None: val_dict = {} for k, val in val_dict.items(): val = val_dict[k] evaluate_full_value = pydevd_xml.should_evaluate_full_value(val) xml.write(pydevd_vars.var_to_xml(val, k, evaluate_full_value=evaluate_full_value)) xml.write("</xml>") return xml.getvalue() def getArray(self, attr, roffset, coffset, rows, cols, format): name = attr.split("\t")[-1] array = pydevd_vars.eval_in_context(name, self.get_namespace(), self.get_namespace()) return pydevd_vars.table_like_struct_to_xml(array, name, roffset, coffset, rows, cols, format) def evaluate(self, expression): xml = StringIO() xml.write("<xml>") result = pydevd_vars.eval_in_context(expression, self.get_namespace(), self.get_namespace()) xml.write(pydevd_vars.var_to_xml(result, expression)) xml.write("</xml>") return xml.getvalue() @silence_warnings_decorator def loadFullValue(self, seq, scope_attrs): """ Evaluate full value for async Console variables in a separate thread and send results to IDE side :param seq: id of command :param scope_attrs: a sequence of variables with their attributes separated by NEXT_VALUE_SEPARATOR (i.e.: obj\tattr1\tattr2NEXT_VALUE_SEPARATORobj2\attr1\tattr2) :return: """ frame_variables = self.get_namespace() var_objects = [] vars = scope_attrs.split(NEXT_VALUE_SEPARATOR) for var_attrs in vars: if '\t' in var_attrs: name, attrs = var_attrs.split('\t', 1) else: name = var_attrs attrs = None if name in frame_variables: var_object = pydevd_vars.resolve_var_object(frame_variables[name], attrs) var_objects.append((var_object, name)) else: var_object = pydevd_vars.eval_in_context(name, frame_variables, frame_variables) var_objects.append((var_object, name)) from _pydevd_bundle.pydevd_comm import GetValueAsyncThreadConsole py_db = getattr(self, 'debugger', None) if py_db is None: py_db = get_global_debugger() if py_db is None: from pydevd import PyDB py_db = PyDB() t = GetValueAsyncThreadConsole(py_db, self.get_server(), seq, var_objects) t.start() def changeVariable(self, attr, value): def do_change_variable(): Exec('%s=%s' % (attr, value), self.get_namespace(), self.get_namespace()) # Important: it has to be really enabled in the main thread, so, schedule # it to run in the main thread. self.exec_queue.put(do_change_variable) def connectToDebugger(self, debuggerPort, debugger_options=None): ''' Used to show console with variables connection. Mainly, monkey-patches things in the debugger structure so that the debugger protocol works. ''' if debugger_options is None: debugger_options = {} env_key = "PYDEVD_EXTRA_ENVS" if env_key in debugger_options: for (env_name, value) in debugger_options[env_key].items(): existing_value = os.environ.get(env_name, None) if existing_value: os.environ[env_name] = "%s%c%s" % (existing_value, os.path.pathsep, value) else: os.environ[env_name] = value if env_name == "PYTHONPATH": sys.path.append(value) del debugger_options[env_key] def do_connect_to_debugger(): try: # Try to import the packages needed to attach the debugger import pydevd from _pydev_bundle._pydev_saved_modules import threading except: # This happens on Jython embedded in host eclipse traceback.print_exc() sys.stderr.write('pydevd is not available, cannot connect\n') from _pydevd_bundle.pydevd_constants import set_thread_id from _pydev_bundle import pydev_localhost set_thread_id(threading.current_thread(), "console_main") VIRTUAL_FRAME_ID = "1" # matches PyStackFrameConsole.java VIRTUAL_CONSOLE_ID = "console_main" # matches PyThreadConsole.java f = FakeFrame() f.f_back = None f.f_globals = {} # As globals=locals here, let's simply let it empty (and save a bit of network traffic). f.f_locals = self.get_namespace() self.debugger = pydevd.PyDB() self.debugger.add_fake_frame(thread_id=VIRTUAL_CONSOLE_ID, frame_id=VIRTUAL_FRAME_ID, frame=f) try: pydevd.apply_debugger_options(debugger_options) self.debugger.connect(pydev_localhost.get_localhost(), debuggerPort) self.debugger.prepare_to_run() self.debugger.disable_tracing() except: traceback.print_exc() sys.stderr.write('Failed to connect to target debugger.\n') # Register to process commands when idle self.debugrunning = False try: import pydevconsole pydevconsole.set_debug_hook(self.debugger.process_internal_commands) except: traceback.print_exc() sys.stderr.write('Version of Python does not support debuggable Interactive Console.\n') # Important: it has to be really enabled in the main thread, so, schedule # it to run in the main thread. self.exec_queue.put(do_connect_to_debugger) return ('connect complete',) def handshake(self): if self.connect_status_queue is not None: self.connect_status_queue.put(True) return "PyCharm" def get_connect_status_queue(self): return self.connect_status_queue def hello(self, input_str): # Don't care what the input string is return ("Hello eclipse",) def enableGui(self, guiname): ''' Enable the GUI specified in guiname (see inputhook for list). As with IPython, enabling multiple GUIs isn't an error, but only the last one's main loop runs and it may not work ''' def do_enable_gui(): from _pydev_bundle.pydev_versioncheck import versionok_for_gui if versionok_for_gui(): try: from pydev_ipython.inputhook import enable_gui enable_gui(guiname) except: sys.stderr.write("Failed to enable GUI event loop integration for '%s'\n" % guiname) traceback.print_exc() elif guiname not in ['none', '', None]: # Only print a warning if the guiname was going to do something sys.stderr.write("PyDev console: Python version does not support GUI event loop integration for '%s'\n" % guiname) # Return value does not matter, so return back what was sent return guiname # Important: it has to be really enabled in the main thread, so, schedule # it to run in the main thread. self.exec_queue.put(do_enable_gui) def get_ipython_hidden_vars_dict(self): return None # ======================================================================================================================= # FakeFrame # ======================================================================================================================= class FakeFrame: ''' Used to show console with variables connection. A class to be used as a mock of a frame. '''
23,769
Python
36.140625
133
0.531869
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_sys_patch.py
import sys def patch_sys_module(): def patched_exc_info(fun): def pydev_debugger_exc_info(): type, value, traceback = fun() if type == ImportError: # we should not show frame added by plugin_import call if traceback and hasattr(traceback, "tb_next"): return type, value, traceback.tb_next return type, value, traceback return pydev_debugger_exc_info system_exc_info = sys.exc_info sys.exc_info = patched_exc_info(system_exc_info) if not hasattr(sys, "system_exc_info"): sys.system_exc_info = system_exc_info def patched_reload(orig_reload): def pydev_debugger_reload(module): orig_reload(module) if module.__name__ == "sys": # if sys module was reloaded we should patch it again patch_sys_module() return pydev_debugger_reload def patch_reload(): import builtins # Py3 if hasattr(builtins, "reload"): sys.builtin_orig_reload = builtins.reload builtins.reload = patched_reload(sys.builtin_orig_reload) # @UndefinedVariable try: import imp sys.imp_orig_reload = imp.reload imp.reload = patched_reload(sys.imp_orig_reload) # @UndefinedVariable except: pass else: try: import importlib sys.importlib_orig_reload = importlib.reload # @UndefinedVariable importlib.reload = patched_reload(sys.importlib_orig_reload) # @UndefinedVariable except: pass del builtins def cancel_patches_in_sys_module(): sys.exc_info = sys.system_exc_info # @UndefinedVariable import builtins # Py3 if hasattr(sys, "builtin_orig_reload"): builtins.reload = sys.builtin_orig_reload if hasattr(sys, "imp_orig_reload"): import imp imp.reload = sys.imp_orig_reload if hasattr(sys, "importlib_orig_reload"): import importlib importlib.reload = sys.importlib_orig_reload del builtins
2,076
Python
27.067567
94
0.611753
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_jy_imports_tipper.py
import traceback from io import StringIO from java.lang import StringBuffer # @UnresolvedImport from java.lang import String # @UnresolvedImport import java.lang # @UnresolvedImport import sys from _pydev_bundle._pydev_tipper_common import do_find from org.python.core import PyReflectedFunction # @UnresolvedImport from org.python import core # @UnresolvedImport from org.python.core import PyClass # @UnresolvedImport # completion types. TYPE_IMPORT = '0' TYPE_CLASS = '1' TYPE_FUNCTION = '2' TYPE_ATTR = '3' TYPE_BUILTIN = '4' TYPE_PARAM = '5' def _imp(name): try: return __import__(name) except: if '.' in name: sub = name[0:name.rfind('.')] return _imp(sub) else: s = 'Unable to import module: %s - sys.path: %s' % (str(name), sys.path) raise RuntimeError(s) import java.util _java_rt_file = getattr(java.util, '__file__', None) def Find(name): f = None if name.startswith('__builtin__'): if name == '__builtin__.str': name = 'org.python.core.PyString' elif name == '__builtin__.dict': name = 'org.python.core.PyDictionary' mod = _imp(name) parent = mod foundAs = '' try: f = getattr(mod, '__file__', None) except: f = None components = name.split('.') old_comp = None for comp in components[1:]: try: # this happens in the following case: # we have mx.DateTime.mxDateTime.mxDateTime.pyd # but after importing it, mx.DateTime.mxDateTime does shadows access to mxDateTime.pyd mod = getattr(mod, comp) except AttributeError: if old_comp != comp: raise if hasattr(mod, '__file__'): f = mod.__file__ else: if len(foundAs) > 0: foundAs = foundAs + '.' foundAs = foundAs + comp old_comp = comp if f is None and name.startswith('java.lang'): # Hack: java.lang.__file__ is None on Jython 2.7 (whereas it pointed to rt.jar on Jython 2.5). f = _java_rt_file if f is not None: if f.endswith('.pyc'): f = f[:-1] elif f.endswith('$py.class'): f = f[:-len('$py.class')] + '.py' return f, mod, parent, foundAs def format_param_class_name(paramClassName): if paramClassName.startswith('<type \'') and paramClassName.endswith('\'>'): paramClassName = paramClassName[len('<type \''):-2] if paramClassName.startswith('['): if paramClassName == '[C': paramClassName = 'char[]' elif paramClassName == '[B': paramClassName = 'byte[]' elif paramClassName == '[I': paramClassName = 'int[]' elif paramClassName.startswith('[L') and paramClassName.endswith(';'): paramClassName = paramClassName[2:-1] paramClassName += '[]' return paramClassName def generate_tip(data, log=None): data = data.replace('\n', '') if data.endswith('.'): data = data.rstrip('.') f, mod, parent, foundAs = Find(data) tips = generate_imports_tip_for_module(mod) return f, tips #======================================================================================================================= # Info #======================================================================================================================= class Info: def __init__(self, name, **kwargs): self.name = name self.doc = kwargs.get('doc', None) self.args = kwargs.get('args', ()) # tuple of strings self.varargs = kwargs.get('varargs', None) # string self.kwargs = kwargs.get('kwargs', None) # string self.ret = kwargs.get('ret', None) # string def basic_as_str(self): '''@returns this class information as a string (just basic format) ''' args = self.args s = 'function:%s args=%s, varargs=%s, kwargs=%s, docs:%s' % \ (self.name, args, self.varargs, self.kwargs, self.doc) return s def get_as_doc(self): s = str(self.name) if self.doc: s += '\n@doc %s\n' % str(self.doc) if self.args: s += '\n@params ' for arg in self.args: s += str(format_param_class_name(arg)) s += ' ' if self.varargs: s += '\n@varargs ' s += str(self.varargs) if self.kwargs: s += '\n@kwargs ' s += str(self.kwargs) if self.ret: s += '\n@return ' s += str(format_param_class_name(str(self.ret))) return str(s) def isclass(cls): return isinstance(cls, core.PyClass) or type(cls) == java.lang.Class def ismethod(func): '''this function should return the information gathered on a function @param func: this is the function we want to get info on @return a tuple where: 0 = indicates whether the parameter passed is a method or not 1 = a list of classes 'Info', with the info gathered from the function this is a list because when we have methods from java with the same name and different signatures, we actually have many methods, each with its own set of arguments ''' try: if isinstance(func, core.PyFunction): # ok, this is from python, created by jython # print_ ' PyFunction' def getargs(func_code): """Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is a list of argument names (possibly containing nested lists), and 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" nargs = func_code.co_argcount names = func_code.co_varnames args = list(names[:nargs]) step = 0 if not hasattr(func_code, 'CO_VARARGS'): from org.python.core import CodeFlag # @UnresolvedImport co_varargs_flag = CodeFlag.CO_VARARGS.flag co_varkeywords_flag = CodeFlag.CO_VARKEYWORDS.flag else: co_varargs_flag = func_code.CO_VARARGS co_varkeywords_flag = func_code.CO_VARKEYWORDS varargs = None if func_code.co_flags & co_varargs_flag: varargs = func_code.co_varnames[nargs] nargs = nargs + 1 varkw = None if func_code.co_flags & co_varkeywords_flag: varkw = func_code.co_varnames[nargs] return args, varargs, varkw args = getargs(func.func_code) return 1, [Info(func.func_name, args=args[0], varargs=args[1], kwargs=args[2], doc=func.func_doc)] if isinstance(func, core.PyMethod): # this is something from java itself, and jython just wrapped it... # things to play in func: # ['__call__', '__class__', '__cmp__', '__delattr__', '__dir__', '__doc__', '__findattr__', '__name__', '_doget', 'im_class', # 'im_func', 'im_self', 'toString'] # print_ ' PyMethod' # that's the PyReflectedFunction... keep going to get it func = func.im_func if isinstance(func, PyReflectedFunction): # this is something from java itself, and jython just wrapped it... # print_ ' PyReflectedFunction' infos = [] for i in range(len(func.argslist)): # things to play in func.argslist[i]: # 'PyArgsCall', 'PyArgsKeywordsCall', 'REPLACE', 'StandardCall', 'args', 'compare', 'compareTo', 'data', 'declaringClass' # 'flags', 'isStatic', 'matches', 'precedence'] # print_ ' ', func.argslist[i].data.__class__ # func.argslist[i].data.__class__ == java.lang.reflect.Method if func.argslist[i]: met = func.argslist[i].data name = met.getName() try: ret = met.getReturnType() except AttributeError: ret = '' parameterTypes = met.getParameterTypes() args = [] for j in range(len(parameterTypes)): paramTypesClass = parameterTypes[j] try: try: paramClassName = paramTypesClass.getName() except: paramClassName = paramTypesClass.getName(paramTypesClass) except AttributeError: try: paramClassName = repr(paramTypesClass) # should be something like <type 'object'> paramClassName = paramClassName.split('\'')[1] except: paramClassName = repr(paramTypesClass) # just in case something else happens... it will at least be visible # if the parameter equals [C, it means it it a char array, so, let's change it a = format_param_class_name(paramClassName) # a = a.replace('[]','Array') # a = a.replace('Object', 'obj') # a = a.replace('String', 's') # a = a.replace('Integer', 'i') # a = a.replace('Char', 'c') # a = a.replace('Double', 'd') args.append(a) # so we don't leave invalid code info = Info(name, args=args, ret=ret) # print_ info.basic_as_str() infos.append(info) return 1, infos except Exception: s = StringIO() traceback.print_exc(file=s) return 1, [Info(str('ERROR'), doc=s.getvalue())] return 0, None def ismodule(mod): # java modules... do we have other way to know that? if not hasattr(mod, 'getClass') and not hasattr(mod, '__class__') \ and hasattr(mod, '__name__'): return 1 return isinstance(mod, core.PyModule) def dir_obj(obj): ret = [] found = java.util.HashMap() original = obj if hasattr(obj, '__class__'): if obj.__class__ == java.lang.Class: # get info about superclasses classes = [] classes.append(obj) try: c = obj.getSuperclass() except TypeError: # may happen on jython when getting the java.lang.Class class c = obj.getSuperclass(obj) while c != None: classes.append(c) c = c.getSuperclass() # get info about interfaces interfs = [] for obj in classes: try: interfs.extend(obj.getInterfaces()) except TypeError: interfs.extend(obj.getInterfaces(obj)) classes.extend(interfs) # now is the time when we actually get info on the declared methods and fields for obj in classes: try: declaredMethods = obj.getDeclaredMethods() except TypeError: declaredMethods = obj.getDeclaredMethods(obj) try: declaredFields = obj.getDeclaredFields() except TypeError: declaredFields = obj.getDeclaredFields(obj) for i in range(len(declaredMethods)): name = declaredMethods[i].getName() ret.append(name) found.put(name, 1) for i in range(len(declaredFields)): name = declaredFields[i].getName() ret.append(name) found.put(name, 1) elif isclass(obj.__class__): d = dir(obj.__class__) for name in d: ret.append(name) found.put(name, 1) # this simple dir does not always get all the info, that's why we have the part before # (e.g.: if we do a dir on String, some methods that are from other interfaces such as # charAt don't appear) d = dir(original) for name in d: if found.get(name) != 1: ret.append(name) return ret def format_arg(arg): '''formats an argument to be shown ''' s = str(arg) dot = s.rfind('.') if dot >= 0: s = s[dot + 1:] s = s.replace(';', '') s = s.replace('[]', 'Array') if len(s) > 0: c = s[0].lower() s = c + s[1:] return s def search_definition(data): '''@return file, line, col ''' data = data.replace('\n', '') if data.endswith('.'): data = data.rstrip('.') f, mod, parent, foundAs = Find(data) try: return do_find(f, mod), foundAs except: return do_find(f, parent), foundAs def generate_imports_tip_for_module(obj_to_complete, dir_comps=None, getattr=getattr, filter=lambda name:True): ''' @param obj_to_complete: the object from where we should get the completions @param dir_comps: if passed, we should not 'dir' the object and should just iterate those passed as a parameter @param getattr: the way to get a given object from the obj_to_complete (used for the completer) @param filter: a callable that receives the name and decides if it should be appended or not to the results @return: list of tuples, so that each tuple represents a completion with: name, doc, args, type (from the TYPE_* constants) ''' ret = [] if dir_comps is None: dir_comps = dir_obj(obj_to_complete) for d in dir_comps: if d is None: continue if not filter(d): continue args = '' doc = '' retType = TYPE_BUILTIN try: obj = getattr(obj_to_complete, d) except (AttributeError, java.lang.NoClassDefFoundError): # jython has a bug in its custom classloader that prevents some things from working correctly, so, let's see if # we can fix that... (maybe fixing it in jython itself would be a better idea, as this is clearly a bug) # for that we need a custom classloader... we have references from it in the below places: # # http://mindprod.com/jgloss/classloader.html # http://www.javaworld.com/javaworld/jw-03-2000/jw-03-classload-p2.html # http://freshmeat.net/articles/view/1643/ # # note: this only happens when we add things to the sys.path at runtime, if they are added to the classpath # before the run, everything goes fine. # # The code below ilustrates what I mean... # # import sys # sys.path.insert(1, r"C:\bin\eclipse310\plugins\org.junit_3.8.1\junit.jar" ) # # import junit.framework # print_ dir(junit.framework) #shows the TestCase class here # # import junit.framework.TestCase # # raises the error: # Traceback (innermost last): # File "<console>", line 1, in ? # ImportError: No module named TestCase # # whereas if we had added the jar to the classpath before, everything would be fine by now... ret.append((d, '', '', retType)) # that's ok, private things cannot be gotten... continue else: isMet = ismethod(obj) if isMet[0] and isMet[1]: info = isMet[1][0] try: args, vargs, kwargs = info.args, info.varargs, info.kwargs doc = info.get_as_doc() r = '' for a in (args): if len(r) > 0: r += ', ' r += format_arg(a) args = '(%s)' % (r) except TypeError: traceback.print_exc() args = '()' retType = TYPE_FUNCTION elif isclass(obj): retType = TYPE_CLASS elif ismodule(obj): retType = TYPE_IMPORT # add token and doc to return - assure only strings. ret.append((d, doc, args, retType)) return ret if __name__ == "__main__": sys.path.append(r'D:\dev_programs\eclipse_3\310\eclipse\plugins\org.junit_3.8.1\junit.jar') sys.stdout.write('%s\n' % Find('junit.framework.TestCase'))
17,063
Python
33.612576
140
0.515033
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_execfile.py
# We must redefine it in Py3k if it's not already there def execfile(file, glob=None, loc=None): if glob is None: import sys glob = sys._getframe().f_back.f_globals if loc is None: loc = glob import tokenize with tokenize.open(file) as stream: contents = stream.read() # execute the script (note: it's important to compile first to have the filename set in debug mode) exec(compile(contents + "\n", file, 'exec'), glob, loc)
483
Python
31.266665
103
0.643892
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py
# License: EPL import os import re import sys from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle.pydevd_constants import get_global_debugger, IS_WINDOWS, IS_JYTHON, get_current_thread_id, \ sorted_dict_repr from _pydev_bundle import pydev_log from contextlib import contextmanager from _pydevd_bundle import pydevd_constants from _pydevd_bundle.pydevd_defaults import PydevdCustomization import ast try: from pathlib import Path except ImportError: Path = None #=============================================================================== # Things that are dependent on having the pydevd debugger #=============================================================================== pydev_src_dir = os.path.dirname(os.path.dirname(__file__)) _arg_patch = threading.local() @contextmanager def skip_subprocess_arg_patch(): _arg_patch.apply_arg_patching = False try: yield finally: _arg_patch.apply_arg_patching = True def _get_apply_arg_patching(): return getattr(_arg_patch, 'apply_arg_patching', True) def _get_setup_updated_with_protocol_and_ppid(setup, is_exec=False): if setup is None: setup = {} setup = setup.copy() # Discard anything related to the protocol (we'll set the the protocol based on the one # currently set). setup.pop(pydevd_constants.ARGUMENT_HTTP_JSON_PROTOCOL, None) setup.pop(pydevd_constants.ARGUMENT_JSON_PROTOCOL, None) setup.pop(pydevd_constants.ARGUMENT_QUOTED_LINE_PROTOCOL, None) if not is_exec: # i.e.: The ppid for the subprocess is the current pid. # If it's an exec, keep it what it was. setup[pydevd_constants.ARGUMENT_PPID] = os.getpid() protocol = pydevd_constants.get_protocol() if protocol == pydevd_constants.HTTP_JSON_PROTOCOL: setup[pydevd_constants.ARGUMENT_HTTP_JSON_PROTOCOL] = True elif protocol == pydevd_constants.JSON_PROTOCOL: setup[pydevd_constants.ARGUMENT_JSON_PROTOCOL] = True elif protocol == pydevd_constants.QUOTED_LINE_PROTOCOL: setup[pydevd_constants.ARGUMENT_QUOTED_LINE_PROTOCOL] = True elif protocol == pydevd_constants.HTTP_PROTOCOL: setup[pydevd_constants.ARGUMENT_HTTP_PROTOCOL] = True else: pydev_log.debug('Unexpected protocol: %s', protocol) return setup class _LastFutureImportFinder(ast.NodeVisitor): def __init__(self): self.last_future_import_found = None def visit_ImportFrom(self, node): if node.module == '__future__': self.last_future_import_found = node def _get_offset_from_line_col(code, line, col): offset = 0 for i, line_contents in enumerate(code.splitlines(True)): if i == line: offset += col return offset else: offset += len(line_contents) return -1 def _separate_future_imports(code): ''' :param code: The code from where we want to get the __future__ imports (note that it's possible that there's no such entry). :return tuple(str, str): The return is a tuple(future_import, code). If the future import is not available a return such as ('', code) is given, otherwise, the future import will end with a ';' (so that it can be put right before the pydevd attach code). ''' try: node = ast.parse(code, '<string>', 'exec') visitor = _LastFutureImportFinder() visitor.visit(node) if visitor.last_future_import_found is None: return '', code node = visitor.last_future_import_found offset = -1 if hasattr(node, 'end_lineno') and hasattr(node, 'end_col_offset'): # Python 3.8 onwards has these (so, use when possible). line, col = node.end_lineno, node.end_col_offset offset = _get_offset_from_line_col(code, line - 1, col) # ast lines are 1-based, make it 0-based. else: # end line/col not available, let's just find the offset and then search # for the alias from there. line, col = node.lineno, node.col_offset offset = _get_offset_from_line_col(code, line - 1, col) # ast lines are 1-based, make it 0-based. if offset >= 0 and node.names: from_future_import_name = node.names[-1].name i = code.find(from_future_import_name, offset) if i < 0: offset = -1 else: offset = i + len(from_future_import_name) if offset >= 0: for i in range(offset, len(code)): if code[i] in (' ', '\t', ';', ')', '\n'): offset += 1 else: break future_import = code[:offset] code_remainder = code[offset:] # Now, put '\n' lines back into the code remainder (we had to search for # `\n)`, but in case we just got the `\n`, it should be at the remainder, # not at the future import. while future_import.endswith('\n'): future_import = future_import[:-1] code_remainder = '\n' + code_remainder if not future_import.endswith(';'): future_import += ';' return future_import, code_remainder # This shouldn't happen... pydev_log.info('Unable to find line %s in code:\n%r', line, code) return '', code except: pydev_log.exception('Error getting from __future__ imports from: %r', code) return '', code def _get_python_c_args(host, port, code, args, setup): setup = _get_setup_updated_with_protocol_and_ppid(setup) # i.e.: We want to make the repr sorted so that it works in tests. setup_repr = setup if setup is None else (sorted_dict_repr(setup)) future_imports = '' if '__future__' in code: # If the code has a __future__ import, we need to be able to strip the __future__ # imports from the code and add them to the start of our code snippet. future_imports, code = _separate_future_imports(code) return ("%simport sys; sys.path.insert(0, r'%s'); import pydevd; pydevd.PydevdCustomization.DEFAULT_PROTOCOL=%r; " "pydevd.settrace(host=%r, port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True, access_token=%r, client_access_token=%r, __setup_holder__=%s); " "%s" ) % ( future_imports, pydev_src_dir, pydevd_constants.get_protocol(), host, port, setup.get('access-token'), setup.get('client-access-token'), setup_repr, code) def _get_host_port(): import pydevd host, port = pydevd.dispatch() return host, port def _is_managed_arg(arg): pydevd_py = _get_str_type_compatible(arg, 'pydevd.py') if arg.endswith(pydevd_py): return True return False def _on_forked_process(setup_tracing=True): pydevd_constants.after_fork() pydev_log.initialize_debug_stream(reinitialize=True) if setup_tracing: pydev_log.debug('pydevd on forked process: %s', os.getpid()) import pydevd pydevd.threadingCurrentThread().__pydevd_main_thread = True pydevd.settrace_forked(setup_tracing=setup_tracing) def _on_set_trace_for_new_thread(global_debugger): if global_debugger is not None: global_debugger.enable_tracing() def _get_str_type_compatible(s, args): ''' This method converts `args` to byte/unicode based on the `s' type. ''' if isinstance(args, (list, tuple)): ret = [] for arg in args: if type(s) == type(arg): ret.append(arg) else: if isinstance(s, bytes): ret.append(arg.encode('utf-8')) else: ret.append(arg.decode('utf-8')) return ret else: if type(s) == type(args): return args else: if isinstance(s, bytes): return args.encode('utf-8') else: return args.decode('utf-8') #=============================================================================== # Things related to monkey-patching #=============================================================================== def is_python(path): single_quote, double_quote = _get_str_type_compatible(path, ["'", '"']) if path.endswith(single_quote) or path.endswith(double_quote): path = path[1:len(path) - 1] filename = os.path.basename(path).lower() for name in _get_str_type_compatible(filename, ['python', 'jython', 'pypy']): if filename.find(name) != -1: return True return False class InvalidTypeInArgsException(Exception): pass def remove_quotes_from_args(args): if sys.platform == "win32": new_args = [] for x in args: if Path is not None and isinstance(x, Path): x = str(x) else: if not isinstance(x, (bytes, str)): raise InvalidTypeInArgsException(str(type(x))) double_quote, two_double_quotes = _get_str_type_compatible(x, ['"', '""']) if x != two_double_quotes: if len(x) > 1 and x.startswith(double_quote) and x.endswith(double_quote): x = x[1:-1] new_args.append(x) return new_args else: new_args = [] for x in args: if Path is not None and isinstance(x, Path): x = x.as_posix() else: if not isinstance(x, (bytes, str)): raise InvalidTypeInArgsException(str(type(x))) new_args.append(x) return new_args def quote_arg_win32(arg): fix_type = lambda x: _get_str_type_compatible(arg, x) # See if we need to quote at all - empty strings need quoting, as do strings # with whitespace or quotes in them. Backslashes do not need quoting. if arg and not set(arg).intersection(fix_type(' "\t\n\v')): return arg # Per https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-commandlinetoargvw, # the standard way to interpret arguments in double quotes is as follows: # # 2N backslashes followed by a quotation mark produce N backslashes followed by # begin/end quote. This does not become part of the parsed argument, but toggles # the "in quotes" mode. # # 2N+1 backslashes followed by a quotation mark again produce N backslashes followed # by a quotation mark literal ("). This does not toggle the "in quotes" mode. # # N backslashes not followed by a quotation mark simply produce N backslashes. # # This code needs to do the reverse transformation, thus: # # N backslashes followed by " produce 2N+1 backslashes followed by " # # N backslashes at the end (i.e. where the closing " goes) produce 2N backslashes. # # N backslashes in any other position remain as is. arg = re.sub(fix_type(r'(\\*)\"'), fix_type(r'\1\1\\"'), arg) arg = re.sub(fix_type(r'(\\*)$'), fix_type(r'\1\1'), arg) return fix_type('"') + arg + fix_type('"') def quote_args(args): if sys.platform == "win32": return list(map(quote_arg_win32, args)) else: return args def patch_args(args, is_exec=False): ''' :param list args: Arguments to patch. :param bool is_exec: If it's an exec, the current process will be replaced (this means we have to keep the same ppid). ''' try: pydev_log.debug("Patching args: %s", args) original_args = args try: unquoted_args = remove_quotes_from_args(args) except InvalidTypeInArgsException as e: pydev_log.info('Unable to monkey-patch subprocess arguments because a type found in the args is invalid: %s', e) return original_args # Internally we should reference original_args (if we want to return them) or unquoted_args # to add to the list which will be then quoted in the end. del args from pydevd import SetupHolder if not unquoted_args: return original_args if not is_python(unquoted_args[0]): pydev_log.debug("Process is not python, returning.") return original_args # Note: we create a copy as string to help with analyzing the arguments, but # the final list should have items from the unquoted_args as they were initially. args_as_str = _get_str_type_compatible('', unquoted_args) params_with_value_in_separate_arg = ( '--check-hash-based-pycs', '--jit' # pypy option ) # All short switches may be combined together. The ones below require a value and the # value itself may be embedded in the arg. # # i.e.: Python accepts things as: # # python -OQold -qmtest # # Which is the same as: # # python -O -Q old -q -m test # # or even: # # python -OQold "-vcimport sys;print(sys)" # # Which is the same as: # # python -O -Q old -v -c "import sys;print(sys)" params_with_combinable_arg = set(('W', 'X', 'Q', 'c', 'm')) module_name = None before_module_flag = '' module_name_i_start = -1 module_name_i_end = -1 code = None code_i = -1 code_i_end = -1 code_flag = '' filename = None filename_i = -1 ignore_next = True # start ignoring the first (the first entry is the python executable) for i, arg_as_str in enumerate(args_as_str): if ignore_next: ignore_next = False continue if arg_as_str.startswith('-'): if arg_as_str == '-': # Contents will be read from the stdin. This is not currently handled. pydev_log.debug('Unable to fix arguments to attach debugger on subprocess when reading from stdin ("python ... -").') return original_args if arg_as_str.startswith(params_with_value_in_separate_arg): if arg_as_str in params_with_value_in_separate_arg: ignore_next = True continue break_out = False for j, c in enumerate(arg_as_str): # i.e.: Python supports -X faulthandler as well as -Xfaulthandler # (in one case we have to ignore the next and in the other we don't # have to ignore it). if c in params_with_combinable_arg: remainder = arg_as_str[j + 1:] if not remainder: ignore_next = True if c == 'm': # i.e.: Something as # python -qm test # python -m test # python -qmtest before_module_flag = arg_as_str[:j] # before_module_flag would then be "-q" if before_module_flag == '-': before_module_flag = '' module_name_i_start = i if not remainder: module_name = unquoted_args[i + 1] module_name_i_end = i + 1 else: # i.e.: python -qmtest should provide 'test' as the module_name module_name = unquoted_args[i][j + 1:] module_name_i_end = module_name_i_start break_out = True break elif c == 'c': # i.e.: Something as # python -qc "import sys" # python -c "import sys" # python "-qcimport sys" code_flag = arg_as_str[:j + 1] # code_flag would then be "-qc" if not remainder: # arg_as_str is something as "-qc", "import sys" code = unquoted_args[i + 1] code_i_end = i + 2 else: # if arg_as_str is something as "-qcimport sys" code = remainder # code would be "import sys" code_i_end = i + 1 code_i = i break_out = True break else: break if break_out: break else: # It doesn't start with '-' and we didn't ignore this entry: # this means that this is the file to be executed. filename = unquoted_args[i] # Note that the filename is not validated here. # There are cases where even a .exe is valid (xonsh.exe): # https://github.com/microsoft/debugpy/issues/945 # So, we should support whatever runpy.run_path # supports in this case. filename_i = i if _is_managed_arg(filename): # no need to add pydevd twice pydev_log.debug('Skipped monkey-patching as pydevd.py is in args already.') return original_args break else: # We didn't find the filename (something is unexpected). pydev_log.debug('Unable to fix arguments to attach debugger on subprocess (filename not found).') return original_args if code_i != -1: host, port = _get_host_port() if port is not None: new_args = [] new_args.extend(unquoted_args[:code_i]) new_args.append(code_flag) new_args.append(_get_python_c_args(host, port, code, unquoted_args, SetupHolder.setup)) new_args.extend(unquoted_args[code_i_end:]) return quote_args(new_args) first_non_vm_index = max(filename_i, module_name_i_start) if first_non_vm_index == -1: pydev_log.debug('Unable to fix arguments to attach debugger on subprocess (could not resolve filename nor module name).') return original_args # Original args should be something as: # ['X:\\pysrc\\pydevd.py', '--multiprocess', '--print-in-debugger-startup', # '--vm_type', 'python', '--client', '127.0.0.1', '--port', '56352', '--file', 'x:\\snippet1.py'] from _pydevd_bundle.pydevd_command_line_handling import setup_to_argv new_args = [] new_args.extend(unquoted_args[:first_non_vm_index]) if before_module_flag: new_args.append(before_module_flag) add_module_at = len(new_args) + 1 new_args.extend(setup_to_argv( _get_setup_updated_with_protocol_and_ppid(SetupHolder.setup, is_exec=is_exec), skip_names=set(('module', 'cmd-line')) )) new_args.append('--file') if module_name is not None: assert module_name_i_start != -1 assert module_name_i_end != -1 # Always after 'pydevd' (i.e.: pydevd "--module" --multiprocess ...) new_args.insert(add_module_at, '--module') new_args.append(module_name) new_args.extend(unquoted_args[module_name_i_end + 1:]) elif filename is not None: assert filename_i != -1 new_args.append(filename) new_args.extend(unquoted_args[filename_i + 1:]) else: raise AssertionError('Internal error (unexpected condition)') return quote_args(new_args) except: pydev_log.exception('Error patching args (debugger not attached to subprocess).') return original_args def str_to_args_windows(args): # See https://docs.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments. # # Implemetation ported from DebugPlugin.parseArgumentsWindows: # https://github.com/eclipse/eclipse.platform.debug/blob/master/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java result = [] DEFAULT = 0 ARG = 1 IN_DOUBLE_QUOTE = 2 state = DEFAULT backslashes = 0 buf = '' args_len = len(args) for i in range(args_len): ch = args[i] if (ch == '\\'): backslashes += 1 continue elif (backslashes != 0): if ch == '"': while backslashes >= 2: backslashes -= 2 buf += '\\' if (backslashes == 1): if (state == DEFAULT): state = ARG buf += '"' backslashes = 0 continue # else fall through to switch else: # false alarm, treat passed backslashes literally... if (state == DEFAULT): state = ARG while backslashes > 0: backslashes -= 1 buf += '\\' # fall through to switch if ch in (' ', '\t'): if (state == DEFAULT): # skip continue elif (state == ARG): state = DEFAULT result.append(buf) buf = '' continue if state in (DEFAULT, ARG): if ch == '"': state = IN_DOUBLE_QUOTE else: state = ARG buf += ch elif state == IN_DOUBLE_QUOTE: if ch == '"': if (i + 1 < args_len and args[i + 1] == '"'): # Undocumented feature in Windows: # Two consecutive double quotes inside a double-quoted argument are interpreted as # a single double quote. buf += '"' i += 1 else: state = ARG else: buf += ch else: raise RuntimeError('Illegal condition') if len(buf) > 0 or state != DEFAULT: result.append(buf) return result def patch_arg_str_win(arg_str): args = str_to_args_windows(arg_str) # Fix https://youtrack.jetbrains.com/issue/PY-9767 (args may be empty) if not args or not is_python(args[0]): return arg_str arg_str = ' '.join(patch_args(args)) pydev_log.debug("New args: %s", arg_str) return arg_str def monkey_patch_module(module, funcname, create_func): if hasattr(module, funcname): original_name = 'original_' + funcname if not hasattr(module, original_name): setattr(module, original_name, getattr(module, funcname)) setattr(module, funcname, create_func(original_name)) def monkey_patch_os(funcname, create_func): monkey_patch_module(os, funcname, create_func) def warn_multiproc(): pass # TODO: Provide logging as messages to the IDE. # pydev_log.error_once( # "pydev debugger: New process is launching (breakpoints won't work in the new process).\n" # "pydev debugger: To debug that process please enable 'Attach to subprocess automatically while debugging?' option in the debugger settings.\n") # def create_warn_multiproc(original_name): def new_warn_multiproc(*args, **kwargs): import os warn_multiproc() return getattr(os, original_name)(*args, **kwargs) return new_warn_multiproc def create_execl(original_name): def new_execl(path, *args): """ os.execl(path, arg0, arg1, ...) os.execle(path, arg0, arg1, ..., env) os.execlp(file, arg0, arg1, ...) os.execlpe(file, arg0, arg1, ..., env) """ if _get_apply_arg_patching(): args = patch_args(args, is_exec=True) send_process_created_message() send_process_about_to_be_replaced() return getattr(os, original_name)(path, *args) return new_execl def create_execv(original_name): def new_execv(path, args): """ os.execv(path, args) os.execvp(file, args) """ if _get_apply_arg_patching(): args = patch_args(args, is_exec=True) send_process_created_message() send_process_about_to_be_replaced() return getattr(os, original_name)(path, args) return new_execv def create_execve(original_name): """ os.execve(path, args, env) os.execvpe(file, args, env) """ def new_execve(path, args, env): if _get_apply_arg_patching(): args = patch_args(args, is_exec=True) send_process_created_message() send_process_about_to_be_replaced() return getattr(os, original_name)(path, args, env) return new_execve def create_spawnl(original_name): def new_spawnl(mode, path, *args): """ os.spawnl(mode, path, arg0, arg1, ...) os.spawnlp(mode, file, arg0, arg1, ...) """ if _get_apply_arg_patching(): args = patch_args(args) send_process_created_message() return getattr(os, original_name)(mode, path, *args) return new_spawnl def create_spawnv(original_name): def new_spawnv(mode, path, args): """ os.spawnv(mode, path, args) os.spawnvp(mode, file, args) """ if _get_apply_arg_patching(): args = patch_args(args) send_process_created_message() return getattr(os, original_name)(mode, path, args) return new_spawnv def create_spawnve(original_name): """ os.spawnve(mode, path, args, env) os.spawnvpe(mode, file, args, env) """ def new_spawnve(mode, path, args, env): if _get_apply_arg_patching(): args = patch_args(args) send_process_created_message() return getattr(os, original_name)(mode, path, args, env) return new_spawnve def create_posix_spawn(original_name): """ os.posix_spawn(executable, args, env, **kwargs) """ def new_posix_spawn(executable, args, env, **kwargs): if _get_apply_arg_patching(): args = patch_args(args) send_process_created_message() return getattr(os, original_name)(executable, args, env, **kwargs) return new_posix_spawn def create_fork_exec(original_name): """ _posixsubprocess.fork_exec(args, executable_list, close_fds, ... (13 more)) """ def new_fork_exec(args, *other_args): import _posixsubprocess # @UnresolvedImport if _get_apply_arg_patching(): args = patch_args(args) send_process_created_message() return getattr(_posixsubprocess, original_name)(args, *other_args) return new_fork_exec def create_warn_fork_exec(original_name): """ _posixsubprocess.fork_exec(args, executable_list, close_fds, ... (13 more)) """ def new_warn_fork_exec(*args): try: import _posixsubprocess warn_multiproc() return getattr(_posixsubprocess, original_name)(*args) except: pass return new_warn_fork_exec def create_CreateProcess(original_name): """ CreateProcess(*args, **kwargs) """ def new_CreateProcess(app_name, cmd_line, *args): try: import _subprocess except ImportError: import _winapi as _subprocess if _get_apply_arg_patching(): cmd_line = patch_arg_str_win(cmd_line) send_process_created_message() return getattr(_subprocess, original_name)(app_name, cmd_line, *args) return new_CreateProcess def create_CreateProcessWarnMultiproc(original_name): """ CreateProcess(*args, **kwargs) """ def new_CreateProcess(*args): try: import _subprocess except ImportError: import _winapi as _subprocess warn_multiproc() return getattr(_subprocess, original_name)(*args) return new_CreateProcess def create_fork(original_name): def new_fork(): # A simple fork will result in a new python process is_new_python_process = True frame = sys._getframe() apply_arg_patch = _get_apply_arg_patching() is_subprocess_fork = False while frame is not None: if frame.f_code.co_name == '_execute_child' and 'subprocess' in frame.f_code.co_filename: is_subprocess_fork = True # If we're actually in subprocess.Popen creating a child, it may # result in something which is not a Python process, (so, we # don't want to connect with it in the forked version). executable = frame.f_locals.get('executable') if executable is not None: is_new_python_process = False if is_python(executable): is_new_python_process = True break frame = frame.f_back frame = None # Just make sure we don't hold on to it. protocol = pydevd_constants.get_protocol() child_process = getattr(os, original_name)() # fork if not child_process: if is_new_python_process: PydevdCustomization.DEFAULT_PROTOCOL = protocol _on_forked_process(setup_tracing=apply_arg_patch and not is_subprocess_fork) else: if is_new_python_process: send_process_created_message() return child_process return new_fork def send_process_created_message(): py_db = get_global_debugger() if py_db is not None: py_db.send_process_created_message() def send_process_about_to_be_replaced(): py_db = get_global_debugger() if py_db is not None: py_db.send_process_about_to_be_replaced() def patch_new_process_functions(): # os.execl(path, arg0, arg1, ...) # os.execle(path, arg0, arg1, ..., env) # os.execlp(file, arg0, arg1, ...) # os.execlpe(file, arg0, arg1, ..., env) # os.execv(path, args) # os.execve(path, args, env) # os.execvp(file, args) # os.execvpe(file, args, env) monkey_patch_os('execl', create_execl) monkey_patch_os('execle', create_execl) monkey_patch_os('execlp', create_execl) monkey_patch_os('execlpe', create_execl) monkey_patch_os('execv', create_execv) monkey_patch_os('execve', create_execve) monkey_patch_os('execvp', create_execv) monkey_patch_os('execvpe', create_execve) # os.spawnl(mode, path, ...) # os.spawnle(mode, path, ..., env) # os.spawnlp(mode, file, ...) # os.spawnlpe(mode, file, ..., env) # os.spawnv(mode, path, args) # os.spawnve(mode, path, args, env) # os.spawnvp(mode, file, args) # os.spawnvpe(mode, file, args, env) monkey_patch_os('spawnl', create_spawnl) monkey_patch_os('spawnle', create_spawnl) monkey_patch_os('spawnlp', create_spawnl) monkey_patch_os('spawnlpe', create_spawnl) monkey_patch_os('spawnv', create_spawnv) monkey_patch_os('spawnve', create_spawnve) monkey_patch_os('spawnvp', create_spawnv) monkey_patch_os('spawnvpe', create_spawnve) monkey_patch_os('posix_spawn', create_posix_spawn) if not IS_JYTHON: if not IS_WINDOWS: monkey_patch_os('fork', create_fork) try: import _posixsubprocess monkey_patch_module(_posixsubprocess, 'fork_exec', create_fork_exec) except ImportError: pass else: # Windows try: import _subprocess except ImportError: import _winapi as _subprocess monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcess) def patch_new_process_functions_with_warning(): monkey_patch_os('execl', create_warn_multiproc) monkey_patch_os('execle', create_warn_multiproc) monkey_patch_os('execlp', create_warn_multiproc) monkey_patch_os('execlpe', create_warn_multiproc) monkey_patch_os('execv', create_warn_multiproc) monkey_patch_os('execve', create_warn_multiproc) monkey_patch_os('execvp', create_warn_multiproc) monkey_patch_os('execvpe', create_warn_multiproc) monkey_patch_os('spawnl', create_warn_multiproc) monkey_patch_os('spawnle', create_warn_multiproc) monkey_patch_os('spawnlp', create_warn_multiproc) monkey_patch_os('spawnlpe', create_warn_multiproc) monkey_patch_os('spawnv', create_warn_multiproc) monkey_patch_os('spawnve', create_warn_multiproc) monkey_patch_os('spawnvp', create_warn_multiproc) monkey_patch_os('spawnvpe', create_warn_multiproc) monkey_patch_os('posix_spawn', create_warn_multiproc) if not IS_JYTHON: if not IS_WINDOWS: monkey_patch_os('fork', create_warn_multiproc) try: import _posixsubprocess monkey_patch_module(_posixsubprocess, 'fork_exec', create_warn_fork_exec) except ImportError: pass else: # Windows try: import _subprocess except ImportError: import _winapi as _subprocess monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcessWarnMultiproc) class _NewThreadStartupWithTrace: def __init__(self, original_func, args, kwargs): self.original_func = original_func self.args = args self.kwargs = kwargs def __call__(self): # We monkey-patch the thread creation so that this function is called in the new thread. At this point # we notify of its creation and start tracing it. py_db = get_global_debugger() thread_id = None if py_db is not None: # Note: if this is a thread from threading.py, we're too early in the boostrap process (because we mocked # the start_new_thread internal machinery and thread._bootstrap has not finished), so, the code below needs # to make sure that we use the current thread bound to the original function and not use # threading.current_thread() unless we're sure it's a dummy thread. t = getattr(self.original_func, '__self__', getattr(self.original_func, 'im_self', None)) if not isinstance(t, threading.Thread): # This is not a threading.Thread but a Dummy thread (so, get it as a dummy thread using # currentThread). t = threading.current_thread() if not getattr(t, 'is_pydev_daemon_thread', False): thread_id = get_current_thread_id(t) py_db.notify_thread_created(thread_id, t) _on_set_trace_for_new_thread(py_db) if getattr(py_db, 'thread_analyser', None) is not None: try: from _pydevd_bundle.pydevd_concurrency_analyser.pydevd_concurrency_logger import log_new_thread log_new_thread(py_db, t) except: sys.stderr.write("Failed to detect new thread for visualization") try: ret = self.original_func(*self.args, **self.kwargs) finally: if thread_id is not None: if py_db is not None: # At thread shutdown we only have pydevd-related code running (which shouldn't # be tracked). py_db.disable_tracing() py_db.notify_thread_not_alive(thread_id) return ret class _NewThreadStartupWithoutTrace: def __init__(self, original_func, args, kwargs): self.original_func = original_func self.args = args self.kwargs = kwargs def __call__(self): return self.original_func(*self.args, **self.kwargs) _UseNewThreadStartup = _NewThreadStartupWithTrace def _get_threading_modules_to_patch(): threading_modules_to_patch = [] try: import thread as _thread except: import _thread threading_modules_to_patch.append(_thread) threading_modules_to_patch.append(threading) return threading_modules_to_patch threading_modules_to_patch = _get_threading_modules_to_patch() def patch_thread_module(thread_module): if getattr(thread_module, '_original_start_new_thread', None) is None: if thread_module is threading: if not hasattr(thread_module, '_start_new_thread'): return # Jython doesn't have it. _original_start_new_thread = thread_module._original_start_new_thread = thread_module._start_new_thread else: _original_start_new_thread = thread_module._original_start_new_thread = thread_module.start_new_thread else: _original_start_new_thread = thread_module._original_start_new_thread class ClassWithPydevStartNewThread: def pydev_start_new_thread(self, function, args=(), kwargs={}): ''' We need to replace the original thread_module.start_new_thread with this function so that threads started through it and not through the threading module are properly traced. ''' return _original_start_new_thread(_UseNewThreadStartup(function, args, kwargs), ()) # This is a hack for the situation where the thread_module.start_new_thread is declared inside a class, such as the one below # class F(object): # start_new_thread = thread_module.start_new_thread # # def start_it(self): # self.start_new_thread(self.function, args, kwargs) # So, if it's an already bound method, calling self.start_new_thread won't really receive a different 'self' -- it # does work in the default case because in builtins self isn't passed either. pydev_start_new_thread = ClassWithPydevStartNewThread().pydev_start_new_thread try: # We need to replace the original thread_module.start_new_thread with this function so that threads started through # it and not through the threading module are properly traced. if thread_module is threading: thread_module._start_new_thread = pydev_start_new_thread else: thread_module.start_new_thread = pydev_start_new_thread thread_module.start_new = pydev_start_new_thread except: pass def patch_thread_modules(): for t in threading_modules_to_patch: patch_thread_module(t) def undo_patch_thread_modules(): for t in threading_modules_to_patch: try: t.start_new_thread = t._original_start_new_thread except: pass try: t.start_new = t._original_start_new_thread except: pass try: t._start_new_thread = t._original_start_new_thread except: pass def disable_trace_thread_modules(): ''' Can be used to temporarily stop tracing threads created with thread.start_new_thread. ''' global _UseNewThreadStartup _UseNewThreadStartup = _NewThreadStartupWithoutTrace def enable_trace_thread_modules(): ''' Can be used to start tracing threads created with thread.start_new_thread again. ''' global _UseNewThreadStartup _UseNewThreadStartup = _NewThreadStartupWithTrace def get_original_start_new_thread(threading_module): try: return threading_module._original_start_new_thread except: return threading_module.start_new_thread
40,358
Python
33.14467
187
0.567199
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_ipython_console.py
import sys from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface import traceback # Uncomment to force PyDev standard shell. # raise ImportError() from _pydev_bundle.pydev_ipython_console_011 import get_pydev_frontend #======================================================================================================================= # InterpreterInterface #======================================================================================================================= class InterpreterInterface(BaseInterpreterInterface): ''' The methods in this class should be registered in the xml-rpc server. ''' def __init__(self, host, client_port, main_thread, show_banner=True, connect_status_queue=None): BaseInterpreterInterface.__init__(self, main_thread, connect_status_queue) self.client_port = client_port self.host = host self.interpreter = get_pydev_frontend(host, client_port) self._input_error_printed = False self.notification_succeeded = False self.notification_tries = 0 self.notification_max_tries = 3 self.show_banner = show_banner self.notify_about_magic() def get_greeting_msg(self): if self.show_banner: self.interpreter.show_banner() return self.interpreter.get_greeting_msg() def do_add_exec(self, code_fragment): self.notify_about_magic() if code_fragment.text.rstrip().endswith('??'): print('IPython-->') try: res = bool(self.interpreter.add_exec(code_fragment.text)) finally: if code_fragment.text.rstrip().endswith('??'): print('<--IPython') return res def get_namespace(self): return self.interpreter.get_namespace() def getCompletions(self, text, act_tok): return self.interpreter.getCompletions(text, act_tok) def close(self): sys.exit(0) def notify_about_magic(self): if not self.notification_succeeded: self.notification_tries += 1 if self.notification_tries > self.notification_max_tries: return completions = self.getCompletions("%", "%") magic_commands = [x[0] for x in completions] server = self.get_server() if server is not None: try: server.NotifyAboutMagic(magic_commands, self.interpreter.is_automagic()) self.notification_succeeded = True except: self.notification_succeeded = False def get_ipython_hidden_vars_dict(self): try: if hasattr(self.interpreter, 'ipython') and hasattr(self.interpreter.ipython, 'user_ns_hidden'): user_ns_hidden = self.interpreter.ipython.user_ns_hidden if isinstance(user_ns_hidden, dict): # Since IPython 2 dict `user_ns_hidden` contains hidden variables and values user_hidden_dict = user_ns_hidden.copy() else: # In IPython 1.x `user_ns_hidden` used to be a set with names of hidden variables user_hidden_dict = dict([(key, val) for key, val in self.interpreter.ipython.user_ns.items() if key in user_ns_hidden]) # while `_`, `__` and `___` were not initialized, they are not presented in `user_ns_hidden` user_hidden_dict.setdefault('_', '') user_hidden_dict.setdefault('__', '') user_hidden_dict.setdefault('___', '') return user_hidden_dict except: # Getting IPython variables shouldn't break loading frame variables traceback.print_exc()
3,821
Python
38
120
0.558754
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_getopt.py
#======================================================================================================================= # getopt code copied since gnu_getopt is not available on jython 2.1 #======================================================================================================================= class GetoptError(Exception): opt = '' msg = '' def __init__(self, msg, opt=''): self.msg = msg self.opt = opt Exception.__init__(self, msg, opt) def __str__(self): return self.msg def gnu_getopt(args, shortopts, longopts=[]): """getopt(args, options[, long_options]) -> opts, args This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing options as soon as a non-option argument is encountered. If the first character of the option string is `+', or if the environment variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-option argument is encountered. """ opts = [] prog_args = [] if type('') == type(longopts): longopts = [longopts] else: longopts = list(longopts) # Allow options after non-option arguments? all_options_first = False if shortopts.startswith('+'): shortopts = shortopts[1:] all_options_first = True while args: if args[0] == '--': prog_args += args[1:] break if args[0][:2] == '--': opts, args = do_longs(opts, args[0][2:], longopts, args[1:]) elif args[0][:1] == '-': opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) else: if all_options_first: prog_args += args break else: prog_args.append(args[0]) args = args[1:] return opts, prog_args def do_longs(opts, opt, longopts, args): try: i = opt.index('=') except ValueError: optarg = None else: opt, optarg = opt[:i], opt[i + 1:] has_arg, opt = long_has_args(opt, longopts) if has_arg: if optarg is None: if not args: raise GetoptError('option --%s requires argument' % opt, opt) optarg, args = args[0], args[1:] elif optarg: raise GetoptError('option --%s must not have an argument' % opt, opt) opts.append(('--' + opt, optarg or '')) return opts, args # Return: # has_arg? # full option name def long_has_args(opt, longopts): possibilities = [o for o in longopts if o.startswith(opt)] if not possibilities: raise GetoptError('option --%s not recognized' % opt, opt) # Is there an exact match? if opt in possibilities: return False, opt elif opt + '=' in possibilities: return True, opt # No exact match, so better be unique. if len(possibilities) > 1: # XXX since possibilities contains all valid continuations, might be # nice to work them into the error msg raise GetoptError('option --%s not a unique prefix' % opt, opt) assert len(possibilities) == 1 unique_match = possibilities[0] has_arg = unique_match.endswith('=') if has_arg: unique_match = unique_match[:-1] return has_arg, unique_match def do_shorts(opts, optstring, shortopts, args): while optstring != '': opt, optstring = optstring[0], optstring[1:] if short_has_arg(opt, shortopts): if optstring == '': if not args: raise GetoptError('option -%s requires argument' % opt, opt) optstring, args = args[0], args[1:] optarg, optstring = optstring, '' else: optarg = '' opts.append(('-' + opt, optarg)) return opts, args def short_has_arg(opt, shortopts): for i in range(len(shortopts)): if opt == shortopts[i] != ':': return shortopts.startswith(':', i + 1) raise GetoptError('option -%s not recognized' % opt, opt) #======================================================================================================================= # End getopt code #=======================================================================================================================
4,458
Python
33.038168
120
0.506729
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_ipython_console_011.py
# TODO that would make IPython integration better # - show output other times then when enter was pressed # - support proper exit to allow IPython to cleanup (e.g. temp files created with %edit) # - support Ctrl-D (Ctrl-Z on Windows) # - use IPython (numbered) prompts in PyDev # - better integration of IPython and PyDev completions # - some of the semantics on handling the code completion are not correct: # eg: Start a line with % and then type c should give %cd as a completion by it doesn't # however type %c and request completions and %cd is given as an option # eg: Completing a magic when user typed it without the leading % causes the % to be inserted # to the left of what should be the first colon. """Interface to TerminalInteractiveShell for PyDev Interactive Console frontend for IPython 0.11 to 1.0+. """ from __future__ import print_function import os import sys import codeop import traceback from IPython.core.error import UsageError from IPython.core.completer import IPCompleter from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC from IPython.core.usage import default_banner_parts from IPython.utils.strdispatch import StrDispatch import IPython.core.release as IPythonRelease from IPython.terminal.interactiveshell import TerminalInteractiveShell try: from traitlets import CBool, Unicode except ImportError: from IPython.utils.traitlets import CBool, Unicode from IPython.core import release from _pydev_bundle.pydev_imports import xmlrpclib default_pydev_banner_parts = default_banner_parts default_pydev_banner = ''.join(default_pydev_banner_parts) def show_in_pager(self, strng, *args, **kwargs): """ Run a string through pager """ # On PyDev we just output the string, there are scroll bars in the console # to handle "paging". This is the same behaviour as when TERM==dump (see # page.py) # for compatibility with mime-bundle form: if isinstance(strng, dict): strng = strng.get('text/plain', strng) print(strng) def create_editor_hook(pydev_host, pydev_client_port): def call_editor(filename, line=0, wait=True): """ Open an editor in PyDev """ if line is None: line = 0 # Make sure to send an absolution path because unlike most editor hooks # we don't launch a process. This is more like what happens in the zmqshell filename = os.path.abspath(filename) # import sys # sys.__stderr__.write('Calling editor at: %s:%s\n' % (pydev_host, pydev_client_port)) # Tell PyDev to open the editor server = xmlrpclib.Server('http://%s:%s' % (pydev_host, pydev_client_port)) server.IPythonEditor(filename, str(line)) if wait: input("Press Enter when done editing:") return call_editor class PyDevIPCompleter(IPCompleter): def __init__(self, *args, **kwargs): """ Create a Completer that reuses the advanced completion support of PyDev in addition to the completion support provided by IPython """ IPCompleter.__init__(self, *args, **kwargs) # Use PyDev for python matches, see getCompletions below if self.python_matches in self.matchers: # `self.python_matches` matches attributes or global python names self.matchers.remove(self.python_matches) class PyDevIPCompleter6(IPCompleter): def __init__(self, *args, **kwargs): """ Create a Completer that reuses the advanced completion support of PyDev in addition to the completion support provided by IPython """ IPCompleter.__init__(self, *args, **kwargs) @property def matchers(self): """All active matcher routines for completion""" # To remove python_matches we now have to override it as it's now a property in the superclass. return [ self.file_matches, self.magic_matches, self.python_func_kw_matches, self.dict_key_matches, ] @matchers.setter def matchers(self, value): # To stop the init in IPCompleter raising an AttributeError we now have to specify a setter as it's now a property in the superclass. return class PyDevTerminalInteractiveShell(TerminalInteractiveShell): banner1 = Unicode(default_pydev_banner, config=True, help="""The part of the banner to be printed before the profile""" ) # TODO term_title: (can PyDev's title be changed???, see terminal.py for where to inject code, in particular set_term_title as used by %cd) # for now, just disable term_title term_title = CBool(False) # Note in version 0.11 there is no guard in the IPython code about displaying a # warning, so with 0.11 you get: # WARNING: Readline services not available or not loaded. # WARNING: The auto-indent feature requires the readline library # Disable readline, readline type code is all handled by PyDev (on Java side) readline_use = CBool(False) # autoindent has no meaning in PyDev (PyDev always handles that on the Java side), # and attempting to enable it will print a warning in the absence of readline. autoindent = CBool(False) # Force console to not give warning about color scheme choice and default to NoColor. # TODO It would be nice to enable colors in PyDev but: # - The PyDev Console (Eclipse Console) does not support the full range of colors, so the # effect isn't as nice anyway at the command line # - If done, the color scheme should default to LightBG, but actually be dependent on # any settings the user has (such as if a dark theme is in use, then Linux is probably # a better theme). colors_force = CBool(True) colors = Unicode("NoColor") # Since IPython 5 the terminal interface is not compatible with Emacs `inferior-shell` and # the `simple_prompt` flag is needed simple_prompt = CBool(True) # In the PyDev Console, GUI control is done via hookable XML-RPC server @staticmethod def enable_gui(gui=None, app=None): """Switch amongst GUI input hooks by name. """ # Deferred import from pydev_ipython.inputhook import enable_gui as real_enable_gui try: return real_enable_gui(gui, app) except ValueError as e: raise UsageError("%s" % e) #------------------------------------------------------------------------- # Things related to hooks #------------------------------------------------------------------------- def init_history(self): # Disable history so that we don't have an additional thread for that # (and we don't use the history anyways). self.config.HistoryManager.enabled = False super(PyDevTerminalInteractiveShell, self).init_history() def init_hooks(self): super(PyDevTerminalInteractiveShell, self).init_hooks() self.set_hook('show_in_pager', show_in_pager) #------------------------------------------------------------------------- # Things related to exceptions #------------------------------------------------------------------------- def showtraceback(self, exc_tuple=None, *args, **kwargs): # IPython does a lot of clever stuff with Exceptions. However mostly # it is related to IPython running in a terminal instead of an IDE. # (e.g. it prints out snippets of code around the stack trace) # PyDev does a lot of clever stuff too, so leave exception handling # with default print_exc that PyDev can parse and do its clever stuff # with (e.g. it puts links back to the original source code) try: if exc_tuple is None: etype, value, tb = sys.exc_info() else: etype, value, tb = exc_tuple except ValueError: return if tb is not None: traceback.print_exception(etype, value, tb) #------------------------------------------------------------------------- # Things related to text completion #------------------------------------------------------------------------- # The way to construct an IPCompleter changed in most versions, # so we have a custom, per version implementation of the construction def _new_completer_100(self): completer = PyDevIPCompleter(shell=self, namespace=self.user_ns, global_namespace=self.user_global_ns, alias_table=self.alias_manager.alias_table, use_readline=self.has_readline, parent=self, ) return completer def _new_completer_234(self): # correct for IPython versions 2.x, 3.x, 4.x completer = PyDevIPCompleter(shell=self, namespace=self.user_ns, global_namespace=self.user_global_ns, use_readline=self.has_readline, parent=self, ) return completer def _new_completer_500(self): completer = PyDevIPCompleter(shell=self, namespace=self.user_ns, global_namespace=self.user_global_ns, use_readline=False, parent=self ) return completer def _new_completer_600(self): completer = PyDevIPCompleter6(shell=self, namespace=self.user_ns, global_namespace=self.user_global_ns, use_readline=False, parent=self ) return completer def add_completer_hooks(self): from IPython.core.completerlib import module_completer, magic_run_completer, cd_completer try: from IPython.core.completerlib import reset_completer except ImportError: # reset_completer was added for rel-0.13 reset_completer = None self.configurables.append(self.Completer) # Add custom completers to the basic ones built into IPCompleter sdisp = self.strdispatchers.get('complete_command', StrDispatch()) self.strdispatchers['complete_command'] = sdisp self.Completer.custom_completers = sdisp self.set_hook('complete_command', module_completer, str_key='import') self.set_hook('complete_command', module_completer, str_key='from') self.set_hook('complete_command', magic_run_completer, str_key='%run') self.set_hook('complete_command', cd_completer, str_key='%cd') if reset_completer: self.set_hook('complete_command', reset_completer, str_key='%reset') def init_completer(self): """Initialize the completion machinery. This creates a completer that provides the completions that are IPython specific. We use this to supplement PyDev's core code completions. """ # PyDev uses its own completer and custom hooks so that it uses # most completions from PyDev's core completer which provides # extra information. # See getCompletions for where the two sets of results are merged if IPythonRelease._version_major >= 6: self.Completer = self._new_completer_600() elif IPythonRelease._version_major >= 5: self.Completer = self._new_completer_500() elif IPythonRelease._version_major >= 2: self.Completer = self._new_completer_234() elif IPythonRelease._version_major >= 1: self.Completer = self._new_completer_100() if hasattr(self.Completer, 'use_jedi'): self.Completer.use_jedi = False self.add_completer_hooks() if IPythonRelease._version_major <= 3: # Only configure readline if we truly are using readline. IPython can # do tab-completion over the network, in GUIs, etc, where readline # itself may be absent if self.has_readline: self.set_readline_completer() #------------------------------------------------------------------------- # Things related to aliases #------------------------------------------------------------------------- def init_alias(self): # InteractiveShell defines alias's we want, but TerminalInteractiveShell defines # ones we don't. So don't use super and instead go right to InteractiveShell InteractiveShell.init_alias(self) #------------------------------------------------------------------------- # Things related to exiting #------------------------------------------------------------------------- def ask_exit(self): """ Ask the shell to exit. Can be overiden and used as a callback. """ # TODO PyDev's console does not have support from the Python side to exit # the console. If user forces the exit (with sys.exit()) then the console # simply reports errors. e.g.: # >>> import sys # >>> sys.exit() # Failed to create input stream: Connection refused # >>> # Console already exited with value: 0 while waiting for an answer. # Error stream: # Output stream: # >>> # # Alternatively if you use the non-IPython shell this is what happens # >>> exit() # <type 'exceptions.SystemExit'>:None # >>> # <type 'exceptions.SystemExit'>:None # >>> # super(PyDevTerminalInteractiveShell, self).ask_exit() print('To exit the PyDev Console, terminate the console within IDE.') #------------------------------------------------------------------------- # Things related to magics #------------------------------------------------------------------------- def init_magics(self): super(PyDevTerminalInteractiveShell, self).init_magics() # TODO Any additional magics for PyDev? InteractiveShellABC.register(PyDevTerminalInteractiveShell) # @UndefinedVariable #======================================================================================================================= # _PyDevFrontEnd #======================================================================================================================= class _PyDevFrontEnd: version = release.__version__ def __init__(self): # Create and initialize our IPython instance. if hasattr(PyDevTerminalInteractiveShell, '_instance') and PyDevTerminalInteractiveShell._instance is not None: self.ipython = PyDevTerminalInteractiveShell._instance else: self.ipython = PyDevTerminalInteractiveShell.instance() self._curr_exec_line = 0 self._curr_exec_lines = [] def show_banner(self): self.ipython.show_banner() def update(self, globals, locals): ns = self.ipython.user_ns for key, value in list(ns.items()): if key not in locals: locals[key] = value self.ipython.user_global_ns.clear() self.ipython.user_global_ns.update(globals) self.ipython.user_ns = locals if hasattr(self.ipython, 'history_manager') and hasattr(self.ipython.history_manager, 'save_thread'): self.ipython.history_manager.save_thread.pydev_do_not_trace = True # don't trace ipython history saving thread def complete(self, string): try: if string: return self.ipython.complete(None, line=string, cursor_pos=string.__len__()) else: return self.ipython.complete(string, string, 0) except: # Silence completer exceptions pass def is_complete(self, string): # Based on IPython 0.10.1 if string in ('', '\n'): # Prefiltering, eg through ipython0, may return an empty # string although some operations have been accomplished. We # thus want to consider an empty string as a complete # statement. return True else: try: # Add line returns here, to make sure that the statement is # complete (except if '\' was used). # This should probably be done in a different place (like # maybe 'prefilter_input' method? For now, this works. clean_string = string.rstrip('\n') if not clean_string.endswith('\\'): clean_string += '\n\n' is_complete = codeop.compile_command( clean_string, "<string>", "exec" ) except Exception: # XXX: Hack: return True so that the # code gets executed and the error captured. is_complete = True return is_complete def getCompletions(self, text, act_tok): # Get completions from IPython and from PyDev and merge the results # IPython only gives context free list of completions, while PyDev # gives detailed information about completions. try: TYPE_IPYTHON = '11' TYPE_IPYTHON_MAGIC = '12' _line, ipython_completions = self.complete(text) from _pydev_bundle._pydev_completer import Completer completer = Completer(self.get_namespace(), None) ret = completer.complete(act_tok) append = ret.append ip = self.ipython pydev_completions = set([f[0] for f in ret]) for ipython_completion in ipython_completions: # PyCharm was not expecting completions with '%'... # Could be fixed in the backend, but it's probably better # fixing it at PyCharm. # if ipython_completion.startswith('%'): # ipython_completion = ipython_completion[1:] if ipython_completion not in pydev_completions: pydev_completions.add(ipython_completion) inf = ip.object_inspect(ipython_completion) if inf['type_name'] == 'Magic function': pydev_type = TYPE_IPYTHON_MAGIC else: pydev_type = TYPE_IPYTHON pydev_doc = inf['docstring'] if pydev_doc is None: pydev_doc = '' append((ipython_completion, pydev_doc, '', pydev_type)) return ret except: import traceback;traceback.print_exc() return [] def get_namespace(self): return self.ipython.user_ns def clear_buffer(self): del self._curr_exec_lines[:] def add_exec(self, line): if self._curr_exec_lines: self._curr_exec_lines.append(line) buf = '\n'.join(self._curr_exec_lines) if self.is_complete(buf): self._curr_exec_line += 1 self.ipython.run_cell(buf) del self._curr_exec_lines[:] return False # execute complete (no more) return True # needs more else: if not self.is_complete(line): # Did not execute self._curr_exec_lines.append(line) return True # needs more else: self._curr_exec_line += 1 self.ipython.run_cell(line, store_history=True) # hist = self.ipython.history_manager.output_hist_reprs # rep = hist.get(self._curr_exec_line, None) # if rep is not None: # print(rep) return False # execute complete (no more) def is_automagic(self): return self.ipython.automagic def get_greeting_msg(self): return 'PyDev console: using IPython %s\n' % self.version class _PyDevFrontEndContainer: _instance = None _last_host_port = None def get_pydev_frontend(pydev_host, pydev_client_port): if _PyDevFrontEndContainer._instance is None: _PyDevFrontEndContainer._instance = _PyDevFrontEnd() if _PyDevFrontEndContainer._last_host_port != (pydev_host, pydev_client_port): _PyDevFrontEndContainer._last_host_port = pydev_host, pydev_client_port # Back channel to PyDev to open editors (in the future other # info may go back this way. This is the same channel that is # used to get stdin, see StdIn in pydev_console_utils) _PyDevFrontEndContainer._instance.ipython.hooks['editor'] = create_editor_hook(pydev_host, pydev_client_port) # Note: setting the callback directly because setting it with set_hook would actually create a chain instead # of ovewriting at each new call). # _PyDevFrontEndContainer._instance.ipython.set_hook('editor', create_editor_hook(pydev_host, pydev_client_port)) return _PyDevFrontEndContainer._instance
21,354
Python
40.305609
143
0.581249
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydev_bundle/fsnotify/__init__.py
''' Sample usage to track changes in a thread. import threading import time watcher = fsnotify.Watcher() watcher.accepted_file_extensions = {'.py', '.pyw'} # Configure target values to compute throttling. # Note: internal sleep times will be updated based on # profiling the actual application runtime to match # those values. watcher.target_time_for_single_scan = 2. watcher.target_time_for_notification = 4. watcher.set_tracked_paths([target_dir]) def start_watching(): # Called from thread for change_enum, change_path in watcher.iter_changes(): if change_enum == fsnotify.Change.added: print('Added: ', change_path) elif change_enum == fsnotify.Change.modified: print('Modified: ', change_path) elif change_enum == fsnotify.Change.deleted: print('Deleted: ', change_path) t = threading.Thread(target=start_watching) t.daemon = True t.start() try: ... finally: watcher.dispose() Note: changes are only reported for files (added/modified/deleted), not directories. ''' import threading import sys from os.path import basename from _pydev_bundle import pydev_log from os import scandir try: from enum import IntEnum except: class IntEnum(object): pass import time __author__ = 'Fabio Zadrozny' __email__ = '[email protected]' __version__ = '0.1.5' # Version here and in setup.py class Change(IntEnum): added = 1 modified = 2 deleted = 3 class _SingleVisitInfo(object): def __init__(self): self.count = 0 self.visited_dirs = set() self.file_to_mtime = {} self.last_sleep_time = time.time() class _PathWatcher(object): ''' Helper to watch a single path. ''' def __init__(self, root_path, accept_directory, accept_file, single_visit_info, max_recursion_level, sleep_time=.0): ''' :type root_path: str :type accept_directory: Callback[str, bool] :type accept_file: Callback[str, bool] :type max_recursion_level: int :type sleep_time: float ''' self.accept_directory = accept_directory self.accept_file = accept_file self._max_recursion_level = max_recursion_level self._root_path = root_path # Initial sleep value for throttling, it'll be auto-updated based on the # Watcher.target_time_for_single_scan. self.sleep_time = sleep_time self.sleep_at_elapsed = 1. / 30. # When created, do the initial snapshot right away! old_file_to_mtime = {} self._check(single_visit_info, lambda _change: None, old_file_to_mtime) def __eq__(self, o): if isinstance(o, _PathWatcher): return self._root_path == o._root_path return False def __ne__(self, o): return not self == o def __hash__(self): return hash(self._root_path) def _check_dir(self, dir_path, single_visit_info, append_change, old_file_to_mtime, level): # This is the actual poll loop if dir_path in single_visit_info.visited_dirs or level > self._max_recursion_level: return single_visit_info.visited_dirs.add(dir_path) try: if isinstance(dir_path, bytes): try: dir_path = dir_path.decode(sys.getfilesystemencoding()) except UnicodeDecodeError: try: dir_path = dir_path.decode('utf-8') except UnicodeDecodeError: return # Ignore if we can't deal with the path. new_files = single_visit_info.file_to_mtime for entry in scandir(dir_path): single_visit_info.count += 1 # Throttle if needed inside the loop # to avoid consuming too much CPU. if single_visit_info.count % 300 == 0: if self.sleep_time > 0: t = time.time() diff = t - single_visit_info.last_sleep_time if diff > self.sleep_at_elapsed: time.sleep(self.sleep_time) single_visit_info.last_sleep_time = time.time() if entry.is_dir(): if self.accept_directory(entry.path): self._check_dir(entry.path, single_visit_info, append_change, old_file_to_mtime, level + 1) elif self.accept_file(entry.path): stat = entry.stat() mtime = (stat.st_mtime_ns, stat.st_size) path = entry.path new_files[path] = mtime old_mtime = old_file_to_mtime.pop(path, None) if not old_mtime: append_change((Change.added, path)) elif old_mtime != mtime: append_change((Change.modified, path)) except OSError: pass # Directory was removed in the meanwhile. def _check(self, single_visit_info, append_change, old_file_to_mtime): self._check_dir(self._root_path, single_visit_info, append_change, old_file_to_mtime, 0) class Watcher(object): # By default (if accept_directory is not specified), these will be the # ignored directories. ignored_dirs = {u'.git', u'__pycache__', u'.idea', u'node_modules', u'.metadata'} # By default (if accept_file is not specified), these will be the # accepted files. accepted_file_extensions = () # Set to the target value for doing full scan of all files (adds a sleep inside the poll loop # which processes files to reach the target time). # Lower values will consume more CPU # Set to 0.0 to have no sleeps (which will result in a higher cpu load). target_time_for_single_scan = 2.0 # Set the target value from the start of one scan to the start of another scan (adds a # sleep after a full poll is done to reach the target time). # Lower values will consume more CPU. # Set to 0.0 to have a new scan start right away without any sleeps. target_time_for_notification = 4.0 # Set to True to print the time for a single poll through all the paths. print_poll_time = False # This is the maximum recursion level. max_recursion_level = 10 def __init__(self, accept_directory=None, accept_file=None): ''' :param Callable[str, bool] accept_directory: Callable that returns whether a directory should be watched. Note: if passed it'll override the `ignored_dirs` :param Callable[str, bool] accept_file: Callable that returns whether a file should be watched. Note: if passed it'll override the `accepted_file_extensions`. ''' self._path_watchers = set() self._disposed = threading.Event() if accept_directory is None: accept_directory = lambda dir_path: basename(dir_path) not in self.ignored_dirs if accept_file is None: accept_file = lambda path_name: \ not self.accepted_file_extensions or path_name.endswith(self.accepted_file_extensions) self.accept_file = accept_file self.accept_directory = accept_directory self._single_visit_info = _SingleVisitInfo() @property def accept_directory(self): return self._accept_directory @accept_directory.setter def accept_directory(self, accept_directory): self._accept_directory = accept_directory for path_watcher in self._path_watchers: path_watcher.accept_directory = accept_directory @property def accept_file(self): return self._accept_file @accept_file.setter def accept_file(self, accept_file): self._accept_file = accept_file for path_watcher in self._path_watchers: path_watcher.accept_file = accept_file def dispose(self): self._disposed.set() @property def path_watchers(self): return tuple(self._path_watchers) def set_tracked_paths(self, paths): """ Note: always resets all path trackers to track the passed paths. """ if not isinstance(paths, (list, tuple, set)): paths = (paths,) # Sort by the path len so that the bigger paths come first (so, # if there's any nesting we want the nested paths to be visited # before the parent paths so that the max_recursion_level is correct). paths = sorted(set(paths), key=lambda path:-len(path)) path_watchers = set() self._single_visit_info = _SingleVisitInfo() initial_time = time.time() for path in paths: sleep_time = 0. # When collecting the first time, sleep_time should be 0! path_watcher = _PathWatcher( path, self.accept_directory, self.accept_file, self._single_visit_info, max_recursion_level=self.max_recursion_level, sleep_time=sleep_time, ) path_watchers.add(path_watcher) actual_time = (time.time() - initial_time) pydev_log.debug('Tracking the following paths for changes: %s', paths) pydev_log.debug('Time to track: %.2fs', actual_time) pydev_log.debug('Folders found: %s', len(self._single_visit_info.visited_dirs)) pydev_log.debug('Files found: %s', len(self._single_visit_info.file_to_mtime)) self._path_watchers = path_watchers def iter_changes(self): ''' Continuously provides changes (until dispose() is called). Changes provided are tuples with the Change enum and filesystem path. :rtype: Iterable[Tuple[Change, str]] ''' while not self._disposed.is_set(): initial_time = time.time() old_visit_info = self._single_visit_info old_file_to_mtime = old_visit_info.file_to_mtime changes = [] append_change = changes.append self._single_visit_info = single_visit_info = _SingleVisitInfo() for path_watcher in self._path_watchers: path_watcher._check(single_visit_info, append_change, old_file_to_mtime) # Note that we pop entries while visiting, so, what remained is what's deleted. for entry in old_file_to_mtime: append_change((Change.deleted, entry)) for change in changes: yield change actual_time = (time.time() - initial_time) if self.print_poll_time: print('--- Total poll time: %.3fs' % actual_time) if actual_time > 0: if self.target_time_for_single_scan <= 0.0: for path_watcher in self._path_watchers: path_watcher.sleep_time = 0.0 else: perc = self.target_time_for_single_scan / actual_time # Prevent from changing the values too much (go slowly into the right # direction). # (to prevent from cases where the user puts the machine on sleep and # values become too skewed). if perc > 2.: perc = 2. elif perc < 0.5: perc = 0.5 for path_watcher in self._path_watchers: if path_watcher.sleep_time <= 0.0: path_watcher.sleep_time = 0.001 new_sleep_time = path_watcher.sleep_time * perc # Prevent from changing the values too much (go slowly into the right # direction). # (to prevent from cases where the user puts the machine on sleep and # values become too skewed). diff_sleep_time = new_sleep_time - path_watcher.sleep_time path_watcher.sleep_time += (diff_sleep_time / (3.0 * len(self._path_watchers))) if actual_time > 0: self._disposed.wait(actual_time) if path_watcher.sleep_time < 0.001: path_watcher.sleep_time = 0.001 # print('new sleep time: %s' % path_watcher.sleep_time) diff = self.target_time_for_notification - actual_time if diff > 0.: self._disposed.wait(diff)
12,704
Python
34.88983
120
0.574465
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_eval_cython_wrapper.py
try: try: from _pydevd_frame_eval_ext import pydevd_frame_evaluator as mod except ImportError: from _pydevd_frame_eval import pydevd_frame_evaluator as mod except ImportError: try: import sys try: is_64bits = sys.maxsize > 2 ** 32 except: # In Jython this call fails, but this is Ok, we don't support Jython for speedups anyways. raise ImportError plat = '32' if is_64bits: plat = '64' # We also accept things as: # # _pydevd_frame_eval.pydevd_frame_evaluator_win32_27_32 # _pydevd_frame_eval.pydevd_frame_evaluator_win32_34_64 # # to have multiple pre-compiled pyds distributed along the IDE # (generated by build_tools/build_binaries_windows.py). mod_name = 'pydevd_frame_evaluator_%s_%s%s_%s' % (sys.platform, sys.version_info[0], sys.version_info[1], plat) check_name = '_pydevd_frame_eval.%s' % (mod_name,) mod = __import__(check_name) mod = getattr(mod, mod_name) except ImportError: raise frame_eval_func = mod.frame_eval_func stop_frame_eval = mod.stop_frame_eval dummy_trace_dispatch = mod.dummy_trace_dispatch get_thread_info_py = mod.get_thread_info_py clear_thread_local_info = mod.clear_thread_local_info
1,343
Python
29.545454
119
0.621742
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_tracing.py
import sys from _pydev_bundle import pydev_log from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle.pydevd_comm import get_global_debugger from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER from _pydevd_bundle.pydevd_additional_thread_info import set_additional_thread_info class DummyTracingHolder: dummy_trace_func = None def set_trace_func(self, trace_func): self.dummy_trace_func = trace_func dummy_tracing_holder = DummyTracingHolder() def update_globals_dict(globals_dict): new_globals = {'_pydev_stop_at_break': _pydev_stop_at_break} globals_dict.update(new_globals) def _get_line_for_frame(frame): # it's absolutely necessary to reset tracing function for frame in order to get the real line number tracing_func = frame.f_trace frame.f_trace = None line = frame.f_lineno frame.f_trace = tracing_func return line def _pydev_stop_at_break(line): frame = sys._getframe(1) # print('pydevd SET TRACING at ', line, 'curr line', frame.f_lineno) t = threading.current_thread() try: additional_info = t.additional_info except: additional_info = set_additional_thread_info(t) if additional_info.is_tracing: return additional_info.is_tracing += 1 try: py_db = get_global_debugger() if py_db is None: return pydev_log.debug("Setting f_trace due to frame eval mode in file: %s on line %s", frame.f_code.co_filename, line) additional_info.trace_suspend_type = 'frame_eval' pydevd_frame_eval_cython_wrapper = sys.modules['_pydevd_frame_eval.pydevd_frame_eval_cython_wrapper'] thread_info = pydevd_frame_eval_cython_wrapper.get_thread_info_py() if thread_info.thread_trace_func is not None: frame.f_trace = thread_info.thread_trace_func else: frame.f_trace = py_db.get_thread_local_trace_func() finally: additional_info.is_tracing -= 1 def _pydev_needs_stop_at_break(line): ''' We separate the functionality into 2 functions so that we can generate a bytecode which generates a spurious line change so that we can do: if _pydev_needs_stop_at_break(): # Set line to line -1 _pydev_stop_at_break() # then, proceed to go to the current line # (which will then trigger a line event). ''' t = threading.current_thread() try: additional_info = t.additional_info except: additional_info = set_additional_thread_info(t) if additional_info.is_tracing: return False additional_info.is_tracing += 1 try: frame = sys._getframe(1) # print('pydev needs stop at break?', line, 'curr line', frame.f_lineno, 'curr trace', frame.f_trace) if frame.f_trace is not None: # i.e.: this frame is already being traced, thus, we don't need to use programmatic breakpoints. return False py_db = get_global_debugger() if py_db is None: return False try: abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] except: abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) canonical_normalized_filename = abs_path_real_path_and_base[1] try: python_breakpoint = py_db.breakpoints[canonical_normalized_filename][line] except: # print("Couldn't find breakpoint in the file %s on line %s" % (frame.f_code.co_filename, line)) # Could be KeyError if line is not there or TypeError if breakpoints_for_file is None. # Note: using catch-all exception for performance reasons (if the user adds a breakpoint # and then removes it after hitting it once, this method added for the programmatic # breakpoint will keep on being called and one of those exceptions will always be raised # here). return False if python_breakpoint: # print('YES') return True finally: additional_info.is_tracing -= 1 return False
4,219
Python
33.308943
120
0.650391
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/release_mem.h
#include "Python.h" void release_co_extra(void *obj) { Py_XDECREF(obj); }
79
C
12.333331
34
0.64557
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_modify_bytecode.py
from collections import namedtuple import dis from functools import partial import itertools import os.path import sys from _pydevd_frame_eval.vendored import bytecode from _pydevd_frame_eval.vendored.bytecode.instr import Instr, Label from _pydev_bundle import pydev_log from _pydevd_frame_eval.pydevd_frame_tracing import _pydev_stop_at_break, _pydev_needs_stop_at_break DEBUG = False class DebugHelper(object): def __init__(self): self._debug_dir = os.path.join(os.path.dirname(__file__), 'debug_info') try: os.makedirs(self._debug_dir) except: pass self._next = partial(next, itertools.count(0)) def _get_filename(self, op_number=None, prefix=''): if op_number is None: op_number = self._next() name = '%03d_before.txt' % op_number else: name = '%03d_change.txt' % op_number filename = os.path.join(self._debug_dir, prefix + name) return filename, op_number def write_bytecode(self, b, op_number=None, prefix=''): filename, op_number = self._get_filename(op_number, prefix) with open(filename, 'w') as stream: bytecode.dump_bytecode(b, stream=stream, lineno=True) return op_number def write_dis(self, code_to_modify, op_number=None, prefix=''): filename, op_number = self._get_filename(op_number, prefix) with open(filename, 'w') as stream: stream.write('-------- ') stream.write('-------- ') stream.write('id(code_to_modify): %s' % id(code_to_modify)) stream.write('\n\n') dis.dis(code_to_modify, file=stream) return op_number _CodeLineInfo = namedtuple('_CodeLineInfo', 'line_to_offset, first_line, last_line') # Note: this method has a version in cython too (that one is usually used, this is just for tests). def _get_code_line_info(code_obj): line_to_offset = {} first_line = None last_line = None for offset, line in dis.findlinestarts(code_obj): line_to_offset[line] = offset if line_to_offset: first_line = min(line_to_offset) last_line = max(line_to_offset) return _CodeLineInfo(line_to_offset, first_line, last_line) if DEBUG: debug_helper = DebugHelper() def get_instructions_to_add( stop_at_line, _pydev_stop_at_break=_pydev_stop_at_break, _pydev_needs_stop_at_break=_pydev_needs_stop_at_break ): ''' This is the bytecode for something as: if _pydev_needs_stop_at_break(): _pydev_stop_at_break() but with some special handling for lines. ''' # Good reference to how things work regarding line numbers and jumps: # https://github.com/python/cpython/blob/3.6/Objects/lnotab_notes.txt # Usually use a stop line -1, but if that'd be 0, using line +1 is ok too. spurious_line = stop_at_line - 1 if spurious_line <= 0: spurious_line = stop_at_line + 1 label = Label() return [ # -- if _pydev_needs_stop_at_break(): Instr("LOAD_CONST", _pydev_needs_stop_at_break, lineno=stop_at_line), Instr("LOAD_CONST", stop_at_line, lineno=stop_at_line), Instr("CALL_FUNCTION", 1, lineno=stop_at_line), Instr("POP_JUMP_IF_FALSE", label, lineno=stop_at_line), # -- _pydev_stop_at_break() # # Note that this has line numbers -1 so that when the NOP just below # is executed we have a spurious line event. Instr("LOAD_CONST", _pydev_stop_at_break, lineno=spurious_line), Instr("LOAD_CONST", stop_at_line, lineno=spurious_line), Instr("CALL_FUNCTION", 1, lineno=spurious_line), Instr("POP_TOP", lineno=spurious_line), # Reason for the NOP: Python will give us a 'line' trace event whenever we forward jump to # the first instruction of a line, so, in the case where we haven't added a programmatic # breakpoint (either because we didn't hit a breakpoint anymore or because it was already # tracing), we don't want the spurious line event due to the line change, so, we make a jump # to the instruction right after the NOP so that the spurious line event is NOT generated in # this case (otherwise we'd have a line event even if the line didn't change). Instr("NOP", lineno=stop_at_line), label, ] class _Node(object): def __init__(self, data): self.prev = None self.next = None self.data = data def append(self, data): node = _Node(data) curr_next = self.next node.next = self.next node.prev = self self.next = node if curr_next is not None: curr_next.prev = node return node def prepend(self, data): node = _Node(data) curr_prev = self.prev node.prev = self.prev node.next = self self.prev = node if curr_prev is not None: curr_prev.next = node return node class _HelperBytecodeList(object): ''' A helper double-linked list to make the manipulation a bit easier (so that we don't need to keep track of indices that change) and performant (because adding multiple items to the middle of a regular list isn't ideal). ''' def __init__(self, lst=None): self._head = None self._tail = None if lst: node = self for item in lst: node = node.append(item) def append(self, data): if self._tail is None: node = _Node(data) self._head = self._tail = node return node else: node = self._tail = self.tail.append(data) return node @property def head(self): node = self._head # Manipulating the node directly may make it unsynchronized. while node.prev: self._head = node = node.prev return node @property def tail(self): node = self._tail # Manipulating the node directly may make it unsynchronized. while node.next: self._tail = node = node.next return node def __iter__(self): node = self.head while node: yield node.data node = node.next _PREDICT_TABLE = { 'LIST_APPEND': ('JUMP_ABSOLUTE',), 'SET_ADD': ('JUMP_ABSOLUTE',), 'GET_ANEXT': ('LOAD_CONST',), 'GET_AWAITABLE': ('LOAD_CONST',), 'DICT_MERGE': ('CALL_FUNCTION_EX',), 'MAP_ADD': ('JUMP_ABSOLUTE',), 'COMPARE_OP': ('POP_JUMP_IF_FALSE', 'POP_JUMP_IF_TRUE',), 'IS_OP': ('POP_JUMP_IF_FALSE', 'POP_JUMP_IF_TRUE',), 'CONTAINS_OP': ('POP_JUMP_IF_FALSE', 'POP_JUMP_IF_TRUE',), # Note: there are some others with PREDICT on ceval, but they have more logic # and it needs more experimentation to know how it behaves in the static generated # code (and it's only an issue for us if there's actually a line change between # those, so, we don't have to really handle all the cases, only the one where # the line number actually changes from one instruction to the predicted one). } # 3.10 optimizations include copying code branches multiple times (for instance # if the body of a finally has a single assign statement it can copy the assign to the case # where an exception happens and doesn't happen for optimization purposes) and as such # we need to add the programmatic breakpoint multiple times. TRACK_MULTIPLE_BRANCHES = sys.version_info[:2] >= (3, 10) # When tracking multiple branches, we try to fix the bytecodes which would be PREDICTED in the # Python eval loop so that we don't have spurious line events that wouldn't usually be issued # in the tracing as they're ignored due to the eval prediction (even though they're in the bytecode). FIX_PREDICT = sys.version_info[:2] >= (3, 10) def insert_pydevd_breaks( code_to_modify, breakpoint_lines, code_line_info=None, _pydev_stop_at_break=_pydev_stop_at_break, _pydev_needs_stop_at_break=_pydev_needs_stop_at_break, ): """ Inserts pydevd programmatic breaks into the code (at the given lines). :param breakpoint_lines: set with the lines where we should add breakpoints. :return: tuple(boolean flag whether insertion was successful, modified code). """ if code_line_info is None: code_line_info = _get_code_line_info(code_to_modify) if not code_line_info.line_to_offset: return False, code_to_modify # Create a copy (and make sure we're dealing with a set). breakpoint_lines = set(breakpoint_lines) # Note that we can even generate breakpoints on the first line of code # now, since we generate a spurious line event -- it may be a bit pointless # as we'll stop in the first line and we don't currently stop the tracing after the # user resumes, but in the future, if we do that, this would be a nice # improvement. # if code_to_modify.co_firstlineno in breakpoint_lines: # return False, code_to_modify for line in breakpoint_lines: if line <= 0: # The first line is line 1, so, a break at line 0 is not valid. pydev_log.info('Trying to add breakpoint in invalid line: %s', line) return False, code_to_modify try: b = bytecode.Bytecode.from_code(code_to_modify) if DEBUG: op_number_bytecode = debug_helper.write_bytecode(b, prefix='bytecode.') helper_list = _HelperBytecodeList(b) modified_breakpoint_lines = breakpoint_lines.copy() curr_node = helper_list.head added_breaks_in_lines = set() last_lineno = None while curr_node is not None: instruction = curr_node.data instruction_lineno = getattr(instruction, 'lineno', None) curr_name = getattr(instruction, 'name', None) if FIX_PREDICT: predict_targets = _PREDICT_TABLE.get(curr_name) if predict_targets: # Odd case: the next instruction may have a line number but it doesn't really # appear in the tracing due to the PREDICT() in ceval, so, fix the bytecode so # that it does things the way that ceval actually interprets it. # See: https://mail.python.org/archives/list/[email protected]/thread/CP2PTFCMTK57KM3M3DLJNWGO66R5RVPB/ next_instruction = curr_node.next.data next_name = getattr(next_instruction, 'name', None) if next_name in predict_targets: next_instruction_lineno = getattr(next_instruction, 'lineno', None) if next_instruction_lineno: next_instruction.lineno = None if instruction_lineno is not None: if TRACK_MULTIPLE_BRANCHES: if last_lineno is None: last_lineno = instruction_lineno else: if last_lineno == instruction_lineno: # If the previous is a label, someone may jump into it, so, we need to add # the break even if it's in the same line. if curr_node.prev.data.__class__ != Label: # Skip adding this as the line is still the same. curr_node = curr_node.next continue last_lineno = instruction_lineno else: if instruction_lineno in added_breaks_in_lines: curr_node = curr_node.next continue if instruction_lineno in modified_breakpoint_lines: added_breaks_in_lines.add(instruction_lineno) if curr_node.prev is not None and curr_node.prev.data.__class__ == Label \ and curr_name == 'POP_TOP': # If we have a SETUP_FINALLY where the target is a POP_TOP, we can't change # the target to be the breakpoint instruction (this can crash the interpreter). for new_instruction in get_instructions_to_add( instruction_lineno, _pydev_stop_at_break=_pydev_stop_at_break, _pydev_needs_stop_at_break=_pydev_needs_stop_at_break, ): curr_node = curr_node.append(new_instruction) else: for new_instruction in get_instructions_to_add( instruction_lineno, _pydev_stop_at_break=_pydev_stop_at_break, _pydev_needs_stop_at_break=_pydev_needs_stop_at_break, ): curr_node.prepend(new_instruction) curr_node = curr_node.next b[:] = helper_list if DEBUG: debug_helper.write_bytecode(b, op_number_bytecode, prefix='bytecode.') new_code = b.to_code() except: pydev_log.exception('Error inserting pydevd breaks.') return False, code_to_modify if DEBUG: op_number = debug_helper.write_dis(code_to_modify) debug_helper.write_dis(new_code, op_number) return True, new_code
13,545
Python
36.010929
127
0.591953
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.c
/* Generated by Cython 0.29.32 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ "_pydevd_frame_eval/release_mem.h" ], "include_dirs": [ "_pydevd_frame_eval" ], "name": "_pydevd_frame_eval.pydevd_frame_evaluator", "sources": [ "_pydevd_frame_eval/pydevd_frame_evaluator.pyx" ] }, "module_name": "_pydevd_frame_eval.pydevd_frame_evaluator" } END: Cython Metadata */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ #include "Python.h" #if PY_VERSION_HEX >= 0x03090000 #include "internal/pycore_gc.h" #include "internal/pycore_interp.h" #endif #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else #define CYTHON_ABI "0_29_32" #define CYTHON_HEX_VERSION 0x001D20F0 #define CYTHON_FUTURE_DIVISION 0 #include <stddef.h> #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900) #endif #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_NOGIL 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(PY_NOGIL) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_NOGIL 1 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #ifndef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_NOGIL 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #elif !defined(CYTHON_USE_PYLONG_INTERNALS) #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #ifndef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #if PY_VERSION_HEX >= 0x030B00A4 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #elif !defined(CYTHON_FAST_THREAD_STATE) #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000) #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) #endif #ifndef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) #endif #if PY_VERSION_HEX >= 0x030B00A4 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #elif !defined(CYTHON_USE_EXC_INFO_STACK) #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS #if PY_MAJOR_VERSION < 3 #include "longintrepr.h" #endif #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR # if defined(__cplusplus) template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } # else # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ #if _MSC_VER < 1300 typedef unsigned char uint8_t; typedef unsigned int uint32_t; #else typedef unsigned __int8 uint8_t; typedef unsigned __int32 uint32_t; #endif #endif #else #include <stdint.h> #endif #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) && __cplusplus >= 201103L #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__ ) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if PY_VERSION_HEX >= 0x030B00A1 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL; const char *fn_cstr=NULL; const char *name_cstr=NULL; PyCodeObject* co=NULL; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); if (!(kwds=PyDict_New())) goto end; if (!(argcount=PyLong_FromLong(a))) goto end; if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; if (!(posonlyargcount=PyLong_FromLong(0))) goto end; if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; if (!(nlocals=PyLong_FromLong(l))) goto end; if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; if (!(stacksize=PyLong_FromLong(s))) goto end; if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; if (!(flags=PyLong_FromLong(f))) goto end; if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too; if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too; Py_XDECREF((PyObject*)co); co = (PyCodeObject*)call_result; call_result = NULL; if (0) { cleanup_code_too: Py_XDECREF((PyObject*)co); co = NULL; } end: Py_XDECREF(kwds); Py_XDECREF(argcount); Py_XDECREF(posonlyargcount); Py_XDECREF(kwonlyargcount); Py_XDECREF(nlocals); Py_XDECREF(stacksize); Py_XDECREF(replace); Py_XDECREF(call_result); Py_XDECREF(empty); if (type) { PyErr_Restore(type, value, traceback); } return co; } #else #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #define __Pyx_PyCFunctionFast _PyCFunctionFast #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #if CYTHON_FAST_PYCCALL #define __Pyx_PyFastCFunction_Check(func)\ ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 #define PyMem_RawMalloc(n) PyMem_Malloc(n) #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) #define PyMem_RawFree(p) PyMem_Free(p) #endif #if CYTHON_COMPILING_IN_PYSTON #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #else #define __Pyx_PyThreadState_Current _PyThreadState_Current #endif #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) #include "pythread.h" #define Py_tss_NEEDS_INIT 0 typedef int Py_tss_t; static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { *key = PyThread_create_key(); return 0; } static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); *key = Py_tss_NEEDS_INIT; return key; } static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { PyObject_Free(key); } static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { return *key != Py_tss_NEEDS_INIT; } static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { PyThread_delete_key(*key); *key = Py_tss_NEEDS_INIT; } static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { return PyThread_set_key_value(*key, value); } static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { return PyThread_get_key_value(*key); } #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) #else #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #if defined(PyUnicode_IS_READY) #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #else #define __Pyx_PyUnicode_READY(op) (0) #endif #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #endif #else #define CYTHON_PEP393_ENABLED 0 #define PyUnicode_1BYTE_KIND 1 #define PyUnicode_2BYTE_KIND 2 #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #ifndef PyObject_Unicode #define PyObject_Unicode PyObject_Str #endif #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #else #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef __Pyx_PyAsyncMethodsStruct typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #endif #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #if !defined(_USE_MATH_DEFINES) #define _USE_MATH_DEFINES #endif #endif #include <math.h> #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #define __PYX_MARK_ERR_POS(f_index, lineno) \ { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE___pydevd_frame_eval__pydevd_frame_evaluator #define __PYX_HAVE_API___pydevd_frame_eval__pydevd_frame_evaluator /* Early includes */ #include "frameobject.h" #include "release_mem.h" #include "code.h" #include "pystate.h" #if PY_VERSION_HEX >= 0x03080000 #include "internal/pycore_pystate.h" #endif #include "ceval.h" #if PY_VERSION_HEX >= 0x03090000 PyObject * noop(PyFrameObject *frame, int exc) { return NULL; } #define CALL_EvalFrameDefault_38(a, b) noop(a, b) #define CALL_EvalFrameDefault_39(a, b, c) _PyEval_EvalFrameDefault(a, b, c) #else PyObject * noop(PyThreadState* tstate, PyFrameObject *frame, int exc) { return NULL; } #define CALL_EvalFrameDefault_39(a, b, c) noop(a, b, c) #define CALL_EvalFrameDefault_38(a, b) _PyEval_EvalFrameDefault(a, b) #endif #ifdef _OPENMP #include <omp.h> #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include <cstdlib> #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char *__pyx_f[] = { "_pydevd_frame_eval/pydevd_frame_evaluator.pyx", "stringsource", "_pydevd_bundle/pydevd_cython.pxd", }; /*--- Type declarations ---*/ struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue; /* "_pydevd_bundle/pydevd_cython.pxd":1 * cdef class PyDBAdditionalThreadInfo: # <<<<<<<<<<<<<< * cdef public int pydev_state * cdef public object pydev_step_stop # Actually, it's a frame or None */ struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo { PyObject_HEAD int pydev_state; PyObject *pydev_step_stop; int pydev_original_step_cmd; int pydev_step_cmd; int pydev_notify_kill; PyObject *pydev_smart_step_stop; int pydev_django_resolve_frame; PyObject *pydev_call_from_jinja2; PyObject *pydev_call_inside_jinja2; int is_tracing; PyObject *conditional_breakpoint_exception; PyObject *pydev_message; int suspend_type; int pydev_next_line; PyObject *pydev_func_name; int suspended_at_unhandled; PyObject *trace_suspend_type; PyObject *top_level_thread_tracer_no_back_frames; PyObject *top_level_thread_tracer_unhandled; PyObject *thread_tracer; PyObject *step_in_initial_location; int pydev_smart_parent_offset; int pydev_smart_child_offset; PyObject *pydev_smart_step_into_variants; PyObject *target_id_to_smart_step_into_variant; int pydev_use_scoped_step_frame; }; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":24 * * * cdef class ThreadInfo: # <<<<<<<<<<<<<< * * cdef public PyDBAdditionalThreadInfo additional_info */ struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo { PyObject_HEAD struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_vtab; struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *additional_info; int is_pydevd_thread; int inside_frame_eval; int fully_initialized; PyObject *thread_trace_func; int _can_create_dummy_thread; int force_stay_in_untraced_mode; }; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":125 * * * cdef class FuncCodeInfo: # <<<<<<<<<<<<<< * * cdef public str co_filename */ struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo { PyObject_HEAD PyObject *co_filename; PyObject *co_name; PyObject *canonical_normalized_filename; int always_skip_code; int breakpoint_found; PyObject *new_code; int breakpoints_mtime; }; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":316 * * * cdef class _CodeLineInfo: # <<<<<<<<<<<<<< * * cdef public dict line_to_offset */ struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo { PyObject_HEAD PyObject *line_to_offset; int first_line; int last_line; }; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":361 * * * cdef class _CacheValue(object): # <<<<<<<<<<<<<< * * cdef public object code_obj_py */ struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue { PyObject_HEAD struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_vtab; PyObject *code_obj_py; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *code_line_info; PyObject *breakpoints_hit_at_lines; PyObject *code_lines_as_set; }; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":24 * * * cdef class ThreadInfo: # <<<<<<<<<<<<<< * * cdef public PyDBAdditionalThreadInfo additional_info */ struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo { PyObject *(*initialize)(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *, PyFrameObject *); PyObject *(*initialize_if_possible)(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *); }; static struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":361 * * * cdef class _CacheValue(object): # <<<<<<<<<<<<<< * * cdef public object code_obj_py */ struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue { PyObject *(*compute_force_stay_in_untraced_mode)(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *, PyObject *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue; /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __pyx_dict_cached_value;\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } #define __Pyx_GetModuleGlobalNameUncached(var, name) {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #else #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) #endif #define __Pyx_BUILD_ASSERT_EXPR(cond)\ (sizeof(char [1 - 2*!(cond)]) - 1) #ifndef Py_MEMBER_SIZE #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #endif #if CYTHON_FAST_PYCALL static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" #if PY_VERSION_HEX >= 0x030b00a6 #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #define __Pxy_PyFrame_Initialize_Offsets()\ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) #define __Pyx_PyFrame_GetLocalsplus(frame)\ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) #endif // CYTHON_FAST_PYCALL #endif /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif /* PyCFunctionFastCall.proto */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); #else #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) #endif /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* PyObjectCall2Args.proto */ static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif /* SliceObject.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** py_start, PyObject** py_stop, PyObject** py_slice, int has_cstart, int has_cstop, int wraparound); /* IncludeStringH.proto */ #include <string.h> /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* StrEquals.proto */ #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals #else #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals #endif /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* GetAttr.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /* GetAttr3.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* PyObjectLookupSpecial.proto */ #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) { PyObject *res; PyTypeObject *tp = Py_TYPE(obj); #if PY_MAJOR_VERSION < 3 if (unlikely(PyInstance_Check(obj))) return __Pyx_PyObject_GetAttrStr(obj, attr_name); #endif res = _PyType_Lookup(tp, attr_name); if (likely(res)) { descrgetfunc f = Py_TYPE(res)->tp_descr_get; if (!f) { Py_INCREF(res); } else { res = f(res, obj, (PyObject *)tp); } } else { PyErr_SetObject(PyExc_AttributeError, attr_name); } return res; } #else #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n) #endif /* PyObjectSetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif /* None.proto */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /* SwapException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #endif /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* KeywordStringCheck.proto */ static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywords.proto */ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); /* ArgTypeTest.proto */ #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ __Pyx__ArgTypeTest(obj, type, name, exact)) static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); #define __Pyx_PyObject_Dict_GetItem(obj, name)\ (likely(PyDict_CheckExact(obj)) ?\ __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) #endif /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* IterFinish.proto */ static CYTHON_INLINE int __Pyx_IterFinish(void); /* UnpackItemEndCheck.proto */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* PySequenceContains.proto */ static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { int result = PySequence_Contains(seq, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* PyObjectGetMethod.proto */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); /* PyObjectCallMethod0.proto */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); /* UnpackTupleError.proto */ static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /* UnpackTuple2.proto */ #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\ (likely(is_tuple || PyTuple_Check(tuple)) ?\ (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\ __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\ (__Pyx_UnpackTupleError(tuple, 2), -1)) :\ __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple)) static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple); static int __Pyx_unpack_tuple2_generic( PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple); /* dict_iter.proto */ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name, Py_ssize_t* p_orig_length, int* p_is_dict); static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos, PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict); /* PyDictContains.proto */ static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) { int result = PyDict_Contains(dict, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* WriteUnraisableException.proto */ static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* HasAttr.proto */ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); /* PyObject_GenericGetAttrNoDict.proto */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr #endif /* PyObject_GenericGetAttr.proto */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr #endif /* SetVTable.proto */ static int __Pyx_SetVtable(PyObject *dict, void *vtable); /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto #define __PYX_HAVE_RT_ImportType_proto enum __Pyx_ImportType_CheckSize { __Pyx_ImportType_CheckSize_Error = 0, __Pyx_ImportType_CheckSize_Warn = 1, __Pyx_ImportType_CheckSize_Ignore = 2 }; static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); #endif /* CLineInTraceback.proto */ #ifdef CYTHON_CLINE_IN_TRACEBACK #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #else static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #endif /* CodeObjectCache.proto */ typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_initialize(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyFrameObject *__pyx_v_frame_obj); /* proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_initialize_if_possible(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_compute_force_stay_in_untraced_mode(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_breakpoints, int __pyx_skip_dispatch); /* proto*/ /* Module declarations from 'cpython.mem' */ /* Module declarations from '_pydevd_bundle.pydevd_cython' */ static PyTypeObject *__pyx_ptype_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo = 0; /* Module declarations from '_pydevd_frame_eval.pydevd_frame_evaluator' */ static PyTypeObject *__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo = 0; static PyTypeObject *__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo = 0; static PyTypeObject *__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo = 0; static PyTypeObject *__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue = 0; static int __pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator__code_extra_index; static int __pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator_IS_PY_39_OWNARDS; static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_thread_info(PyFrameObject *); /*proto*/ static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_func_code_info(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *, PyFrameObject *, PyCodeObject *); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_generate_code_with_breakpoints(PyObject *, PyObject *); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval_38(PyFrameObject *, int); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval_39(PyThreadState *, PyFrameObject *, int); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_ThreadInfo__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *, PyObject *); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_FuncCodeInfo__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *, PyObject *); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CodeLineInfo__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *, PyObject *); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CacheValue__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *, PyObject *); /*proto*/ #define __Pyx_MODULE_NAME "_pydevd_frame_eval.pydevd_frame_evaluator" extern int __pyx_module_is_main__pydevd_frame_eval__pydevd_frame_evaluator; int __pyx_module_is_main__pydevd_frame_eval__pydevd_frame_evaluator = 0; /* Implementation of '_pydevd_frame_eval.pydevd_frame_evaluator' */ static PyObject *__pyx_builtin_AttributeError; static PyObject *__pyx_builtin_min; static PyObject *__pyx_builtin_max; static const char __pyx_k_[] = "/"; static const char __pyx_k__2[] = "\\"; static const char __pyx_k__3[] = "."; static const char __pyx_k__5[] = ""; static const char __pyx_k_arg[] = "arg"; static const char __pyx_k_dis[] = "dis"; static const char __pyx_k_get[] = "get"; static const char __pyx_k_max[] = "max"; static const char __pyx_k_min[] = "min"; static const char __pyx_k_new[] = "__new__"; static const char __pyx_k_obj[] = "obj"; static const char __pyx_k_run[] = "run"; static const char __pyx_k_sys[] = "sys"; static const char __pyx_k_call[] = "__call__"; static const char __pyx_k_dict[] = "__dict__"; static const char __pyx_k_exec[] = "_exec"; static const char __pyx_k_exit[] = "__exit__"; static const char __pyx_k_line[] = "line"; static const char __pyx_k_main[] = "main"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_cache[] = "_cache"; static const char __pyx_k_enter[] = "__enter__"; static const char __pyx_k_event[] = "event"; static const char __pyx_k_frame[] = "frame"; static const char __pyx_k_local[] = "local"; static const char __pyx_k_mtime[] = "mtime"; static const char __pyx_k_rfind[] = "rfind"; static const char __pyx_k_state[] = "state"; static const char __pyx_k_active[] = "_active"; static const char __pyx_k_call_2[] = "call"; static const char __pyx_k_f_back[] = "f_back"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_main_2[] = "__main__"; static const char __pyx_k_offset[] = "offset"; static const char __pyx_k_pickle[] = "pickle"; static const char __pyx_k_plugin[] = "plugin"; static const char __pyx_k_pydevd[] = "pydevd"; static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_thread[] = "thread"; static const char __pyx_k_update[] = "update"; static const char __pyx_k_f_trace[] = "f_trace"; static const char __pyx_k_SetTrace[] = "SetTrace"; static const char __pyx_k_can_skip[] = "can_skip"; static const char __pyx_k_code_obj[] = "code_obj"; static const char __pyx_k_getstate[] = "__getstate__"; static const char __pyx_k_pyx_type[] = "__pyx_type"; static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_bootstrap[] = "__bootstrap"; static const char __pyx_k_decref_py[] = "decref_py"; static const char __pyx_k_get_ident[] = "_get_ident"; static const char __pyx_k_last_line[] = "last_line"; static const char __pyx_k_pyx_state[] = "__pyx_state"; static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_threading[] = "threading"; static const char __pyx_k_CacheValue[] = "_CacheValue"; static const char __pyx_k_ThreadInfo[] = "ThreadInfo"; static const char __pyx_k_first_line[] = "first_line"; static const char __pyx_k_global_dbg[] = "global_dbg"; static const char __pyx_k_issuperset[] = "issuperset"; static const char __pyx_k_pyx_result[] = "__pyx_result"; static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_DebugHelper[] = "DebugHelper"; static const char __pyx_k_PickleError[] = "PickleError"; static const char __pyx_k_bootstrap_2[] = "_bootstrap"; static const char __pyx_k_breakpoints[] = "breakpoints"; static const char __pyx_k_code_obj_py[] = "code_obj_py"; static const char __pyx_k_get_ident_2[] = "get_ident"; static const char __pyx_k_thread_info[] = "thread_info"; static const char __pyx_k_CodeLineInfo[] = "_CodeLineInfo"; static const char __pyx_k_FuncCodeInfo[] = "FuncCodeInfo"; static const char __pyx_k_intersection[] = "intersection"; static const char __pyx_k_pydev_monkey[] = "pydev_monkey"; static const char __pyx_k_pyx_checksum[] = "__pyx_checksum"; static const char __pyx_k_stringsource[] = "stringsource"; static const char __pyx_k_version_info[] = "version_info"; static const char __pyx_k_get_file_type[] = "get_file_type"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_thread_active[] = "_thread_active"; static const char __pyx_k_AttributeError[] = "AttributeError"; static const char __pyx_k_code_line_info[] = "code_line_info"; static const char __pyx_k_current_thread[] = "current_thread"; static const char __pyx_k_findlinestarts[] = "findlinestarts"; static const char __pyx_k_line_to_offset[] = "line_to_offset"; static const char __pyx_k_pydevd_tracing[] = "pydevd_tracing"; static const char __pyx_k_set_trace_func[] = "set_trace_func"; static const char __pyx_k_trace_dispatch[] = "trace_dispatch"; static const char __pyx_k_additional_info[] = "additional_info"; static const char __pyx_k_bootstrap_inner[] = "__bootstrap_inner"; static const char __pyx_k_frame_eval_func[] = "frame_eval_func"; static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_stop_frame_eval[] = "stop_frame_eval"; static const char __pyx_k_bootstrap_inner_2[] = "_bootstrap_inner"; static const char __pyx_k_pydevd_file_utils[] = "pydevd_file_utils"; static const char __pyx_k_signature_factory[] = "signature_factory"; static const char __pyx_k_thread_local_info[] = "_thread_local_info"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_get_code_line_info[] = "_get_code_line_info"; static const char __pyx_k_get_thread_info_py[] = "get_thread_info_py"; static const char __pyx_k_show_return_values[] = "show_return_values"; static const char __pyx_k_get_cache_file_type[] = "get_cache_file_type"; static const char __pyx_k_update_globals_dict[] = "update_globals_dict"; static const char __pyx_k_GlobalDebuggerHolder[] = "GlobalDebuggerHolder"; static const char __pyx_k_dummy_trace_dispatch[] = "dummy_trace_dispatch"; static const char __pyx_k_dummy_tracing_holder[] = "dummy_tracing_holder"; static const char __pyx_k_insert_pydevd_breaks[] = "insert_pydevd_breaks"; static const char __pyx_k_get_func_code_info_py[] = "get_func_code_info_py"; static const char __pyx_k_has_plugin_line_breaks[] = "has_plugin_line_breaks"; static const char __pyx_k_is_pydev_daemon_thread[] = "is_pydev_daemon_thread"; static const char __pyx_k_clear_thread_local_info[] = "clear_thread_local_info"; static const char __pyx_k_pyx_unpickle_ThreadInfo[] = "__pyx_unpickle_ThreadInfo"; static const char __pyx_k_breakpoints_hit_at_lines[] = "breakpoints_hit_at_lines"; static const char __pyx_k_pyx_unpickle__CacheValue[] = "__pyx_unpickle__CacheValue"; static const char __pyx_k_pyx_unpickle_FuncCodeInfo[] = "__pyx_unpickle_FuncCodeInfo"; static const char __pyx_k_break_on_caught_exceptions[] = "break_on_caught_exceptions"; static const char __pyx_k_pyx_unpickle__CodeLineInfo[] = "__pyx_unpickle__CodeLineInfo"; static const char __pyx_k_get_cached_code_obj_info_py[] = "get_cached_code_obj_info_py"; static const char __pyx_k_has_plugin_exception_breaks[] = "has_plugin_exception_breaks"; static const char __pyx_k_NORM_PATHS_AND_BASE_CONTAINER[] = "NORM_PATHS_AND_BASE_CONTAINER"; static const char __pyx_k_pydevd_bundle_pydevd_constants[] = "_pydevd_bundle.pydevd_constants"; static const char __pyx_k_pydevd_frame_eval_pydevd_frame[] = "_pydevd_frame_eval.pydevd_frame_tracing"; static const char __pyx_k_If_a_code_object_is_cached_that[] = "If a code object is cached, that same code object must be reused."; static const char __pyx_k_get_abs_path_real_path_and_base[] = "get_abs_path_real_path_and_base_from_frame"; static const char __pyx_k_pydev_bundle__pydev_saved_modul[] = "_pydev_bundle._pydev_saved_modules"; static const char __pyx_k_pydevd_bundle_pydevd_additional[] = "_pydevd_bundle.pydevd_additional_thread_info"; static const char __pyx_k_pydevd_bundle_pydevd_trace_disp[] = "_pydevd_bundle.pydevd_trace_dispatch"; static const char __pyx_k_pydevd_frame_eval_pydevd_modify[] = "_pydevd_frame_eval.pydevd_modify_bytecode"; static const char __pyx_k_set_additional_thread_info_lock[] = "_set_additional_thread_info_lock"; static const char __pyx_k_Incompatible_checksums_0x_x_vs_0[] = "Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))"; static const char __pyx_k_break_on_user_uncaught_exception[] = "break_on_user_uncaught_exceptions"; static const char __pyx_k_compute_force_stay_in_untraced_m[] = "compute_force_stay_in_untraced_mode"; static const char __pyx_k_fix_top_level_trace_and_get_trac[] = "fix_top_level_trace_and_get_trace_func"; static const char __pyx_k_function_breakpoint_name_to_brea[] = "function_breakpoint_name_to_breakpoint"; static const char __pyx_k_generate_code_with_breakpoints_p[] = "generate_code_with_breakpoints_py"; static const char __pyx_k_pydevd_frame_eval_pydevd_frame_2[] = "_pydevd_frame_eval/pydevd_frame_evaluator.pyx"; static const char __pyx_k_pydevd_frame_eval_pydevd_frame_3[] = "_pydevd_frame_eval.pydevd_frame_evaluator"; static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_2[] = "Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))"; static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_3[] = "Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))"; static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_4[] = "Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))"; static PyObject *__pyx_kp_s_; static PyObject *__pyx_n_s_AttributeError; static PyObject *__pyx_n_s_CacheValue; static PyObject *__pyx_n_s_CodeLineInfo; static PyObject *__pyx_n_s_DebugHelper; static PyObject *__pyx_n_s_FuncCodeInfo; static PyObject *__pyx_n_s_GlobalDebuggerHolder; static PyObject *__pyx_kp_s_If_a_code_object_is_cached_that; static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0; static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2; static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3; static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_4; static PyObject *__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER; static PyObject *__pyx_n_s_PickleError; static PyObject *__pyx_n_s_SetTrace; static PyObject *__pyx_n_s_ThreadInfo; static PyObject *__pyx_kp_s__2; static PyObject *__pyx_kp_s__3; static PyObject *__pyx_kp_s__5; static PyObject *__pyx_n_s_active; static PyObject *__pyx_n_s_additional_info; static PyObject *__pyx_n_s_arg; static PyObject *__pyx_n_s_bootstrap; static PyObject *__pyx_n_s_bootstrap_2; static PyObject *__pyx_n_s_bootstrap_inner; static PyObject *__pyx_n_s_bootstrap_inner_2; static PyObject *__pyx_n_s_break_on_caught_exceptions; static PyObject *__pyx_n_s_break_on_user_uncaught_exception; static PyObject *__pyx_n_s_breakpoints; static PyObject *__pyx_n_s_breakpoints_hit_at_lines; static PyObject *__pyx_n_s_cache; static PyObject *__pyx_n_s_call; static PyObject *__pyx_n_s_call_2; static PyObject *__pyx_n_s_can_skip; static PyObject *__pyx_n_s_clear_thread_local_info; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_code_line_info; static PyObject *__pyx_n_s_code_obj; static PyObject *__pyx_n_s_code_obj_py; static PyObject *__pyx_n_s_compute_force_stay_in_untraced_m; static PyObject *__pyx_n_s_current_thread; static PyObject *__pyx_n_s_decref_py; static PyObject *__pyx_n_s_dict; static PyObject *__pyx_n_s_dis; static PyObject *__pyx_n_s_dummy_trace_dispatch; static PyObject *__pyx_n_s_dummy_tracing_holder; static PyObject *__pyx_n_s_enter; static PyObject *__pyx_n_s_event; static PyObject *__pyx_n_s_exec; static PyObject *__pyx_n_s_exit; static PyObject *__pyx_n_s_f_back; static PyObject *__pyx_n_s_f_trace; static PyObject *__pyx_n_s_findlinestarts; static PyObject *__pyx_n_s_first_line; static PyObject *__pyx_n_s_fix_top_level_trace_and_get_trac; static PyObject *__pyx_n_s_frame; static PyObject *__pyx_n_s_frame_eval_func; static PyObject *__pyx_n_s_function_breakpoint_name_to_brea; static PyObject *__pyx_n_s_generate_code_with_breakpoints_p; static PyObject *__pyx_n_s_get; static PyObject *__pyx_n_s_get_abs_path_real_path_and_base; static PyObject *__pyx_n_s_get_cache_file_type; static PyObject *__pyx_n_s_get_cached_code_obj_info_py; static PyObject *__pyx_n_s_get_code_line_info; static PyObject *__pyx_n_s_get_file_type; static PyObject *__pyx_n_s_get_func_code_info_py; static PyObject *__pyx_n_s_get_ident; static PyObject *__pyx_n_s_get_ident_2; static PyObject *__pyx_n_s_get_thread_info_py; static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_global_dbg; static PyObject *__pyx_n_s_has_plugin_exception_breaks; static PyObject *__pyx_n_s_has_plugin_line_breaks; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_insert_pydevd_breaks; static PyObject *__pyx_n_s_intersection; static PyObject *__pyx_n_s_is_pydev_daemon_thread; static PyObject *__pyx_n_s_issuperset; static PyObject *__pyx_n_s_last_line; static PyObject *__pyx_n_s_line; static PyObject *__pyx_n_s_line_to_offset; static PyObject *__pyx_n_s_local; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_main_2; static PyObject *__pyx_n_s_max; static PyObject *__pyx_n_s_min; static PyObject *__pyx_n_s_mtime; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_new; static PyObject *__pyx_n_s_obj; static PyObject *__pyx_n_s_offset; static PyObject *__pyx_n_s_pickle; static PyObject *__pyx_n_s_plugin; static PyObject *__pyx_n_s_pydev_bundle__pydev_saved_modul; static PyObject *__pyx_n_s_pydev_monkey; static PyObject *__pyx_n_s_pydevd; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_additional; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_constants; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_trace_disp; static PyObject *__pyx_n_s_pydevd_file_utils; static PyObject *__pyx_n_s_pydevd_frame_eval_pydevd_frame; static PyObject *__pyx_kp_s_pydevd_frame_eval_pydevd_frame_2; static PyObject *__pyx_n_s_pydevd_frame_eval_pydevd_frame_3; static PyObject *__pyx_n_s_pydevd_frame_eval_pydevd_modify; static PyObject *__pyx_n_s_pydevd_tracing; static PyObject *__pyx_n_s_pyx_PickleError; static PyObject *__pyx_n_s_pyx_checksum; static PyObject *__pyx_n_s_pyx_result; static PyObject *__pyx_n_s_pyx_state; static PyObject *__pyx_n_s_pyx_type; static PyObject *__pyx_n_s_pyx_unpickle_FuncCodeInfo; static PyObject *__pyx_n_s_pyx_unpickle_ThreadInfo; static PyObject *__pyx_n_s_pyx_unpickle__CacheValue; static PyObject *__pyx_n_s_pyx_unpickle__CodeLineInfo; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_rfind; static PyObject *__pyx_n_s_run; static PyObject *__pyx_n_s_set_additional_thread_info_lock; static PyObject *__pyx_n_s_set_trace_func; static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_show_return_values; static PyObject *__pyx_n_s_signature_factory; static PyObject *__pyx_n_s_state; static PyObject *__pyx_n_s_stop_frame_eval; static PyObject *__pyx_kp_s_stringsource; static PyObject *__pyx_n_s_sys; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_thread; static PyObject *__pyx_n_s_thread_active; static PyObject *__pyx_n_s_thread_info; static PyObject *__pyx_n_s_thread_local_info; static PyObject *__pyx_n_s_threading; static PyObject *__pyx_n_s_trace_dispatch; static PyObject *__pyx_n_s_update; static PyObject *__pyx_n_s_update_globals_dict; static PyObject *__pyx_n_s_version_info; static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_clear_thread_local_info(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo___reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_2__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo___init__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_2__reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_4__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_2dummy_trace_dispatch(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_frame, PyObject *__pyx_v_event, PyObject *__pyx_v_arg); /* proto */ static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_4get_thread_info_py(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_6decref_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */ static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_8get_func_code_info_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_thread_info, PyObject *__pyx_v_frame, PyObject *__pyx_v_code_obj); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo___init__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_line_to_offset, int __pyx_v_first_line, int __pyx_v_last_line); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_2__reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_4__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10_get_code_line_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code_obj); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12get_cached_code_obj_info_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code_obj_py); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_code_obj_py, struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_code_line_info, PyObject *__pyx_v_breakpoints_hit_at_lines); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_2compute_force_stay_in_untraced_mode(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_breakpoints); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_4__reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_6__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_14generate_code_with_breakpoints_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code_obj_py, PyObject *__pyx_v_breakpoints); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_16frame_eval_func(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_18stop_frame_eval(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_20__pyx_unpickle_ThreadInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_22__pyx_unpickle_FuncCodeInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_24__pyx_unpickle__CodeLineInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_26__pyx_unpickle__CacheValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; static PyObject *__pyx_int_3; static PyObject *__pyx_int_9; static PyObject *__pyx_int_2520179; static PyObject *__pyx_int_11485321; static PyObject *__pyx_int_64258489; static PyObject *__pyx_int_66829570; static PyObject *__pyx_int_72405718; static PyObject *__pyx_int_95010005; static PyObject *__pyx_int_156687530; static PyObject *__pyx_int_180628038; static PyObject *__pyx_int_188670045; static PyObject *__pyx_int_193022138; static PyObject *__pyx_int_240343912; static PyObject *__pyx_int_249558979; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; static PyObject *__pyx_slice__24; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__16; static PyObject *__pyx_tuple__18; static PyObject *__pyx_tuple__20; static PyObject *__pyx_tuple__22; static PyObject *__pyx_tuple__25; static PyObject *__pyx_tuple__26; static PyObject *__pyx_tuple__28; static PyObject *__pyx_tuple__30; static PyObject *__pyx_tuple__32; static PyObject *__pyx_tuple__34; static PyObject *__pyx_tuple__36; static PyObject *__pyx_codeobj__10; static PyObject *__pyx_codeobj__12; static PyObject *__pyx_codeobj__13; static PyObject *__pyx_codeobj__15; static PyObject *__pyx_codeobj__17; static PyObject *__pyx_codeobj__19; static PyObject *__pyx_codeobj__21; static PyObject *__pyx_codeobj__23; static PyObject *__pyx_codeobj__27; static PyObject *__pyx_codeobj__29; static PyObject *__pyx_codeobj__31; static PyObject *__pyx_codeobj__33; static PyObject *__pyx_codeobj__35; static PyObject *__pyx_codeobj__37; /* Late includes */ /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * _thread_active = threading._active * * def clear_thread_local_info(): # <<<<<<<<<<<<<< * global _thread_local_info * _thread_local_info = threading.local() */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_1clear_thread_local_info(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_1clear_thread_local_info = {"clear_thread_local_info", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_1clear_thread_local_info, METH_NOARGS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_1clear_thread_local_info(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("clear_thread_local_info (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_clear_thread_local_info(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_clear_thread_local_info(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("clear_thread_local_info", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":21 * def clear_thread_local_info(): * global _thread_local_info * _thread_local_info = threading.local() # <<<<<<<<<<<<<< * * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_local); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_thread_local_info, __pyx_t_1) < 0) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * _thread_active = threading._active * * def clear_thread_local_info(): # <<<<<<<<<<<<<< * global _thread_local_info * _thread_local_info = threading.local() */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.clear_thread_local_info", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 * cdef public bint force_stay_in_untraced_mode * * cdef initialize(self, PyFrameObject * frame_obj): # <<<<<<<<<<<<<< * # Places that create a ThreadInfo should verify that * # a current Python frame is being executed! */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_initialize(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyFrameObject *__pyx_v_frame_obj) { PyObject *__pyx_v_basename = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_j = NULL; PyObject *__pyx_v_co_name = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyFrameObject *__pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("initialize", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":42 * # Places that create a ThreadInfo should verify that * # a current Python frame is being executed! * assert frame_obj != NULL # <<<<<<<<<<<<<< * * self.additional_info = None */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_frame_obj != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 42, __pyx_L1_error) } } #endif /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":44 * assert frame_obj != NULL * * self.additional_info = None # <<<<<<<<<<<<<< * self.is_pydevd_thread = False * self.inside_frame_eval = 0 */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->additional_info); __Pyx_DECREF(((PyObject *)__pyx_v_self->additional_info)); __pyx_v_self->additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)Py_None); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":45 * * self.additional_info = None * self.is_pydevd_thread = False # <<<<<<<<<<<<<< * self.inside_frame_eval = 0 * self.fully_initialized = False */ __pyx_v_self->is_pydevd_thread = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":46 * self.additional_info = None * self.is_pydevd_thread = False * self.inside_frame_eval = 0 # <<<<<<<<<<<<<< * self.fully_initialized = False * self.thread_trace_func = None */ __pyx_v_self->inside_frame_eval = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":47 * self.is_pydevd_thread = False * self.inside_frame_eval = 0 * self.fully_initialized = False # <<<<<<<<<<<<<< * self.thread_trace_func = None * */ __pyx_v_self->fully_initialized = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 * self.inside_frame_eval = 0 * self.fully_initialized = False * self.thread_trace_func = None # <<<<<<<<<<<<<< * * # Get the root (if it's not a Thread initialized from the threading */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->thread_trace_func); __Pyx_DECREF(__pyx_v_self->thread_trace_func); __pyx_v_self->thread_trace_func = Py_None; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":54 * # otherwise, we have to wait for the threading module itself to * # create the Thread entry). * while frame_obj.f_back != NULL: # <<<<<<<<<<<<<< * frame_obj = frame_obj.f_back * */ while (1) { __pyx_t_1 = ((__pyx_v_frame_obj->f_back != NULL) != 0); if (!__pyx_t_1) break; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":55 * # create the Thread entry). * while frame_obj.f_back != NULL: * frame_obj = frame_obj.f_back # <<<<<<<<<<<<<< * * basename = <str> frame_obj.f_code.co_filename */ __pyx_t_2 = __pyx_v_frame_obj->f_back; __pyx_v_frame_obj = __pyx_t_2; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":57 * frame_obj = frame_obj.f_back * * basename = <str> frame_obj.f_code.co_filename # <<<<<<<<<<<<<< * i = basename.rfind('/') * j = basename.rfind('\\') */ __pyx_t_3 = ((PyObject *)__pyx_v_frame_obj->f_code->co_filename); __Pyx_INCREF(__pyx_t_3); __pyx_v_basename = __pyx_t_3; __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":58 * * basename = <str> frame_obj.f_code.co_filename * i = basename.rfind('/') # <<<<<<<<<<<<<< * j = basename.rfind('\\') * if j > i: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_basename, __pyx_n_s_rfind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_s_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_s_); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_i = __pyx_t_3; __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":59 * basename = <str> frame_obj.f_code.co_filename * i = basename.rfind('/') * j = basename.rfind('\\') # <<<<<<<<<<<<<< * if j > i: * i = j */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_basename, __pyx_n_s_rfind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_s__2) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_s__2); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_j = __pyx_t_3; __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 * i = basename.rfind('/') * j = basename.rfind('\\') * if j > i: # <<<<<<<<<<<<<< * i = j * if i >= 0: */ __pyx_t_3 = PyObject_RichCompare(__pyx_v_j, __pyx_v_i, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":61 * j = basename.rfind('\\') * if j > i: * i = j # <<<<<<<<<<<<<< * if i >= 0: * basename = basename[i + 1:] */ __Pyx_INCREF(__pyx_v_j); __Pyx_DECREF_SET(__pyx_v_i, __pyx_v_j); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 * i = basename.rfind('/') * j = basename.rfind('\\') * if j > i: # <<<<<<<<<<<<<< * i = j * if i >= 0: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":62 * if j > i: * i = j * if i >= 0: # <<<<<<<<<<<<<< * basename = basename[i + 1:] * # remove ext */ __pyx_t_3 = PyObject_RichCompare(__pyx_v_i, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":63 * i = j * if i >= 0: * basename = basename[i + 1:] # <<<<<<<<<<<<<< * # remove ext * i = basename.rfind('.') */ __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_basename, 0, 0, &__pyx_t_3, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_basename, __pyx_t_4); __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":62 * if j > i: * i = j * if i >= 0: # <<<<<<<<<<<<<< * basename = basename[i + 1:] * # remove ext */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":65 * basename = basename[i + 1:] * # remove ext * i = basename.rfind('.') # <<<<<<<<<<<<<< * if i >= 0: * basename = basename[:i] */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_basename, __pyx_n_s_rfind); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s__3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_4); __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":66 * # remove ext * i = basename.rfind('.') * if i >= 0: # <<<<<<<<<<<<<< * basename = basename[:i] * */ __pyx_t_4 = PyObject_RichCompare(__pyx_v_i, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":67 * i = basename.rfind('.') * if i >= 0: * basename = basename[:i] # <<<<<<<<<<<<<< * * co_name = <str> frame_obj.f_code.co_name */ __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_basename, 0, 0, NULL, &__pyx_v_i, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_basename, __pyx_t_4); __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":66 * # remove ext * i = basename.rfind('.') * if i >= 0: # <<<<<<<<<<<<<< * basename = basename[:i] * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":69 * basename = basename[:i] * * co_name = <str> frame_obj.f_code.co_name # <<<<<<<<<<<<<< * * # In these cases we cannot create a dummy thread (an actual */ __pyx_t_4 = ((PyObject *)__pyx_v_frame_obj->f_code->co_name); __Pyx_INCREF(__pyx_t_4); __pyx_v_co_name = __pyx_t_4; __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":73 * # In these cases we cannot create a dummy thread (an actual * # thread will be created later or tracing will already be set). * if basename == 'threading' and co_name in ('__bootstrap', '_bootstrap', '__bootstrap_inner', '_bootstrap_inner'): # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * elif basename == 'pydev_monkey' and co_name == '__call__': */ __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_v_basename, __pyx_n_s_threading, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 73, __pyx_L1_error) if (__pyx_t_6) { } else { __pyx_t_1 = __pyx_t_6; goto __pyx_L9_bool_binop_done; } __Pyx_INCREF(__pyx_v_co_name); __pyx_t_4 = __pyx_v_co_name; __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_n_s_bootstrap, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 73, __pyx_L1_error) if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L11_bool_binop_done; } __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_n_s_bootstrap_2, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 73, __pyx_L1_error) if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L11_bool_binop_done; } __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_n_s_bootstrap_inner, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 73, __pyx_L1_error) if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L11_bool_binop_done; } __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_n_s_bootstrap_inner_2, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 73, __pyx_L1_error) __pyx_t_6 = __pyx_t_7; __pyx_L11_bool_binop_done:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = (__pyx_t_6 != 0); __pyx_t_1 = __pyx_t_7; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":74 * # thread will be created later or tracing will already be set). * if basename == 'threading' and co_name in ('__bootstrap', '_bootstrap', '__bootstrap_inner', '_bootstrap_inner'): * self._can_create_dummy_thread = False # <<<<<<<<<<<<<< * elif basename == 'pydev_monkey' and co_name == '__call__': * self._can_create_dummy_thread = False */ __pyx_v_self->_can_create_dummy_thread = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":73 * # In these cases we cannot create a dummy thread (an actual * # thread will be created later or tracing will already be set). * if basename == 'threading' and co_name in ('__bootstrap', '_bootstrap', '__bootstrap_inner', '_bootstrap_inner'): # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * elif basename == 'pydev_monkey' and co_name == '__call__': */ goto __pyx_L8; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 * if basename == 'threading' and co_name in ('__bootstrap', '_bootstrap', '__bootstrap_inner', '_bootstrap_inner'): * self._can_create_dummy_thread = False * elif basename == 'pydev_monkey' and co_name == '__call__': # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): */ __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_basename, __pyx_n_s_pydev_monkey, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 75, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_1 = __pyx_t_7; goto __pyx_L15_bool_binop_done; } __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_co_name, __pyx_n_s_call, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 75, __pyx_L1_error) __pyx_t_1 = __pyx_t_7; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":76 * self._can_create_dummy_thread = False * elif basename == 'pydev_monkey' and co_name == '__call__': * self._can_create_dummy_thread = False # <<<<<<<<<<<<<< * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): * self._can_create_dummy_thread = False */ __pyx_v_self->_can_create_dummy_thread = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 * if basename == 'threading' and co_name in ('__bootstrap', '_bootstrap', '__bootstrap_inner', '_bootstrap_inner'): * self._can_create_dummy_thread = False * elif basename == 'pydev_monkey' and co_name == '__call__': # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): */ goto __pyx_L8; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 * elif basename == 'pydev_monkey' and co_name == '__call__': * self._can_create_dummy_thread = False * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * elif basename == 'pydevd_tracing': */ __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_basename, __pyx_n_s_pydevd, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 77, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_1 = __pyx_t_7; goto __pyx_L17_bool_binop_done; } __Pyx_INCREF(__pyx_v_co_name); __pyx_t_4 = __pyx_v_co_name; __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_n_s_run, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 77, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_7 = __pyx_t_6; goto __pyx_L19_bool_binop_done; } __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_n_s_main, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 77, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_7 = __pyx_t_6; goto __pyx_L19_bool_binop_done; } __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_n_s_exec, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 77, __pyx_L1_error) __pyx_t_7 = __pyx_t_6; __pyx_L19_bool_binop_done:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = (__pyx_t_7 != 0); __pyx_t_1 = __pyx_t_6; __pyx_L17_bool_binop_done:; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":78 * self._can_create_dummy_thread = False * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): * self._can_create_dummy_thread = False # <<<<<<<<<<<<<< * elif basename == 'pydevd_tracing': * self._can_create_dummy_thread = False */ __pyx_v_self->_can_create_dummy_thread = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 * elif basename == 'pydev_monkey' and co_name == '__call__': * self._can_create_dummy_thread = False * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * elif basename == 'pydevd_tracing': */ goto __pyx_L8; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":79 * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): * self._can_create_dummy_thread = False * elif basename == 'pydevd_tracing': # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * else: */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_basename, __pyx_n_s_pydevd_tracing, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 79, __pyx_L1_error) if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":80 * self._can_create_dummy_thread = False * elif basename == 'pydevd_tracing': * self._can_create_dummy_thread = False # <<<<<<<<<<<<<< * else: * self._can_create_dummy_thread = True */ __pyx_v_self->_can_create_dummy_thread = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":79 * elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'): * self._can_create_dummy_thread = False * elif basename == 'pydevd_tracing': # <<<<<<<<<<<<<< * self._can_create_dummy_thread = False * else: */ goto __pyx_L8; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":82 * self._can_create_dummy_thread = False * else: * self._can_create_dummy_thread = True # <<<<<<<<<<<<<< * * # print('Can create dummy thread for thread started in: %s %s' % (basename, co_name)) */ /*else*/ { __pyx_v_self->_can_create_dummy_thread = 1; } __pyx_L8:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 * cdef public bint force_stay_in_untraced_mode * * cdef initialize(self, PyFrameObject * frame_obj): # <<<<<<<<<<<<<< * # Places that create a ThreadInfo should verify that * # a current Python frame is being executed! */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.initialize", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_basename); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_j); __Pyx_XDECREF(__pyx_v_co_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 * # print('Can create dummy thread for thread started in: %s %s' % (basename, co_name)) * * cdef initialize_if_possible(self): # <<<<<<<<<<<<<< * # Don't call threading.currentThread because if we're too early in the process * # we may create a dummy thread. */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_initialize_if_possible(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_v_thread_ident = NULL; PyObject *__pyx_v_t = NULL; PyObject *__pyx_v_additional_info = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; int __pyx_t_18; int __pyx_t_19; char const *__pyx_t_20; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("initialize_if_possible", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 * # Don't call threading.currentThread because if we're too early in the process * # we may create a dummy thread. * self.inside_frame_eval += 1 # <<<<<<<<<<<<<< * * try: */ __pyx_v_self->inside_frame_eval = (__pyx_v_self->inside_frame_eval + 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":91 * self.inside_frame_eval += 1 * * try: # <<<<<<<<<<<<<< * thread_ident = _get_ident() * t = _thread_active.get(thread_ident) */ /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":92 * * try: * thread_ident = _get_ident() # <<<<<<<<<<<<<< * t = _thread_active.get(thread_ident) * if t is None: */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_ident); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_thread_ident = __pyx_t_1; __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * try: * thread_ident = _get_ident() * t = _thread_active.get(thread_ident) # <<<<<<<<<<<<<< * if t is None: * if self._can_create_dummy_thread: */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_thread_active); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_thread_ident) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_thread_ident); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_t = __pyx_t_1; __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":94 * thread_ident = _get_ident() * t = _thread_active.get(thread_ident) * if t is None: # <<<<<<<<<<<<<< * if self._can_create_dummy_thread: * # Initialize the dummy thread and set the tracing (both are needed to */ __pyx_t_4 = (__pyx_v_t == Py_None); __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":95 * t = _thread_active.get(thread_ident) * if t is None: * if self._can_create_dummy_thread: # <<<<<<<<<<<<<< * # Initialize the dummy thread and set the tracing (both are needed to * # actually stop on breakpoints). */ __pyx_t_5 = (__pyx_v_self->_can_create_dummy_thread != 0); if (__pyx_t_5) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":98 * # Initialize the dummy thread and set the tracing (both are needed to * # actually stop on breakpoints). * t = threading.current_thread() # <<<<<<<<<<<<<< * SetTrace(dummy_trace_dispatch) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_threading); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_current_thread); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":99 * # actually stop on breakpoints). * t = threading.current_thread() * SetTrace(dummy_trace_dispatch) # <<<<<<<<<<<<<< * else: * return # Cannot initialize until thread becomes active. */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SetTrace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_dummy_trace_dispatch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":95 * t = _thread_active.get(thread_ident) * if t is None: * if self._can_create_dummy_thread: # <<<<<<<<<<<<<< * # Initialize the dummy thread and set the tracing (both are needed to * # actually stop on breakpoints). */ goto __pyx_L7; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":101 * SetTrace(dummy_trace_dispatch) * else: * return # Cannot initialize until thread becomes active. # <<<<<<<<<<<<<< * * if getattr(t, 'is_pydev_daemon_thread', False): */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L3_return; } __pyx_L7:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":94 * thread_ident = _get_ident() * t = _thread_active.get(thread_ident) * if t is None: # <<<<<<<<<<<<<< * if self._can_create_dummy_thread: * # Initialize the dummy thread and set the tracing (both are needed to */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":103 * return # Cannot initialize until thread becomes active. * * if getattr(t, 'is_pydev_daemon_thread', False): # <<<<<<<<<<<<<< * self.is_pydevd_thread = True * self.fully_initialized = True */ __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_t, __pyx_n_s_is_pydev_daemon_thread, Py_False); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 103, __pyx_L4_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":104 * * if getattr(t, 'is_pydev_daemon_thread', False): * self.is_pydevd_thread = True # <<<<<<<<<<<<<< * self.fully_initialized = True * else: */ __pyx_v_self->is_pydevd_thread = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":105 * if getattr(t, 'is_pydev_daemon_thread', False): * self.is_pydevd_thread = True * self.fully_initialized = True # <<<<<<<<<<<<<< * else: * try: */ __pyx_v_self->fully_initialized = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":103 * return # Cannot initialize until thread becomes active. * * if getattr(t, 'is_pydev_daemon_thread', False): # <<<<<<<<<<<<<< * self.is_pydevd_thread = True * self.fully_initialized = True */ goto __pyx_L8; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":107 * self.fully_initialized = True * else: * try: # <<<<<<<<<<<<<< * additional_info = t.additional_info * if additional_info is None: */ /*else*/ { { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":108 * else: * try: * additional_info = t.additional_info # <<<<<<<<<<<<<< * if additional_info is None: * raise AttributeError() */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_additional_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_additional_info = __pyx_t_1; __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":109 * try: * additional_info = t.additional_info * if additional_info is None: # <<<<<<<<<<<<<< * raise AttributeError() * except: */ __pyx_t_5 = (__pyx_v_additional_info == Py_None); __pyx_t_4 = (__pyx_t_5 != 0); if (unlikely(__pyx_t_4)) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":110 * additional_info = t.additional_info * if additional_info is None: * raise AttributeError() # <<<<<<<<<<<<<< * except: * with _set_additional_thread_info_lock: */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_AttributeError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 110, __pyx_L9_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":109 * try: * additional_info = t.additional_info * if additional_info is None: # <<<<<<<<<<<<<< * raise AttributeError() * except: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":107 * self.fully_initialized = True * else: * try: # <<<<<<<<<<<<<< * additional_info = t.additional_info * if additional_info is None: */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L14_try_end; __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":111 * if additional_info is None: * raise AttributeError() * except: # <<<<<<<<<<<<<< * with _set_additional_thread_info_lock: * # If it's not there, set it within a lock to avoid any racing */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.initialize_if_possible", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 111, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":112 * raise AttributeError() * except: * with _set_additional_thread_info_lock: # <<<<<<<<<<<<<< * # If it's not there, set it within a lock to avoid any racing * # conditions. */ /*with:*/ { __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_set_additional_thread_info_lock); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 112, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 112, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_n_s_enter); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 112, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } __pyx_t_11 = (__pyx_t_13) ? __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13) : __Pyx_PyObject_CallNoArg(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 112, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /*try:*/ { { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":115 * # If it's not there, set it within a lock to avoid any racing * # conditions. * additional_info = getattr(thread, 'additional_info', None) # <<<<<<<<<<<<<< * if additional_info is None: * additional_info = PyDBAdditionalThreadInfo() */ __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_thread); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 115, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = __Pyx_GetAttr3(__pyx_t_6, __pyx_n_s_additional_info, Py_None); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 115, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_additional_info, __pyx_t_11); __pyx_t_11 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":116 * # conditions. * additional_info = getattr(thread, 'additional_info', None) * if additional_info is None: # <<<<<<<<<<<<<< * additional_info = PyDBAdditionalThreadInfo() * t.additional_info = additional_info */ __pyx_t_4 = (__pyx_v_additional_info == Py_None); __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":117 * additional_info = getattr(thread, 'additional_info', None) * if additional_info is None: * additional_info = PyDBAdditionalThreadInfo() # <<<<<<<<<<<<<< * t.additional_info = additional_info * self.additional_info = additional_info */ __pyx_t_11 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 117, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF_SET(__pyx_v_additional_info, __pyx_t_11); __pyx_t_11 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":116 * # conditions. * additional_info = getattr(thread, 'additional_info', None) * if additional_info is None: # <<<<<<<<<<<<<< * additional_info = PyDBAdditionalThreadInfo() * t.additional_info = additional_info */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":118 * if additional_info is None: * additional_info = PyDBAdditionalThreadInfo() * t.additional_info = additional_info # <<<<<<<<<<<<<< * self.additional_info = additional_info * self.fully_initialized = True */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_t, __pyx_n_s_additional_info, __pyx_v_additional_info) < 0) __PYX_ERR(0, 118, __pyx_L24_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":112 * raise AttributeError() * except: * with _set_additional_thread_info_lock: # <<<<<<<<<<<<<< * # If it's not there, set it within a lock to avoid any racing * # conditions. */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L31_try_end; __pyx_L24_error:; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.initialize_if_possible", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_6, &__pyx_t_12) < 0) __PYX_ERR(0, 112, __pyx_L26_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyTuple_Pack(3, __pyx_t_11, __pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 112, __pyx_L26_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_13, NULL); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 112, __pyx_L26_except_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__pyx_t_5 < 0) __PYX_ERR(0, 112, __pyx_L26_except_error) __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestoreWithState(__pyx_t_11, __pyx_t_6, __pyx_t_12); __pyx_t_11 = 0; __pyx_t_6 = 0; __pyx_t_12 = 0; __PYX_ERR(0, 112, __pyx_L26_except_error) } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L25_exception_handled; } __pyx_L26_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); goto __pyx_L11_except_error; __pyx_L25_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_L31_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_10) { __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__4, NULL); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 112, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } goto __pyx_L23; } __pyx_L23:; } goto __pyx_L36; __pyx_L18_error:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L11_except_error; __pyx_L36:; } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L10_exception_handled; } __pyx_L11_except_error:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":107 * self.fully_initialized = True * else: * try: # <<<<<<<<<<<<<< * additional_info = t.additional_info * if additional_info is None: */ __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L4_error; __pyx_L10_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_L14_try_end:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":119 * additional_info = PyDBAdditionalThreadInfo() * t.additional_info = additional_info * self.additional_info = additional_info # <<<<<<<<<<<<<< * self.fully_initialized = True * finally: */ if (unlikely(!__pyx_v_additional_info)) { __Pyx_RaiseUnboundLocalError("additional_info"); __PYX_ERR(0, 119, __pyx_L4_error) } if (!(likely(((__pyx_v_additional_info) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_additional_info, __pyx_ptype_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo))))) __PYX_ERR(0, 119, __pyx_L4_error) __pyx_t_3 = __pyx_v_additional_info; __Pyx_INCREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->additional_info); __Pyx_DECREF(((PyObject *)__pyx_v_self->additional_info)); __pyx_v_self->additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)__pyx_t_3); __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":120 * t.additional_info = additional_info * self.additional_info = additional_info * self.fully_initialized = True # <<<<<<<<<<<<<< * finally: * self.inside_frame_eval -= 1 */ __pyx_v_self->fully_initialized = 1; } __pyx_L8:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":122 * self.fully_initialized = True * finally: * self.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * * */ /*finally:*/ { /*normal exit:*/{ __pyx_v_self->inside_frame_eval = (__pyx_v_self->inside_frame_eval - 1); goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_10 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_16, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_18 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename; { __pyx_v_self->inside_frame_eval = (__pyx_v_self->inside_frame_eval - 1); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_16, __pyx_t_15); } __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ErrRestore(__pyx_t_9, __pyx_t_8, __pyx_t_7); __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_10 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_15 = __pyx_r; __pyx_r = 0; __pyx_v_self->inside_frame_eval = (__pyx_v_self->inside_frame_eval - 1); __pyx_r = __pyx_t_15; __pyx_t_15 = 0; goto __pyx_L0; } __pyx_L5:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 * # print('Can create dummy thread for thread started in: %s %s' % (basename, co_name)) * * cdef initialize_if_possible(self): # <<<<<<<<<<<<<< * # Don't call threading.currentThread because if we're too early in the process * # we may create a dummy thread. */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.initialize_if_possible", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_thread_ident); __Pyx_XDECREF(__pyx_v_t); __Pyx_XDECREF(__pyx_v_additional_info); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":26 * cdef class ThreadInfo: * * cdef public PyDBAdditionalThreadInfo additional_info # <<<<<<<<<<<<<< * cdef public bint is_pydevd_thread * cdef public int inside_frame_eval */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->additional_info)); __pyx_r = ((PyObject *)__pyx_v_self->additional_info); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo))))) __PYX_ERR(0, 26, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->additional_info); __Pyx_DECREF(((PyObject *)__pyx_v_self->additional_info)); __pyx_v_self->additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.additional_info.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->additional_info); __Pyx_DECREF(((PyObject *)__pyx_v_self->additional_info)); __pyx_v_self->additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":27 * * cdef public PyDBAdditionalThreadInfo additional_info * cdef public bint is_pydevd_thread # <<<<<<<<<<<<<< * cdef public int inside_frame_eval * cdef public bint fully_initialized */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->is_pydevd_thread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.is_pydevd_thread.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L1_error) __pyx_v_self->is_pydevd_thread = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.is_pydevd_thread.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":28 * cdef public PyDBAdditionalThreadInfo additional_info * cdef public bint is_pydevd_thread * cdef public int inside_frame_eval # <<<<<<<<<<<<<< * cdef public bint fully_initialized * cdef public object thread_trace_func */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->inside_frame_eval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.inside_frame_eval.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 28, __pyx_L1_error) __pyx_v_self->inside_frame_eval = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.inside_frame_eval.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":29 * cdef public bint is_pydevd_thread * cdef public int inside_frame_eval * cdef public bint fully_initialized # <<<<<<<<<<<<<< * cdef public object thread_trace_func * cdef bint _can_create_dummy_thread */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->fully_initialized); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.fully_initialized.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 29, __pyx_L1_error) __pyx_v_self->fully_initialized = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.fully_initialized.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 * cdef public int inside_frame_eval * cdef public bint fully_initialized * cdef public object thread_trace_func # <<<<<<<<<<<<<< * cdef bint _can_create_dummy_thread * */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->thread_trace_func); __pyx_r = __pyx_v_self->thread_trace_func; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->thread_trace_func); __Pyx_DECREF(__pyx_v_self->thread_trace_func); __pyx_v_self->thread_trace_func = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->thread_trace_func); __Pyx_DECREF(__pyx_v_self->thread_trace_func); __pyx_v_self->thread_trace_func = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 * # If True the debugger should not go into trace mode even if the new * # code for a function is None and there are breakpoints. * cdef public bint force_stay_in_untraced_mode # <<<<<<<<<<<<<< * * cdef initialize(self, PyFrameObject * frame_obj): */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->force_stay_in_untraced_mode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.force_stay_in_untraced_mode.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 37, __pyx_L1_error) __pyx_v_self->force_stay_in_untraced_mode = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.force_stay_in_untraced_mode.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo___reduce_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo___reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_t_8; int __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self._can_create_dummy_thread, self.additional_info, self.force_stay_in_untraced_mode, self.fully_initialized, self.inside_frame_eval, self.is_pydevd_thread, self.thread_trace_func) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None: */ __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_can_create_dummy_thread); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->force_stay_in_untraced_mode); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->fully_initialized); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->inside_frame_eval); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_self->is_pydevd_thread); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self->additional_info)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->additional_info)); PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_self->additional_info)); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5); __Pyx_INCREF(__pyx_v_self->thread_trace_func); __Pyx_GIVEREF(__pyx_v_self->thread_trace_func); PyTuple_SET_ITEM(__pyx_t_6, 6, __pyx_v_self->thread_trace_func); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_v_state = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self._can_create_dummy_thread, self.additional_info, self.force_stay_in_untraced_mode, self.fully_initialized, self.inside_frame_eval, self.is_pydevd_thread, self.thread_trace_func) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None: * state += (_dict,) */ __pyx_t_6 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v__dict = __pyx_t_6; __pyx_t_6 = 0; /* "(tree fragment)":7 * state = (self._can_create_dummy_thread, self.additional_info, self.force_stay_in_untraced_mode, self.fully_initialized, self.inside_frame_eval, self.is_pydevd_thread, self.thread_trace_func) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_7 = (__pyx_v__dict != Py_None); __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v__dict); __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; /* "(tree fragment)":9 * if _dict is not None: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = self.additional_info is not None or self.thread_trace_func is not None */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self._can_create_dummy_thread, self.additional_info, self.force_stay_in_untraced_mode, self.fully_initialized, self.inside_frame_eval, self.is_pydevd_thread, self.thread_trace_func) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = self.additional_info is not None or self.thread_trace_func is not None # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, None), state */ /*else*/ { __pyx_t_7 = (((PyObject *)__pyx_v_self->additional_info) != Py_None); __pyx_t_9 = (__pyx_t_7 != 0); if (!__pyx_t_9) { } else { __pyx_t_8 = __pyx_t_9; goto __pyx_L4_bool_binop_done; } __pyx_t_9 = (__pyx_v_self->thread_trace_func != Py_None); __pyx_t_7 = (__pyx_t_9 != 0); __pyx_t_8 = __pyx_t_7; __pyx_L4_bool_binop_done:; __pyx_v_use_setstate = __pyx_t_8; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = self.additional_info is not None or self.thread_trace_func is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, None), state * else: */ __pyx_t_8 = (__pyx_v_use_setstate != 0); if (__pyx_t_8) { /* "(tree fragment)":13 * use_setstate = self.additional_info is not None or self.thread_trace_func is not None * if use_setstate: * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_ThreadInfo); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_11485321); __Pyx_GIVEREF(__pyx_int_11485321); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_11485321); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_6, 2, Py_None); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = self.additional_info is not None or self.thread_trace_func is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, None), state * else: * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_ThreadInfo__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_ThreadInfo); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_11485321); __Pyx_GIVEREF(__pyx_int_11485321); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_11485321); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_ThreadInfo__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_2__setstate_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_2__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_ThreadInfo__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error) __pyx_t_1 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_ThreadInfo__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_ThreadInfo, (type(self), 0x0af4089, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_ThreadInfo__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":139 * cdef public int breakpoints_mtime * * def __init__(self): # <<<<<<<<<<<<<< * self.co_filename = '' * self.canonical_normalized_filename = '' */ /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo___init__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo___init__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":140 * * def __init__(self): * self.co_filename = '' # <<<<<<<<<<<<<< * self.canonical_normalized_filename = '' * self.always_skip_code = False */ __Pyx_INCREF(__pyx_kp_s__5); __Pyx_GIVEREF(__pyx_kp_s__5); __Pyx_GOTREF(__pyx_v_self->co_filename); __Pyx_DECREF(__pyx_v_self->co_filename); __pyx_v_self->co_filename = __pyx_kp_s__5; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":141 * def __init__(self): * self.co_filename = '' * self.canonical_normalized_filename = '' # <<<<<<<<<<<<<< * self.always_skip_code = False * */ __Pyx_INCREF(__pyx_kp_s__5); __Pyx_GIVEREF(__pyx_kp_s__5); __Pyx_GOTREF(__pyx_v_self->canonical_normalized_filename); __Pyx_DECREF(__pyx_v_self->canonical_normalized_filename); __pyx_v_self->canonical_normalized_filename = __pyx_kp_s__5; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":142 * self.co_filename = '' * self.canonical_normalized_filename = '' * self.always_skip_code = False # <<<<<<<<<<<<<< * * # If breakpoints are found but new_code is None, */ __pyx_v_self->always_skip_code = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":147 * # this means we weren't able to actually add the code * # where needed, so, fallback to tracing. * self.breakpoint_found = False # <<<<<<<<<<<<<< * self.new_code = None * self.breakpoints_mtime = -1 */ __pyx_v_self->breakpoint_found = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":148 * # where needed, so, fallback to tracing. * self.breakpoint_found = False * self.new_code = None # <<<<<<<<<<<<<< * self.breakpoints_mtime = -1 * */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->new_code); __Pyx_DECREF(__pyx_v_self->new_code); __pyx_v_self->new_code = Py_None; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":149 * self.breakpoint_found = False * self.new_code = None * self.breakpoints_mtime = -1 # <<<<<<<<<<<<<< * * */ __pyx_v_self->breakpoints_mtime = -1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":139 * cdef public int breakpoints_mtime * * def __init__(self): # <<<<<<<<<<<<<< * self.co_filename = '' * self.canonical_normalized_filename = '' */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":127 * cdef class FuncCodeInfo: * * cdef public str co_filename # <<<<<<<<<<<<<< * cdef public str co_name * cdef public str canonical_normalized_filename */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->co_filename); __pyx_r = __pyx_v_self->co_filename; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 127, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->co_filename); __Pyx_DECREF(__pyx_v_self->co_filename); __pyx_v_self->co_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.co_filename.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->co_filename); __Pyx_DECREF(__pyx_v_self->co_filename); __pyx_v_self->co_filename = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":128 * * cdef public str co_filename * cdef public str co_name # <<<<<<<<<<<<<< * cdef public str canonical_normalized_filename * cdef bint always_skip_code */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->co_name); __pyx_r = __pyx_v_self->co_name; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 128, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->co_name); __Pyx_DECREF(__pyx_v_self->co_name); __pyx_v_self->co_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.co_name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->co_name); __Pyx_DECREF(__pyx_v_self->co_name); __pyx_v_self->co_name = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":129 * cdef public str co_filename * cdef public str co_name * cdef public str canonical_normalized_filename # <<<<<<<<<<<<<< * cdef bint always_skip_code * cdef public bint breakpoint_found */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->canonical_normalized_filename); __pyx_r = __pyx_v_self->canonical_normalized_filename; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 129, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->canonical_normalized_filename); __Pyx_DECREF(__pyx_v_self->canonical_normalized_filename); __pyx_v_self->canonical_normalized_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.canonical_normalized_filename.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->canonical_normalized_filename); __Pyx_DECREF(__pyx_v_self->canonical_normalized_filename); __pyx_v_self->canonical_normalized_filename = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":131 * cdef public str canonical_normalized_filename * cdef bint always_skip_code * cdef public bint breakpoint_found # <<<<<<<<<<<<<< * cdef public object new_code * */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->breakpoint_found); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.breakpoint_found.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L1_error) __pyx_v_self->breakpoint_found = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.breakpoint_found.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":132 * cdef bint always_skip_code * cdef public bint breakpoint_found * cdef public object new_code # <<<<<<<<<<<<<< * * # When breakpoints_mtime != PyDb.mtime the validity of breakpoints have */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->new_code); __pyx_r = __pyx_v_self->new_code; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->new_code); __Pyx_DECREF(__pyx_v_self->new_code); __pyx_v_self->new_code = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->new_code); __Pyx_DECREF(__pyx_v_self->new_code); __pyx_v_self->new_code = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":137 * # to be re-evaluated (if invalid a new FuncCodeInfo must be created and * # tracing can't be disabled for the related frames). * cdef public int breakpoints_mtime # <<<<<<<<<<<<<< * * def __init__(self): */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->breakpoints_mtime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.breakpoints_mtime.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error) __pyx_v_self->breakpoints_mtime = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.breakpoints_mtime.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_2__reduce_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_2__reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.always_skip_code, self.breakpoint_found, self.breakpoints_mtime, self.canonical_normalized_filename, self.co_filename, self.co_name, self.new_code) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None: */ __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->always_skip_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->breakpoint_found); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->breakpoints_mtime); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); __Pyx_INCREF(__pyx_v_self->canonical_normalized_filename); __Pyx_GIVEREF(__pyx_v_self->canonical_normalized_filename); PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_self->canonical_normalized_filename); __Pyx_INCREF(__pyx_v_self->co_filename); __Pyx_GIVEREF(__pyx_v_self->co_filename); PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_self->co_filename); __Pyx_INCREF(__pyx_v_self->co_name); __Pyx_GIVEREF(__pyx_v_self->co_name); PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_self->co_name); __Pyx_INCREF(__pyx_v_self->new_code); __Pyx_GIVEREF(__pyx_v_self->new_code); PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_v_self->new_code); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_v_state = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.always_skip_code, self.breakpoint_found, self.breakpoints_mtime, self.canonical_normalized_filename, self.co_filename, self.co_name, self.new_code) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None: * state += (_dict,) */ __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v__dict = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":7 * state = (self.always_skip_code, self.breakpoint_found, self.breakpoints_mtime, self.canonical_normalized_filename, self.co_filename, self.co_name, self.new_code) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_5 = (__pyx_v__dict != Py_None); __pyx_t_6 = (__pyx_t_5 != 0); if (__pyx_t_6) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict); __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "(tree fragment)":9 * if _dict is not None: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = self.canonical_normalized_filename is not None or self.co_filename is not None or self.co_name is not None or self.new_code is not None */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.always_skip_code, self.breakpoint_found, self.breakpoints_mtime, self.canonical_normalized_filename, self.co_filename, self.co_name, self.new_code) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = self.canonical_normalized_filename is not None or self.co_filename is not None or self.co_name is not None or self.new_code is not None # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, None), state */ /*else*/ { __pyx_t_5 = (__pyx_v_self->canonical_normalized_filename != ((PyObject*)Py_None)); __pyx_t_7 = (__pyx_t_5 != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = (__pyx_v_self->co_filename != ((PyObject*)Py_None)); __pyx_t_5 = (__pyx_t_7 != 0); if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = (__pyx_v_self->co_name != ((PyObject*)Py_None)); __pyx_t_7 = (__pyx_t_5 != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = (__pyx_v_self->new_code != Py_None); __pyx_t_5 = (__pyx_t_7 != 0); __pyx_t_6 = __pyx_t_5; __pyx_L4_bool_binop_done:; __pyx_v_use_setstate = __pyx_t_6; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = self.canonical_normalized_filename is not None or self.co_filename is not None or self.co_name is not None or self.new_code is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, None), state * else: */ __pyx_t_6 = (__pyx_v_use_setstate != 0); if (__pyx_t_6) { /* "(tree fragment)":13 * use_setstate = self.canonical_normalized_filename is not None or self.co_filename is not None or self.co_name is not None or self.new_code is not None * if use_setstate: * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pyx_unpickle_FuncCodeInfo); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_188670045); __Pyx_GIVEREF(__pyx_int_188670045); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_188670045); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None); __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = self.canonical_normalized_filename is not None or self.co_filename is not None or self.co_name is not None or self.new_code is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, None), state * else: * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_FuncCodeInfo__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_FuncCodeInfo); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_188670045); __Pyx_GIVEREF(__pyx_int_188670045); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_188670045); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_FuncCodeInfo__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_4__setstate_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_4__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_FuncCodeInfo__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error) __pyx_t_1 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_FuncCodeInfo__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_FuncCodeInfo, (type(self), 0xb3ee05d, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_FuncCodeInfo__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":152 * * * def dummy_trace_dispatch(frame, str event, arg): # <<<<<<<<<<<<<< * if event == 'call': * if frame.f_trace is not None: */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_3dummy_trace_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_3dummy_trace_dispatch = {"dummy_trace_dispatch", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_3dummy_trace_dispatch, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_3dummy_trace_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_frame = 0; PyObject *__pyx_v_event = 0; PyObject *__pyx_v_arg = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dummy_trace_dispatch (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_frame,&__pyx_n_s_event,&__pyx_n_s_arg,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_frame)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_event)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("dummy_trace_dispatch", 1, 3, 3, 1); __PYX_ERR(0, 152, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arg)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("dummy_trace_dispatch", 1, 3, 3, 2); __PYX_ERR(0, 152, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dummy_trace_dispatch") < 0)) __PYX_ERR(0, 152, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_frame = values[0]; __pyx_v_event = ((PyObject*)values[1]); __pyx_v_arg = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("dummy_trace_dispatch", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 152, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.dummy_trace_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_event), (&PyString_Type), 1, "event", 1))) __PYX_ERR(0, 152, __pyx_L1_error) __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_2dummy_trace_dispatch(__pyx_self, __pyx_v_frame, __pyx_v_event, __pyx_v_arg); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_2dummy_trace_dispatch(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_frame, PyObject *__pyx_v_event, PyObject *__pyx_v_arg) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("dummy_trace_dispatch", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":153 * * def dummy_trace_dispatch(frame, str event, arg): * if event == 'call': # <<<<<<<<<<<<<< * if frame.f_trace is not None: * return frame.f_trace(frame, event, arg) */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_event, __pyx_n_s_call_2, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 153, __pyx_L1_error) __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":154 * def dummy_trace_dispatch(frame, str event, arg): * if event == 'call': * if frame.f_trace is not None: # <<<<<<<<<<<<<< * return frame.f_trace(frame, event, arg) * return None */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = (__pyx_t_3 != Py_None); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":155 * if event == 'call': * if frame.f_trace is not None: * return frame.f_trace(frame, event, arg) # <<<<<<<<<<<<<< * return None * */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_frame, __pyx_v_event, __pyx_v_arg}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_frame, __pyx_v_event, __pyx_v_arg}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_frame); __Pyx_INCREF(__pyx_v_event); __Pyx_GIVEREF(__pyx_v_event); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_event); __Pyx_INCREF(__pyx_v_arg); __Pyx_GIVEREF(__pyx_v_arg); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_arg); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":154 * def dummy_trace_dispatch(frame, str event, arg): * if event == 'call': * if frame.f_trace is not None: # <<<<<<<<<<<<<< * return frame.f_trace(frame, event, arg) * return None */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":153 * * def dummy_trace_dispatch(frame, str event, arg): * if event == 'call': # <<<<<<<<<<<<<< * if frame.f_trace is not None: * return frame.f_trace(frame, event, arg) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":156 * if frame.f_trace is not None: * return frame.f_trace(frame, event, arg) * return None # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":152 * * * def dummy_trace_dispatch(frame, str event, arg): # <<<<<<<<<<<<<< * if event == 'call': * if frame.f_trace is not None: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.dummy_trace_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":159 * * * def get_thread_info_py() -> ThreadInfo: # <<<<<<<<<<<<<< * return get_thread_info(PyEval_GetFrame()) * */ /* Python wrapper */ static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_5get_thread_info_py(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_5get_thread_info_py = {"get_thread_info_py", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_5get_thread_info_py, METH_NOARGS, 0}; static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_5get_thread_info_py(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_thread_info_py (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_4get_thread_info_py(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_4get_thread_info_py(CYTHON_UNUSED PyObject *__pyx_self) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_thread_info_py", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":160 * * def get_thread_info_py() -> ThreadInfo: * return get_thread_info(PyEval_GetFrame()) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_1 = ((PyObject *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_thread_info(PyEval_GetFrame())); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":159 * * * def get_thread_info_py() -> ThreadInfo: # <<<<<<<<<<<<<< * return get_thread_info(PyEval_GetFrame()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_thread_info_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":163 * * * cdef ThreadInfo get_thread_info(PyFrameObject * frame_obj): # <<<<<<<<<<<<<< * ''' * Provides thread-related info. */ static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_thread_info(PyFrameObject *__pyx_v_frame_obj) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_thread_info = 0; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; int __pyx_t_9; int __pyx_t_10; char const *__pyx_t_11; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_thread_info", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":170 * ''' * cdef ThreadInfo thread_info * try: # <<<<<<<<<<<<<< * # Note: changing to a `dict[thread.ident] = thread_info` had almost no * # effect in the performance. */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":173 * # Note: changing to a `dict[thread.ident] = thread_info` had almost no * # effect in the performance. * thread_info = _thread_local_info.thread_info # <<<<<<<<<<<<<< * except: * if frame_obj == NULL: */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_thread_local_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 173, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_thread_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 173, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo))))) __PYX_ERR(0, 173, __pyx_L3_error) __pyx_v_thread_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_t_5); __pyx_t_5 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":170 * ''' * cdef ThreadInfo thread_info * try: # <<<<<<<<<<<<<< * # Note: changing to a `dict[thread.ident] = thread_info` had almost no * # effect in the performance. */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":174 * # effect in the performance. * thread_info = _thread_local_info.thread_info * except: # <<<<<<<<<<<<<< * if frame_obj == NULL: * return None */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_thread_info", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 174, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_6); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":175 * thread_info = _thread_local_info.thread_info * except: * if frame_obj == NULL: # <<<<<<<<<<<<<< * return None * thread_info = ThreadInfo() */ __pyx_t_7 = ((__pyx_v_frame_obj == NULL) != 0); if (__pyx_t_7) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":176 * except: * if frame_obj == NULL: * return None # <<<<<<<<<<<<<< * thread_info = ThreadInfo() * thread_info.initialize(frame_obj) */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_r = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)Py_None); __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":175 * thread_info = _thread_local_info.thread_info * except: * if frame_obj == NULL: # <<<<<<<<<<<<<< * return None * thread_info = ThreadInfo() */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":177 * if frame_obj == NULL: * return None * thread_info = ThreadInfo() # <<<<<<<<<<<<<< * thread_info.initialize(frame_obj) * thread_info.inside_frame_eval += 1 */ __pyx_t_8 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 177, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_XDECREF_SET(__pyx_v_thread_info, ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_t_8)); __pyx_t_8 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":178 * return None * thread_info = ThreadInfo() * thread_info.initialize(frame_obj) # <<<<<<<<<<<<<< * thread_info.inside_frame_eval += 1 * try: */ __pyx_t_8 = ((struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_thread_info->__pyx_vtab)->initialize(__pyx_v_thread_info, __pyx_v_frame_obj); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 178, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":179 * thread_info = ThreadInfo() * thread_info.initialize(frame_obj) * thread_info.inside_frame_eval += 1 # <<<<<<<<<<<<<< * try: * _thread_local_info.thread_info = thread_info */ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval + 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":180 * thread_info.initialize(frame_obj) * thread_info.inside_frame_eval += 1 * try: # <<<<<<<<<<<<<< * _thread_local_info.thread_info = thread_info * */ /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":181 * thread_info.inside_frame_eval += 1 * try: * _thread_local_info.thread_info = thread_info # <<<<<<<<<<<<<< * * # Note: _code_extra_index is not actually thread-related, */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_thread_local_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 181, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_8); if (__Pyx_PyObject_SetAttrStr(__pyx_t_8, __pyx_n_s_thread_info, ((PyObject *)__pyx_v_thread_info)) < 0) __PYX_ERR(0, 181, __pyx_L15_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":186 * # but this is a good point to initialize it. * global _code_extra_index * if _code_extra_index == -1: # <<<<<<<<<<<<<< * _code_extra_index = <int> _PyEval_RequestCodeExtraIndex(release_co_extra) * */ __pyx_t_7 = ((__pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator__code_extra_index == -1L) != 0); if (__pyx_t_7) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":187 * global _code_extra_index * if _code_extra_index == -1: * _code_extra_index = <int> _PyEval_RequestCodeExtraIndex(release_co_extra) # <<<<<<<<<<<<<< * * thread_info.initialize_if_possible() */ __pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator__code_extra_index = ((int)_PyEval_RequestCodeExtraIndex(release_co_extra)); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":186 * # but this is a good point to initialize it. * global _code_extra_index * if _code_extra_index == -1: # <<<<<<<<<<<<<< * _code_extra_index = <int> _PyEval_RequestCodeExtraIndex(release_co_extra) * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":189 * _code_extra_index = <int> _PyEval_RequestCodeExtraIndex(release_co_extra) * * thread_info.initialize_if_possible() # <<<<<<<<<<<<<< * finally: * thread_info.inside_frame_eval -= 1 */ __pyx_t_8 = ((struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_thread_info->__pyx_vtab)->initialize_if_possible(__pyx_v_thread_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 189, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":191 * thread_info.initialize_if_possible() * finally: * thread_info.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * * return thread_info */ /*finally:*/ { /*normal exit:*/{ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); goto __pyx_L16; } __pyx_L15_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename; { __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11; goto __pyx_L5_except_error; } __pyx_L16:; } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L4_exception_handled; } __pyx_L5_except_error:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":170 * ''' * cdef ThreadInfo thread_info * try: # <<<<<<<<<<<<<< * # Note: changing to a `dict[thread.ident] = thread_info` had almost no * # effect in the performance. */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); __pyx_L8_try_end:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":193 * thread_info.inside_frame_eval -= 1 * * return thread_info # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_thread_info)); __pyx_r = __pyx_v_thread_info; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":163 * * * cdef ThreadInfo get_thread_info(PyFrameObject * frame_obj): # <<<<<<<<<<<<<< * ''' * Provides thread-related info. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_thread_info", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_thread_info); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":196 * * * def decref_py(obj): # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_7decref_py(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/ static char __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_6decref_py[] = "\n Helper to be called from Python.\n "; static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_7decref_py = {"decref_py", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_7decref_py, METH_O, __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_6decref_py}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_7decref_py(PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("decref_py (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_6decref_py(__pyx_self, ((PyObject *)__pyx_v_obj)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_6decref_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("decref_py", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":200 * Helper to be called from Python. * ''' * Py_DECREF(obj) # <<<<<<<<<<<<<< * * */ Py_DECREF(__pyx_v_obj); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":196 * * * def decref_py(obj): # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":203 * * * def get_func_code_info_py(thread_info, frame, code_obj) -> FuncCodeInfo: # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ /* Python wrapper */ static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_9get_func_code_info_py(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_8get_func_code_info_py[] = "\n Helper to be called from Python.\n "; static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_9get_func_code_info_py = {"get_func_code_info_py", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_9get_func_code_info_py, METH_VARARGS|METH_KEYWORDS, __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_8get_func_code_info_py}; static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_9get_func_code_info_py(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_thread_info = 0; PyObject *__pyx_v_frame = 0; PyObject *__pyx_v_code_obj = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_func_code_info_py (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_thread_info,&__pyx_n_s_frame,&__pyx_n_s_code_obj,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_thread_info)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_frame)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_func_code_info_py", 1, 3, 3, 1); __PYX_ERR(0, 203, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_code_obj)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_func_code_info_py", 1, 3, 3, 2); __PYX_ERR(0, 203, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_func_code_info_py") < 0)) __PYX_ERR(0, 203, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_thread_info = values[0]; __pyx_v_frame = values[1]; __pyx_v_code_obj = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_func_code_info_py", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 203, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_func_code_info_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_8get_func_code_info_py(__pyx_self, __pyx_v_thread_info, __pyx_v_frame, __pyx_v_code_obj); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_8get_func_code_info_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_thread_info, PyObject *__pyx_v_frame, PyObject *__pyx_v_code_obj) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_func_code_info_py", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":207 * Helper to be called from Python. * ''' * return get_func_code_info(<ThreadInfo> thread_info, <PyFrameObject *> frame, <PyCodeObject *> code_obj) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_1 = ((PyObject *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_func_code_info(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_thread_info), ((PyFrameObject *)__pyx_v_frame), ((PyCodeObject *)__pyx_v_code_obj))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":203 * * * def get_func_code_info_py(thread_info, frame, code_obj) -> FuncCodeInfo: # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_func_code_info_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":212 * cdef int _code_extra_index = -1 * * cdef FuncCodeInfo get_func_code_info(ThreadInfo thread_info, PyFrameObject * frame_obj, PyCodeObject * code_obj): # <<<<<<<<<<<<<< * ''' * Provides code-object related info. */ static struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_func_code_info(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_thread_info, PyFrameObject *__pyx_v_frame_obj, PyCodeObject *__pyx_v_code_obj) { PyObject *__pyx_v_main_debugger = 0; PyObject *__pyx_v_extra; PyObject *__pyx_v_extra_obj; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_func_code_info_obj = NULL; PyObject *__pyx_v_co_filename = 0; PyObject *__pyx_v_co_name = 0; PyObject *__pyx_v_cache_file_type = 0; PyObject *__pyx_v_cache_file_type_key = 0; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_func_code_info = NULL; PyObject *__pyx_v_abs_path_real_path_and_base = NULL; PyObject *__pyx_v_file_type = NULL; PyObject *__pyx_v_breakpoints = 0; PyObject *__pyx_v_function_breakpoint = 0; PyObject *__pyx_v_code_obj_py = 0; PyObject *__pyx_v_cached_code_obj_info = 0; PyObject *__pyx_v_breakpoint_found = NULL; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; int __pyx_t_13; PyObject *(*__pyx_t_14)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_func_code_info", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":228 * # print('get_func_code_info', f_code.co_name, f_code.co_filename) * * cdef object main_debugger = GlobalDebuggerHolder.global_dbg # <<<<<<<<<<<<<< * thread_info.force_stay_in_untraced_mode = False # This is an output value of the function. * */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GlobalDebuggerHolder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_global_dbg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_main_debugger = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":229 * * cdef object main_debugger = GlobalDebuggerHolder.global_dbg * thread_info.force_stay_in_untraced_mode = False # This is an output value of the function. # <<<<<<<<<<<<<< * * cdef PyObject * extra */ __pyx_v_thread_info->force_stay_in_untraced_mode = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":232 * * cdef PyObject * extra * _PyCode_GetExtra(<PyObject *> code_obj, _code_extra_index, & extra) # <<<<<<<<<<<<<< * if extra is not NULL: * extra_obj = <PyObject *> extra */ (void)(_PyCode_GetExtra(((PyObject *)__pyx_v_code_obj), __pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator__code_extra_index, (&__pyx_v_extra))); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":233 * cdef PyObject * extra * _PyCode_GetExtra(<PyObject *> code_obj, _code_extra_index, & extra) * if extra is not NULL: # <<<<<<<<<<<<<< * extra_obj = <PyObject *> extra * if extra_obj is not NULL: */ __pyx_t_3 = ((__pyx_v_extra != NULL) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":234 * _PyCode_GetExtra(<PyObject *> code_obj, _code_extra_index, & extra) * if extra is not NULL: * extra_obj = <PyObject *> extra # <<<<<<<<<<<<<< * if extra_obj is not NULL: * func_code_info_obj = <FuncCodeInfo> extra_obj */ __pyx_v_extra_obj = ((PyObject *)__pyx_v_extra); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":235 * if extra is not NULL: * extra_obj = <PyObject *> extra * if extra_obj is not NULL: # <<<<<<<<<<<<<< * func_code_info_obj = <FuncCodeInfo> extra_obj * if func_code_info_obj.breakpoints_mtime == main_debugger.mtime: */ __pyx_t_3 = ((__pyx_v_extra_obj != NULL) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":236 * extra_obj = <PyObject *> extra * if extra_obj is not NULL: * func_code_info_obj = <FuncCodeInfo> extra_obj # <<<<<<<<<<<<<< * if func_code_info_obj.breakpoints_mtime == main_debugger.mtime: * # if DEBUG: */ __pyx_t_2 = ((PyObject *)__pyx_v_extra_obj); __Pyx_INCREF(__pyx_t_2); __pyx_v_func_code_info_obj = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":237 * if extra_obj is not NULL: * func_code_info_obj = <FuncCodeInfo> extra_obj * if func_code_info_obj.breakpoints_mtime == main_debugger.mtime: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_func_code_info: matched mtime', f_code.co_name, f_code.co_filename) */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_func_code_info_obj->breakpoints_mtime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_mtime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":241 * # print('get_func_code_info: matched mtime', f_code.co_name, f_code.co_filename) * * return func_code_info_obj # <<<<<<<<<<<<<< * * cdef str co_filename = <str> code_obj.co_filename */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_func_code_info_obj)); __pyx_r = __pyx_v_func_code_info_obj; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":237 * if extra_obj is not NULL: * func_code_info_obj = <FuncCodeInfo> extra_obj * if func_code_info_obj.breakpoints_mtime == main_debugger.mtime: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_func_code_info: matched mtime', f_code.co_name, f_code.co_filename) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":235 * if extra is not NULL: * extra_obj = <PyObject *> extra * if extra_obj is not NULL: # <<<<<<<<<<<<<< * func_code_info_obj = <FuncCodeInfo> extra_obj * if func_code_info_obj.breakpoints_mtime == main_debugger.mtime: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":233 * cdef PyObject * extra * _PyCode_GetExtra(<PyObject *> code_obj, _code_extra_index, & extra) * if extra is not NULL: # <<<<<<<<<<<<<< * extra_obj = <PyObject *> extra * if extra_obj is not NULL: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":243 * return func_code_info_obj * * cdef str co_filename = <str> code_obj.co_filename # <<<<<<<<<<<<<< * cdef str co_name = <str> code_obj.co_name * cdef dict cache_file_type */ __pyx_t_4 = ((PyObject *)__pyx_v_code_obj->co_filename); __Pyx_INCREF(__pyx_t_4); __pyx_v_co_filename = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":244 * * cdef str co_filename = <str> code_obj.co_filename * cdef str co_name = <str> code_obj.co_name # <<<<<<<<<<<<<< * cdef dict cache_file_type * cdef tuple cache_file_type_key */ __pyx_t_4 = ((PyObject *)__pyx_v_code_obj->co_name); __Pyx_INCREF(__pyx_t_4); __pyx_v_co_name = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":248 * cdef tuple cache_file_type_key * * func_code_info = FuncCodeInfo() # <<<<<<<<<<<<<< * func_code_info.breakpoints_mtime = main_debugger.mtime * */ __pyx_t_4 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_func_code_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_t_4); __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":249 * * func_code_info = FuncCodeInfo() * func_code_info.breakpoints_mtime = main_debugger.mtime # <<<<<<<<<<<<<< * * func_code_info.co_filename = co_filename */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_mtime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_func_code_info->breakpoints_mtime = __pyx_t_5; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":251 * func_code_info.breakpoints_mtime = main_debugger.mtime * * func_code_info.co_filename = co_filename # <<<<<<<<<<<<<< * func_code_info.co_name = co_name * */ __Pyx_INCREF(__pyx_v_co_filename); __Pyx_GIVEREF(__pyx_v_co_filename); __Pyx_GOTREF(__pyx_v_func_code_info->co_filename); __Pyx_DECREF(__pyx_v_func_code_info->co_filename); __pyx_v_func_code_info->co_filename = __pyx_v_co_filename; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":252 * * func_code_info.co_filename = co_filename * func_code_info.co_name = co_name # <<<<<<<<<<<<<< * * if not func_code_info.always_skip_code: */ __Pyx_INCREF(__pyx_v_co_name); __Pyx_GIVEREF(__pyx_v_co_name); __Pyx_GOTREF(__pyx_v_func_code_info->co_name); __Pyx_DECREF(__pyx_v_func_code_info->co_name); __pyx_v_func_code_info->co_name = __pyx_v_co_name; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":254 * func_code_info.co_name = co_name * * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] */ __pyx_t_3 = ((!(__pyx_v_func_code_info->always_skip_code != 0)) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":255 * * if not func_code_info.always_skip_code: * try: # <<<<<<<<<<<<<< * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] * except: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":256 * if not func_code_info.always_skip_code: * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] # <<<<<<<<<<<<<< * except: * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(<object>frame_obj) */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_4, __pyx_v_co_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_abs_path_real_path_and_base = __pyx_t_1; __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":255 * * if not func_code_info.always_skip_code: * try: # <<<<<<<<<<<<<< * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] * except: */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":257 * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] * except: # <<<<<<<<<<<<<< * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(<object>frame_obj) * */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_func_code_info", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_2) < 0) __PYX_ERR(0, 257, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_2); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":258 * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] * except: * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(<object>frame_obj) # <<<<<<<<<<<<<< * * func_code_info.canonical_normalized_filename = abs_path_real_path_and_base[1] */ __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 258, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } __pyx_t_9 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, ((PyObject *)__pyx_v_frame_obj)) : __Pyx_PyObject_CallOneArg(__pyx_t_10, ((PyObject *)__pyx_v_frame_obj)); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 258, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_abs_path_real_path_and_base, __pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":255 * * if not func_code_info.always_skip_code: * try: # <<<<<<<<<<<<<< * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] * except: */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L12_try_end:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":260 * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(<object>frame_obj) * * func_code_info.canonical_normalized_filename = abs_path_real_path_and_base[1] # <<<<<<<<<<<<<< * * cache_file_type = main_debugger.get_cache_file_type() */ __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_func_code_info->canonical_normalized_filename); __Pyx_DECREF(__pyx_v_func_code_info->canonical_normalized_filename); __pyx_v_func_code_info->canonical_normalized_filename = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":262 * func_code_info.canonical_normalized_filename = abs_path_real_path_and_base[1] * * cache_file_type = main_debugger.get_cache_file_type() # <<<<<<<<<<<<<< * # Note: this cache key must be the same from PyDB.get_file_type() -- see it for comments * # on the cache. */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_get_cache_file_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 262, __pyx_L1_error) __pyx_v_cache_file_type = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":265 * # Note: this cache key must be the same from PyDB.get_file_type() -- see it for comments * # on the cache. * cache_file_type_key = (frame_obj.f_code.co_firstlineno, abs_path_real_path_and_base[0], <object>frame_obj.f_code) # <<<<<<<<<<<<<< * try: * file_type = cache_file_type[cache_file_type_key] # Make it faster */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_frame_obj->f_code->co_firstlineno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_v_frame_obj->f_code)); __Pyx_GIVEREF(((PyObject *)__pyx_v_frame_obj->f_code)); PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_frame_obj->f_code)); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_v_cache_file_type_key = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":266 * # on the cache. * cache_file_type_key = (frame_obj.f_code.co_firstlineno, abs_path_real_path_and_base[0], <object>frame_obj.f_code) * try: # <<<<<<<<<<<<<< * file_type = cache_file_type[cache_file_type_key] # Make it faster * except: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":267 * cache_file_type_key = (frame_obj.f_code.co_firstlineno, abs_path_real_path_and_base[0], <object>frame_obj.f_code) * try: * file_type = cache_file_type[cache_file_type_key] # Make it faster # <<<<<<<<<<<<<< * except: * file_type = main_debugger.get_file_type(<object>frame_obj, abs_path_real_path_and_base) # we don't want to debug anything related to pydevd */ if (unlikely(__pyx_v_cache_file_type == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 267, __pyx_L15_error) } __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_cache_file_type, __pyx_v_cache_file_type_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_file_type = __pyx_t_1; __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":266 * # on the cache. * cache_file_type_key = (frame_obj.f_code.co_firstlineno, abs_path_real_path_and_base[0], <object>frame_obj.f_code) * try: # <<<<<<<<<<<<<< * file_type = cache_file_type[cache_file_type_key] # Make it faster * except: */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L20_try_end; __pyx_L15_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":268 * try: * file_type = cache_file_type[cache_file_type_key] # Make it faster * except: # <<<<<<<<<<<<<< * file_type = main_debugger.get_file_type(<object>frame_obj, abs_path_real_path_and_base) # we don't want to debug anything related to pydevd * */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_func_code_info", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_2) < 0) __PYX_ERR(0, 268, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_2); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":269 * file_type = cache_file_type[cache_file_type_key] # Make it faster * except: * file_type = main_debugger.get_file_type(<object>frame_obj, abs_path_real_path_and_base) # we don't want to debug anything related to pydevd # <<<<<<<<<<<<<< * * if file_type is not None: */ __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_get_file_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 269, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_frame_obj), __pyx_v_abs_path_real_path_and_base}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 269, __pyx_L17_except_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_frame_obj), __pyx_v_abs_path_real_path_and_base}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 269, __pyx_L17_except_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 269, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_frame_obj)); __Pyx_GIVEREF(((PyObject *)__pyx_v_frame_obj)); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, ((PyObject *)__pyx_v_frame_obj)); __Pyx_INCREF(__pyx_v_abs_path_real_path_and_base); __Pyx_GIVEREF(__pyx_v_abs_path_real_path_and_base); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_v_abs_path_real_path_and_base); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 269, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_file_type, __pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L16_exception_handled; } __pyx_L17_except_error:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":266 * # on the cache. * cache_file_type_key = (frame_obj.f_code.co_firstlineno, abs_path_real_path_and_base[0], <object>frame_obj.f_code) * try: # <<<<<<<<<<<<<< * file_type = cache_file_type[cache_file_type_key] # Make it faster * except: */ __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); goto __pyx_L1_error; __pyx_L16_exception_handled:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); __pyx_L20_try_end:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":271 * file_type = main_debugger.get_file_type(<object>frame_obj, abs_path_real_path_and_base) # we don't want to debug anything related to pydevd * * if file_type is not None: # <<<<<<<<<<<<<< * func_code_info.always_skip_code = True * */ __pyx_t_3 = (__pyx_v_file_type != Py_None); __pyx_t_13 = (__pyx_t_3 != 0); if (__pyx_t_13) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":272 * * if file_type is not None: * func_code_info.always_skip_code = True # <<<<<<<<<<<<<< * * if not func_code_info.always_skip_code: */ __pyx_v_func_code_info->always_skip_code = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":271 * file_type = main_debugger.get_file_type(<object>frame_obj, abs_path_real_path_and_base) # we don't want to debug anything related to pydevd * * if file_type is not None: # <<<<<<<<<<<<<< * func_code_info.always_skip_code = True * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":254 * func_code_info.co_name = co_name * * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename] */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":274 * func_code_info.always_skip_code = True * * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * if main_debugger is not None: * */ __pyx_t_13 = ((!(__pyx_v_func_code_info->always_skip_code != 0)) != 0); if (__pyx_t_13) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":275 * * if not func_code_info.always_skip_code: * if main_debugger is not None: # <<<<<<<<<<<<<< * * breakpoints: dict = main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename) */ __pyx_t_13 = (__pyx_v_main_debugger != Py_None); __pyx_t_3 = (__pyx_t_13 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":277 * if main_debugger is not None: * * breakpoints: dict = main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename) # <<<<<<<<<<<<<< * function_breakpoint: object = main_debugger.function_breakpoint_name_to_breakpoint.get(func_code_info.co_name) * # print('\n---') */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_breakpoints); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_func_code_info->canonical_normalized_filename) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_func_code_info->canonical_normalized_filename); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 277, __pyx_L1_error) __pyx_v_breakpoints = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":278 * * breakpoints: dict = main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename) * function_breakpoint: object = main_debugger.function_breakpoint_name_to_breakpoint.get(func_code_info.co_name) # <<<<<<<<<<<<<< * # print('\n---') * # print(main_debugger.breakpoints) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_function_breakpoint_name_to_brea); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_func_code_info->co_name) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_func_code_info->co_name); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_function_breakpoint = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":283 * # print(func_code_info.canonical_normalized_filename) * # print(main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename)) * code_obj_py: object = <object> code_obj # <<<<<<<<<<<<<< * cached_code_obj_info: object = _cache.get(code_obj_py) * if cached_code_obj_info: */ __pyx_t_2 = ((PyObject *)__pyx_v_code_obj); __Pyx_INCREF(__pyx_t_2); __pyx_v_code_obj_py = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":284 * # print(main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename)) * code_obj_py: object = <object> code_obj * cached_code_obj_info: object = _cache.get(code_obj_py) # <<<<<<<<<<<<<< * if cached_code_obj_info: * # The cache is for new code objects, so, in this case it's already */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cache); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_code_obj_py) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_code_obj_py); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_cached_code_obj_info = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":285 * code_obj_py: object = <object> code_obj * cached_code_obj_info: object = _cache.get(code_obj_py) * if cached_code_obj_info: # <<<<<<<<<<<<<< * # The cache is for new code objects, so, in this case it's already * # using the new code and we can't change it as this is a generator! */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_cached_code_obj_info); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 285, __pyx_L1_error) if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":291 * # we may not want to go into tracing mode (as would usually happen * # when the new_code is None). * func_code_info.new_code = None # <<<<<<<<<<<<<< * breakpoint_found, thread_info.force_stay_in_untraced_mode = \ * cached_code_obj_info.compute_force_stay_in_untraced_mode(breakpoints) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_func_code_info->new_code); __Pyx_DECREF(__pyx_v_func_code_info->new_code); __pyx_v_func_code_info->new_code = Py_None; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":293 * func_code_info.new_code = None * breakpoint_found, thread_info.force_stay_in_untraced_mode = \ * cached_code_obj_info.compute_force_stay_in_untraced_mode(breakpoints) # <<<<<<<<<<<<<< * func_code_info.breakpoint_found = breakpoint_found * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_cached_code_obj_info, __pyx_n_s_compute_force_stay_in_untraced_m); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_breakpoints) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_breakpoints); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 292, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_14 = Py_TYPE(__pyx_t_9)->tp_iternext; index = 0; __pyx_t_1 = __pyx_t_14(__pyx_t_9); if (unlikely(!__pyx_t_1)) goto __pyx_L27_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_4 = __pyx_t_14(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L27_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_9), 2) < 0) __PYX_ERR(0, 292, __pyx_L1_error) __pyx_t_14 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L28_unpacking_done; __pyx_L27_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_14 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 292, __pyx_L1_error) __pyx_L28_unpacking_done:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":292 * # when the new_code is None). * func_code_info.new_code = None * breakpoint_found, thread_info.force_stay_in_untraced_mode = \ # <<<<<<<<<<<<<< * cached_code_obj_info.compute_force_stay_in_untraced_mode(breakpoints) * func_code_info.breakpoint_found = breakpoint_found */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_breakpoint_found = __pyx_t_1; __pyx_t_1 = 0; __pyx_v_thread_info->force_stay_in_untraced_mode = __pyx_t_3; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":294 * breakpoint_found, thread_info.force_stay_in_untraced_mode = \ * cached_code_obj_info.compute_force_stay_in_untraced_mode(breakpoints) * func_code_info.breakpoint_found = breakpoint_found # <<<<<<<<<<<<<< * * elif function_breakpoint: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_breakpoint_found); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 294, __pyx_L1_error) __pyx_v_func_code_info->breakpoint_found = __pyx_t_3; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":285 * code_obj_py: object = <object> code_obj * cached_code_obj_info: object = _cache.get(code_obj_py) * if cached_code_obj_info: # <<<<<<<<<<<<<< * # The cache is for new code objects, so, in this case it's already * # using the new code and we can't change it as this is a generator! */ goto __pyx_L26; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":296 * func_code_info.breakpoint_found = breakpoint_found * * elif function_breakpoint: # <<<<<<<<<<<<<< * # Go directly into tracing mode * func_code_info.breakpoint_found = True */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_function_breakpoint); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 296, __pyx_L1_error) if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":298 * elif function_breakpoint: * # Go directly into tracing mode * func_code_info.breakpoint_found = True # <<<<<<<<<<<<<< * func_code_info.new_code = None * */ __pyx_v_func_code_info->breakpoint_found = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":299 * # Go directly into tracing mode * func_code_info.breakpoint_found = True * func_code_info.new_code = None # <<<<<<<<<<<<<< * * elif breakpoints: */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_func_code_info->new_code); __Pyx_DECREF(__pyx_v_func_code_info->new_code); __pyx_v_func_code_info->new_code = Py_None; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":296 * func_code_info.breakpoint_found = breakpoint_found * * elif function_breakpoint: # <<<<<<<<<<<<<< * # Go directly into tracing mode * func_code_info.breakpoint_found = True */ goto __pyx_L26; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":301 * func_code_info.new_code = None * * elif breakpoints: # <<<<<<<<<<<<<< * # if DEBUG: * # print('found breakpoints', code_obj_py.co_name, breakpoints) */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_breakpoints); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 301, __pyx_L1_error) if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":307 * # Note: new_code can be None if unable to generate. * # It should automatically put the new code object in the cache. * breakpoint_found, func_code_info.new_code = generate_code_with_breakpoints(code_obj_py, breakpoints) # <<<<<<<<<<<<<< * func_code_info.breakpoint_found = breakpoint_found * */ __pyx_t_2 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_generate_code_with_breakpoints(__pyx_v_code_obj_py, __pyx_v_breakpoints); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 307, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_14 = Py_TYPE(__pyx_t_9)->tp_iternext; index = 0; __pyx_t_4 = __pyx_t_14(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L29_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_1 = __pyx_t_14(__pyx_t_9); if (unlikely(!__pyx_t_1)) goto __pyx_L29_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_9), 2) < 0) __PYX_ERR(0, 307, __pyx_L1_error) __pyx_t_14 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L30_unpacking_done; __pyx_L29_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_14 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 307, __pyx_L1_error) __pyx_L30_unpacking_done:; } __pyx_v_breakpoint_found = __pyx_t_4; __pyx_t_4 = 0; __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_func_code_info->new_code); __Pyx_DECREF(__pyx_v_func_code_info->new_code); __pyx_v_func_code_info->new_code = __pyx_t_1; __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":308 * # It should automatically put the new code object in the cache. * breakpoint_found, func_code_info.new_code = generate_code_with_breakpoints(code_obj_py, breakpoints) * func_code_info.breakpoint_found = breakpoint_found # <<<<<<<<<<<<<< * * Py_INCREF(func_code_info) */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_breakpoint_found); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L1_error) __pyx_v_func_code_info->breakpoint_found = __pyx_t_3; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":301 * func_code_info.new_code = None * * elif breakpoints: # <<<<<<<<<<<<<< * # if DEBUG: * # print('found breakpoints', code_obj_py.co_name, breakpoints) */ } __pyx_L26:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":275 * * if not func_code_info.always_skip_code: * if main_debugger is not None: # <<<<<<<<<<<<<< * * breakpoints: dict = main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":274 * func_code_info.always_skip_code = True * * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * if main_debugger is not None: * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":310 * func_code_info.breakpoint_found = breakpoint_found * * Py_INCREF(func_code_info) # <<<<<<<<<<<<<< * _PyCode_SetExtra(<PyObject *> code_obj, _code_extra_index, <PyObject *> func_code_info) * */ Py_INCREF(((PyObject *)__pyx_v_func_code_info)); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":311 * * Py_INCREF(func_code_info) * _PyCode_SetExtra(<PyObject *> code_obj, _code_extra_index, <PyObject *> func_code_info) # <<<<<<<<<<<<<< * * return func_code_info */ (void)(_PyCode_SetExtra(((PyObject *)__pyx_v_code_obj), __pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator__code_extra_index, ((PyObject *)__pyx_v_func_code_info))); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":313 * _PyCode_SetExtra(<PyObject *> code_obj, _code_extra_index, <PyObject *> func_code_info) * * return func_code_info # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_func_code_info)); __pyx_r = __pyx_v_func_code_info; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":212 * cdef int _code_extra_index = -1 * * cdef FuncCodeInfo get_func_code_info(ThreadInfo thread_info, PyFrameObject * frame_obj, PyCodeObject * code_obj): # <<<<<<<<<<<<<< * ''' * Provides code-object related info. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_func_code_info", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_main_debugger); __Pyx_XDECREF((PyObject *)__pyx_v_func_code_info_obj); __Pyx_XDECREF(__pyx_v_co_filename); __Pyx_XDECREF(__pyx_v_co_name); __Pyx_XDECREF(__pyx_v_cache_file_type); __Pyx_XDECREF(__pyx_v_cache_file_type_key); __Pyx_XDECREF((PyObject *)__pyx_v_func_code_info); __Pyx_XDECREF(__pyx_v_abs_path_real_path_and_base); __Pyx_XDECREF(__pyx_v_file_type); __Pyx_XDECREF(__pyx_v_breakpoints); __Pyx_XDECREF(__pyx_v_function_breakpoint); __Pyx_XDECREF(__pyx_v_code_obj_py); __Pyx_XDECREF(__pyx_v_cached_code_obj_info); __Pyx_XDECREF(__pyx_v_breakpoint_found); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":322 * cdef public int last_line * * def __init__(self, dict line_to_offset, int first_line, int last_line): # <<<<<<<<<<<<<< * self.line_to_offset = line_to_offset * self.first_line = first_line */ /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_line_to_offset = 0; int __pyx_v_first_line; int __pyx_v_last_line; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_line_to_offset,&__pyx_n_s_first_line,&__pyx_n_s_last_line,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_line_to_offset)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_first_line)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 322, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_last_line)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 322, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 322, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_line_to_offset = ((PyObject*)values[0]); __pyx_v_first_line = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_first_line == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 322, __pyx_L3_error) __pyx_v_last_line = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_last_line == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 322, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 322, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_line_to_offset), (&PyDict_Type), 1, "line_to_offset", 1))) __PYX_ERR(0, 322, __pyx_L1_error) __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo___init__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self), __pyx_v_line_to_offset, __pyx_v_first_line, __pyx_v_last_line); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo___init__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_line_to_offset, int __pyx_v_first_line, int __pyx_v_last_line) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":323 * * def __init__(self, dict line_to_offset, int first_line, int last_line): * self.line_to_offset = line_to_offset # <<<<<<<<<<<<<< * self.first_line = first_line * self.last_line = last_line */ __Pyx_INCREF(__pyx_v_line_to_offset); __Pyx_GIVEREF(__pyx_v_line_to_offset); __Pyx_GOTREF(__pyx_v_self->line_to_offset); __Pyx_DECREF(__pyx_v_self->line_to_offset); __pyx_v_self->line_to_offset = __pyx_v_line_to_offset; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":324 * def __init__(self, dict line_to_offset, int first_line, int last_line): * self.line_to_offset = line_to_offset * self.first_line = first_line # <<<<<<<<<<<<<< * self.last_line = last_line * */ __pyx_v_self->first_line = __pyx_v_first_line; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":325 * self.line_to_offset = line_to_offset * self.first_line = first_line * self.last_line = last_line # <<<<<<<<<<<<<< * * */ __pyx_v_self->last_line = __pyx_v_last_line; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":322 * cdef public int last_line * * def __init__(self, dict line_to_offset, int first_line, int last_line): # <<<<<<<<<<<<<< * self.line_to_offset = line_to_offset * self.first_line = first_line */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":318 * cdef class _CodeLineInfo: * * cdef public dict line_to_offset # <<<<<<<<<<<<<< * cdef public int first_line * cdef public int last_line */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->line_to_offset); __pyx_r = __pyx_v_self->line_to_offset; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 318, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->line_to_offset); __Pyx_DECREF(__pyx_v_self->line_to_offset); __pyx_v_self->line_to_offset = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.line_to_offset.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->line_to_offset); __Pyx_DECREF(__pyx_v_self->line_to_offset); __pyx_v_self->line_to_offset = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":319 * * cdef public dict line_to_offset * cdef public int first_line # <<<<<<<<<<<<<< * cdef public int last_line * */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->first_line); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.first_line.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 319, __pyx_L1_error) __pyx_v_self->first_line = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.first_line.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":320 * cdef public dict line_to_offset * cdef public int first_line * cdef public int last_line # <<<<<<<<<<<<<< * * def __init__(self, dict line_to_offset, int first_line, int last_line): */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->last_line); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.last_line.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 320, __pyx_L1_error) __pyx_v_self->last_line = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.last_line.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_2__reduce_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_2__reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.first_line, self.last_line, self.line_to_offset) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None: */ __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->first_line); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->last_line); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_INCREF(__pyx_v_self->line_to_offset); __Pyx_GIVEREF(__pyx_v_self->line_to_offset); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self->line_to_offset); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_v_state = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.first_line, self.last_line, self.line_to_offset) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None: * state += (_dict,) */ __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v__dict = __pyx_t_3; __pyx_t_3 = 0; /* "(tree fragment)":7 * state = (self.first_line, self.last_line, self.line_to_offset) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_4 = (__pyx_v__dict != Py_None); __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict); __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "(tree fragment)":9 * if _dict is not None: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = self.line_to_offset is not None */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.first_line, self.last_line, self.line_to_offset) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = self.line_to_offset is not None # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, None), state */ /*else*/ { __pyx_t_5 = (__pyx_v_self->line_to_offset != ((PyObject*)Py_None)); __pyx_v_use_setstate = __pyx_t_5; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = self.line_to_offset is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, None), state * else: */ __pyx_t_5 = (__pyx_v_use_setstate != 0); if (__pyx_t_5) { /* "(tree fragment)":13 * use_setstate = self.line_to_offset is not None * if use_setstate: * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle__CodeLineInfo); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_66829570); __Pyx_GIVEREF(__pyx_int_66829570); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_66829570); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = self.line_to_offset is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, None), state * else: * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle__CodeLineInfo__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle__CodeLineInfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_66829570); __Pyx_GIVEREF(__pyx_int_66829570); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_66829570); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle__CodeLineInfo__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_4__setstate_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_4__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle__CodeLineInfo__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error) __pyx_t_1 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CodeLineInfo__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle__CodeLineInfo, (type(self), 0x3fbbd02, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle__CodeLineInfo__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":329 * * # Note: this method has a version in pure-python too. * def _get_code_line_info(code_obj): # <<<<<<<<<<<<<< * line_to_offset: dict = {} * first_line: int = None */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_get_code_line_info(PyObject *__pyx_self, PyObject *__pyx_v_code_obj); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_get_code_line_info = {"_get_code_line_info", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_get_code_line_info, METH_O, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_get_code_line_info(PyObject *__pyx_self, PyObject *__pyx_v_code_obj) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_get_code_line_info (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10_get_code_line_info(__pyx_self, ((PyObject *)__pyx_v_code_obj)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_10_get_code_line_info(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code_obj) { PyObject *__pyx_v_line_to_offset = 0; PyObject *__pyx_v_first_line = 0; PyObject *__pyx_v_last_line = 0; int __pyx_v_offset; int __pyx_v_line; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_get_code_line_info", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":330 * # Note: this method has a version in pure-python too. * def _get_code_line_info(code_obj): * line_to_offset: dict = {} # <<<<<<<<<<<<<< * first_line: int = None * last_line: int = None */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_line_to_offset = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":331 * def _get_code_line_info(code_obj): * line_to_offset: dict = {} * first_line: int = None # <<<<<<<<<<<<<< * last_line: int = None * */ __Pyx_INCREF(Py_None); __pyx_v_first_line = Py_None; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":332 * line_to_offset: dict = {} * first_line: int = None * last_line: int = None # <<<<<<<<<<<<<< * * cdef int offset */ __Pyx_INCREF(Py_None); __pyx_v_last_line = Py_None; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":337 * cdef int line * * for offset, line in dis.findlinestarts(code_obj): # <<<<<<<<<<<<<< * line_to_offset[line] = offset * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_dis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_findlinestarts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_code_obj) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_code_obj); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 337, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 337, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 337, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 337, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 337, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 337, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 337, __pyx_L1_error) __pyx_L6_unpacking_done:; } __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_offset = __pyx_t_9; __pyx_v_line = __pyx_t_10; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":338 * * for offset, line in dis.findlinestarts(code_obj): * line_to_offset[line] = offset # <<<<<<<<<<<<<< * * if line_to_offset: */ __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_line); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(PyDict_SetItem(__pyx_v_line_to_offset, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":337 * cdef int line * * for offset, line in dis.findlinestarts(code_obj): # <<<<<<<<<<<<<< * line_to_offset[line] = offset * */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":340 * line_to_offset[line] = offset * * if line_to_offset: # <<<<<<<<<<<<<< * first_line = min(line_to_offset) * last_line = max(line_to_offset) */ __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_line_to_offset); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 340, __pyx_L1_error) if (__pyx_t_11) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":341 * * if line_to_offset: * first_line = min(line_to_offset) # <<<<<<<<<<<<<< * last_line = max(line_to_offset) * return _CodeLineInfo(line_to_offset, first_line, last_line) */ __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_line_to_offset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_first_line, __pyx_t_3); __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":342 * if line_to_offset: * first_line = min(line_to_offset) * last_line = max(line_to_offset) # <<<<<<<<<<<<<< * return _CodeLineInfo(line_to_offset, first_line, last_line) * */ __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_line_to_offset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_last_line, __pyx_t_3); __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":340 * line_to_offset[line] = offset * * if line_to_offset: # <<<<<<<<<<<<<< * first_line = min(line_to_offset) * last_line = max(line_to_offset) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":343 * first_line = min(line_to_offset) * last_line = max(line_to_offset) * return _CodeLineInfo(line_to_offset, first_line, last_line) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_line_to_offset); __Pyx_GIVEREF(__pyx_v_line_to_offset); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_line_to_offset); __Pyx_INCREF(__pyx_v_first_line); __Pyx_GIVEREF(__pyx_v_first_line); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_first_line); __Pyx_INCREF(__pyx_v_last_line); __Pyx_GIVEREF(__pyx_v_last_line); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_last_line); __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":329 * * # Note: this method has a version in pure-python too. * def _get_code_line_info(code_obj): # <<<<<<<<<<<<<< * line_to_offset: dict = {} * first_line: int = None */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._get_code_line_info", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_line_to_offset); __Pyx_XDECREF(__pyx_v_first_line); __Pyx_XDECREF(__pyx_v_last_line); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":353 * _cache: dict = {} * * def get_cached_code_obj_info_py(code_obj_py): # <<<<<<<<<<<<<< * ''' * :return _CacheValue: */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13get_cached_code_obj_info_py(PyObject *__pyx_self, PyObject *__pyx_v_code_obj_py); /*proto*/ static char __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_12get_cached_code_obj_info_py[] = "\n :return _CacheValue:\n :note: on cython use _cache.get(code_obj_py) directly.\n "; static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_13get_cached_code_obj_info_py = {"get_cached_code_obj_info_py", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13get_cached_code_obj_info_py, METH_O, __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_12get_cached_code_obj_info_py}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13get_cached_code_obj_info_py(PyObject *__pyx_self, PyObject *__pyx_v_code_obj_py) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_cached_code_obj_info_py (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12get_cached_code_obj_info_py(__pyx_self, ((PyObject *)__pyx_v_code_obj_py)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_12get_cached_code_obj_info_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code_obj_py) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_cached_code_obj_info_py", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":358 * :note: on cython use _cache.get(code_obj_py) directly. * ''' * return _cache.get(code_obj_py) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_cache); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_code_obj_py) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_code_obj_py); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":353 * _cache: dict = {} * * def get_cached_code_obj_info_py(code_obj_py): # <<<<<<<<<<<<<< * ''' * :return _CacheValue: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_cached_code_obj_info_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":368 * cdef public set code_lines_as_set * * def __init__(self, object code_obj_py, _CodeLineInfo code_line_info, set breakpoints_hit_at_lines): # <<<<<<<<<<<<<< * ''' * :param code_obj_py: */ /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__[] = "\n :param code_obj_py:\n :param _CodeLineInfo code_line_info:\n :param set[int] breakpoints_hit_at_lines:\n "; #if CYTHON_UPDATE_DESCRIPTOR_DOC struct wrapperbase __pyx_wrapperbase_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__; #endif static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_code_obj_py = 0; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_code_line_info = 0; PyObject *__pyx_v_breakpoints_hit_at_lines = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_code_obj_py,&__pyx_n_s_code_line_info,&__pyx_n_s_breakpoints_hit_at_lines,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_code_obj_py)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_code_line_info)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 368, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_breakpoints_hit_at_lines)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 368, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 368, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_code_obj_py = values[0]; __pyx_v_code_line_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)values[1]); __pyx_v_breakpoints_hit_at_lines = ((PyObject*)values[2]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 368, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_code_line_info), __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo, 1, "code_line_info", 0))) __PYX_ERR(0, 368, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_breakpoints_hit_at_lines), (&PySet_Type), 1, "breakpoints_hit_at_lines", 1))) __PYX_ERR(0, 368, __pyx_L1_error) __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self), __pyx_v_code_obj_py, __pyx_v_code_line_info, __pyx_v_breakpoints_hit_at_lines); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_code_obj_py, struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v_code_line_info, PyObject *__pyx_v_breakpoints_hit_at_lines) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":374 * :param set[int] breakpoints_hit_at_lines: * ''' * self.code_obj_py = code_obj_py # <<<<<<<<<<<<<< * self.code_line_info = code_line_info * self.breakpoints_hit_at_lines = breakpoints_hit_at_lines */ __Pyx_INCREF(__pyx_v_code_obj_py); __Pyx_GIVEREF(__pyx_v_code_obj_py); __Pyx_GOTREF(__pyx_v_self->code_obj_py); __Pyx_DECREF(__pyx_v_self->code_obj_py); __pyx_v_self->code_obj_py = __pyx_v_code_obj_py; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":375 * ''' * self.code_obj_py = code_obj_py * self.code_line_info = code_line_info # <<<<<<<<<<<<<< * self.breakpoints_hit_at_lines = breakpoints_hit_at_lines * self.code_lines_as_set = set(code_line_info.line_to_offset) */ __Pyx_INCREF(((PyObject *)__pyx_v_code_line_info)); __Pyx_GIVEREF(((PyObject *)__pyx_v_code_line_info)); __Pyx_GOTREF(__pyx_v_self->code_line_info); __Pyx_DECREF(((PyObject *)__pyx_v_self->code_line_info)); __pyx_v_self->code_line_info = __pyx_v_code_line_info; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":376 * self.code_obj_py = code_obj_py * self.code_line_info = code_line_info * self.breakpoints_hit_at_lines = breakpoints_hit_at_lines # <<<<<<<<<<<<<< * self.code_lines_as_set = set(code_line_info.line_to_offset) * */ __Pyx_INCREF(__pyx_v_breakpoints_hit_at_lines); __Pyx_GIVEREF(__pyx_v_breakpoints_hit_at_lines); __Pyx_GOTREF(__pyx_v_self->breakpoints_hit_at_lines); __Pyx_DECREF(__pyx_v_self->breakpoints_hit_at_lines); __pyx_v_self->breakpoints_hit_at_lines = __pyx_v_breakpoints_hit_at_lines; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":377 * self.code_line_info = code_line_info * self.breakpoints_hit_at_lines = breakpoints_hit_at_lines * self.code_lines_as_set = set(code_line_info.line_to_offset) # <<<<<<<<<<<<<< * * cpdef compute_force_stay_in_untraced_mode(self, breakpoints): */ __pyx_t_1 = PySet_New(__pyx_v_code_line_info->line_to_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->code_lines_as_set); __Pyx_DECREF(__pyx_v_self->code_lines_as_set); __pyx_v_self->code_lines_as_set = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":368 * cdef public set code_lines_as_set * * def __init__(self, object code_obj_py, _CodeLineInfo code_line_info, set breakpoints_hit_at_lines): # <<<<<<<<<<<<<< * ''' * :param code_obj_py: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":379 * self.code_lines_as_set = set(code_line_info.line_to_offset) * * cpdef compute_force_stay_in_untraced_mode(self, breakpoints): # <<<<<<<<<<<<<< * ''' * :param breakpoints: */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_3compute_force_stay_in_untraced_mode(PyObject *__pyx_v_self, PyObject *__pyx_v_breakpoints); /*proto*/ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_compute_force_stay_in_untraced_mode(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_breakpoints, int __pyx_skip_dispatch) { int __pyx_v_force_stay_in_untraced_mode; int __pyx_v_breakpoint_found; PyObject *__pyx_v_target_breakpoints = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("compute_force_stay_in_untraced_mode", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_compute_force_stay_in_untraced_m); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_3compute_force_stay_in_untraced_mode)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_breakpoints) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_breakpoints); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":389 * cdef set target_breakpoints * * force_stay_in_untraced_mode = False # <<<<<<<<<<<<<< * * target_breakpoints = self.code_lines_as_set.intersection(breakpoints) */ __pyx_v_force_stay_in_untraced_mode = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":391 * force_stay_in_untraced_mode = False * * target_breakpoints = self.code_lines_as_set.intersection(breakpoints) # <<<<<<<<<<<<<< * breakpoint_found = bool(target_breakpoints) * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->code_lines_as_set, __pyx_n_s_intersection); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_breakpoints) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_breakpoints); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(PySet_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 391, __pyx_L1_error) __pyx_v_target_breakpoints = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":392 * * target_breakpoints = self.code_lines_as_set.intersection(breakpoints) * breakpoint_found = bool(target_breakpoints) # <<<<<<<<<<<<<< * * if not breakpoint_found: */ __pyx_t_5 = (__pyx_v_target_breakpoints != Py_None)&&(PySet_GET_SIZE(__pyx_v_target_breakpoints) != 0); __pyx_v_breakpoint_found = (!(!__pyx_t_5)); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":394 * breakpoint_found = bool(target_breakpoints) * * if not breakpoint_found: # <<<<<<<<<<<<<< * force_stay_in_untraced_mode = True * else: */ __pyx_t_5 = ((!(__pyx_v_breakpoint_found != 0)) != 0); if (__pyx_t_5) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":395 * * if not breakpoint_found: * force_stay_in_untraced_mode = True # <<<<<<<<<<<<<< * else: * force_stay_in_untraced_mode = self.breakpoints_hit_at_lines.issuperset(set(breakpoints)) */ __pyx_v_force_stay_in_untraced_mode = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":394 * breakpoint_found = bool(target_breakpoints) * * if not breakpoint_found: # <<<<<<<<<<<<<< * force_stay_in_untraced_mode = True * else: */ goto __pyx_L3; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":397 * force_stay_in_untraced_mode = True * else: * force_stay_in_untraced_mode = self.breakpoints_hit_at_lines.issuperset(set(breakpoints)) # <<<<<<<<<<<<<< * * return breakpoint_found, force_stay_in_untraced_mode */ /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->breakpoints_hit_at_lines, __pyx_n_s_issuperset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySet_New(__pyx_v_breakpoints); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_force_stay_in_untraced_mode = __pyx_t_5; } __pyx_L3:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":399 * force_stay_in_untraced_mode = self.breakpoints_hit_at_lines.issuperset(set(breakpoints)) * * return breakpoint_found, force_stay_in_untraced_mode # <<<<<<<<<<<<<< * * def generate_code_with_breakpoints_py(object code_obj_py, dict breakpoints): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_breakpoint_found); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_force_stay_in_untraced_mode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":379 * self.code_lines_as_set = set(code_line_info.line_to_offset) * * cpdef compute_force_stay_in_untraced_mode(self, breakpoints): # <<<<<<<<<<<<<< * ''' * :param breakpoints: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.compute_force_stay_in_untraced_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_target_breakpoints); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_3compute_force_stay_in_untraced_mode(PyObject *__pyx_v_self, PyObject *__pyx_v_breakpoints); /*proto*/ static char __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_2compute_force_stay_in_untraced_mode[] = "\n :param breakpoints:\n set(breakpoint_lines) or dict(breakpoint_line->breakpoint info)\n :return tuple(breakpoint_found, force_stay_in_untraced_mode)\n "; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_3compute_force_stay_in_untraced_mode(PyObject *__pyx_v_self, PyObject *__pyx_v_breakpoints) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("compute_force_stay_in_untraced_mode (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_2compute_force_stay_in_untraced_mode(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self), ((PyObject *)__pyx_v_breakpoints)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_2compute_force_stay_in_untraced_mode(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_breakpoints) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("compute_force_stay_in_untraced_mode", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_compute_force_stay_in_untraced_mode(__pyx_v_self, __pyx_v_breakpoints, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.compute_force_stay_in_untraced_mode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":363 * cdef class _CacheValue(object): * * cdef public object code_obj_py # <<<<<<<<<<<<<< * cdef public _CodeLineInfo code_line_info * cdef public set breakpoints_hit_at_lines */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->code_obj_py); __pyx_r = __pyx_v_self->code_obj_py; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->code_obj_py); __Pyx_DECREF(__pyx_v_self->code_obj_py); __pyx_v_self->code_obj_py = __pyx_v_value; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->code_obj_py); __Pyx_DECREF(__pyx_v_self->code_obj_py); __pyx_v_self->code_obj_py = Py_None; /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":364 * * cdef public object code_obj_py * cdef public _CodeLineInfo code_line_info # <<<<<<<<<<<<<< * cdef public set breakpoints_hit_at_lines * cdef public set code_lines_as_set */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->code_line_info)); __pyx_r = ((PyObject *)__pyx_v_self->code_line_info); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo))))) __PYX_ERR(0, 364, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->code_line_info); __Pyx_DECREF(((PyObject *)__pyx_v_self->code_line_info)); __pyx_v_self->code_line_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.code_line_info.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->code_line_info); __Pyx_DECREF(((PyObject *)__pyx_v_self->code_line_info)); __pyx_v_self->code_line_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":365 * cdef public object code_obj_py * cdef public _CodeLineInfo code_line_info * cdef public set breakpoints_hit_at_lines # <<<<<<<<<<<<<< * cdef public set code_lines_as_set * */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->breakpoints_hit_at_lines); __pyx_r = __pyx_v_self->breakpoints_hit_at_lines; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PySet_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 365, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->breakpoints_hit_at_lines); __Pyx_DECREF(__pyx_v_self->breakpoints_hit_at_lines); __pyx_v_self->breakpoints_hit_at_lines = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.breakpoints_hit_at_lines.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->breakpoints_hit_at_lines); __Pyx_DECREF(__pyx_v_self->breakpoints_hit_at_lines); __pyx_v_self->breakpoints_hit_at_lines = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":366 * cdef public _CodeLineInfo code_line_info * cdef public set breakpoints_hit_at_lines * cdef public set code_lines_as_set # <<<<<<<<<<<<<< * * def __init__(self, object code_obj_py, _CodeLineInfo code_line_info, set breakpoints_hit_at_lines): */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set___get__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set___get__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->code_lines_as_set); __pyx_r = __pyx_v_self->code_lines_as_set; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_2__set__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_2__set__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(PySet_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 366, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->code_lines_as_set); __Pyx_DECREF(__pyx_v_self->code_lines_as_set); __pyx_v_self->code_lines_as_set = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.code_lines_as_set.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_4__del__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_4__del__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->code_lines_as_set); __Pyx_DECREF(__pyx_v_self->code_lines_as_set); __pyx_v_self->code_lines_as_set = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_4__reduce_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_4__reduce_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.breakpoints_hit_at_lines, self.code_line_info, self.code_lines_as_set, self.code_obj_py) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None: */ __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_self->breakpoints_hit_at_lines); __Pyx_GIVEREF(__pyx_v_self->breakpoints_hit_at_lines); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->breakpoints_hit_at_lines); __Pyx_INCREF(((PyObject *)__pyx_v_self->code_line_info)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->code_line_info)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self->code_line_info)); __Pyx_INCREF(__pyx_v_self->code_lines_as_set); __Pyx_GIVEREF(__pyx_v_self->code_lines_as_set); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_self->code_lines_as_set); __Pyx_INCREF(__pyx_v_self->code_obj_py); __Pyx_GIVEREF(__pyx_v_self->code_obj_py); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_self->code_obj_py); __pyx_v_state = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.breakpoints_hit_at_lines, self.code_line_info, self.code_lines_as_set, self.code_obj_py) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None: * state += (_dict,) */ __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v__dict = __pyx_t_1; __pyx_t_1 = 0; /* "(tree fragment)":7 * state = (self.breakpoints_hit_at_lines, self.code_line_info, self.code_lines_as_set, self.code_obj_py) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_2 = (__pyx_v__dict != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict); __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "(tree fragment)":9 * if _dict is not None: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = self.breakpoints_hit_at_lines is not None or self.code_line_info is not None or self.code_lines_as_set is not None or self.code_obj_py is not None */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.breakpoints_hit_at_lines, self.code_line_info, self.code_lines_as_set, self.code_obj_py) * _dict = getattr(self, '__dict__', None) * if _dict is not None: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = self.breakpoints_hit_at_lines is not None or self.code_line_info is not None or self.code_lines_as_set is not None or self.code_obj_py is not None # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, None), state */ /*else*/ { __pyx_t_2 = (__pyx_v_self->breakpoints_hit_at_lines != ((PyObject*)Py_None)); __pyx_t_5 = (__pyx_t_2 != 0); if (!__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = (((PyObject *)__pyx_v_self->code_line_info) != Py_None); __pyx_t_2 = (__pyx_t_5 != 0); if (!__pyx_t_2) { } else { __pyx_t_3 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_self->code_lines_as_set != ((PyObject*)Py_None)); __pyx_t_5 = (__pyx_t_2 != 0); if (!__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = (__pyx_v_self->code_obj_py != Py_None); __pyx_t_2 = (__pyx_t_5 != 0); __pyx_t_3 = __pyx_t_2; __pyx_L4_bool_binop_done:; __pyx_v_use_setstate = __pyx_t_3; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = self.breakpoints_hit_at_lines is not None or self.code_line_info is not None or self.code_lines_as_set is not None or self.code_obj_py is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, None), state * else: */ __pyx_t_3 = (__pyx_v_use_setstate != 0); if (__pyx_t_3) { /* "(tree fragment)":13 * use_setstate = self.breakpoints_hit_at_lines is not None or self.code_line_info is not None or self.code_lines_as_set is not None or self.code_obj_py is not None * if use_setstate: * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle__CacheValue); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_64258489); __Pyx_GIVEREF(__pyx_int_64258489); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_64258489); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None); __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state); __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = self.breakpoints_hit_at_lines is not None or self.code_line_info is not None or self.code_lines_as_set is not None or self.code_obj_py is not None * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, None), state * else: * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle__CacheValue__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle__CacheValue); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_INCREF(__pyx_int_64258489); __Pyx_GIVEREF(__pyx_int_64258489); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_64258489); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); __pyx_t_6 = 0; __pyx_t_1 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle__CacheValue__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_6__setstate_cython__(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_6__setstate_cython__(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle__CacheValue__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error) __pyx_t_1 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CacheValue__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle__CacheValue, (type(self), 0x3d481b9, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle__CacheValue__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":401 * return breakpoint_found, force_stay_in_untraced_mode * * def generate_code_with_breakpoints_py(object code_obj_py, dict breakpoints): # <<<<<<<<<<<<<< * return generate_code_with_breakpoints(code_obj_py, breakpoints) * */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_15generate_code_with_breakpoints_py(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_15generate_code_with_breakpoints_py = {"generate_code_with_breakpoints_py", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_15generate_code_with_breakpoints_py, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_15generate_code_with_breakpoints_py(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_code_obj_py = 0; PyObject *__pyx_v_breakpoints = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("generate_code_with_breakpoints_py (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_code_obj_py,&__pyx_n_s_breakpoints,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_code_obj_py)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_breakpoints)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("generate_code_with_breakpoints_py", 1, 2, 2, 1); __PYX_ERR(0, 401, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "generate_code_with_breakpoints_py") < 0)) __PYX_ERR(0, 401, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_code_obj_py = values[0]; __pyx_v_breakpoints = ((PyObject*)values[1]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("generate_code_with_breakpoints_py", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 401, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.generate_code_with_breakpoints_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_breakpoints), (&PyDict_Type), 1, "breakpoints", 1))) __PYX_ERR(0, 401, __pyx_L1_error) __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_14generate_code_with_breakpoints_py(__pyx_self, __pyx_v_code_obj_py, __pyx_v_breakpoints); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_14generate_code_with_breakpoints_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code_obj_py, PyObject *__pyx_v_breakpoints) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("generate_code_with_breakpoints_py", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":402 * * def generate_code_with_breakpoints_py(object code_obj_py, dict breakpoints): * return generate_code_with_breakpoints(code_obj_py, breakpoints) # <<<<<<<<<<<<<< * * # DEBUG = True */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_generate_code_with_breakpoints(__pyx_v_code_obj_py, __pyx_v_breakpoints); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":401 * return breakpoint_found, force_stay_in_untraced_mode * * def generate_code_with_breakpoints_py(object code_obj_py, dict breakpoints): # <<<<<<<<<<<<<< * return generate_code_with_breakpoints(code_obj_py, breakpoints) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.generate_code_with_breakpoints_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":407 * # debug_helper = DebugHelper() * * cdef generate_code_with_breakpoints(object code_obj_py, dict breakpoints): # <<<<<<<<<<<<<< * ''' * :param breakpoints: */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_generate_code_with_breakpoints(PyObject *__pyx_v_code_obj_py, PyObject *__pyx_v_breakpoints) { int __pyx_v_success; int __pyx_v_breakpoint_line; int __pyx_v_breakpoint_found; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v_cache_value = 0; PyObject *__pyx_v_breakpoints_hit_at_lines = 0; PyObject *__pyx_v_line_to_offset = 0; PyObject *__pyx_v_code_line_info = NULL; PyObject *__pyx_v_new_code = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; Py_ssize_t __pyx_t_5; Py_ssize_t __pyx_t_6; int __pyx_t_7; int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; PyObject *__pyx_t_11 = NULL; PyObject *(*__pyx_t_12)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("generate_code_with_breakpoints", 0); __Pyx_INCREF(__pyx_v_code_obj_py); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":424 * cdef dict line_to_offset * * assert code_obj_py not in _cache, 'If a code object is cached, that same code object must be reused.' # <<<<<<<<<<<<<< * * # if DEBUG: */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cache); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_code_obj_py, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 424, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_If_a_code_object_is_cached_that); __PYX_ERR(0, 424, __pyx_L1_error) } } #endif /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":429 * # initial_code_obj_py = code_obj_py * * code_line_info = _get_code_line_info(code_obj_py) # <<<<<<<<<<<<<< * * success = True */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_code_line_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_code_obj_py) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_code_obj_py); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_code_line_info = __pyx_t_1; __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":431 * code_line_info = _get_code_line_info(code_obj_py) * * success = True # <<<<<<<<<<<<<< * * breakpoints_hit_at_lines = set() */ __pyx_v_success = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":433 * success = True * * breakpoints_hit_at_lines = set() # <<<<<<<<<<<<<< * line_to_offset = code_line_info.line_to_offset * */ __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_breakpoints_hit_at_lines = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":434 * * breakpoints_hit_at_lines = set() * line_to_offset = code_line_info.line_to_offset # <<<<<<<<<<<<<< * * for breakpoint_line in breakpoints: */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_code_line_info, __pyx_n_s_line_to_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 434, __pyx_L1_error) __pyx_v_line_to_offset = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":436 * line_to_offset = code_line_info.line_to_offset * * for breakpoint_line in breakpoints: # <<<<<<<<<<<<<< * if breakpoint_line in line_to_offset: * breakpoints_hit_at_lines.add(breakpoint_line) */ __pyx_t_5 = 0; if (unlikely(__pyx_v_breakpoints == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 436, __pyx_L1_error) } __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_breakpoints, 1, ((PyObject *)NULL), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; while (1) { __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_6, &__pyx_t_5, &__pyx_t_3, NULL, NULL, __pyx_t_7); if (unlikely(__pyx_t_8 == 0)) break; if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_breakpoint_line = __pyx_t_8; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":437 * * for breakpoint_line in breakpoints: * if breakpoint_line in line_to_offset: # <<<<<<<<<<<<<< * breakpoints_hit_at_lines.add(breakpoint_line) * */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_breakpoint_line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(__pyx_v_line_to_offset == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 437, __pyx_L1_error) } __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_t_3, __pyx_v_line_to_offset, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = (__pyx_t_2 != 0); if (__pyx_t_9) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":438 * for breakpoint_line in breakpoints: * if breakpoint_line in line_to_offset: * breakpoints_hit_at_lines.add(breakpoint_line) # <<<<<<<<<<<<<< * * if breakpoints_hit_at_lines: */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_breakpoint_line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = PySet_Add(__pyx_v_breakpoints_hit_at_lines, __pyx_t_3); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":437 * * for breakpoint_line in breakpoints: * if breakpoint_line in line_to_offset: # <<<<<<<<<<<<<< * breakpoints_hit_at_lines.add(breakpoint_line) * */ } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":440 * breakpoints_hit_at_lines.add(breakpoint_line) * * if breakpoints_hit_at_lines: # <<<<<<<<<<<<<< * success, new_code = insert_pydevd_breaks( * code_obj_py, */ __pyx_t_9 = (PySet_GET_SIZE(__pyx_v_breakpoints_hit_at_lines) != 0); if (__pyx_t_9) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":441 * * if breakpoints_hit_at_lines: * success, new_code = insert_pydevd_breaks( # <<<<<<<<<<<<<< * code_obj_py, * breakpoints_hit_at_lines, */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_insert_pydevd_breaks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":444 * code_obj_py, * breakpoints_hit_at_lines, * code_line_info # <<<<<<<<<<<<<< * ) * */ __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_code_obj_py, __pyx_v_breakpoints_hit_at_lines, __pyx_v_code_line_info}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_code_obj_py, __pyx_v_breakpoints_hit_at_lines, __pyx_v_code_line_info}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_11 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_code_obj_py); __Pyx_GIVEREF(__pyx_v_code_obj_py); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_7, __pyx_v_code_obj_py); __Pyx_INCREF(__pyx_v_breakpoints_hit_at_lines); __Pyx_GIVEREF(__pyx_v_breakpoints_hit_at_lines); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_7, __pyx_v_breakpoints_hit_at_lines); __Pyx_INCREF(__pyx_v_code_line_info); __Pyx_GIVEREF(__pyx_v_code_line_info); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_7, __pyx_v_code_line_info); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 441, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_11 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_11 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_11)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_11); if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_4), 2) < 0) __PYX_ERR(0, 441, __pyx_L1_error) __pyx_t_12 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 441, __pyx_L1_error) __pyx_L8_unpacking_done:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":441 * * if breakpoints_hit_at_lines: * success, new_code = insert_pydevd_breaks( # <<<<<<<<<<<<<< * code_obj_py, * breakpoints_hit_at_lines, */ __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_success = __pyx_t_9; __pyx_v_new_code = __pyx_t_11; __pyx_t_11 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":447 * ) * * if not success: # <<<<<<<<<<<<<< * code_obj_py = None * else: */ __pyx_t_9 = ((!(__pyx_v_success != 0)) != 0); if (__pyx_t_9) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":448 * * if not success: * code_obj_py = None # <<<<<<<<<<<<<< * else: * code_obj_py = new_code */ __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_code_obj_py, Py_None); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":447 * ) * * if not success: # <<<<<<<<<<<<<< * code_obj_py = None * else: */ goto __pyx_L9; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":450 * code_obj_py = None * else: * code_obj_py = new_code # <<<<<<<<<<<<<< * * breakpoint_found = bool(breakpoints_hit_at_lines) */ /*else*/ { __Pyx_INCREF(__pyx_v_new_code); __Pyx_DECREF_SET(__pyx_v_code_obj_py, __pyx_v_new_code); } __pyx_L9:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":440 * breakpoints_hit_at_lines.add(breakpoint_line) * * if breakpoints_hit_at_lines: # <<<<<<<<<<<<<< * success, new_code = insert_pydevd_breaks( * code_obj_py, */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":452 * code_obj_py = new_code * * breakpoint_found = bool(breakpoints_hit_at_lines) # <<<<<<<<<<<<<< * if breakpoint_found and success: * # if DEBUG: */ __pyx_t_9 = (PySet_GET_SIZE(__pyx_v_breakpoints_hit_at_lines) != 0); __pyx_v_breakpoint_found = (!(!__pyx_t_9)); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":453 * * breakpoint_found = bool(breakpoints_hit_at_lines) * if breakpoint_found and success: # <<<<<<<<<<<<<< * # if DEBUG: * # op_number = debug_helper.write_dis( */ __pyx_t_2 = (__pyx_v_breakpoint_found != 0); if (__pyx_t_2) { } else { __pyx_t_9 = __pyx_t_2; goto __pyx_L11_bool_binop_done; } __pyx_t_2 = (__pyx_v_success != 0); __pyx_t_9 = __pyx_t_2; __pyx_L11_bool_binop_done:; if (__pyx_t_9) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":466 * # ) * * cache_value = _CacheValue(code_obj_py, code_line_info, breakpoints_hit_at_lines) # <<<<<<<<<<<<<< * _cache[code_obj_py] = cache_value * */ __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_code_obj_py); __Pyx_GIVEREF(__pyx_v_code_obj_py); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_code_obj_py); __Pyx_INCREF(__pyx_v_code_line_info); __Pyx_GIVEREF(__pyx_v_code_line_info); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_code_line_info); __Pyx_INCREF(__pyx_v_breakpoints_hit_at_lines); __Pyx_GIVEREF(__pyx_v_breakpoints_hit_at_lines); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_breakpoints_hit_at_lines); __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue), __pyx_t_1, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_cache_value = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_t_11); __pyx_t_11 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":467 * * cache_value = _CacheValue(code_obj_py, code_line_info, breakpoints_hit_at_lines) * _cache[code_obj_py] = cache_value # <<<<<<<<<<<<<< * * return breakpoint_found, code_obj_py */ __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cache); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (unlikely(PyObject_SetItem(__pyx_t_11, __pyx_v_code_obj_py, ((PyObject *)__pyx_v_cache_value)) < 0)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":453 * * breakpoint_found = bool(breakpoints_hit_at_lines) * if breakpoint_found and success: # <<<<<<<<<<<<<< * # if DEBUG: * # op_number = debug_helper.write_dis( */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":469 * _cache[code_obj_py] = cache_value * * return breakpoint_found, code_obj_py # <<<<<<<<<<<<<< * * import sys */ __Pyx_XDECREF(__pyx_r); __pyx_t_11 = __Pyx_PyBool_FromLong(__pyx_v_breakpoint_found); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __Pyx_INCREF(__pyx_v_code_obj_py); __Pyx_GIVEREF(__pyx_v_code_obj_py); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_code_obj_py); __pyx_t_11 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":407 * # debug_helper = DebugHelper() * * cdef generate_code_with_breakpoints(object code_obj_py, dict breakpoints): # <<<<<<<<<<<<<< * ''' * :param breakpoints: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.generate_code_with_breakpoints", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_cache_value); __Pyx_XDECREF(__pyx_v_breakpoints_hit_at_lines); __Pyx_XDECREF(__pyx_v_line_to_offset); __Pyx_XDECREF(__pyx_v_code_line_info); __Pyx_XDECREF(__pyx_v_new_code); __Pyx_XDECREF(__pyx_v_code_obj_py); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":475 * cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * if IS_PY_39_OWNARDS: */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_17frame_eval_func(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_17frame_eval_func = {"frame_eval_func", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_17frame_eval_func, METH_NOARGS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_17frame_eval_func(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("frame_eval_func (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_16frame_eval_func(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_16frame_eval_func(CYTHON_UNUSED PyObject *__pyx_self) { PyThreadState *__pyx_v_state; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("frame_eval_func", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":476 * * def frame_eval_func(): * cdef PyThreadState *state = PyThreadState_Get() # <<<<<<<<<<<<<< * if IS_PY_39_OWNARDS: * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_39 */ __pyx_v_state = PyThreadState_Get(); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":477 * def frame_eval_func(): * cdef PyThreadState *state = PyThreadState_Get() * if IS_PY_39_OWNARDS: # <<<<<<<<<<<<<< * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_39 * else: */ __pyx_t_1 = (__pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator_IS_PY_39_OWNARDS != 0); if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":478 * cdef PyThreadState *state = PyThreadState_Get() * if IS_PY_39_OWNARDS: * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_39 # <<<<<<<<<<<<<< * else: * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_38 */ __pyx_v_state->interp->eval_frame = ((_PyFrameEvalFunction *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval_39); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":477 * def frame_eval_func(): * cdef PyThreadState *state = PyThreadState_Get() * if IS_PY_39_OWNARDS: # <<<<<<<<<<<<<< * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_39 * else: */ goto __pyx_L3; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":480 * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_39 * else: * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_38 # <<<<<<<<<<<<<< * dummy_tracing_holder.set_trace_func(dummy_trace_dispatch) * */ /*else*/ { __pyx_v_state->interp->eval_frame = ((_PyFrameEvalFunction *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval_38); } __pyx_L3:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":481 * else: * state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_38 * dummy_tracing_holder.set_trace_func(dummy_trace_dispatch) # <<<<<<<<<<<<<< * * */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_dummy_tracing_holder); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_set_trace_func); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_dummy_trace_dispatch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":475 * cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * if IS_PY_39_OWNARDS: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.frame_eval_func", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":484 * * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_19stop_frame_eval(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_19stop_frame_eval = {"stop_frame_eval", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_19stop_frame_eval, METH_NOARGS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_19stop_frame_eval(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop_frame_eval (wrapper)", 0); __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_18stop_frame_eval(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_18stop_frame_eval(CYTHON_UNUSED PyObject *__pyx_self) { PyThreadState *__pyx_v_state; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop_frame_eval", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":485 * * def stop_frame_eval(): * cdef PyThreadState *state = PyThreadState_Get() # <<<<<<<<<<<<<< * state.interp.eval_frame = _PyEval_EvalFrameDefault * */ __pyx_v_state = PyThreadState_Get(); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":486 * def stop_frame_eval(): * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault # <<<<<<<<<<<<<< * * # During the build we'll generate 2 versions of the code below so that we're compatible with */ __pyx_v_state->interp->eval_frame = _PyEval_EvalFrameDefault; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":484 * * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":494 * ### WARNING: GENERATED CODE, DO NOT EDIT! * ### WARNING: GENERATED CODE, DO NOT EDIT! * cdef PyObject * get_bytecode_while_frame_eval_38(PyFrameObject * frame_obj, int exc): # <<<<<<<<<<<<<< * ''' * This function makes the actual evaluation and changes the bytecode to a version */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval_38(PyFrameObject *__pyx_v_frame_obj, int __pyx_v_exc) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_thread_info = 0; CYTHON_UNUSED int __pyx_v_STATE_SUSPEND; int __pyx_v_CMD_STEP_INTO; int __pyx_v_CMD_STEP_OVER; int __pyx_v_CMD_STEP_OVER_MY_CODE; int __pyx_v_CMD_STEP_INTO_MY_CODE; int __pyx_v_CMD_STEP_INTO_COROUTINE; int __pyx_v_CMD_SMART_STEP_INTO; int __pyx_v_can_skip; struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *__pyx_v_additional_info = 0; PyObject *__pyx_v_main_debugger = 0; PyObject *__pyx_v_frame = NULL; PyObject *__pyx_v_trace_func = NULL; PyObject *__pyx_v_apply_to_global = NULL; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_func_code_info = 0; PyObject *__pyx_v_old = NULL; PyObject *__pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; PyObject *(*__pyx_t_12)(PyObject *); int __pyx_t_13; char const *__pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_bytecode_while_frame_eval_38", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":499 * where programmatic breakpoints are added. * ''' * if GlobalDebuggerHolder is None or _thread_local_info is None or exc: # <<<<<<<<<<<<<< * # Sometimes during process shutdown these global variables become None * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_GlobalDebuggerHolder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = (__pyx_t_2 == Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_3 != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_thread_local_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (__pyx_t_2 == Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (__pyx_t_4 != 0); if (!__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = (__pyx_v_exc != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":501 * if GlobalDebuggerHolder is None or _thread_local_info is None or exc: * # Sometimes during process shutdown these global variables become None * return CALL_EvalFrameDefault_38(frame_obj, exc) # <<<<<<<<<<<<<< * * # co_filename: str = <str>frame_obj.f_code.co_filename */ __pyx_r = CALL_EvalFrameDefault_38(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":499 * where programmatic breakpoints are added. * ''' * if GlobalDebuggerHolder is None or _thread_local_info is None or exc: # <<<<<<<<<<<<<< * # Sometimes during process shutdown these global variables become None * return CALL_EvalFrameDefault_38(frame_obj, exc) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":508 * * cdef ThreadInfo thread_info * cdef int STATE_SUSPEND = 2 # <<<<<<<<<<<<<< * cdef int CMD_STEP_INTO = 107 * cdef int CMD_STEP_OVER = 108 */ __pyx_v_STATE_SUSPEND = 2; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":509 * cdef ThreadInfo thread_info * cdef int STATE_SUSPEND = 2 * cdef int CMD_STEP_INTO = 107 # <<<<<<<<<<<<<< * cdef int CMD_STEP_OVER = 108 * cdef int CMD_STEP_OVER_MY_CODE = 159 */ __pyx_v_CMD_STEP_INTO = 0x6B; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":510 * cdef int STATE_SUSPEND = 2 * cdef int CMD_STEP_INTO = 107 * cdef int CMD_STEP_OVER = 108 # <<<<<<<<<<<<<< * cdef int CMD_STEP_OVER_MY_CODE = 159 * cdef int CMD_STEP_INTO_MY_CODE = 144 */ __pyx_v_CMD_STEP_OVER = 0x6C; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":511 * cdef int CMD_STEP_INTO = 107 * cdef int CMD_STEP_OVER = 108 * cdef int CMD_STEP_OVER_MY_CODE = 159 # <<<<<<<<<<<<<< * cdef int CMD_STEP_INTO_MY_CODE = 144 * cdef int CMD_STEP_INTO_COROUTINE = 206 */ __pyx_v_CMD_STEP_OVER_MY_CODE = 0x9F; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":512 * cdef int CMD_STEP_OVER = 108 * cdef int CMD_STEP_OVER_MY_CODE = 159 * cdef int CMD_STEP_INTO_MY_CODE = 144 # <<<<<<<<<<<<<< * cdef int CMD_STEP_INTO_COROUTINE = 206 * cdef int CMD_SMART_STEP_INTO = 128 */ __pyx_v_CMD_STEP_INTO_MY_CODE = 0x90; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":513 * cdef int CMD_STEP_OVER_MY_CODE = 159 * cdef int CMD_STEP_INTO_MY_CODE = 144 * cdef int CMD_STEP_INTO_COROUTINE = 206 # <<<<<<<<<<<<<< * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True */ __pyx_v_CMD_STEP_INTO_COROUTINE = 0xCE; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":514 * cdef int CMD_STEP_INTO_MY_CODE = 144 * cdef int CMD_STEP_INTO_COROUTINE = 206 * cdef int CMD_SMART_STEP_INTO = 128 # <<<<<<<<<<<<<< * cdef bint can_skip = True * try: */ __pyx_v_CMD_SMART_STEP_INTO = 0x80; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":515 * cdef int CMD_STEP_INTO_COROUTINE = 206 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True # <<<<<<<<<<<<<< * try: * thread_info = _thread_local_info.thread_info */ __pyx_v_can_skip = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":516 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True * try: # <<<<<<<<<<<<<< * thread_info = _thread_local_info.thread_info * except: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":517 * cdef bint can_skip = True * try: * thread_info = _thread_local_info.thread_info # <<<<<<<<<<<<<< * except: * thread_info = get_thread_info(frame_obj) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_thread_local_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_thread_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 517, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo))))) __PYX_ERR(0, 517, __pyx_L7_error) __pyx_v_thread_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_t_8); __pyx_t_8 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":516 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True * try: # <<<<<<<<<<<<<< * thread_info = _thread_local_info.thread_info * except: */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":518 * try: * thread_info = _thread_local_info.thread_info * except: # <<<<<<<<<<<<<< * thread_info = get_thread_info(frame_obj) * if thread_info is None: */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval_38", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_2, &__pyx_t_9) < 0) __PYX_ERR(0, 518, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_9); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":519 * thread_info = _thread_local_info.thread_info * except: * thread_info = get_thread_info(frame_obj) # <<<<<<<<<<<<<< * if thread_info is None: * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __pyx_t_10 = ((PyObject *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_thread_info(__pyx_v_frame_obj)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 519, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_v_thread_info, ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_t_10)); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":520 * except: * thread_info = get_thread_info(frame_obj) * if thread_info is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * */ __pyx_t_1 = (((PyObject *)__pyx_v_thread_info) == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":521 * thread_info = get_thread_info(frame_obj) * if thread_info is None: * return CALL_EvalFrameDefault_38(frame_obj, exc) # <<<<<<<<<<<<<< * * if thread_info.inside_frame_eval: */ __pyx_r = CALL_EvalFrameDefault_38(__pyx_v_frame_obj, __pyx_v_exc); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L10_except_return; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":520 * except: * thread_info = get_thread_info(frame_obj) * if thread_info is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":516 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True * try: # <<<<<<<<<<<<<< * thread_info = _thread_local_info.thread_info * except: */ __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L10_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L0; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); __pyx_L12_try_end:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":523 * return CALL_EvalFrameDefault_38(frame_obj, exc) * * if thread_info.inside_frame_eval: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * */ __pyx_t_3 = (__pyx_v_thread_info->inside_frame_eval != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":524 * * if thread_info.inside_frame_eval: * return CALL_EvalFrameDefault_38(frame_obj, exc) # <<<<<<<<<<<<<< * * if not thread_info.fully_initialized: */ __pyx_r = CALL_EvalFrameDefault_38(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":523 * return CALL_EvalFrameDefault_38(frame_obj, exc) * * if thread_info.inside_frame_eval: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":526 * return CALL_EvalFrameDefault_38(frame_obj, exc) * * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: */ __pyx_t_3 = ((!(__pyx_v_thread_info->fully_initialized != 0)) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":527 * * if not thread_info.fully_initialized: * thread_info.initialize_if_possible() # <<<<<<<<<<<<<< * if not thread_info.fully_initialized: * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __pyx_t_9 = ((struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_thread_info->__pyx_vtab)->initialize_if_possible(__pyx_v_thread_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":528 * if not thread_info.fully_initialized: * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * */ __pyx_t_3 = ((!(__pyx_v_thread_info->fully_initialized != 0)) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":529 * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: * return CALL_EvalFrameDefault_38(frame_obj, exc) # <<<<<<<<<<<<<< * * # Can only get additional_info when fully initialized. */ __pyx_r = CALL_EvalFrameDefault_38(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":528 * if not thread_info.fully_initialized: * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":526 * return CALL_EvalFrameDefault_38(frame_obj, exc) * * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":532 * * # Can only get additional_info when fully initialized. * cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info # <<<<<<<<<<<<<< * if thread_info.is_pydevd_thread or additional_info.is_tracing: * # Make sure that we don't trace pydevd threads or inside our own calls. */ __pyx_t_9 = ((PyObject *)__pyx_v_thread_info->additional_info); __Pyx_INCREF(__pyx_t_9); __pyx_v_additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)__pyx_t_9); __pyx_t_9 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":533 * # Can only get additional_info when fully initialized. * cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info * if thread_info.is_pydevd_thread or additional_info.is_tracing: # <<<<<<<<<<<<<< * # Make sure that we don't trace pydevd threads or inside our own calls. * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __pyx_t_1 = (__pyx_v_thread_info->is_pydevd_thread != 0); if (!__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L20_bool_binop_done; } __pyx_t_1 = (__pyx_v_additional_info->is_tracing != 0); __pyx_t_3 = __pyx_t_1; __pyx_L20_bool_binop_done:; if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":535 * if thread_info.is_pydevd_thread or additional_info.is_tracing: * # Make sure that we don't trace pydevd threads or inside our own calls. * return CALL_EvalFrameDefault_38(frame_obj, exc) # <<<<<<<<<<<<<< * * # frame = <object> frame_obj */ __pyx_r = CALL_EvalFrameDefault_38(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":533 * # Can only get additional_info when fully initialized. * cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info * if thread_info.is_pydevd_thread or additional_info.is_tracing: # <<<<<<<<<<<<<< * # Make sure that we don't trace pydevd threads or inside our own calls. * return CALL_EvalFrameDefault_38(frame_obj, exc) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":542 * # print('get_bytecode_while_frame_eval', frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename) * * thread_info.inside_frame_eval += 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = True * try: */ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval + 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":543 * * thread_info.inside_frame_eval += 1 * additional_info.is_tracing = True # <<<<<<<<<<<<<< * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg */ __pyx_v_additional_info->is_tracing = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":544 * thread_info.inside_frame_eval += 1 * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: */ /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":545 * additional_info.is_tracing = True * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg # <<<<<<<<<<<<<< * if main_debugger is None: * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_GlobalDebuggerHolder); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 545, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_global_dbg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_main_debugger = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":546 * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * frame = <object> frame_obj */ __pyx_t_3 = (__pyx_v_main_debugger == Py_None); __pyx_t_1 = (__pyx_t_3 != 0); if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":547 * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: * return CALL_EvalFrameDefault_38(frame_obj, exc) # <<<<<<<<<<<<<< * frame = <object> frame_obj * */ __pyx_r = CALL_EvalFrameDefault_38(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L22_return; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":546 * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_38(frame_obj, exc) * frame = <object> frame_obj */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":548 * if main_debugger is None: * return CALL_EvalFrameDefault_38(frame_obj, exc) * frame = <object> frame_obj # <<<<<<<<<<<<<< * * if thread_info.thread_trace_func is None: */ __pyx_t_2 = ((PyObject *)__pyx_v_frame_obj); __Pyx_INCREF(__pyx_t_2); __pyx_v_frame = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":550 * frame = <object> frame_obj * * if thread_info.thread_trace_func is None: # <<<<<<<<<<<<<< * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: */ __pyx_t_1 = (__pyx_v_thread_info->thread_trace_func == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":551 * * if thread_info.thread_trace_func is None: * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) # <<<<<<<<<<<<<< * if apply_to_global: * thread_info.thread_trace_func = trace_func */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_fix_top_level_trace_and_get_trac); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_main_debugger, __pyx_v_frame}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_main_debugger, __pyx_v_frame}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_main_debugger); __Pyx_GIVEREF(__pyx_v_main_debugger); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_v_main_debugger); __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_v_frame); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 551, __pyx_L23_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_9 = PyList_GET_ITEM(sequence, 0); __pyx_t_10 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); #else __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_9 = __pyx_t_12(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L27_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); index = 1; __pyx_t_10 = __pyx_t_12(__pyx_t_8); if (unlikely(!__pyx_t_10)) goto __pyx_L27_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_8), 2) < 0) __PYX_ERR(0, 551, __pyx_L23_error) __pyx_t_12 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L28_unpacking_done; __pyx_L27_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_12 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 551, __pyx_L23_error) __pyx_L28_unpacking_done:; } __pyx_v_trace_func = __pyx_t_9; __pyx_t_9 = 0; __pyx_v_apply_to_global = __pyx_t_10; __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":552 * if thread_info.thread_trace_func is None: * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: # <<<<<<<<<<<<<< * thread_info.thread_trace_func = trace_func * */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_apply_to_global); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 552, __pyx_L23_error) if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":553 * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: * thread_info.thread_trace_func = trace_func # <<<<<<<<<<<<<< * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ */ __Pyx_INCREF(__pyx_v_trace_func); __Pyx_GIVEREF(__pyx_v_trace_func); __Pyx_GOTREF(__pyx_v_thread_info->thread_trace_func); __Pyx_DECREF(__pyx_v_thread_info->thread_trace_func); __pyx_v_thread_info->thread_trace_func = __pyx_v_trace_func; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":552 * if thread_info.thread_trace_func is None: * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: # <<<<<<<<<<<<<< * thread_info.thread_trace_func = trace_func * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":550 * frame = <object> frame_obj * * if thread_info.thread_trace_func is None: # <<<<<<<<<<<<<< * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":555 * thread_info.thread_trace_func = trace_func * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ # <<<<<<<<<<<<<< * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ */ __pyx_t_11 = __pyx_v_additional_info->pydev_step_cmd; __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_STEP_INTO) != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L33_bool_binop_done; } __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_STEP_INTO_MY_CODE) != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L33_bool_binop_done; } __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_STEP_INTO_COROUTINE) != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L33_bool_binop_done; } __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_SMART_STEP_INTO) != 0); __pyx_t_1 = __pyx_t_4; __pyx_L33_bool_binop_done:; __pyx_t_4 = (__pyx_t_1 != 0); if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":556 * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ * main_debugger.break_on_caught_exceptions or \ # <<<<<<<<<<<<<< * main_debugger.break_on_user_uncaught_exceptions or \ * main_debugger.has_plugin_exception_breaks or \ */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_break_on_caught_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 556, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 556, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":557 * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ # <<<<<<<<<<<<<< * main_debugger.has_plugin_exception_breaks or \ * main_debugger.signature_factory or \ */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_break_on_user_uncaught_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 557, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 557, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":558 * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ * main_debugger.has_plugin_exception_breaks or \ # <<<<<<<<<<<<<< * main_debugger.signature_factory or \ * additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_exception_breaks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 558, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":559 * main_debugger.break_on_user_uncaught_exceptions or \ * main_debugger.has_plugin_exception_breaks or \ * main_debugger.signature_factory or \ # <<<<<<<<<<<<<< * additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop: * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_signature_factory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 559, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 559, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":560 * main_debugger.has_plugin_exception_breaks or \ * main_debugger.signature_factory or \ * additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop: # <<<<<<<<<<<<<< * * # if DEBUG: */ __pyx_t_11 = __pyx_v_additional_info->pydev_step_cmd; __pyx_t_1 = ((__pyx_t_11 == __pyx_v_CMD_STEP_OVER) != 0); if (!__pyx_t_1) { } else { __pyx_t_4 = __pyx_t_1; goto __pyx_L42_bool_binop_done; } __pyx_t_1 = ((__pyx_t_11 == __pyx_v_CMD_STEP_OVER_MY_CODE) != 0); __pyx_t_4 = __pyx_t_1; __pyx_L42_bool_binop_done:; __pyx_t_1 = (__pyx_t_4 != 0); if (__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L31_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_show_return_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 560, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L31_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_back); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = (__pyx_t_2 == __pyx_v_additional_info->pydev_step_stop); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_1 != 0); __pyx_t_3 = __pyx_t_4; __pyx_L31_bool_binop_done:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":555 * thread_info.thread_trace_func = trace_func * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ # <<<<<<<<<<<<<< * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ */ if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":564 * # if DEBUG: * # print('get_bytecode_while_frame_eval enabled trace') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ __pyx_t_3 = (__pyx_v_thread_info->thread_trace_func != Py_None); __pyx_t_4 = (__pyx_t_3 != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":565 * # print('get_bytecode_while_frame_eval enabled trace') * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func # <<<<<<<<<<<<<< * else: * frame.f_trace = <object> main_debugger.trace_dispatch */ __pyx_t_2 = __pyx_v_thread_info->thread_trace_func; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_2) < 0) __PYX_ERR(0, 565, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":564 * # if DEBUG: * # print('get_bytecode_while_frame_eval enabled trace') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ goto __pyx_L45; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":567 * frame.f_trace = thread_info.thread_trace_func * else: * frame.f_trace = <object> main_debugger.trace_dispatch # <<<<<<<<<<<<<< * else: * func_code_info: FuncCodeInfo = get_func_code_info(thread_info, frame_obj, frame_obj.f_code) */ /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 567, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __pyx_t_2; __Pyx_INCREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_10) < 0) __PYX_ERR(0, 567, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L45:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":555 * thread_info.thread_trace_func = trace_func * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ # <<<<<<<<<<<<<< * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ */ goto __pyx_L30; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":569 * frame.f_trace = <object> main_debugger.trace_dispatch * else: * func_code_info: FuncCodeInfo = get_func_code_info(thread_info, frame_obj, frame_obj.f_code) # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code) */ /*else*/ { __pyx_t_10 = ((PyObject *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_func_code_info(__pyx_v_thread_info, __pyx_v_frame_obj, __pyx_v_frame_obj->f_code)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 569, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_func_code_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":572 * # if DEBUG: * # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code) * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: */ __pyx_t_4 = ((!(__pyx_v_func_code_info->always_skip_code != 0)) != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":574 * if not func_code_info.always_skip_code: * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: # <<<<<<<<<<<<<< * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * */ __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_line_breaks); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 574, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 574, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L48_bool_binop_done; } __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_exception_breaks); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 574, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 574, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_4 = __pyx_t_3; __pyx_L48_bool_binop_done:; if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":575 * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) # <<<<<<<<<<<<<< * * if not can_skip: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_plugin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_can_skip); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 575, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_main_debugger, ((PyObject *)__pyx_v_frame_obj)}; __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 575, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_10); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_main_debugger, ((PyObject *)__pyx_v_frame_obj)}; __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 575, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_10); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 575, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_main_debugger); __Pyx_GIVEREF(__pyx_v_main_debugger); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_main_debugger); __Pyx_INCREF(((PyObject *)__pyx_v_frame_obj)); __Pyx_GIVEREF(((PyObject *)__pyx_v_frame_obj)); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, ((PyObject *)__pyx_v_frame_obj)); __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 575, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 575, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_v_can_skip = __pyx_t_4; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":577 * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * * if not can_skip: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') */ __pyx_t_4 = ((!(__pyx_v_can_skip != 0)) != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":580 * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ __pyx_t_4 = (__pyx_v_thread_info->thread_trace_func != Py_None); __pyx_t_3 = (__pyx_t_4 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":581 * # print('get_bytecode_while_frame_eval not can_skip') * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func # <<<<<<<<<<<<<< * else: * frame.f_trace = <object> main_debugger.trace_dispatch */ __pyx_t_10 = __pyx_v_thread_info->thread_trace_func; __Pyx_INCREF(__pyx_t_10); if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_10) < 0) __PYX_ERR(0, 581, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":580 * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ goto __pyx_L51; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":583 * frame.f_trace = thread_info.thread_trace_func * else: * frame.f_trace = <object> main_debugger.trace_dispatch # <<<<<<<<<<<<<< * * if can_skip and func_code_info.breakpoint_found: */ /*else*/ { __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 583, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = __pyx_t_10; __Pyx_INCREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_9) < 0) __PYX_ERR(0, 583, __pyx_L23_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_L51:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":577 * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * * if not can_skip: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":574 * if not func_code_info.always_skip_code: * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: # <<<<<<<<<<<<<< * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":585 * frame.f_trace = <object> main_debugger.trace_dispatch * * if can_skip and func_code_info.breakpoint_found: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) */ __pyx_t_4 = (__pyx_v_can_skip != 0); if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L53_bool_binop_done; } __pyx_t_4 = (__pyx_v_func_code_info->breakpoint_found != 0); __pyx_t_3 = __pyx_t_4; __pyx_L53_bool_binop_done:; if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":588 * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) * if not thread_info.force_stay_in_untraced_mode: # <<<<<<<<<<<<<< * # If breakpoints are found but new_code is None, * # this means we weren't able to actually add the code */ __pyx_t_3 = ((!(__pyx_v_thread_info->force_stay_in_untraced_mode != 0)) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":592 * # this means we weren't able to actually add the code * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: # <<<<<<<<<<<<<< * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func */ __pyx_t_3 = (__pyx_v_func_code_info->new_code == Py_None); __pyx_t_4 = (__pyx_t_3 != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":593 * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ __pyx_t_4 = (__pyx_v_thread_info->thread_trace_func != Py_None); __pyx_t_3 = (__pyx_t_4 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":594 * if func_code_info.new_code is None: * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func # <<<<<<<<<<<<<< * else: * frame.f_trace = <object> main_debugger.trace_dispatch */ __pyx_t_9 = __pyx_v_thread_info->thread_trace_func; __Pyx_INCREF(__pyx_t_9); if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_9) < 0) __PYX_ERR(0, 594, __pyx_L23_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":593 * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ goto __pyx_L57; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":596 * frame.f_trace = thread_info.thread_trace_func * else: * frame.f_trace = <object> main_debugger.trace_dispatch # <<<<<<<<<<<<<< * else: * # print('Using frame eval break for', <object> frame_obj.f_code.co_name) */ /*else*/ { __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 596, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __pyx_t_9; __Pyx_INCREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_10) < 0) __PYX_ERR(0, 596, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L57:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":592 * # this means we weren't able to actually add the code * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: # <<<<<<<<<<<<<< * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func */ goto __pyx_L56; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":599 * else: * # print('Using frame eval break for', <object> frame_obj.f_code.co_name) * update_globals_dict(<object> frame_obj.f_globals) # <<<<<<<<<<<<<< * Py_INCREF(func_code_info.new_code) * old = <object> frame_obj.f_code */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 599, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_10 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, ((PyObject *)__pyx_v_frame_obj->f_globals)) : __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_frame_obj->f_globals)); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 599, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":600 * # print('Using frame eval break for', <object> frame_obj.f_code.co_name) * update_globals_dict(<object> frame_obj.f_globals) * Py_INCREF(func_code_info.new_code) # <<<<<<<<<<<<<< * old = <object> frame_obj.f_code * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code */ __pyx_t_10 = __pyx_v_func_code_info->new_code; __Pyx_INCREF(__pyx_t_10); Py_INCREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":601 * update_globals_dict(<object> frame_obj.f_globals) * Py_INCREF(func_code_info.new_code) * old = <object> frame_obj.f_code # <<<<<<<<<<<<<< * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code * Py_DECREF(old) */ __pyx_t_10 = ((PyObject *)__pyx_v_frame_obj->f_code); __Pyx_INCREF(__pyx_t_10); __pyx_v_old = __pyx_t_10; __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":602 * Py_INCREF(func_code_info.new_code) * old = <object> frame_obj.f_code * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code # <<<<<<<<<<<<<< * Py_DECREF(old) * else: */ __pyx_v_frame_obj->f_code = ((PyCodeObject *)__pyx_v_func_code_info->new_code); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":603 * old = <object> frame_obj.f_code * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code * Py_DECREF(old) # <<<<<<<<<<<<<< * else: * # When we're forcing to stay in traced mode we need to */ Py_DECREF(__pyx_v_old); } __pyx_L56:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":588 * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) * if not thread_info.force_stay_in_untraced_mode: # <<<<<<<<<<<<<< * # If breakpoints are found but new_code is None, * # this means we weren't able to actually add the code */ goto __pyx_L55; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":608 * # update the globals dict (because this means that we're reusing * # a previous code which had breakpoints added in a new frame). * update_globals_dict(<object> frame_obj.f_globals) # <<<<<<<<<<<<<< * * finally: */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 608, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_10 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, ((PyObject *)__pyx_v_frame_obj->f_globals)) : __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_frame_obj->f_globals)); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 608, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L55:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":585 * frame.f_trace = <object> main_debugger.trace_dispatch * * if can_skip and func_code_info.breakpoint_found: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":572 * # if DEBUG: * # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code) * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: */ } } __pyx_L30:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":611 * * finally: * thread_info.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = False * */ /*finally:*/ { /*normal exit:*/{ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":612 * finally: * thread_info.inside_frame_eval -= 1 * additional_info.is_tracing = False # <<<<<<<<<<<<<< * * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __pyx_v_additional_info->is_tracing = 0; goto __pyx_L24; } __pyx_L23_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_11 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":611 * * finally: * thread_info.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = False * */ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":612 * finally: * thread_info.inside_frame_eval -= 1 * additional_info.is_tracing = False # <<<<<<<<<<<<<< * * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __pyx_v_additional_info->is_tracing = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_6, __pyx_t_5); __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L22_return: { __pyx_t_18 = __pyx_r; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":611 * * finally: * thread_info.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = False * */ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":612 * finally: * thread_info.inside_frame_eval -= 1 * additional_info.is_tracing = False # <<<<<<<<<<<<<< * * return CALL_EvalFrameDefault_38(frame_obj, exc) */ __pyx_v_additional_info->is_tracing = 0; __pyx_r = __pyx_t_18; goto __pyx_L0; } __pyx_L24:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":614 * additional_info.is_tracing = False * * return CALL_EvalFrameDefault_38(frame_obj, exc) # <<<<<<<<<<<<<< * ### WARNING: GENERATED CODE, DO NOT EDIT! * ### WARNING: GENERATED CODE, DO NOT EDIT! */ __pyx_r = CALL_EvalFrameDefault_38(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":494 * ### WARNING: GENERATED CODE, DO NOT EDIT! * ### WARNING: GENERATED CODE, DO NOT EDIT! * cdef PyObject * get_bytecode_while_frame_eval_38(PyFrameObject * frame_obj, int exc): # <<<<<<<<<<<<<< * ''' * This function makes the actual evaluation and changes the bytecode to a version */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval_38", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_thread_info); __Pyx_XDECREF((PyObject *)__pyx_v_additional_info); __Pyx_XDECREF(__pyx_v_main_debugger); __Pyx_XDECREF(__pyx_v_frame); __Pyx_XDECREF(__pyx_v_trace_func); __Pyx_XDECREF(__pyx_v_apply_to_global); __Pyx_XDECREF((PyObject *)__pyx_v_func_code_info); __Pyx_XDECREF(__pyx_v_old); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":623 * ### WARNING: GENERATED CODE, DO NOT EDIT! * ### WARNING: GENERATED CODE, DO NOT EDIT! * cdef PyObject * get_bytecode_while_frame_eval_39(PyThreadState* tstate, PyFrameObject * frame_obj, int exc): # <<<<<<<<<<<<<< * ''' * This function makes the actual evaluation and changes the bytecode to a version */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval_39(PyThreadState *__pyx_v_tstate, PyFrameObject *__pyx_v_frame_obj, int __pyx_v_exc) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v_thread_info = 0; CYTHON_UNUSED int __pyx_v_STATE_SUSPEND; int __pyx_v_CMD_STEP_INTO; int __pyx_v_CMD_STEP_OVER; int __pyx_v_CMD_STEP_OVER_MY_CODE; int __pyx_v_CMD_STEP_INTO_MY_CODE; int __pyx_v_CMD_STEP_INTO_COROUTINE; int __pyx_v_CMD_SMART_STEP_INTO; int __pyx_v_can_skip; struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *__pyx_v_additional_info = 0; PyObject *__pyx_v_main_debugger = 0; PyObject *__pyx_v_frame = NULL; PyObject *__pyx_v_trace_func = NULL; PyObject *__pyx_v_apply_to_global = NULL; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v_func_code_info = 0; PyObject *__pyx_v_old = NULL; PyObject *__pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; PyObject *(*__pyx_t_12)(PyObject *); int __pyx_t_13; char const *__pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_bytecode_while_frame_eval_39", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":628 * where programmatic breakpoints are added. * ''' * if GlobalDebuggerHolder is None or _thread_local_info is None or exc: # <<<<<<<<<<<<<< * # Sometimes during process shutdown these global variables become None * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_GlobalDebuggerHolder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = (__pyx_t_2 == Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_3 != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_thread_local_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (__pyx_t_2 == Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (__pyx_t_4 != 0); if (!__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = (__pyx_v_exc != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":630 * if GlobalDebuggerHolder is None or _thread_local_info is None or exc: * # Sometimes during process shutdown these global variables become None * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) # <<<<<<<<<<<<<< * * # co_filename: str = <str>frame_obj.f_code.co_filename */ __pyx_r = CALL_EvalFrameDefault_39(__pyx_v_tstate, __pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":628 * where programmatic breakpoints are added. * ''' * if GlobalDebuggerHolder is None or _thread_local_info is None or exc: # <<<<<<<<<<<<<< * # Sometimes during process shutdown these global variables become None * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":637 * * cdef ThreadInfo thread_info * cdef int STATE_SUSPEND = 2 # <<<<<<<<<<<<<< * cdef int CMD_STEP_INTO = 107 * cdef int CMD_STEP_OVER = 108 */ __pyx_v_STATE_SUSPEND = 2; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":638 * cdef ThreadInfo thread_info * cdef int STATE_SUSPEND = 2 * cdef int CMD_STEP_INTO = 107 # <<<<<<<<<<<<<< * cdef int CMD_STEP_OVER = 108 * cdef int CMD_STEP_OVER_MY_CODE = 159 */ __pyx_v_CMD_STEP_INTO = 0x6B; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":639 * cdef int STATE_SUSPEND = 2 * cdef int CMD_STEP_INTO = 107 * cdef int CMD_STEP_OVER = 108 # <<<<<<<<<<<<<< * cdef int CMD_STEP_OVER_MY_CODE = 159 * cdef int CMD_STEP_INTO_MY_CODE = 144 */ __pyx_v_CMD_STEP_OVER = 0x6C; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":640 * cdef int CMD_STEP_INTO = 107 * cdef int CMD_STEP_OVER = 108 * cdef int CMD_STEP_OVER_MY_CODE = 159 # <<<<<<<<<<<<<< * cdef int CMD_STEP_INTO_MY_CODE = 144 * cdef int CMD_STEP_INTO_COROUTINE = 206 */ __pyx_v_CMD_STEP_OVER_MY_CODE = 0x9F; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":641 * cdef int CMD_STEP_OVER = 108 * cdef int CMD_STEP_OVER_MY_CODE = 159 * cdef int CMD_STEP_INTO_MY_CODE = 144 # <<<<<<<<<<<<<< * cdef int CMD_STEP_INTO_COROUTINE = 206 * cdef int CMD_SMART_STEP_INTO = 128 */ __pyx_v_CMD_STEP_INTO_MY_CODE = 0x90; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":642 * cdef int CMD_STEP_OVER_MY_CODE = 159 * cdef int CMD_STEP_INTO_MY_CODE = 144 * cdef int CMD_STEP_INTO_COROUTINE = 206 # <<<<<<<<<<<<<< * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True */ __pyx_v_CMD_STEP_INTO_COROUTINE = 0xCE; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":643 * cdef int CMD_STEP_INTO_MY_CODE = 144 * cdef int CMD_STEP_INTO_COROUTINE = 206 * cdef int CMD_SMART_STEP_INTO = 128 # <<<<<<<<<<<<<< * cdef bint can_skip = True * try: */ __pyx_v_CMD_SMART_STEP_INTO = 0x80; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":644 * cdef int CMD_STEP_INTO_COROUTINE = 206 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True # <<<<<<<<<<<<<< * try: * thread_info = _thread_local_info.thread_info */ __pyx_v_can_skip = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":645 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True * try: # <<<<<<<<<<<<<< * thread_info = _thread_local_info.thread_info * except: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":646 * cdef bint can_skip = True * try: * thread_info = _thread_local_info.thread_info # <<<<<<<<<<<<<< * except: * thread_info = get_thread_info(frame_obj) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_thread_local_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_thread_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 646, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo))))) __PYX_ERR(0, 646, __pyx_L7_error) __pyx_v_thread_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_t_8); __pyx_t_8 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":645 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True * try: # <<<<<<<<<<<<<< * thread_info = _thread_local_info.thread_info * except: */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":647 * try: * thread_info = _thread_local_info.thread_info * except: # <<<<<<<<<<<<<< * thread_info = get_thread_info(frame_obj) * if thread_info is None: */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval_39", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_2, &__pyx_t_9) < 0) __PYX_ERR(0, 647, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_9); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":648 * thread_info = _thread_local_info.thread_info * except: * thread_info = get_thread_info(frame_obj) # <<<<<<<<<<<<<< * if thread_info is None: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __pyx_t_10 = ((PyObject *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_thread_info(__pyx_v_frame_obj)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 648, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_v_thread_info, ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_t_10)); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":649 * except: * thread_info = get_thread_info(frame_obj) * if thread_info is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * */ __pyx_t_1 = (((PyObject *)__pyx_v_thread_info) == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":650 * thread_info = get_thread_info(frame_obj) * if thread_info is None: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) # <<<<<<<<<<<<<< * * if thread_info.inside_frame_eval: */ __pyx_r = CALL_EvalFrameDefault_39(__pyx_v_tstate, __pyx_v_frame_obj, __pyx_v_exc); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L10_except_return; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":649 * except: * thread_info = get_thread_info(frame_obj) * if thread_info is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":645 * cdef int CMD_SMART_STEP_INTO = 128 * cdef bint can_skip = True * try: # <<<<<<<<<<<<<< * thread_info = _thread_local_info.thread_info * except: */ __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L10_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L0; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); __pyx_L12_try_end:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":652 * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * * if thread_info.inside_frame_eval: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * */ __pyx_t_3 = (__pyx_v_thread_info->inside_frame_eval != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":653 * * if thread_info.inside_frame_eval: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) # <<<<<<<<<<<<<< * * if not thread_info.fully_initialized: */ __pyx_r = CALL_EvalFrameDefault_39(__pyx_v_tstate, __pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":652 * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * * if thread_info.inside_frame_eval: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":655 * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: */ __pyx_t_3 = ((!(__pyx_v_thread_info->fully_initialized != 0)) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":656 * * if not thread_info.fully_initialized: * thread_info.initialize_if_possible() # <<<<<<<<<<<<<< * if not thread_info.fully_initialized: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __pyx_t_9 = ((struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v_thread_info->__pyx_vtab)->initialize_if_possible(__pyx_v_thread_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":657 * if not thread_info.fully_initialized: * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * */ __pyx_t_3 = ((!(__pyx_v_thread_info->fully_initialized != 0)) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":658 * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) # <<<<<<<<<<<<<< * * # Can only get additional_info when fully initialized. */ __pyx_r = CALL_EvalFrameDefault_39(__pyx_v_tstate, __pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":657 * if not thread_info.fully_initialized: * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":655 * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * * if not thread_info.fully_initialized: # <<<<<<<<<<<<<< * thread_info.initialize_if_possible() * if not thread_info.fully_initialized: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":661 * * # Can only get additional_info when fully initialized. * cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info # <<<<<<<<<<<<<< * if thread_info.is_pydevd_thread or additional_info.is_tracing: * # Make sure that we don't trace pydevd threads or inside our own calls. */ __pyx_t_9 = ((PyObject *)__pyx_v_thread_info->additional_info); __Pyx_INCREF(__pyx_t_9); __pyx_v_additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)__pyx_t_9); __pyx_t_9 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":662 * # Can only get additional_info when fully initialized. * cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info * if thread_info.is_pydevd_thread or additional_info.is_tracing: # <<<<<<<<<<<<<< * # Make sure that we don't trace pydevd threads or inside our own calls. * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __pyx_t_1 = (__pyx_v_thread_info->is_pydevd_thread != 0); if (!__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L20_bool_binop_done; } __pyx_t_1 = (__pyx_v_additional_info->is_tracing != 0); __pyx_t_3 = __pyx_t_1; __pyx_L20_bool_binop_done:; if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":664 * if thread_info.is_pydevd_thread or additional_info.is_tracing: * # Make sure that we don't trace pydevd threads or inside our own calls. * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) # <<<<<<<<<<<<<< * * # frame = <object> frame_obj */ __pyx_r = CALL_EvalFrameDefault_39(__pyx_v_tstate, __pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":662 * # Can only get additional_info when fully initialized. * cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info * if thread_info.is_pydevd_thread or additional_info.is_tracing: # <<<<<<<<<<<<<< * # Make sure that we don't trace pydevd threads or inside our own calls. * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":671 * # print('get_bytecode_while_frame_eval', frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename) * * thread_info.inside_frame_eval += 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = True * try: */ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval + 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":672 * * thread_info.inside_frame_eval += 1 * additional_info.is_tracing = True # <<<<<<<<<<<<<< * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg */ __pyx_v_additional_info->is_tracing = 1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":673 * thread_info.inside_frame_eval += 1 * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: */ /*try:*/ { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":674 * additional_info.is_tracing = True * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg # <<<<<<<<<<<<<< * if main_debugger is None: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_GlobalDebuggerHolder); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 674, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_global_dbg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 674, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_main_debugger = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":675 * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * frame = <object> frame_obj */ __pyx_t_3 = (__pyx_v_main_debugger == Py_None); __pyx_t_1 = (__pyx_t_3 != 0); if (__pyx_t_1) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":676 * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) # <<<<<<<<<<<<<< * frame = <object> frame_obj * */ __pyx_r = CALL_EvalFrameDefault_39(__pyx_v_tstate, __pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L22_return; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":675 * try: * main_debugger: object = GlobalDebuggerHolder.global_dbg * if main_debugger is None: # <<<<<<<<<<<<<< * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * frame = <object> frame_obj */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":677 * if main_debugger is None: * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) * frame = <object> frame_obj # <<<<<<<<<<<<<< * * if thread_info.thread_trace_func is None: */ __pyx_t_2 = ((PyObject *)__pyx_v_frame_obj); __Pyx_INCREF(__pyx_t_2); __pyx_v_frame = __pyx_t_2; __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":679 * frame = <object> frame_obj * * if thread_info.thread_trace_func is None: # <<<<<<<<<<<<<< * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: */ __pyx_t_1 = (__pyx_v_thread_info->thread_trace_func == Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":680 * * if thread_info.thread_trace_func is None: * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) # <<<<<<<<<<<<<< * if apply_to_global: * thread_info.thread_trace_func = trace_func */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_fix_top_level_trace_and_get_trac); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_main_debugger, __pyx_v_frame}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_main_debugger, __pyx_v_frame}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_main_debugger); __Pyx_GIVEREF(__pyx_v_main_debugger); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_v_main_debugger); __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_v_frame); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 680, __pyx_L23_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_9 = PyList_GET_ITEM(sequence, 0); __pyx_t_10 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); #else __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 680, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_9 = __pyx_t_12(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L27_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); index = 1; __pyx_t_10 = __pyx_t_12(__pyx_t_8); if (unlikely(!__pyx_t_10)) goto __pyx_L27_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_8), 2) < 0) __PYX_ERR(0, 680, __pyx_L23_error) __pyx_t_12 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L28_unpacking_done; __pyx_L27_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_12 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 680, __pyx_L23_error) __pyx_L28_unpacking_done:; } __pyx_v_trace_func = __pyx_t_9; __pyx_t_9 = 0; __pyx_v_apply_to_global = __pyx_t_10; __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":681 * if thread_info.thread_trace_func is None: * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: # <<<<<<<<<<<<<< * thread_info.thread_trace_func = trace_func * */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_apply_to_global); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 681, __pyx_L23_error) if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":682 * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: * thread_info.thread_trace_func = trace_func # <<<<<<<<<<<<<< * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ */ __Pyx_INCREF(__pyx_v_trace_func); __Pyx_GIVEREF(__pyx_v_trace_func); __Pyx_GOTREF(__pyx_v_thread_info->thread_trace_func); __Pyx_DECREF(__pyx_v_thread_info->thread_trace_func); __pyx_v_thread_info->thread_trace_func = __pyx_v_trace_func; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":681 * if thread_info.thread_trace_func is None: * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: # <<<<<<<<<<<<<< * thread_info.thread_trace_func = trace_func * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":679 * frame = <object> frame_obj * * if thread_info.thread_trace_func is None: # <<<<<<<<<<<<<< * trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame) * if apply_to_global: */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":684 * thread_info.thread_trace_func = trace_func * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ # <<<<<<<<<<<<<< * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ */ __pyx_t_11 = __pyx_v_additional_info->pydev_step_cmd; __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_STEP_INTO) != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L33_bool_binop_done; } __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_STEP_INTO_MY_CODE) != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L33_bool_binop_done; } __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_STEP_INTO_COROUTINE) != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L33_bool_binop_done; } __pyx_t_4 = ((__pyx_t_11 == __pyx_v_CMD_SMART_STEP_INTO) != 0); __pyx_t_1 = __pyx_t_4; __pyx_L33_bool_binop_done:; __pyx_t_4 = (__pyx_t_1 != 0); if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":685 * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ * main_debugger.break_on_caught_exceptions or \ # <<<<<<<<<<<<<< * main_debugger.break_on_user_uncaught_exceptions or \ * main_debugger.has_plugin_exception_breaks or \ */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_break_on_caught_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 685, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 685, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":686 * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ # <<<<<<<<<<<<<< * main_debugger.has_plugin_exception_breaks or \ * main_debugger.signature_factory or \ */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_break_on_user_uncaught_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 686, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 686, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":687 * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ * main_debugger.has_plugin_exception_breaks or \ # <<<<<<<<<<<<<< * main_debugger.signature_factory or \ * additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_exception_breaks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 687, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 687, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":688 * main_debugger.break_on_user_uncaught_exceptions or \ * main_debugger.has_plugin_exception_breaks or \ * main_debugger.signature_factory or \ # <<<<<<<<<<<<<< * additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop: * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_signature_factory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 688, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 688, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L31_bool_binop_done; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":689 * main_debugger.has_plugin_exception_breaks or \ * main_debugger.signature_factory or \ * additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop: # <<<<<<<<<<<<<< * * # if DEBUG: */ __pyx_t_11 = __pyx_v_additional_info->pydev_step_cmd; __pyx_t_1 = ((__pyx_t_11 == __pyx_v_CMD_STEP_OVER) != 0); if (!__pyx_t_1) { } else { __pyx_t_4 = __pyx_t_1; goto __pyx_L42_bool_binop_done; } __pyx_t_1 = ((__pyx_t_11 == __pyx_v_CMD_STEP_OVER_MY_CODE) != 0); __pyx_t_4 = __pyx_t_1; __pyx_L42_bool_binop_done:; __pyx_t_1 = (__pyx_t_4 != 0); if (__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L31_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_show_return_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 689, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L31_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_back); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = (__pyx_t_2 == __pyx_v_additional_info->pydev_step_stop); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_1 != 0); __pyx_t_3 = __pyx_t_4; __pyx_L31_bool_binop_done:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":684 * thread_info.thread_trace_func = trace_func * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ # <<<<<<<<<<<<<< * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ */ if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":693 * # if DEBUG: * # print('get_bytecode_while_frame_eval enabled trace') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ __pyx_t_3 = (__pyx_v_thread_info->thread_trace_func != Py_None); __pyx_t_4 = (__pyx_t_3 != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":694 * # print('get_bytecode_while_frame_eval enabled trace') * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func # <<<<<<<<<<<<<< * else: * frame.f_trace = <object> main_debugger.trace_dispatch */ __pyx_t_2 = __pyx_v_thread_info->thread_trace_func; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_2) < 0) __PYX_ERR(0, 694, __pyx_L23_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":693 * # if DEBUG: * # print('get_bytecode_while_frame_eval enabled trace') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ goto __pyx_L45; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":696 * frame.f_trace = thread_info.thread_trace_func * else: * frame.f_trace = <object> main_debugger.trace_dispatch # <<<<<<<<<<<<<< * else: * func_code_info: FuncCodeInfo = get_func_code_info(thread_info, frame_obj, frame_obj.f_code) */ /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 696, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __pyx_t_2; __Pyx_INCREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_10) < 0) __PYX_ERR(0, 696, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L45:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":684 * thread_info.thread_trace_func = trace_func * * if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \ # <<<<<<<<<<<<<< * main_debugger.break_on_caught_exceptions or \ * main_debugger.break_on_user_uncaught_exceptions or \ */ goto __pyx_L30; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":698 * frame.f_trace = <object> main_debugger.trace_dispatch * else: * func_code_info: FuncCodeInfo = get_func_code_info(thread_info, frame_obj, frame_obj.f_code) # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code) */ /*else*/ { __pyx_t_10 = ((PyObject *)__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_func_code_info(__pyx_v_thread_info, __pyx_v_frame_obj, __pyx_v_frame_obj->f_code)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 698, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_func_code_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":701 * # if DEBUG: * # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code) * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: */ __pyx_t_4 = ((!(__pyx_v_func_code_info->always_skip_code != 0)) != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":703 * if not func_code_info.always_skip_code: * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: # <<<<<<<<<<<<<< * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * */ __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_line_breaks); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 703, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 703, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L48_bool_binop_done; } __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_exception_breaks); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 703, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 703, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_4 = __pyx_t_3; __pyx_L48_bool_binop_done:; if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":704 * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) # <<<<<<<<<<<<<< * * if not can_skip: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_plugin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_can_skip); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 704, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_main_debugger, ((PyObject *)__pyx_v_frame_obj)}; __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 704, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_10); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_main_debugger, ((PyObject *)__pyx_v_frame_obj)}; __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 704, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_10); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 704, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_main_debugger); __Pyx_GIVEREF(__pyx_v_main_debugger); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_main_debugger); __Pyx_INCREF(((PyObject *)__pyx_v_frame_obj)); __Pyx_GIVEREF(((PyObject *)__pyx_v_frame_obj)); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, ((PyObject *)__pyx_v_frame_obj)); __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 704, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 704, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_v_can_skip = __pyx_t_4; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":706 * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * * if not can_skip: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') */ __pyx_t_4 = ((!(__pyx_v_can_skip != 0)) != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":709 * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ __pyx_t_4 = (__pyx_v_thread_info->thread_trace_func != Py_None); __pyx_t_3 = (__pyx_t_4 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":710 * # print('get_bytecode_while_frame_eval not can_skip') * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func # <<<<<<<<<<<<<< * else: * frame.f_trace = <object> main_debugger.trace_dispatch */ __pyx_t_10 = __pyx_v_thread_info->thread_trace_func; __Pyx_INCREF(__pyx_t_10); if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_10) < 0) __PYX_ERR(0, 710, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":709 * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ goto __pyx_L51; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":712 * frame.f_trace = thread_info.thread_trace_func * else: * frame.f_trace = <object> main_debugger.trace_dispatch # <<<<<<<<<<<<<< * * if can_skip and func_code_info.breakpoint_found: */ /*else*/ { __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 712, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = __pyx_t_10; __Pyx_INCREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_9) < 0) __PYX_ERR(0, 712, __pyx_L23_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_L51:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":706 * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * * if not can_skip: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval not can_skip') */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":703 * if not func_code_info.always_skip_code: * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: # <<<<<<<<<<<<<< * can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj) * */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":714 * frame.f_trace = <object> main_debugger.trace_dispatch * * if can_skip and func_code_info.breakpoint_found: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) */ __pyx_t_4 = (__pyx_v_can_skip != 0); if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L53_bool_binop_done; } __pyx_t_4 = (__pyx_v_func_code_info->breakpoint_found != 0); __pyx_t_3 = __pyx_t_4; __pyx_L53_bool_binop_done:; if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":717 * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) * if not thread_info.force_stay_in_untraced_mode: # <<<<<<<<<<<<<< * # If breakpoints are found but new_code is None, * # this means we weren't able to actually add the code */ __pyx_t_3 = ((!(__pyx_v_thread_info->force_stay_in_untraced_mode != 0)) != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":721 * # this means we weren't able to actually add the code * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: # <<<<<<<<<<<<<< * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func */ __pyx_t_3 = (__pyx_v_func_code_info->new_code == Py_None); __pyx_t_4 = (__pyx_t_3 != 0); if (__pyx_t_4) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":722 * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ __pyx_t_4 = (__pyx_v_thread_info->thread_trace_func != Py_None); __pyx_t_3 = (__pyx_t_4 != 0); if (__pyx_t_3) { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":723 * if func_code_info.new_code is None: * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func # <<<<<<<<<<<<<< * else: * frame.f_trace = <object> main_debugger.trace_dispatch */ __pyx_t_9 = __pyx_v_thread_info->thread_trace_func; __Pyx_INCREF(__pyx_t_9); if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_9) < 0) __PYX_ERR(0, 723, __pyx_L23_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":722 * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: * if thread_info.thread_trace_func is not None: # <<<<<<<<<<<<<< * frame.f_trace = thread_info.thread_trace_func * else: */ goto __pyx_L57; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":725 * frame.f_trace = thread_info.thread_trace_func * else: * frame.f_trace = <object> main_debugger.trace_dispatch # <<<<<<<<<<<<<< * else: * # print('Using frame eval break for', <object> frame_obj.f_code.co_name) */ /*else*/ { __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 725, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __pyx_t_9; __Pyx_INCREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_frame, __pyx_n_s_f_trace, __pyx_t_10) < 0) __PYX_ERR(0, 725, __pyx_L23_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L57:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":721 * # this means we weren't able to actually add the code * # where needed, so, fallback to tracing. * if func_code_info.new_code is None: # <<<<<<<<<<<<<< * if thread_info.thread_trace_func is not None: * frame.f_trace = thread_info.thread_trace_func */ goto __pyx_L56; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":728 * else: * # print('Using frame eval break for', <object> frame_obj.f_code.co_name) * update_globals_dict(<object> frame_obj.f_globals) # <<<<<<<<<<<<<< * Py_INCREF(func_code_info.new_code) * old = <object> frame_obj.f_code */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 728, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_10 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, ((PyObject *)__pyx_v_frame_obj->f_globals)) : __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_frame_obj->f_globals)); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 728, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":729 * # print('Using frame eval break for', <object> frame_obj.f_code.co_name) * update_globals_dict(<object> frame_obj.f_globals) * Py_INCREF(func_code_info.new_code) # <<<<<<<<<<<<<< * old = <object> frame_obj.f_code * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code */ __pyx_t_10 = __pyx_v_func_code_info->new_code; __Pyx_INCREF(__pyx_t_10); Py_INCREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":730 * update_globals_dict(<object> frame_obj.f_globals) * Py_INCREF(func_code_info.new_code) * old = <object> frame_obj.f_code # <<<<<<<<<<<<<< * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code * Py_DECREF(old) */ __pyx_t_10 = ((PyObject *)__pyx_v_frame_obj->f_code); __Pyx_INCREF(__pyx_t_10); __pyx_v_old = __pyx_t_10; __pyx_t_10 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":731 * Py_INCREF(func_code_info.new_code) * old = <object> frame_obj.f_code * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code # <<<<<<<<<<<<<< * Py_DECREF(old) * else: */ __pyx_v_frame_obj->f_code = ((PyCodeObject *)__pyx_v_func_code_info->new_code); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":732 * old = <object> frame_obj.f_code * frame_obj.f_code = <PyCodeObject *> func_code_info.new_code * Py_DECREF(old) # <<<<<<<<<<<<<< * else: * # When we're forcing to stay in traced mode we need to */ Py_DECREF(__pyx_v_old); } __pyx_L56:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":717 * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) * if not thread_info.force_stay_in_untraced_mode: # <<<<<<<<<<<<<< * # If breakpoints are found but new_code is None, * # this means we weren't able to actually add the code */ goto __pyx_L55; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":737 * # update the globals dict (because this means that we're reusing * # a previous code which had breakpoints added in a new frame). * update_globals_dict(<object> frame_obj.f_globals) # <<<<<<<<<<<<<< * * finally: */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 737, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_10 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, ((PyObject *)__pyx_v_frame_obj->f_globals)) : __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_frame_obj->f_globals)); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 737, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L55:; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":714 * frame.f_trace = <object> main_debugger.trace_dispatch * * if can_skip and func_code_info.breakpoint_found: # <<<<<<<<<<<<<< * # if DEBUG: * # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code) */ } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":701 * # if DEBUG: * # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code) * if not func_code_info.always_skip_code: # <<<<<<<<<<<<<< * * if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks: */ } } __pyx_L30:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":740 * * finally: * thread_info.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = False * */ /*finally:*/ { /*normal exit:*/{ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":741 * finally: * thread_info.inside_frame_eval -= 1 * additional_info.is_tracing = False # <<<<<<<<<<<<<< * * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __pyx_v_additional_info->is_tracing = 0; goto __pyx_L24; } __pyx_L23_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_11 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":740 * * finally: * thread_info.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = False * */ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":741 * finally: * thread_info.inside_frame_eval -= 1 * additional_info.is_tracing = False # <<<<<<<<<<<<<< * * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __pyx_v_additional_info->is_tracing = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_6, __pyx_t_5); __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L22_return: { __pyx_t_18 = __pyx_r; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":740 * * finally: * thread_info.inside_frame_eval -= 1 # <<<<<<<<<<<<<< * additional_info.is_tracing = False * */ __pyx_v_thread_info->inside_frame_eval = (__pyx_v_thread_info->inside_frame_eval - 1); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":741 * finally: * thread_info.inside_frame_eval -= 1 * additional_info.is_tracing = False # <<<<<<<<<<<<<< * * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) */ __pyx_v_additional_info->is_tracing = 0; __pyx_r = __pyx_t_18; goto __pyx_L0; } __pyx_L24:; } /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":743 * additional_info.is_tracing = False * * return CALL_EvalFrameDefault_39(tstate, frame_obj, exc) # <<<<<<<<<<<<<< * ### WARNING: GENERATED CODE, DO NOT EDIT! * ### WARNING: GENERATED CODE, DO NOT EDIT! */ __pyx_r = CALL_EvalFrameDefault_39(__pyx_v_tstate, __pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":623 * ### WARNING: GENERATED CODE, DO NOT EDIT! * ### WARNING: GENERATED CODE, DO NOT EDIT! * cdef PyObject * get_bytecode_while_frame_eval_39(PyThreadState* tstate, PyFrameObject * frame_obj, int exc): # <<<<<<<<<<<<<< * ''' * This function makes the actual evaluation and changes the bytecode to a version */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval_39", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_thread_info); __Pyx_XDECREF((PyObject *)__pyx_v_additional_info); __Pyx_XDECREF(__pyx_v_main_debugger); __Pyx_XDECREF(__pyx_v_frame); __Pyx_XDECREF(__pyx_v_trace_func); __Pyx_XDECREF(__pyx_v_apply_to_global); __Pyx_XDECREF((PyObject *)__pyx_v_func_code_info); __Pyx_XDECREF(__pyx_v_old); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __pyx_unpickle_ThreadInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_21__pyx_unpickle_ThreadInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_21__pyx_unpickle_ThreadInfo = {"__pyx_unpickle_ThreadInfo", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_21__pyx_unpickle_ThreadInfo, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_21__pyx_unpickle_ThreadInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_ThreadInfo (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ThreadInfo", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ThreadInfo", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ThreadInfo") < 0)) __PYX_ERR(1, 1, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error) __pyx_v___pyx_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ThreadInfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle_ThreadInfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_20__pyx_unpickle_ThreadInfo(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_20__pyx_unpickle_ThreadInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_PickleError = 0; PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_ThreadInfo", 0); /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0x0af4089, 0xe535b68, 0xb8148ba): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__6, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "(tree fragment)":5 * cdef object __pyx_result * if __pyx_checksum not in (0x0af4089, 0xe535b68, 0xb8148ba): * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<< * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) * __pyx_result = ThreadInfo.__new__(__pyx_type) */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_PickleError); __Pyx_GIVEREF(__pyx_n_s_PickleError); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError); __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v___pyx_PickleError = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * if __pyx_checksum not in (0x0af4089, 0xe535b68, 0xb8148ba): * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) # <<<<<<<<<<<<<< * __pyx_result = ThreadInfo.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_v___pyx_PickleError); __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 6, __pyx_L1_error) /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0x0af4089, 0xe535b68, 0xb8148ba): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) */ } /* "(tree fragment)":7 * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) * __pyx_result = ThreadInfo.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) * __pyx_result = ThreadInfo.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_3 = (__pyx_v___pyx_state != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "(tree fragment)":9 * __pyx_result = ThreadInfo.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error) __pyx_t_4 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_ThreadInfo__set_state(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) * __pyx_result = ThreadInfo.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":1 * def __pyx_unpickle_ThreadInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle_ThreadInfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_PickleError); __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_ThreadInfo__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; Py_ssize_t __pyx_t_4; int __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_ThreadInfo__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] # <<<<<<<<<<<<<< * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[7]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->_can_create_dummy_thread = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo))))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->additional_info); __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->additional_info)); __pyx_v___pyx_result->additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->force_stay_in_untraced_mode = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->fully_initialized = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->inside_frame_eval = __pyx_t_3; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->is_pydevd_thread = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->thread_trace_func); __Pyx_DECREF(__pyx_v___pyx_result->thread_trace_func); __pyx_v___pyx_result->thread_trace_func = __pyx_t_1; __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[7]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 13, __pyx_L1_error) } __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_4 > 7) != 0); if (__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_6 = (__pyx_t_5 != 0); __pyx_t_2 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* "(tree fragment)":14 * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[7]) # <<<<<<<<<<<<<< */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 14, __pyx_L1_error) } __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[7]) */ } /* "(tree fragment)":11 * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle_ThreadInfo__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __pyx_unpickle_FuncCodeInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_23__pyx_unpickle_FuncCodeInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_23__pyx_unpickle_FuncCodeInfo = {"__pyx_unpickle_FuncCodeInfo", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_23__pyx_unpickle_FuncCodeInfo, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_23__pyx_unpickle_FuncCodeInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_FuncCodeInfo (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_FuncCodeInfo", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_FuncCodeInfo", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_FuncCodeInfo") < 0)) __PYX_ERR(1, 1, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error) __pyx_v___pyx_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_FuncCodeInfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle_FuncCodeInfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_22__pyx_unpickle_FuncCodeInfo(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_22__pyx_unpickle_FuncCodeInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_PickleError = 0; PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_FuncCodeInfo", 0); /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0xb3ee05d, 0x450d2d6, 0x956dcaa): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))" % __pyx_checksum) */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__7, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "(tree fragment)":5 * cdef object __pyx_result * if __pyx_checksum not in (0xb3ee05d, 0x450d2d6, 0x956dcaa): * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<< * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))" % __pyx_checksum) * __pyx_result = FuncCodeInfo.__new__(__pyx_type) */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_PickleError); __Pyx_GIVEREF(__pyx_n_s_PickleError); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError); __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v___pyx_PickleError = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * if __pyx_checksum not in (0xb3ee05d, 0x450d2d6, 0x956dcaa): * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))" % __pyx_checksum) # <<<<<<<<<<<<<< * __pyx_result = FuncCodeInfo.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_v___pyx_PickleError); __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 6, __pyx_L1_error) /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0xb3ee05d, 0x450d2d6, 0x956dcaa): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))" % __pyx_checksum) */ } /* "(tree fragment)":7 * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))" % __pyx_checksum) * __pyx_result = FuncCodeInfo.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_FuncCodeInfo__set_state(<FuncCodeInfo> __pyx_result, __pyx_state) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))" % __pyx_checksum) * __pyx_result = FuncCodeInfo.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_FuncCodeInfo__set_state(<FuncCodeInfo> __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_3 = (__pyx_v___pyx_state != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "(tree fragment)":9 * __pyx_result = FuncCodeInfo.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_FuncCodeInfo__set_state(<FuncCodeInfo> __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_FuncCodeInfo__set_state(FuncCodeInfo __pyx_result, tuple __pyx_state): */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error) __pyx_t_4 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_FuncCodeInfo__set_state(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb3ee05d, 0x450d2d6, 0x956dcaa) = (always_skip_code, breakpoint_found, breakpoints_mtime, canonical_normalized_filename, co_filename, co_name, new_code))" % __pyx_checksum) * __pyx_result = FuncCodeInfo.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_FuncCodeInfo__set_state(<FuncCodeInfo> __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_FuncCodeInfo__set_state(<FuncCodeInfo> __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_FuncCodeInfo__set_state(FuncCodeInfo __pyx_result, tuple __pyx_state): * __pyx_result.always_skip_code = __pyx_state[0]; __pyx_result.breakpoint_found = __pyx_state[1]; __pyx_result.breakpoints_mtime = __pyx_state[2]; __pyx_result.canonical_normalized_filename = __pyx_state[3]; __pyx_result.co_filename = __pyx_state[4]; __pyx_result.co_name = __pyx_state[5]; __pyx_result.new_code = __pyx_state[6] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":1 * def __pyx_unpickle_FuncCodeInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle_FuncCodeInfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_PickleError); __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_FuncCodeInfo__set_state(<FuncCodeInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_FuncCodeInfo__set_state(FuncCodeInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result.always_skip_code = __pyx_state[0]; __pyx_result.breakpoint_found = __pyx_state[1]; __pyx_result.breakpoints_mtime = __pyx_state[2]; __pyx_result.canonical_normalized_filename = __pyx_state[3]; __pyx_result.co_filename = __pyx_state[4]; __pyx_result.co_name = __pyx_state[5]; __pyx_result.new_code = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle_FuncCodeInfo__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; Py_ssize_t __pyx_t_4; int __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_FuncCodeInfo__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_FuncCodeInfo__set_state(FuncCodeInfo __pyx_result, tuple __pyx_state): * __pyx_result.always_skip_code = __pyx_state[0]; __pyx_result.breakpoint_found = __pyx_state[1]; __pyx_result.breakpoints_mtime = __pyx_state[2]; __pyx_result.canonical_normalized_filename = __pyx_state[3]; __pyx_result.co_filename = __pyx_state[4]; __pyx_result.co_name = __pyx_state[5]; __pyx_result.new_code = __pyx_state[6] # <<<<<<<<<<<<<< * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[7]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->always_skip_code = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->breakpoint_found = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->breakpoints_mtime = __pyx_t_3; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->canonical_normalized_filename); __Pyx_DECREF(__pyx_v___pyx_result->canonical_normalized_filename); __pyx_v___pyx_result->canonical_normalized_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->co_filename); __Pyx_DECREF(__pyx_v___pyx_result->co_filename); __pyx_v___pyx_result->co_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->co_name); __Pyx_DECREF(__pyx_v___pyx_result->co_name); __pyx_v___pyx_result->co_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->new_code); __Pyx_DECREF(__pyx_v___pyx_result->new_code); __pyx_v___pyx_result->new_code = __pyx_t_1; __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle_FuncCodeInfo__set_state(FuncCodeInfo __pyx_result, tuple __pyx_state): * __pyx_result.always_skip_code = __pyx_state[0]; __pyx_result.breakpoint_found = __pyx_state[1]; __pyx_result.breakpoints_mtime = __pyx_state[2]; __pyx_result.canonical_normalized_filename = __pyx_state[3]; __pyx_result.co_filename = __pyx_state[4]; __pyx_result.co_name = __pyx_state[5]; __pyx_result.new_code = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[7]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 13, __pyx_L1_error) } __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_4 > 7) != 0); if (__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_6 = (__pyx_t_5 != 0); __pyx_t_2 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* "(tree fragment)":14 * __pyx_result.always_skip_code = __pyx_state[0]; __pyx_result.breakpoint_found = __pyx_state[1]; __pyx_result.breakpoints_mtime = __pyx_state[2]; __pyx_result.canonical_normalized_filename = __pyx_state[3]; __pyx_result.co_filename = __pyx_state[4]; __pyx_result.co_name = __pyx_state[5]; __pyx_result.new_code = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[7]) # <<<<<<<<<<<<<< */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 14, __pyx_L1_error) } __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle_FuncCodeInfo__set_state(FuncCodeInfo __pyx_result, tuple __pyx_state): * __pyx_result.always_skip_code = __pyx_state[0]; __pyx_result.breakpoint_found = __pyx_state[1]; __pyx_result.breakpoints_mtime = __pyx_state[2]; __pyx_result.canonical_normalized_filename = __pyx_state[3]; __pyx_result.co_filename = __pyx_state[4]; __pyx_result.co_name = __pyx_state[5]; __pyx_result.new_code = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[7]) */ } /* "(tree fragment)":11 * __pyx_unpickle_FuncCodeInfo__set_state(<FuncCodeInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_FuncCodeInfo__set_state(FuncCodeInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result.always_skip_code = __pyx_state[0]; __pyx_result.breakpoint_found = __pyx_state[1]; __pyx_result.breakpoints_mtime = __pyx_state[2]; __pyx_result.canonical_normalized_filename = __pyx_state[3]; __pyx_result.co_filename = __pyx_state[4]; __pyx_result.co_name = __pyx_state[5]; __pyx_result.new_code = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle_FuncCodeInfo__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __pyx_unpickle__CodeLineInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_25__pyx_unpickle__CodeLineInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_25__pyx_unpickle__CodeLineInfo = {"__pyx_unpickle__CodeLineInfo", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_25__pyx_unpickle__CodeLineInfo, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_25__pyx_unpickle__CodeLineInfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle__CodeLineInfo (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__CodeLineInfo", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__CodeLineInfo", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__CodeLineInfo") < 0)) __PYX_ERR(1, 1, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error) __pyx_v___pyx_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__CodeLineInfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle__CodeLineInfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_24__pyx_unpickle__CodeLineInfo(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_24__pyx_unpickle__CodeLineInfo(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_PickleError = 0; PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle__CodeLineInfo", 0); /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0x3fbbd02, 0x5a9bcd5, 0x0267473): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))" % __pyx_checksum) */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__8, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "(tree fragment)":5 * cdef object __pyx_result * if __pyx_checksum not in (0x3fbbd02, 0x5a9bcd5, 0x0267473): * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<< * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))" % __pyx_checksum) * __pyx_result = _CodeLineInfo.__new__(__pyx_type) */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_PickleError); __Pyx_GIVEREF(__pyx_n_s_PickleError); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError); __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v___pyx_PickleError = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * if __pyx_checksum not in (0x3fbbd02, 0x5a9bcd5, 0x0267473): * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))" % __pyx_checksum) # <<<<<<<<<<<<<< * __pyx_result = _CodeLineInfo.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_v___pyx_PickleError); __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 6, __pyx_L1_error) /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0x3fbbd02, 0x5a9bcd5, 0x0267473): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))" % __pyx_checksum) */ } /* "(tree fragment)":7 * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))" % __pyx_checksum) * __pyx_result = _CodeLineInfo.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))" % __pyx_checksum) * __pyx_result = _CodeLineInfo.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_3 = (__pyx_v___pyx_state != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "(tree fragment)":9 * __pyx_result = _CodeLineInfo.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error) __pyx_t_4 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CodeLineInfo__set_state(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3fbbd02, 0x5a9bcd5, 0x0267473) = (first_line, last_line, line_to_offset))" % __pyx_checksum) * __pyx_result = _CodeLineInfo.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":1 * def __pyx_unpickle__CodeLineInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle__CodeLineInfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_PickleError); __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CodeLineInfo__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; Py_ssize_t __pyx_t_4; int __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle__CodeLineInfo__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] # <<<<<<<<<<<<<< * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[3]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->first_line = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->last_line = __pyx_t_2; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->line_to_offset); __Pyx_DECREF(__pyx_v___pyx_result->line_to_offset); __pyx_v___pyx_result->line_to_offset = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[3]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 13, __pyx_L1_error) } __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_4 > 3) != 0); if (__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_6 = (__pyx_t_5 != 0); __pyx_t_3 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_3) { /* "(tree fragment)":14 * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[3]) # <<<<<<<<<<<<<< */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 14, __pyx_L1_error) } __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[3]) */ } /* "(tree fragment)":11 * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle__CodeLineInfo__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __pyx_unpickle__CacheValue(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* Python wrapper */ static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_27__pyx_unpickle__CacheValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_27__pyx_unpickle__CacheValue = {"__pyx_unpickle__CacheValue", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_27__pyx_unpickle__CacheValue, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_27__pyx_unpickle__CacheValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle__CacheValue (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__CacheValue", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__CacheValue", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__CacheValue") < 0)) __PYX_ERR(1, 1, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error) __pyx_v___pyx_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__CacheValue", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle__CacheValue", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_26__pyx_unpickle__CacheValue(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_26__pyx_unpickle__CacheValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_PickleError = 0; PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle__CacheValue", 0); /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0x3d481b9, 0xac42a46, 0xedff7c3): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))" % __pyx_checksum) */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__9, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "(tree fragment)":5 * cdef object __pyx_result * if __pyx_checksum not in (0x3d481b9, 0xac42a46, 0xedff7c3): * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<< * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))" % __pyx_checksum) * __pyx_result = _CacheValue.__new__(__pyx_type) */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_PickleError); __Pyx_GIVEREF(__pyx_n_s_PickleError); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError); __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v___pyx_PickleError = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * if __pyx_checksum not in (0x3d481b9, 0xac42a46, 0xedff7c3): * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))" % __pyx_checksum) # <<<<<<<<<<<<<< * __pyx_result = _CacheValue.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_v___pyx_PickleError); __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 6, __pyx_L1_error) /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0x3d481b9, 0xac42a46, 0xedff7c3): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))" % __pyx_checksum) */ } /* "(tree fragment)":7 * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))" % __pyx_checksum) * __pyx_result = _CacheValue.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle__CacheValue__set_state(<_CacheValue> __pyx_result, __pyx_state) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))" % __pyx_checksum) * __pyx_result = _CacheValue.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle__CacheValue__set_state(<_CacheValue> __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_3 = (__pyx_v___pyx_state != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "(tree fragment)":9 * __pyx_result = _CacheValue.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle__CacheValue__set_state(<_CacheValue> __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle__CacheValue__set_state(_CacheValue __pyx_result, tuple __pyx_state): */ if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error) __pyx_t_4 = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CacheValue__set_state(((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":8 * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x3d481b9, 0xac42a46, 0xedff7c3) = (breakpoints_hit_at_lines, code_line_info, code_lines_as_set, code_obj_py))" % __pyx_checksum) * __pyx_result = _CacheValue.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle__CacheValue__set_state(<_CacheValue> __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle__CacheValue__set_state(<_CacheValue> __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle__CacheValue__set_state(_CacheValue __pyx_result, tuple __pyx_state): * __pyx_result.breakpoints_hit_at_lines = __pyx_state[0]; __pyx_result.code_line_info = __pyx_state[1]; __pyx_result.code_lines_as_set = __pyx_state[2]; __pyx_result.code_obj_py = __pyx_state[3] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":1 * def __pyx_unpickle__CacheValue(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle__CacheValue", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_PickleError); __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle__CacheValue__set_state(<_CacheValue> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle__CacheValue__set_state(_CacheValue __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result.breakpoints_hit_at_lines = __pyx_state[0]; __pyx_result.code_line_info = __pyx_state[1]; __pyx_result.code_lines_as_set = __pyx_state[2]; __pyx_result.code_obj_py = __pyx_state[3] * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): */ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator___pyx_unpickle__CacheValue__set_state(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; Py_ssize_t __pyx_t_3; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle__CacheValue__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle__CacheValue__set_state(_CacheValue __pyx_result, tuple __pyx_state): * __pyx_result.breakpoints_hit_at_lines = __pyx_state[0]; __pyx_result.code_line_info = __pyx_state[1]; __pyx_result.code_lines_as_set = __pyx_state[2]; __pyx_result.code_obj_py = __pyx_state[3] # <<<<<<<<<<<<<< * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[4]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PySet_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->breakpoints_hit_at_lines); __Pyx_DECREF(__pyx_v___pyx_result->breakpoints_hit_at_lines); __pyx_v___pyx_result->breakpoints_hit_at_lines = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo))))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->code_line_info); __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->code_line_info)); __pyx_v___pyx_result->code_line_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PySet_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->code_lines_as_set); __Pyx_DECREF(__pyx_v___pyx_result->code_lines_as_set); __pyx_v___pyx_result->code_lines_as_set = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 12, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->code_obj_py); __Pyx_DECREF(__pyx_v___pyx_result->code_obj_py); __pyx_v___pyx_result->code_obj_py = __pyx_t_1; __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle__CacheValue__set_state(_CacheValue __pyx_result, tuple __pyx_state): * __pyx_result.breakpoints_hit_at_lines = __pyx_state[0]; __pyx_result.code_line_info = __pyx_state[1]; __pyx_result.code_lines_as_set = __pyx_state[2]; __pyx_result.code_obj_py = __pyx_state[3] * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[4]) */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 13, __pyx_L1_error) } __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_4 = ((__pyx_t_3 > 4) != 0); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error) __pyx_t_5 = (__pyx_t_4 != 0); __pyx_t_2 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* "(tree fragment)":14 * __pyx_result.breakpoints_hit_at_lines = __pyx_state[0]; __pyx_result.code_line_info = __pyx_state[1]; __pyx_result.code_lines_as_set = __pyx_state[2]; __pyx_result.code_obj_py = __pyx_state[3] * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): * __pyx_result.__dict__.update(__pyx_state[4]) # <<<<<<<<<<<<<< */ __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 14, __pyx_L1_error) } __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle__CacheValue__set_state(_CacheValue __pyx_result, tuple __pyx_state): * __pyx_result.breakpoints_hit_at_lines = __pyx_state[0]; __pyx_result.code_line_info = __pyx_state[1]; __pyx_result.code_lines_as_set = __pyx_state[2]; __pyx_result.code_obj_py = __pyx_state[3] * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< * __pyx_result.__dict__.update(__pyx_state[4]) */ } /* "(tree fragment)":11 * __pyx_unpickle__CacheValue__set_state(<_CacheValue> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle__CacheValue__set_state(_CacheValue __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result.breakpoints_hit_at_lines = __pyx_state[0]; __pyx_result.code_line_info = __pyx_state[1]; __pyx_result.code_lines_as_set = __pyx_state[2]; __pyx_result.code_obj_py = __pyx_state[3] * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.__pyx_unpickle__CacheValue__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo __pyx_vtable_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo; static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)o); p->__pyx_vtab = __pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo; p->additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)Py_None); Py_INCREF(Py_None); p->thread_trace_func = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo(PyObject *o) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->additional_info); Py_CLEAR(p->thread_trace_func); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)o; if (p->additional_info) { e = (*v)(((PyObject *)p->additional_info), a); if (e) return e; } if (p->thread_trace_func) { e = (*v)(p->thread_trace_func, a); if (e) return e; } return 0; } static int __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo(PyObject *o) { PyObject* tmp; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *)o; tmp = ((PyObject*)p->additional_info); p->additional_info = ((struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->thread_trace_func); p->thread_trace_func = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_additional_info(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_additional_info(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_15additional_info_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_is_pydevd_thread(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_is_pydevd_thread(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_16is_pydevd_thread_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_inside_frame_eval(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_inside_frame_eval(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17inside_frame_eval_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_fully_initialized(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_fully_initialized(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17fully_initialized_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_thread_trace_func(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_thread_trace_func(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_17thread_trace_func_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_force_stay_in_untraced_mode(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_force_stay_in_untraced_mode(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_27force_stay_in_untraced_mode_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyMethodDef __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo[] = { {"__reduce_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_1__reduce_cython__, METH_NOARGS, 0}, {"__setstate_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_3__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo[] = { {(char *)"additional_info", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_additional_info, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_additional_info, (char *)0, 0}, {(char *)"is_pydevd_thread", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_is_pydevd_thread, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_is_pydevd_thread, (char *)0, 0}, {(char *)"inside_frame_eval", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_inside_frame_eval, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_inside_frame_eval, (char *)0, 0}, {(char *)"fully_initialized", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_fully_initialized, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_fully_initialized, (char *)0, 0}, {(char *)"thread_trace_func", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_thread_trace_func, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_thread_trace_func, (char *)0, 0}, {(char *)"force_stay_in_untraced_mode", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_force_stay_in_untraced_mode, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_force_stay_in_untraced_mode, (char *)0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo = { PyVarObject_HEAD_INIT(0, 0) "_pydevd_frame_eval.pydevd_frame_evaluator.ThreadInfo", /*tp_name*/ sizeof(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo, /*tp_traverse*/ __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, /*tp_vectorcall*/ #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, /*tp_print*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 0, /*tp_pypy_flags*/ #endif }; static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)o); p->co_filename = ((PyObject*)Py_None); Py_INCREF(Py_None); p->co_name = ((PyObject*)Py_None); Py_INCREF(Py_None); p->canonical_normalized_filename = ((PyObject*)Py_None); Py_INCREF(Py_None); p->new_code = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo(PyObject *o) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->co_filename); Py_CLEAR(p->co_name); Py_CLEAR(p->canonical_normalized_filename); Py_CLEAR(p->new_code); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)o; if (p->new_code) { e = (*v)(p->new_code, a); if (e) return e; } return 0; } static int __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo(PyObject *o) { PyObject* tmp; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo *)o; tmp = ((PyObject*)p->new_code); p->new_code = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_filename(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_filename(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_11co_filename_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_name(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_name(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_7co_name_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_canonical_normalized_filename(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_canonical_normalized_filename(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_29canonical_normalized_filename_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoint_found(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoint_found(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_16breakpoint_found_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_new_code(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_new_code(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_8new_code_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoints_mtime(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoints_mtime(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_17breakpoints_mtime_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyMethodDef __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo[] = { {"__reduce_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_3__reduce_cython__, METH_NOARGS, 0}, {"__setstate_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_5__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo[] = { {(char *)"co_filename", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_filename, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_filename, (char *)0, 0}, {(char *)"co_name", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_name, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_co_name, (char *)0, 0}, {(char *)"canonical_normalized_filename", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_canonical_normalized_filename, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_canonical_normalized_filename, (char *)0, 0}, {(char *)"breakpoint_found", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoint_found, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoint_found, (char *)0, 0}, {(char *)"new_code", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_new_code, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_new_code, (char *)0, 0}, {(char *)"breakpoints_mtime", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoints_mtime, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_breakpoints_mtime, (char *)0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo = { PyVarObject_HEAD_INIT(0, 0) "_pydevd_frame_eval.pydevd_frame_evaluator.FuncCodeInfo", /*tp_name*/ sizeof(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo, /*tp_traverse*/ __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_12FuncCodeInfo_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, /*tp_vectorcall*/ #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, /*tp_print*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 0, /*tp_pypy_flags*/ #endif }; static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)o); p->line_to_offset = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo(PyObject *o) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->line_to_offset); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)o; if (p->line_to_offset) { e = (*v)(p->line_to_offset, a); if (e) return e; } return 0; } static int __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo(PyObject *o) { PyObject* tmp; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)o; tmp = ((PyObject*)p->line_to_offset); p->line_to_offset = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_line_to_offset(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_line_to_offset(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_14line_to_offset_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_first_line(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_first_line(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_10first_line_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_last_line(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_last_line(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_9last_line_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyMethodDef __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo[] = { {"__reduce_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_3__reduce_cython__, METH_NOARGS, 0}, {"__setstate_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_5__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo[] = { {(char *)"line_to_offset", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_line_to_offset, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_line_to_offset, (char *)0, 0}, {(char *)"first_line", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_first_line, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_first_line, (char *)0, 0}, {(char *)"last_line", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_last_line, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_last_line, (char *)0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo = { PyVarObject_HEAD_INIT(0, 0) "_pydevd_frame_eval.pydevd_frame_evaluator._CodeLineInfo", /*tp_name*/ sizeof(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo, /*tp_traverse*/ __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_13_CodeLineInfo_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, /*tp_vectorcall*/ #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, /*tp_print*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 0, /*tp_pypy_flags*/ #endif }; static struct __pyx_vtabstruct_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue __pyx_vtable_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue; static PyObject *__pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)o); p->__pyx_vtab = __pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue; p->code_obj_py = Py_None; Py_INCREF(Py_None); p->code_line_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)Py_None); Py_INCREF(Py_None); p->breakpoints_hit_at_lines = ((PyObject*)Py_None); Py_INCREF(Py_None); p->code_lines_as_set = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue(PyObject *o) { struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->code_obj_py); Py_CLEAR(p->code_line_info); Py_CLEAR(p->breakpoints_hit_at_lines); Py_CLEAR(p->code_lines_as_set); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)o; if (p->code_obj_py) { e = (*v)(p->code_obj_py, a); if (e) return e; } if (p->code_line_info) { e = (*v)(((PyObject *)p->code_line_info), a); if (e) return e; } if (p->breakpoints_hit_at_lines) { e = (*v)(p->breakpoints_hit_at_lines, a); if (e) return e; } if (p->code_lines_as_set) { e = (*v)(p->code_lines_as_set, a); if (e) return e; } return 0; } static int __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue(PyObject *o) { PyObject* tmp; struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *p = (struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *)o; tmp = ((PyObject*)p->code_obj_py); p->code_obj_py = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->code_line_info); p->code_line_info = ((struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->breakpoints_hit_at_lines); p->breakpoints_hit_at_lines = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->code_lines_as_set); p->code_lines_as_set = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_obj_py(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_obj_py(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_11code_obj_py_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_line_info(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_line_info(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_14code_line_info_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_breakpoints_hit_at_lines(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_breakpoints_hit_at_lines(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_24breakpoints_hit_at_lines_5__del__(o); } } static PyObject *__pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_lines_as_set(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_1__get__(o); } static int __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_lines_as_set(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_3__set__(o, v); } else { return __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_17code_lines_as_set_5__del__(o); } } static PyMethodDef __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue[] = { {"compute_force_stay_in_untraced_mode", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_3compute_force_stay_in_untraced_mode, METH_O, __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_2compute_force_stay_in_untraced_mode}, {"__reduce_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_5__reduce_cython__, METH_NOARGS, 0}, {"__setstate_cython__", (PyCFunction)__pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_7__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue[] = { {(char *)"code_obj_py", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_obj_py, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_obj_py, (char *)0, 0}, {(char *)"code_line_info", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_line_info, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_line_info, (char *)0, 0}, {(char *)"breakpoints_hit_at_lines", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_breakpoints_hit_at_lines, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_breakpoints_hit_at_lines, (char *)0, 0}, {(char *)"code_lines_as_set", __pyx_getprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_lines_as_set, __pyx_setprop_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_code_lines_as_set, (char *)0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue = { PyVarObject_HEAD_INIT(0, 0) "_pydevd_frame_eval.pydevd_frame_evaluator._CacheValue", /*tp_name*/ sizeof(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue, /*tp_traverse*/ __pyx_tp_clear_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, /*tp_vectorcall*/ #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, /*tp_print*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 0, /*tp_pypy_flags*/ #endif }; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_pydevd_frame_evaluator(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_pydevd_frame_evaluator}, {0, NULL} }; #endif static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, "pydevd_frame_evaluator", 0, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ #else -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0}, {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, {&__pyx_n_s_CacheValue, __pyx_k_CacheValue, sizeof(__pyx_k_CacheValue), 0, 0, 1, 1}, {&__pyx_n_s_CodeLineInfo, __pyx_k_CodeLineInfo, sizeof(__pyx_k_CodeLineInfo), 0, 0, 1, 1}, {&__pyx_n_s_DebugHelper, __pyx_k_DebugHelper, sizeof(__pyx_k_DebugHelper), 0, 0, 1, 1}, {&__pyx_n_s_FuncCodeInfo, __pyx_k_FuncCodeInfo, sizeof(__pyx_k_FuncCodeInfo), 0, 0, 1, 1}, {&__pyx_n_s_GlobalDebuggerHolder, __pyx_k_GlobalDebuggerHolder, sizeof(__pyx_k_GlobalDebuggerHolder), 0, 0, 1, 1}, {&__pyx_kp_s_If_a_code_object_is_cached_that, __pyx_k_If_a_code_object_is_cached_that, sizeof(__pyx_k_If_a_code_object_is_cached_that), 0, 0, 1, 0}, {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_k_Incompatible_checksums_0x_x_vs_0, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0), 0, 0, 1, 0}, {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2, __pyx_k_Incompatible_checksums_0x_x_vs_0_2, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_2), 0, 0, 1, 0}, {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3, __pyx_k_Incompatible_checksums_0x_x_vs_0_3, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_3), 0, 0, 1, 0}, {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_4, __pyx_k_Incompatible_checksums_0x_x_vs_0_4, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_4), 0, 0, 1, 0}, {&__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_k_NORM_PATHS_AND_BASE_CONTAINER, sizeof(__pyx_k_NORM_PATHS_AND_BASE_CONTAINER), 0, 0, 1, 1}, {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1}, {&__pyx_n_s_SetTrace, __pyx_k_SetTrace, sizeof(__pyx_k_SetTrace), 0, 0, 1, 1}, {&__pyx_n_s_ThreadInfo, __pyx_k_ThreadInfo, sizeof(__pyx_k_ThreadInfo), 0, 0, 1, 1}, {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0}, {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0}, {&__pyx_n_s_active, __pyx_k_active, sizeof(__pyx_k_active), 0, 0, 1, 1}, {&__pyx_n_s_additional_info, __pyx_k_additional_info, sizeof(__pyx_k_additional_info), 0, 0, 1, 1}, {&__pyx_n_s_arg, __pyx_k_arg, sizeof(__pyx_k_arg), 0, 0, 1, 1}, {&__pyx_n_s_bootstrap, __pyx_k_bootstrap, sizeof(__pyx_k_bootstrap), 0, 0, 1, 1}, {&__pyx_n_s_bootstrap_2, __pyx_k_bootstrap_2, sizeof(__pyx_k_bootstrap_2), 0, 0, 1, 1}, {&__pyx_n_s_bootstrap_inner, __pyx_k_bootstrap_inner, sizeof(__pyx_k_bootstrap_inner), 0, 0, 1, 1}, {&__pyx_n_s_bootstrap_inner_2, __pyx_k_bootstrap_inner_2, sizeof(__pyx_k_bootstrap_inner_2), 0, 0, 1, 1}, {&__pyx_n_s_break_on_caught_exceptions, __pyx_k_break_on_caught_exceptions, sizeof(__pyx_k_break_on_caught_exceptions), 0, 0, 1, 1}, {&__pyx_n_s_break_on_user_uncaught_exception, __pyx_k_break_on_user_uncaught_exception, sizeof(__pyx_k_break_on_user_uncaught_exception), 0, 0, 1, 1}, {&__pyx_n_s_breakpoints, __pyx_k_breakpoints, sizeof(__pyx_k_breakpoints), 0, 0, 1, 1}, {&__pyx_n_s_breakpoints_hit_at_lines, __pyx_k_breakpoints_hit_at_lines, sizeof(__pyx_k_breakpoints_hit_at_lines), 0, 0, 1, 1}, {&__pyx_n_s_cache, __pyx_k_cache, sizeof(__pyx_k_cache), 0, 0, 1, 1}, {&__pyx_n_s_call, __pyx_k_call, sizeof(__pyx_k_call), 0, 0, 1, 1}, {&__pyx_n_s_call_2, __pyx_k_call_2, sizeof(__pyx_k_call_2), 0, 0, 1, 1}, {&__pyx_n_s_can_skip, __pyx_k_can_skip, sizeof(__pyx_k_can_skip), 0, 0, 1, 1}, {&__pyx_n_s_clear_thread_local_info, __pyx_k_clear_thread_local_info, sizeof(__pyx_k_clear_thread_local_info), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_code_line_info, __pyx_k_code_line_info, sizeof(__pyx_k_code_line_info), 0, 0, 1, 1}, {&__pyx_n_s_code_obj, __pyx_k_code_obj, sizeof(__pyx_k_code_obj), 0, 0, 1, 1}, {&__pyx_n_s_code_obj_py, __pyx_k_code_obj_py, sizeof(__pyx_k_code_obj_py), 0, 0, 1, 1}, {&__pyx_n_s_compute_force_stay_in_untraced_m, __pyx_k_compute_force_stay_in_untraced_m, sizeof(__pyx_k_compute_force_stay_in_untraced_m), 0, 0, 1, 1}, {&__pyx_n_s_current_thread, __pyx_k_current_thread, sizeof(__pyx_k_current_thread), 0, 0, 1, 1}, {&__pyx_n_s_decref_py, __pyx_k_decref_py, sizeof(__pyx_k_decref_py), 0, 0, 1, 1}, {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, {&__pyx_n_s_dis, __pyx_k_dis, sizeof(__pyx_k_dis), 0, 0, 1, 1}, {&__pyx_n_s_dummy_trace_dispatch, __pyx_k_dummy_trace_dispatch, sizeof(__pyx_k_dummy_trace_dispatch), 0, 0, 1, 1}, {&__pyx_n_s_dummy_tracing_holder, __pyx_k_dummy_tracing_holder, sizeof(__pyx_k_dummy_tracing_holder), 0, 0, 1, 1}, {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1}, {&__pyx_n_s_event, __pyx_k_event, sizeof(__pyx_k_event), 0, 0, 1, 1}, {&__pyx_n_s_exec, __pyx_k_exec, sizeof(__pyx_k_exec), 0, 0, 1, 1}, {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1}, {&__pyx_n_s_f_back, __pyx_k_f_back, sizeof(__pyx_k_f_back), 0, 0, 1, 1}, {&__pyx_n_s_f_trace, __pyx_k_f_trace, sizeof(__pyx_k_f_trace), 0, 0, 1, 1}, {&__pyx_n_s_findlinestarts, __pyx_k_findlinestarts, sizeof(__pyx_k_findlinestarts), 0, 0, 1, 1}, {&__pyx_n_s_first_line, __pyx_k_first_line, sizeof(__pyx_k_first_line), 0, 0, 1, 1}, {&__pyx_n_s_fix_top_level_trace_and_get_trac, __pyx_k_fix_top_level_trace_and_get_trac, sizeof(__pyx_k_fix_top_level_trace_and_get_trac), 0, 0, 1, 1}, {&__pyx_n_s_frame, __pyx_k_frame, sizeof(__pyx_k_frame), 0, 0, 1, 1}, {&__pyx_n_s_frame_eval_func, __pyx_k_frame_eval_func, sizeof(__pyx_k_frame_eval_func), 0, 0, 1, 1}, {&__pyx_n_s_function_breakpoint_name_to_brea, __pyx_k_function_breakpoint_name_to_brea, sizeof(__pyx_k_function_breakpoint_name_to_brea), 0, 0, 1, 1}, {&__pyx_n_s_generate_code_with_breakpoints_p, __pyx_k_generate_code_with_breakpoints_p, sizeof(__pyx_k_generate_code_with_breakpoints_p), 0, 0, 1, 1}, {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_get_abs_path_real_path_and_base, __pyx_k_get_abs_path_real_path_and_base, sizeof(__pyx_k_get_abs_path_real_path_and_base), 0, 0, 1, 1}, {&__pyx_n_s_get_cache_file_type, __pyx_k_get_cache_file_type, sizeof(__pyx_k_get_cache_file_type), 0, 0, 1, 1}, {&__pyx_n_s_get_cached_code_obj_info_py, __pyx_k_get_cached_code_obj_info_py, sizeof(__pyx_k_get_cached_code_obj_info_py), 0, 0, 1, 1}, {&__pyx_n_s_get_code_line_info, __pyx_k_get_code_line_info, sizeof(__pyx_k_get_code_line_info), 0, 0, 1, 1}, {&__pyx_n_s_get_file_type, __pyx_k_get_file_type, sizeof(__pyx_k_get_file_type), 0, 0, 1, 1}, {&__pyx_n_s_get_func_code_info_py, __pyx_k_get_func_code_info_py, sizeof(__pyx_k_get_func_code_info_py), 0, 0, 1, 1}, {&__pyx_n_s_get_ident, __pyx_k_get_ident, sizeof(__pyx_k_get_ident), 0, 0, 1, 1}, {&__pyx_n_s_get_ident_2, __pyx_k_get_ident_2, sizeof(__pyx_k_get_ident_2), 0, 0, 1, 1}, {&__pyx_n_s_get_thread_info_py, __pyx_k_get_thread_info_py, sizeof(__pyx_k_get_thread_info_py), 0, 0, 1, 1}, {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_global_dbg, __pyx_k_global_dbg, sizeof(__pyx_k_global_dbg), 0, 0, 1, 1}, {&__pyx_n_s_has_plugin_exception_breaks, __pyx_k_has_plugin_exception_breaks, sizeof(__pyx_k_has_plugin_exception_breaks), 0, 0, 1, 1}, {&__pyx_n_s_has_plugin_line_breaks, __pyx_k_has_plugin_line_breaks, sizeof(__pyx_k_has_plugin_line_breaks), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_insert_pydevd_breaks, __pyx_k_insert_pydevd_breaks, sizeof(__pyx_k_insert_pydevd_breaks), 0, 0, 1, 1}, {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1}, {&__pyx_n_s_is_pydev_daemon_thread, __pyx_k_is_pydev_daemon_thread, sizeof(__pyx_k_is_pydev_daemon_thread), 0, 0, 1, 1}, {&__pyx_n_s_issuperset, __pyx_k_issuperset, sizeof(__pyx_k_issuperset), 0, 0, 1, 1}, {&__pyx_n_s_last_line, __pyx_k_last_line, sizeof(__pyx_k_last_line), 0, 0, 1, 1}, {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1}, {&__pyx_n_s_line_to_offset, __pyx_k_line_to_offset, sizeof(__pyx_k_line_to_offset), 0, 0, 1, 1}, {&__pyx_n_s_local, __pyx_k_local, sizeof(__pyx_k_local), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_main_2, __pyx_k_main_2, sizeof(__pyx_k_main_2), 0, 0, 1, 1}, {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1}, {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1}, {&__pyx_n_s_mtime, __pyx_k_mtime, sizeof(__pyx_k_mtime), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1}, {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1}, {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1}, {&__pyx_n_s_plugin, __pyx_k_plugin, sizeof(__pyx_k_plugin), 0, 0, 1, 1}, {&__pyx_n_s_pydev_bundle__pydev_saved_modul, __pyx_k_pydev_bundle__pydev_saved_modul, sizeof(__pyx_k_pydev_bundle__pydev_saved_modul), 0, 0, 1, 1}, {&__pyx_n_s_pydev_monkey, __pyx_k_pydev_monkey, sizeof(__pyx_k_pydev_monkey), 0, 0, 1, 1}, {&__pyx_n_s_pydevd, __pyx_k_pydevd, sizeof(__pyx_k_pydevd), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_bundle_pydevd_additional, __pyx_k_pydevd_bundle_pydevd_additional, sizeof(__pyx_k_pydevd_bundle_pydevd_additional), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_bundle_pydevd_constants, __pyx_k_pydevd_bundle_pydevd_constants, sizeof(__pyx_k_pydevd_bundle_pydevd_constants), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_bundle_pydevd_trace_disp, __pyx_k_pydevd_bundle_pydevd_trace_disp, sizeof(__pyx_k_pydevd_bundle_pydevd_trace_disp), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_file_utils, __pyx_k_pydevd_file_utils, sizeof(__pyx_k_pydevd_file_utils), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_k_pydevd_frame_eval_pydevd_frame, sizeof(__pyx_k_pydevd_frame_eval_pydevd_frame), 0, 0, 1, 1}, {&__pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_k_pydevd_frame_eval_pydevd_frame_2, sizeof(__pyx_k_pydevd_frame_eval_pydevd_frame_2), 0, 0, 1, 0}, {&__pyx_n_s_pydevd_frame_eval_pydevd_frame_3, __pyx_k_pydevd_frame_eval_pydevd_frame_3, sizeof(__pyx_k_pydevd_frame_eval_pydevd_frame_3), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_frame_eval_pydevd_modify, __pyx_k_pydevd_frame_eval_pydevd_modify, sizeof(__pyx_k_pydevd_frame_eval_pydevd_modify), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_tracing, __pyx_k_pydevd_tracing, sizeof(__pyx_k_pydevd_tracing), 0, 0, 1, 1}, {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1}, {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1}, {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1}, {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1}, {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1}, {&__pyx_n_s_pyx_unpickle_FuncCodeInfo, __pyx_k_pyx_unpickle_FuncCodeInfo, sizeof(__pyx_k_pyx_unpickle_FuncCodeInfo), 0, 0, 1, 1}, {&__pyx_n_s_pyx_unpickle_ThreadInfo, __pyx_k_pyx_unpickle_ThreadInfo, sizeof(__pyx_k_pyx_unpickle_ThreadInfo), 0, 0, 1, 1}, {&__pyx_n_s_pyx_unpickle__CacheValue, __pyx_k_pyx_unpickle__CacheValue, sizeof(__pyx_k_pyx_unpickle__CacheValue), 0, 0, 1, 1}, {&__pyx_n_s_pyx_unpickle__CodeLineInfo, __pyx_k_pyx_unpickle__CodeLineInfo, sizeof(__pyx_k_pyx_unpickle__CodeLineInfo), 0, 0, 1, 1}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_rfind, __pyx_k_rfind, sizeof(__pyx_k_rfind), 0, 0, 1, 1}, {&__pyx_n_s_run, __pyx_k_run, sizeof(__pyx_k_run), 0, 0, 1, 1}, {&__pyx_n_s_set_additional_thread_info_lock, __pyx_k_set_additional_thread_info_lock, sizeof(__pyx_k_set_additional_thread_info_lock), 0, 0, 1, 1}, {&__pyx_n_s_set_trace_func, __pyx_k_set_trace_func, sizeof(__pyx_k_set_trace_func), 0, 0, 1, 1}, {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_show_return_values, __pyx_k_show_return_values, sizeof(__pyx_k_show_return_values), 0, 0, 1, 1}, {&__pyx_n_s_signature_factory, __pyx_k_signature_factory, sizeof(__pyx_k_signature_factory), 0, 0, 1, 1}, {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1}, {&__pyx_n_s_stop_frame_eval, __pyx_k_stop_frame_eval, sizeof(__pyx_k_stop_frame_eval), 0, 0, 1, 1}, {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0}, {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_thread, __pyx_k_thread, sizeof(__pyx_k_thread), 0, 0, 1, 1}, {&__pyx_n_s_thread_active, __pyx_k_thread_active, sizeof(__pyx_k_thread_active), 0, 0, 1, 1}, {&__pyx_n_s_thread_info, __pyx_k_thread_info, sizeof(__pyx_k_thread_info), 0, 0, 1, 1}, {&__pyx_n_s_thread_local_info, __pyx_k_thread_local_info, sizeof(__pyx_k_thread_local_info), 0, 0, 1, 1}, {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1}, {&__pyx_n_s_trace_dispatch, __pyx_k_trace_dispatch, sizeof(__pyx_k_trace_dispatch), 0, 0, 1, 1}, {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, {&__pyx_n_s_update_globals_dict, __pyx_k_update_globals_dict, sizeof(__pyx_k_update_globals_dict), 0, 0, 1, 1}, {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 110, __pyx_L1_error) __pyx_builtin_min = __Pyx_GetBuiltinName(__pyx_n_s_min); if (!__pyx_builtin_min) __PYX_ERR(0, 341, __pyx_L1_error) __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) __PYX_ERR(0, 342, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":112 * raise AttributeError() * except: * with _set_additional_thread_info_lock: # <<<<<<<<<<<<<< * # If it's not there, set it within a lock to avoid any racing * # conditions. */ __pyx_tuple__4 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "(tree fragment)":4 * cdef object __pyx_PickleError * cdef object __pyx_result * if __pyx_checksum not in (0x0af4089, 0xe535b68, 0xb8148ba): # <<<<<<<<<<<<<< * from pickle import PickleError as __pyx_PickleError * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x0af4089, 0xe535b68, 0xb8148ba) = (_can_create_dummy_thread, additional_info, force_stay_in_untraced_mode, fully_initialized, inside_frame_eval, is_pydevd_thread, thread_trace_func))" % __pyx_checksum) */ __pyx_tuple__6 = PyTuple_Pack(3, __pyx_int_11485321, __pyx_int_240343912, __pyx_int_193022138); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); __pyx_tuple__7 = PyTuple_Pack(3, __pyx_int_188670045, __pyx_int_72405718, __pyx_int_156687530); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); __pyx_tuple__8 = PyTuple_Pack(3, __pyx_int_66829570, __pyx_int_95010005, __pyx_int_2520179); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); __pyx_tuple__9 = PyTuple_Pack(3, __pyx_int_64258489, __pyx_int_180628038, __pyx_int_249558979); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * _thread_active = threading._active * * def clear_thread_local_info(): # <<<<<<<<<<<<<< * global _thread_local_info * _thread_local_info = threading.local() */ __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_clear_thread_local_info, 19, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 19, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":152 * * * def dummy_trace_dispatch(frame, str event, arg): # <<<<<<<<<<<<<< * if event == 'call': * if frame.f_trace is not None: */ __pyx_tuple__11 = PyTuple_Pack(3, __pyx_n_s_frame, __pyx_n_s_event, __pyx_n_s_arg); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_dummy_trace_dispatch, 152, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 152, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":159 * * * def get_thread_info_py() -> ThreadInfo: # <<<<<<<<<<<<<< * return get_thread_info(PyEval_GetFrame()) * */ __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_get_thread_info_py, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 159, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":196 * * * def decref_py(obj): # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ __pyx_tuple__14 = PyTuple_Pack(1, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_decref_py, 196, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 196, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":203 * * * def get_func_code_info_py(thread_info, frame, code_obj) -> FuncCodeInfo: # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ __pyx_tuple__16 = PyTuple_Pack(3, __pyx_n_s_thread_info, __pyx_n_s_frame, __pyx_n_s_code_obj); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_get_func_code_info_py, 203, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 203, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":329 * * # Note: this method has a version in pure-python too. * def _get_code_line_info(code_obj): # <<<<<<<<<<<<<< * line_to_offset: dict = {} * first_line: int = None */ __pyx_tuple__18 = PyTuple_Pack(6, __pyx_n_s_code_obj, __pyx_n_s_line_to_offset, __pyx_n_s_first_line, __pyx_n_s_last_line, __pyx_n_s_offset, __pyx_n_s_line); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 329, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_get_code_line_info, 329, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 329, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":353 * _cache: dict = {} * * def get_cached_code_obj_info_py(code_obj_py): # <<<<<<<<<<<<<< * ''' * :return _CacheValue: */ __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_code_obj_py); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_get_cached_code_obj_info_py, 353, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 353, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":401 * return breakpoint_found, force_stay_in_untraced_mode * * def generate_code_with_breakpoints_py(object code_obj_py, dict breakpoints): # <<<<<<<<<<<<<< * return generate_code_with_breakpoints(code_obj_py, breakpoints) * */ __pyx_tuple__22 = PyTuple_Pack(2, __pyx_n_s_code_obj_py, __pyx_n_s_breakpoints); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_generate_code_with_breakpoints_p, 401, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 401, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":473 * import sys * * cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9) # <<<<<<<<<<<<<< * * def frame_eval_func(): */ __pyx_slice__24 = PySlice_New(Py_None, __pyx_int_2, Py_None); if (unlikely(!__pyx_slice__24)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__24); __Pyx_GIVEREF(__pyx_slice__24); __pyx_tuple__25 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_9); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":475 * cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * if IS_PY_39_OWNARDS: */ __pyx_tuple__26 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 475, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26); __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_frame_eval_func, 475, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 475, __pyx_L1_error) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":484 * * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ __pyx_tuple__28 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__28); __Pyx_GIVEREF(__pyx_tuple__28); __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pydevd_frame_eval_pydevd_frame_2, __pyx_n_s_stop_frame_eval, 484, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 484, __pyx_L1_error) /* "(tree fragment)":1 * def __pyx_unpickle_ThreadInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ __pyx_tuple__30 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__30); __Pyx_GIVEREF(__pyx_tuple__30); __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ThreadInfo, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(1, 1, __pyx_L1_error) __pyx_tuple__32 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32); __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_FuncCodeInfo, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(1, 1, __pyx_L1_error) __pyx_tuple__34 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__CodeLineInfo, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(1, 1, __pyx_L1_error) __pyx_tuple__36 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__CacheValue, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_9 = PyInt_FromLong(9); if (unlikely(!__pyx_int_9)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_2520179 = PyInt_FromLong(2520179L); if (unlikely(!__pyx_int_2520179)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_11485321 = PyInt_FromLong(11485321L); if (unlikely(!__pyx_int_11485321)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_64258489 = PyInt_FromLong(64258489L); if (unlikely(!__pyx_int_64258489)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_66829570 = PyInt_FromLong(66829570L); if (unlikely(!__pyx_int_66829570)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_72405718 = PyInt_FromLong(72405718L); if (unlikely(!__pyx_int_72405718)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_95010005 = PyInt_FromLong(95010005L); if (unlikely(!__pyx_int_95010005)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_156687530 = PyInt_FromLong(156687530L); if (unlikely(!__pyx_int_156687530)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_180628038 = PyInt_FromLong(180628038L); if (unlikely(!__pyx_int_180628038)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_188670045 = PyInt_FromLong(188670045L); if (unlikely(!__pyx_int_188670045)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_193022138 = PyInt_FromLong(193022138L); if (unlikely(!__pyx_int_193022138)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_240343912 = PyInt_FromLong(240343912L); if (unlikely(!__pyx_int_240343912)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_249558979 = PyInt_FromLong(249558979L); if (unlikely(!__pyx_int_249558979)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ static int __Pyx_modinit_global_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ __pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo = &__pyx_vtable_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo; __pyx_vtable_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo.initialize = (PyObject *(*)(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *, PyFrameObject *))__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_initialize; __pyx_vtable_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo.initialize_if_possible = (PyObject *(*)(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo *))__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_10ThreadInfo_initialize_if_possible; if (PyType_Ready(&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo) < 0) __PYX_ERR(0, 24, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo.tp_print = 0; #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo.tp_dictoffset && __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo.tp_getattro == PyObject_GenericGetAttr)) { __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo.tp_getattro = __Pyx_PyObject_GenericGetAttr; } if (__Pyx_SetVtable(__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo.tp_dict, __pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo) < 0) __PYX_ERR(0, 24, __pyx_L1_error) if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ThreadInfo, (PyObject *)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo) < 0) __PYX_ERR(0, 24, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo) < 0) __PYX_ERR(0, 24, __pyx_L1_error) __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo = &__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_ThreadInfo; if (PyType_Ready(&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo) < 0) __PYX_ERR(0, 125, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo.tp_print = 0; #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo.tp_dictoffset && __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo.tp_getattro == PyObject_GenericGetAttr)) { __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo.tp_getattro = __Pyx_PyObject_GenericGetAttr; } if (PyObject_SetAttr(__pyx_m, __pyx_n_s_FuncCodeInfo, (PyObject *)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo) < 0) __PYX_ERR(0, 125, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo) < 0) __PYX_ERR(0, 125, __pyx_L1_error) __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo = &__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator_FuncCodeInfo; if (PyType_Ready(&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo) < 0) __PYX_ERR(0, 316, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo.tp_print = 0; #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo.tp_dictoffset && __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo.tp_getattro == PyObject_GenericGetAttr)) { __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo.tp_getattro = __Pyx_PyObject_GenericGetAttr; } if (PyObject_SetAttr(__pyx_m, __pyx_n_s_CodeLineInfo, (PyObject *)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo) < 0) __PYX_ERR(0, 316, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo) < 0) __PYX_ERR(0, 316, __pyx_L1_error) __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo = &__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CodeLineInfo; __pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue = &__pyx_vtable_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue; __pyx_vtable_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue.compute_force_stay_in_untraced_mode = (PyObject *(*)(struct __pyx_obj_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue *, PyObject *, int __pyx_skip_dispatch))__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue_compute_force_stay_in_untraced_mode; if (PyType_Ready(&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue) < 0) __PYX_ERR(0, 361, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue.tp_print = 0; #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue.tp_dictoffset && __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue.tp_getattro == PyObject_GenericGetAttr)) { __pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue.tp_getattro = __Pyx_PyObject_GenericGetAttr; } #if CYTHON_UPDATE_DESCRIPTOR_DOC { PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 361, __pyx_L1_error) if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { __pyx_wrapperbase_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; __pyx_wrapperbase_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__.doc = __pyx_doc_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__; ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_CacheValue___init__; } } #endif if (__Pyx_SetVtable(__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue.tp_dict, __pyx_vtabptr_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue) < 0) __PYX_ERR(0, 361, __pyx_L1_error) if (PyObject_SetAttr(__pyx_m, __pyx_n_s_CacheValue, (PyObject *)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue) < 0) __PYX_ERR(0, 361, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue) < 0) __PYX_ERR(0, 361, __pyx_L1_error) __pyx_ptype_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue = &__pyx_type_18_pydevd_frame_eval_22pydevd_frame_evaluator__CacheValue; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule("_pydevd_bundle.pydevd_cython"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_ptype_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo = __Pyx_ImportType(__pyx_t_1, "_pydevd_bundle.pydevd_cython", "PyDBAdditionalThreadInfo", sizeof(struct __pyx_obj_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo), __Pyx_ImportType_CheckSize_Warn); if (!__pyx_ptype_14_pydevd_bundle_13pydevd_cython_PyDBAdditionalThreadInfo) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #elif PY_MAJOR_VERSION < 3 #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" void #else #define __Pyx_PyMODINIT_FUNC void #endif #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif #if PY_MAJOR_VERSION < 3 __Pyx_PyMODINIT_FUNC initpydevd_frame_evaluator(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC initpydevd_frame_evaluator(void) #else __Pyx_PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { #if PY_VERSION_HEX >= 0x030700A1 static PY_INT64_T main_interpreter_id = -1; PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); if (main_interpreter_id == -1) { main_interpreter_id = current_id; return (unlikely(current_id == -1)) ? -1 : 0; } else if (unlikely(main_interpreter_id != current_id)) #else static PyInterpreterState *main_interpreter = NULL; PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; if (!main_interpreter) { main_interpreter = current_interpreter; } else if (unlikely(main_interpreter != current_interpreter)) #endif { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { result = PyDict_SetItemString(moddict, to_name, value); } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; if (__Pyx_check_single_interpreter()) return NULL; if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_pydevd_frame_evaluator(PyObject *__pyx_pyinit_module) #endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'pydevd_frame_evaluator' has already been imported. Re-initialisation is not supported."); return -1; } #elif PY_MAJOR_VERSION >= 3 if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); #endif __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS PyEval_InitThreads(); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("pydevd_frame_evaluator", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_b); __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_cython_runtime); if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main__pydevd_frame_eval__pydevd_frame_evaluator) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "_pydevd_frame_eval.pydevd_frame_evaluator")) { if (unlikely(PyDict_SetItemString(modules, "_pydevd_frame_eval.pydevd_frame_evaluator", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); (void)__Pyx_modinit_variable_export_code(); (void)__Pyx_modinit_function_export_code(); if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_variable_import_code(); (void)__Pyx_modinit_function_import_code(); /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":2 * from __future__ import print_function * from _pydev_bundle._pydev_saved_modules import threading, thread # <<<<<<<<<<<<<< * from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder * import dis */ __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_threading); __Pyx_GIVEREF(__pyx_n_s_threading); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_threading); __Pyx_INCREF(__pyx_n_s_thread); __Pyx_GIVEREF(__pyx_n_s_thread); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_thread); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydev_bundle__pydev_saved_modul, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_threading); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_thread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_thread, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":3 * from __future__ import print_function * from _pydev_bundle._pydev_saved_modules import threading, thread * from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder # <<<<<<<<<<<<<< * import dis * import sys */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_GlobalDebuggerHolder); __Pyx_GIVEREF(__pyx_n_s_GlobalDebuggerHolder); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_GlobalDebuggerHolder); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_constants, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_GlobalDebuggerHolder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_GlobalDebuggerHolder, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":4 * from _pydev_bundle._pydev_saved_modules import threading, thread * from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder * import dis # <<<<<<<<<<<<<< * import sys * from _pydevd_frame_eval.pydevd_frame_tracing import update_globals_dict, dummy_tracing_holder */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_dis, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_dis, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":5 * from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder * import dis * import sys # <<<<<<<<<<<<<< * from _pydevd_frame_eval.pydevd_frame_tracing import update_globals_dict, dummy_tracing_holder * from _pydevd_frame_eval.pydevd_modify_bytecode import DebugHelper, insert_pydevd_breaks */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":6 * import dis * import sys * from _pydevd_frame_eval.pydevd_frame_tracing import update_globals_dict, dummy_tracing_holder # <<<<<<<<<<<<<< * from _pydevd_frame_eval.pydevd_modify_bytecode import DebugHelper, insert_pydevd_breaks * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER */ __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_update_globals_dict); __Pyx_GIVEREF(__pyx_n_s_update_globals_dict); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_update_globals_dict); __Pyx_INCREF(__pyx_n_s_dummy_tracing_holder); __Pyx_GIVEREF(__pyx_n_s_dummy_tracing_holder); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_dummy_tracing_holder); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_update_globals_dict, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_dummy_tracing_holder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_dummy_tracing_holder, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":7 * import sys * from _pydevd_frame_eval.pydevd_frame_tracing import update_globals_dict, dummy_tracing_holder * from _pydevd_frame_eval.pydevd_modify_bytecode import DebugHelper, insert_pydevd_breaks # <<<<<<<<<<<<<< * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER * from _pydevd_bundle.pydevd_trace_dispatch import fix_top_level_trace_and_get_trace_func */ __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_DebugHelper); __Pyx_GIVEREF(__pyx_n_s_DebugHelper); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_DebugHelper); __Pyx_INCREF(__pyx_n_s_insert_pydevd_breaks); __Pyx_GIVEREF(__pyx_n_s_insert_pydevd_breaks); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_insert_pydevd_breaks); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_modify, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_DebugHelper); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_DebugHelper, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_insert_pydevd_breaks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_insert_pydevd_breaks, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":8 * from _pydevd_frame_eval.pydevd_frame_tracing import update_globals_dict, dummy_tracing_holder * from _pydevd_frame_eval.pydevd_modify_bytecode import DebugHelper, insert_pydevd_breaks * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER # <<<<<<<<<<<<<< * from _pydevd_bundle.pydevd_trace_dispatch import fix_top_level_trace_and_get_trace_func * */ __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_abs_path_real_path_and_base); __Pyx_GIVEREF(__pyx_n_s_get_abs_path_real_path_and_base); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_abs_path_real_path_and_base); __Pyx_INCREF(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); __Pyx_GIVEREF(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_file_utils, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_abs_path_real_path_and_base, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":9 * from _pydevd_frame_eval.pydevd_modify_bytecode import DebugHelper, insert_pydevd_breaks * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER * from _pydevd_bundle.pydevd_trace_dispatch import fix_top_level_trace_and_get_trace_func # <<<<<<<<<<<<<< * * from _pydevd_bundle.pydevd_additional_thread_info import _set_additional_thread_info_lock */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_fix_top_level_trace_and_get_trac); __Pyx_GIVEREF(__pyx_n_s_fix_top_level_trace_and_get_trac); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_fix_top_level_trace_and_get_trac); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_trace_disp, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_fix_top_level_trace_and_get_trac); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fix_top_level_trace_and_get_trac, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":11 * from _pydevd_bundle.pydevd_trace_dispatch import fix_top_level_trace_and_get_trace_func * * from _pydevd_bundle.pydevd_additional_thread_info import _set_additional_thread_info_lock # <<<<<<<<<<<<<< * from _pydevd_bundle.pydevd_cython cimport PyDBAdditionalThreadInfo * from pydevd_tracing import SetTrace */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_set_additional_thread_info_lock); __Pyx_GIVEREF(__pyx_n_s_set_additional_thread_info_lock); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_set_additional_thread_info_lock); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_additional, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_set_additional_thread_info_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_additional_thread_info_lock, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":13 * from _pydevd_bundle.pydevd_additional_thread_info import _set_additional_thread_info_lock * from _pydevd_bundle.pydevd_cython cimport PyDBAdditionalThreadInfo * from pydevd_tracing import SetTrace # <<<<<<<<<<<<<< * * _get_ident = threading.get_ident # Note this is py3 only, if py2 needed to be supported, _get_ident would be needed. */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_SetTrace); __Pyx_GIVEREF(__pyx_n_s_SetTrace); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_SetTrace); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_tracing, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_SetTrace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_SetTrace, __pyx_t_2) < 0) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":15 * from pydevd_tracing import SetTrace * * _get_ident = threading.get_ident # Note this is py3 only, if py2 needed to be supported, _get_ident would be needed. # <<<<<<<<<<<<<< * _thread_local_info = threading.local() * _thread_active = threading._active */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_threading); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get_ident_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_ident, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":16 * * _get_ident = threading.get_ident # Note this is py3 only, if py2 needed to be supported, _get_ident would be needed. * _thread_local_info = threading.local() # <<<<<<<<<<<<<< * _thread_active = threading._active * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_local); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_thread_local_info, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":17 * _get_ident = threading.get_ident # Note this is py3 only, if py2 needed to be supported, _get_ident would be needed. * _thread_local_info = threading.local() * _thread_active = threading._active # <<<<<<<<<<<<<< * * def clear_thread_local_info(): */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_active); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_thread_active, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * _thread_active = threading._active * * def clear_thread_local_info(): # <<<<<<<<<<<<<< * global _thread_local_info * _thread_local_info = threading.local() */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_1clear_thread_local_info, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_clear_thread_local_info, __pyx_t_1) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":152 * * * def dummy_trace_dispatch(frame, str event, arg): # <<<<<<<<<<<<<< * if event == 'call': * if frame.f_trace is not None: */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_3dummy_trace_dispatch, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_dummy_trace_dispatch, __pyx_t_1) < 0) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":159 * * * def get_thread_info_py() -> ThreadInfo: # <<<<<<<<<<<<<< * return get_thread_info(PyEval_GetFrame()) * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_5get_thread_info_py, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_thread_info_py, __pyx_t_1) < 0) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":196 * * * def decref_py(obj): # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_7decref_py, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_decref_py, __pyx_t_1) < 0) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":203 * * * def get_func_code_info_py(thread_info, frame, code_obj) -> FuncCodeInfo: # <<<<<<<<<<<<<< * ''' * Helper to be called from Python. */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_9get_func_code_info_py, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_func_code_info_py, __pyx_t_1) < 0) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":210 * * * cdef int _code_extra_index = -1 # <<<<<<<<<<<<<< * * cdef FuncCodeInfo get_func_code_info(ThreadInfo thread_info, PyFrameObject * frame_obj, PyCodeObject * code_obj): */ __pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator__code_extra_index = -1; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":329 * * # Note: this method has a version in pure-python too. * def _get_code_line_info(code_obj): # <<<<<<<<<<<<<< * line_to_offset: dict = {} * first_line: int = None */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_11_get_code_line_info, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_code_line_info, __pyx_t_1) < 0) __PYX_ERR(0, 329, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":351 * # handled by the cython side in `FuncCodeInfo get_func_code_info` by providing the * # same code info if the debugger mtime is still the same). * _cache: dict = {} # <<<<<<<<<<<<<< * * def get_cached_code_obj_info_py(code_obj_py): */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_cache, __pyx_t_1) < 0) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":353 * _cache: dict = {} * * def get_cached_code_obj_info_py(code_obj_py): # <<<<<<<<<<<<<< * ''' * :return _CacheValue: */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_13get_cached_code_obj_info_py, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_cached_code_obj_info_py, __pyx_t_1) < 0) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":401 * return breakpoint_found, force_stay_in_untraced_mode * * def generate_code_with_breakpoints_py(object code_obj_py, dict breakpoints): # <<<<<<<<<<<<<< * return generate_code_with_breakpoints(code_obj_py, breakpoints) * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_15generate_code_with_breakpoints_py, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_generate_code_with_breakpoints_p, __pyx_t_1) < 0) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":471 * return breakpoint_found, code_obj_py * * import sys # <<<<<<<<<<<<<< * * cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9) */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":473 * import sys * * cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9) # <<<<<<<<<<<<<< * * def frame_eval_func(): */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 2, NULL, NULL, &__pyx_slice__24, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_tuple__25, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_18_pydevd_frame_eval_22pydevd_frame_evaluator_IS_PY_39_OWNARDS = __pyx_t_3; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":475 * cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * if IS_PY_39_OWNARDS: */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_17frame_eval_func, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_frame_eval_func, __pyx_t_2) < 0) __PYX_ERR(0, 475, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":484 * * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_19stop_frame_eval, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_stop_frame_eval, __pyx_t_2) < 0) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __pyx_unpickle_ThreadInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_21__pyx_unpickle_ThreadInfo, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ThreadInfo, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":11 * __pyx_unpickle_ThreadInfo__set_state(<ThreadInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_ThreadInfo__set_state(ThreadInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result._can_create_dummy_thread = __pyx_state[0]; __pyx_result.additional_info = __pyx_state[1]; __pyx_result.force_stay_in_untraced_mode = __pyx_state[2]; __pyx_result.fully_initialized = __pyx_state[3]; __pyx_result.inside_frame_eval = __pyx_state[4]; __pyx_result.is_pydevd_thread = __pyx_state[5]; __pyx_result.thread_trace_func = __pyx_state[6] * if len(__pyx_state) > 7 and hasattr(__pyx_result, '__dict__'): */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_23__pyx_unpickle_FuncCodeInfo, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_FuncCodeInfo, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __pyx_unpickle__CodeLineInfo(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_PickleError * cdef object __pyx_result */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_25__pyx_unpickle__CodeLineInfo, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__CodeLineInfo, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":11 * __pyx_unpickle__CodeLineInfo__set_state(<_CodeLineInfo> __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle__CodeLineInfo__set_state(_CodeLineInfo __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< * __pyx_result.first_line = __pyx_state[0]; __pyx_result.last_line = __pyx_state[1]; __pyx_result.line_to_offset = __pyx_state[2] * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_27__pyx_unpickle__CacheValue, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__CacheValue, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":1 * from __future__ import print_function # <<<<<<<<<<<<<< * from _pydev_bundle._pydev_saved_modules import threading, thread * from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init _pydevd_frame_eval.pydevd_frame_evaluator", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_CLEAR(__pyx_m); } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init _pydevd_frame_eval.pydevd_frame_evaluator"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #elif PY_MAJOR_VERSION >= 3 return __pyx_m; #else return; #endif } /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #endif /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } else if (unlikely(PyErr_Occurred())) { return NULL; } #else result = PyDict_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } #endif #else result = PyObject_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; assert(globals != NULL); /* XXX Perhaps we should create a specialized PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) { return NULL; } fastlocals = __Pyx_PyFrame_GetLocalsplus(f); for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; } result = PyEval_EvalFrameEx(f,0); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; return result; } #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); PyObject *closure; #if PY_MAJOR_VERSION >= 3 PyObject *kwdefs; #endif PyObject *kwtuple, **k; PyObject **d; Py_ssize_t nd; Py_ssize_t nk; PyObject *result; assert(kwargs == NULL || PyDict_Check(kwargs)); nk = kwargs ? PyDict_Size(kwargs) : 0; if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { return NULL; } if ( #if PY_MAJOR_VERSION >= 3 co->co_kwonlyargcount == 0 && #endif likely(kwargs == NULL || nk == 0) && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { if (argdefs == NULL && co->co_argcount == nargs) { result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); goto done; } else if (nargs == 0 && argdefs != NULL && co->co_argcount == Py_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); goto done; } } if (kwargs != NULL) { Py_ssize_t pos, i; kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { result = NULL; goto done; } k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { Py_INCREF(k[i]); Py_INCREF(k[i+1]); i += 2; } nk = i / 2; } else { kwtuple = NULL; k = NULL; } closure = PyFunction_GET_CLOSURE(func); #if PY_MAJOR_VERSION >= 3 kwdefs = PyFunction_GET_KW_DEFAULTS(func); #endif if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); nd = Py_SIZE(argdefs); } else { d = NULL; nd = 0; } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, closure); #endif Py_XDECREF(kwtuple); done: Py_LeaveRecursiveCall(); return result; } #endif #endif /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = Py_TYPE(func)->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallNoArg */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, NULL, 0); } #endif #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) #else if (likely(PyCFunction_Check(func))) #endif { if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif /* PyCFunctionFastCall */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { PyCFunctionObject *func = (PyCFunctionObject*)func_obj; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); int flags = PyCFunction_GET_FLAGS(func); assert(PyCFunction_Check(func)); assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); assert(nargs >= 0); assert(nargs == 0 || args != NULL); /* _PyCFunction_FastCallDict() must not be called with an exception set, because it may clear it (directly or indirectly) and so the caller loses its exception */ assert(!PyErr_Occurred()); if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); } else { return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); } } #endif /* PyObjectCallOneArg */ #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, &arg, 1); } #endif if (likely(PyCFunction_Check(func))) { if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); #if CYTHON_FAST_PYCCALL } else if (__Pyx_PyFastCFunction_Check(func)) { return __Pyx_PyCFunction_FastCall(func, &arg, 1); #endif } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif /* PyObjectCall2Args */ static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { PyObject *args, *result = NULL; #if CYTHON_FAST_PYCALL if (PyFunction_Check(function)) { PyObject *args[2] = {arg1, arg2}; return __Pyx_PyFunction_FastCall(function, args, 2); } #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(function)) { PyObject *args[2] = {arg1, arg2}; return __Pyx_PyCFunction_FastCall(function, args, 2); } #endif args = PyTuple_New(2); if (unlikely(!args)) goto done; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); Py_INCREF(function); result = __Pyx_PyObject_Call(function, args, NULL); Py_DECREF(args); Py_DECREF(function); done: return result; } /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { (void)inplace; (void)zerodivision_check; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a + b); if (likely((x^a) >= 0 || (x^b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; #ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; #endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { a = likely(size) ? digits[0] : 0; if (size == -1) a = -a; } else { switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); #ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); #endif } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; double a = PyFloat_AS_DOUBLE(op1); double result; PyFPE_START_PROTECT("add", return NULL) result = ((double)a) + (double)b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); } #endif /* SliceObject */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { #if CYTHON_USE_TYPE_SLOTS PyMappingMethods* mp; #if PY_MAJOR_VERSION < 3 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; if (likely(ms && ms->sq_slice)) { if (!has_cstart) { if (_py_start && (*_py_start != Py_None)) { cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstart = 0; } if (!has_cstop) { if (_py_stop && (*_py_stop != Py_None)) { cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstop = PY_SSIZE_T_MAX; } if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { Py_ssize_t l = ms->sq_length(obj); if (likely(l >= 0)) { if (cstop < 0) { cstop += l; if (cstop < 0) cstop = 0; } if (cstart < 0) { cstart += l; if (cstart < 0) cstart = 0; } } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) goto bad; PyErr_Clear(); } } return ms->sq_slice(obj, cstart, cstop); } #endif mp = Py_TYPE(obj)->tp_as_mapping; if (likely(mp && mp->mp_subscript)) #endif { PyObject* result; PyObject *py_slice, *py_start, *py_stop; if (_py_slice) { py_slice = *_py_slice; } else { PyObject* owned_start = NULL; PyObject* owned_stop = NULL; if (_py_start) { py_start = *_py_start; } else { if (has_cstart) { owned_start = py_start = PyInt_FromSsize_t(cstart); if (unlikely(!py_start)) goto bad; } else py_start = Py_None; } if (_py_stop) { py_stop = *_py_stop; } else { if (has_cstop) { owned_stop = py_stop = PyInt_FromSsize_t(cstop); if (unlikely(!py_stop)) { Py_XDECREF(owned_start); goto bad; } } else py_stop = Py_None; } py_slice = PySlice_New(py_start, py_stop, Py_None); Py_XDECREF(owned_start); Py_XDECREF(owned_stop); if (unlikely(!py_slice)) goto bad; } #if CYTHON_USE_TYPE_SLOTS result = mp->mp_subscript(obj, py_slice); #else result = PyObject_GetItem(obj, py_slice); #endif if (!_py_slice) { Py_DECREF(py_slice); } return result; } PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); bad: return NULL; } /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else #if PY_MAJOR_VERSION < 3 PyObject* owned_ref = NULL; #endif int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); #if PY_MAJOR_VERSION < 3 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { owned_ref = PyUnicode_FromObject(s2); if (unlikely(!owned_ref)) return -1; s2 = owned_ref; s2_is_unicode = 1; } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { owned_ref = PyUnicode_FromObject(s1); if (unlikely(!owned_ref)) return -1; s1 = owned_ref; s1_is_unicode = 1; } else if (((!s2_is_unicode) & (!s1_is_unicode))) { return __Pyx_PyBytes_Equals(s1, s2, equals); } #endif if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length; int kind; void *data1, *data2; if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; length = __Pyx_PyUnicode_GET_LENGTH(s1); if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; #if CYTHON_PEP393_ENABLED hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; #else hash1 = ((PyUnicodeObject*)s1)->hash; hash2 = ((PyUnicodeObject*)s2)->hash; #endif if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ); return_ne: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_NE); #endif } /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i<n; i++) { if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; } #endif for (i=0; i<n; i++) { if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1; } return 0; } static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { PyObject *exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; if (unlikely(PyTuple_Check(err))) return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; } #endif /* GetAttr */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_USE_TYPE_SLOTS #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) #else if (likely(PyString_Check(n))) #endif return __Pyx_PyObject_GetAttrStr(o, n); #endif return PyObject_GetAttr(o, n); } /* GetAttr3 */ static PyObject *__Pyx_GetAttr3Default(PyObject *d) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; __Pyx_PyErr_Clear(); Py_INCREF(d); return d; } static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { PyObject *r = __Pyx_GetAttr(o, n); return (likely(r)) ? r : __Pyx_GetAttr3Default(d); } /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) { _PyErr_StackItem *exc_info = tstate->exc_info; while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } return exc_info; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); *type = exc_info->exc_type; *value = exc_info->exc_value; *tb = exc_info->exc_traceback; #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; #endif Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = type; exc_info->exc_value = value; exc_info->exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } #endif /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif { PyObject *local_type, *local_value, *local_tb; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if CYTHON_USE_EXC_INFO_STACK { _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = local_type; exc_info->exc_value = local_value; exc_info->exc_traceback = local_tb; } #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } /* PyObjectSetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_setattro)) return tp->tp_setattro(obj, attr_name, value); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_setattr)) return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); #endif return PyObject_SetAttr(obj, attr_name, value); } #endif /* None */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } /* ExtTypeTest */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(__Pyx_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } /* SwapException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = *type; exc_info->exc_value = *value; exc_info->exc_traceback = *tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #endif /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* KeywordStringCheck */ static int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) { PyObject* key = 0; Py_ssize_t pos = 0; #if CYTHON_COMPILING_IN_PYPY if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) goto invalid_keyword; return 1; #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); return 0; #endif invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif return 0; } /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } /* ParseKeywords */ static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } /* ArgTypeTest */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } else if (exact) { #if PY_MAJOR_VERSION == 2 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { if (likely(__Pyx_TypeCheck(obj, type))) return 1; } PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } /* DictGetItem */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { if (unlikely(PyTuple_Check(key))) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) { PyErr_SetObject(PyExc_KeyError, args); Py_DECREF(args); } } else { PyErr_SetObject(PyExc_KeyError, key); } } return NULL; } Py_INCREF(value); return value; } #endif /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return m->sq_item(o, i); } } #else if (is_list || PySequence_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { PyObject *exc_value, *exc_tb; exc_value = tstate->curexc_value; exc_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; Py_DECREF(exc_type); Py_XDECREF(exc_value); Py_XDECREF(exc_tb); return 0; } else { return -1; } } return 0; #else if (unlikely(PyErr_Occurred())) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { PyErr_Clear(); return 0; } else { return -1; } } return 0; #endif } /* UnpackItemEndCheck */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else { return __Pyx_IterFinish(); } return 0; } /* PyObjectGetMethod */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { PyObject *attr; #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP PyTypeObject *tp = Py_TYPE(obj); PyObject *descr; descrgetfunc f = NULL; PyObject **dictptr, *dict; int meth_found = 0; assert (*method == NULL); if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; } if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { return 0; } descr = _PyType_Lookup(tp, name); if (likely(descr != NULL)) { Py_INCREF(descr); #if PY_MAJOR_VERSION >= 3 #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type))) #endif #else #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr))) #endif #endif { meth_found = 1; } else { f = Py_TYPE(descr)->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } } } dictptr = _PyObject_GetDictPtr(obj); if (dictptr != NULL && (dict = *dictptr) != NULL) { Py_INCREF(dict); attr = __Pyx_PyDict_GetItemStr(dict, name); if (attr != NULL) { Py_INCREF(attr); Py_DECREF(dict); Py_XDECREF(descr); goto try_unpack; } Py_DECREF(dict); } if (meth_found) { *method = descr; return 1; } if (f != NULL) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } if (descr != NULL) { *method = descr; return 0; } PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'%.50s' object has no attribute '%U'", tp->tp_name, name); #else "'%.50s' object has no attribute '%.400s'", tp->tp_name, PyString_AS_STRING(name)); #endif return 0; #else attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; #endif try_unpack: #if CYTHON_UNPACK_METHODS if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { PyObject *function = PyMethod_GET_FUNCTION(attr); Py_INCREF(function); Py_DECREF(attr); *method = function; return 1; } #endif *method = attr; return 0; } /* PyObjectCallMethod0 */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { PyObject *method = NULL, *result = NULL; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_CallOneArg(method, obj); Py_DECREF(method); return result; } if (unlikely(!method)) goto bad; result = __Pyx_PyObject_CallNoArg(method); Py_DECREF(method); bad: return result; } /* RaiseNoneIterError */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } /* UnpackTupleError */ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { if (t == Py_None) { __Pyx_RaiseNoneNotIterableError(); } else if (PyTuple_GET_SIZE(t) < index) { __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); } else { __Pyx_RaiseTooManyValuesError(index); } } /* UnpackTuple2 */ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) { PyObject *value1 = NULL, *value2 = NULL; #if CYTHON_COMPILING_IN_PYPY value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad; value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad; #else value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1); value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2); #endif if (decref_tuple) { Py_DECREF(tuple); } *pvalue1 = value1; *pvalue2 = value2; return 0; #if CYTHON_COMPILING_IN_PYPY bad: Py_XDECREF(value1); Py_XDECREF(value2); if (decref_tuple) { Py_XDECREF(tuple); } return -1; #endif } static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int has_known_size, int decref_tuple) { Py_ssize_t index; PyObject *value1 = NULL, *value2 = NULL, *iter = NULL; iternextfunc iternext; iter = PyObject_GetIter(tuple); if (unlikely(!iter)) goto bad; if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; } iternext = Py_TYPE(iter)->tp_iternext; value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; } value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; } if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad; Py_DECREF(iter); *pvalue1 = value1; *pvalue2 = value2; return 0; unpacking_failed: if (!has_known_size && __Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); bad: Py_XDECREF(iter); Py_XDECREF(value1); Py_XDECREF(value2); if (decref_tuple) { Py_XDECREF(tuple); } return -1; } /* dict_iter */ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name, Py_ssize_t* p_orig_length, int* p_source_is_dict) { is_dict = is_dict || likely(PyDict_CheckExact(iterable)); *p_source_is_dict = is_dict; if (is_dict) { #if !CYTHON_COMPILING_IN_PYPY *p_orig_length = PyDict_Size(iterable); Py_INCREF(iterable); return iterable; #elif PY_MAJOR_VERSION >= 3 static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; PyObject **pp = NULL; if (method_name) { const char *name = PyUnicode_AsUTF8(method_name); if (strcmp(name, "iteritems") == 0) pp = &py_items; else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; else if (strcmp(name, "itervalues") == 0) pp = &py_values; if (pp) { if (!*pp) { *pp = PyUnicode_FromString(name + 4); if (!*pp) return NULL; } method_name = *pp; } } #endif } *p_orig_length = 0; if (method_name) { PyObject* iter; iterable = __Pyx_PyObject_CallMethod0(iterable, method_name); if (!iterable) return NULL; #if !CYTHON_COMPILING_IN_PYPY if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable)) return iterable; #endif iter = PyObject_GetIter(iterable); Py_DECREF(iterable); return iter; } return PyObject_GetIter(iterable); } static CYTHON_INLINE int __Pyx_dict_iter_next( PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos, PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) { PyObject* next_item; #if !CYTHON_COMPILING_IN_PYPY if (source_is_dict) { PyObject *key, *value; if (unlikely(orig_length != PyDict_Size(iter_obj))) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); return -1; } if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) { return 0; } if (pitem) { PyObject* tuple = PyTuple_New(2); if (unlikely(!tuple)) { return -1; } Py_INCREF(key); Py_INCREF(value); PyTuple_SET_ITEM(tuple, 0, key); PyTuple_SET_ITEM(tuple, 1, value); *pitem = tuple; } else { if (pkey) { Py_INCREF(key); *pkey = key; } if (pvalue) { Py_INCREF(value); *pvalue = value; } } return 1; } else if (PyTuple_CheckExact(iter_obj)) { Py_ssize_t pos = *ppos; if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0; *ppos = pos + 1; next_item = PyTuple_GET_ITEM(iter_obj, pos); Py_INCREF(next_item); } else if (PyList_CheckExact(iter_obj)) { Py_ssize_t pos = *ppos; if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0; *ppos = pos + 1; next_item = PyList_GET_ITEM(iter_obj, pos); Py_INCREF(next_item); } else #endif { next_item = PyIter_Next(iter_obj); if (unlikely(!next_item)) { return __Pyx_IterFinish(); } } if (pitem) { *pitem = next_item; } else if (pkey && pvalue) { if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) return -1; } else if (pkey) { *pkey = next_item; } else { *pvalue = next_item; } return 1; } /* WriteUnraisableException */ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; __Pyx_PyThreadState_declare #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #ifdef _MSC_VER else state = (PyGILState_STATE)-1; #endif #endif __Pyx_PyThreadState_assign __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* HasAttr */ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { PyObject *r; if (unlikely(!__Pyx_PyBaseString_Check(n))) { PyErr_SetString(PyExc_TypeError, "hasattr(): attribute name must be string"); return -1; } r = __Pyx_GetAttr(o, n); if (unlikely(!r)) { PyErr_Clear(); return 0; } else { Py_DECREF(r); return 1; } } /* PyObject_GenericGetAttrNoDict */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'%.50s' object has no attribute '%U'", tp->tp_name, attr_name); #else "'%.50s' object has no attribute '%.400s'", tp->tp_name, PyString_AS_STRING(attr_name)); #endif return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { PyObject *descr; PyTypeObject *tp = Py_TYPE(obj); if (unlikely(!PyString_Check(attr_name))) { return PyObject_GenericGetAttr(obj, attr_name); } assert(!tp->tp_dictoffset); descr = _PyType_Lookup(tp, attr_name); if (unlikely(!descr)) { return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); } Py_INCREF(descr); #if PY_MAJOR_VERSION < 3 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) #endif { descrgetfunc f = Py_TYPE(descr)->tp_descr_get; if (unlikely(f)) { PyObject *res = f(descr, obj, (PyObject *)tp); Py_DECREF(descr); return res; } } return descr; } #endif /* PyObject_GenericGetAttr */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { return PyObject_GenericGetAttr(obj, attr_name); } return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); } #endif /* SetVTable */ static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); #endif if (!ob) goto bad; if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) goto bad; Py_DECREF(ob); return 0; bad: Py_XDECREF(ob); return -1; } /* PyObjectGetAttrStrNoError */ static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; } /* SetupReduce */ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } Py_XDECREF(name_attr); return ret; } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; PyObject *object_reduce = NULL; PyObject *object_getstate = NULL; PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; PyObject *getstate = NULL; #if CYTHON_USE_PYTYPE_LOOKUP getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate); #else getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate); if (!getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (getstate) { #if CYTHON_USE_PYTYPE_LOOKUP object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate); #else object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate); if (!object_getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (object_getstate != getstate) { goto __PYX_GOOD; } } #if CYTHON_USE_PYTYPE_LOOKUP object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #else object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #endif reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD; if (reduce_ex == object_reduce_ex) { #if CYTHON_USE_PYTYPE_LOOKUP object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; #else object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; #endif reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD; if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython); if (likely(reduce_cython)) { ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (reduce == object_reduce || PyErr_Occurred()) { goto __PYX_BAD; } setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython); if (likely(setstate_cython)) { ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (!setstate || PyErr_Occurred()) { goto __PYX_BAD; } } PyType_Modified((PyTypeObject*)type_obj); } } goto __PYX_GOOD; __PYX_BAD: if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; __PYX_GOOD: #if !CYTHON_USE_PYTYPE_LOOKUP Py_XDECREF(object_reduce); Py_XDECREF(object_reduce_ex); Py_XDECREF(object_getstate); Py_XDECREF(getstate); #endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); Py_XDECREF(setstate); Py_XDECREF(setstate_cython); return ret; } /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size) { PyObject *result = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if ((size_t)basicsize < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* CLineInTraceback */ #ifndef CYTHON_CLINE_IN_TRACEBACK static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif if (unlikely(!__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, *cython_runtime_dict, __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { PyErr_Clear(); use_cline = NULL; } } if (!use_cline) { c_line = 0; (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; #if PY_MAJOR_VERSION < 3 PyObject *py_srcfile = NULL; py_srcfile = PyString_FromString(filename); if (!py_srcfile) goto bad; #endif if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); if (!py_funcname) goto bad; #endif } #if PY_MAJOR_VERSION < 3 py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); #else py_code = PyCode_NewEmpty(filename, funcname, py_line); #endif Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline return py_code; bad: Py_XDECREF(py_funcname); #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_srcfile); #endif return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = a->tp_base; if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } #if PY_MAJOR_VERSION == 2 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { PyObject *exception, *value, *tb; int res; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&exception, &value, &tb); res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } if (!res) { res = PyObject_IsSubclass(err, exc_type2); if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } } __Pyx_ErrRestore(exception, value, tb); return res; } #else static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; if (!res) { res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } return res; } #endif static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i<n; i++) { if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; } #endif for (i=0; i<n; i++) { PyObject *t = PyTuple_GET_ITEM(tuple, i); #if PY_MAJOR_VERSION < 3 if (likely(exc_type == t)) return 1; #endif if (likely(PyExceptionClass_Check(t))) { if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; } else { } } return 0; } static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { if (likely(err == exc_type)) return 1; if (likely(PyExceptionClass_Check(err))) { if (likely(PyExceptionClass_Check(exc_type))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); } else if (likely(PyTuple_Check(exc_type))) { return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); } else { } } return PyErr_GivenExceptionMatches(err, exc_type); } static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { assert(PyExceptionClass_Check(exc_type1)); assert(PyExceptionClass_Check(exc_type2)); if (likely(err == exc_type1 || err == exc_type2)) return 1; if (likely(PyExceptionClass_Check(err))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); } return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); } #endif /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[5]; int same=1, i, found_dot; const char* rt_from_call = Py_GetVersion(); PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); found_dot = 0; for (i = 0; i < 4; i++) { if (!ctversion[i]) { same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); break; } if (rt_from_call[i] != ctversion[i]) { same = 0; break; } } if (!same) { char rtversion[5] = {'\0'}; char message[200]; for (i=0; i<4; ++i) { if (rt_from_call[i] == '.') { if (found_dot) break; found_dot = 1; } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { break; } rtversion[i] = rt_from_call[i]; } PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } /* InitStrings */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #if !CYTHON_PEP393_ENABLED static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; } #else static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif } #endif #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { #if PY_MAJOR_VERSION >= 3 if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type %.200s). " "The ability to return an instance of a strict subclass of int " "is deprecated, and may be removed in a future version of Python.", Py_TYPE(result)->tp_name)) { Py_DECREF(result); return NULL; } return result; } #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", type_name, type_name, Py_TYPE(result)->tp_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x) || PyLong_Check(x))) #else if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; res = m->nb_long(x); } #else if (likely(m && m->nb_int)) { name = "int"; res = m->nb_int(x); } #endif #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Int(x); } #endif if (likely(res)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else if (unlikely(!PyLong_CheckExact(res))) { #endif return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); #if PY_MAJOR_VERSION < 3 } else if (likely(PyInt_CheckExact(o))) { return PyInt_AS_LONG(o); #endif } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyInt_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */
935,795
C
44.435813
391
0.592001
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_eval_main.py
import os from _pydev_bundle import pydev_log from _pydevd_bundle.pydevd_trace_dispatch import USING_CYTHON from _pydevd_bundle.pydevd_constants import USE_CYTHON_FLAG, ENV_FALSE_LOWER_VALUES, \ ENV_TRUE_LOWER_VALUES, IS_PY36_OR_GREATER, IS_PY38_OR_GREATER, SUPPORT_GEVENT, IS_PYTHON_STACKLESS, \ PYDEVD_USE_FRAME_EVAL, PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING frame_eval_func = None stop_frame_eval = None dummy_trace_dispatch = None clear_thread_local_info = None # "NO" means we should not use frame evaluation, 'YES' we should use it (and fail if not there) and unspecified uses if possible. if ( PYDEVD_USE_FRAME_EVAL in ENV_FALSE_LOWER_VALUES or USE_CYTHON_FLAG in ENV_FALSE_LOWER_VALUES or not USING_CYTHON or # Frame eval mode does not work with ipython compatible debugging (this happens because the # way that frame eval works is run untraced and set tracing only for the frames with # breakpoints, but ipython compatible debugging creates separate frames for what's logically # the same frame). PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING ): USING_FRAME_EVAL = False elif SUPPORT_GEVENT or (IS_PYTHON_STACKLESS and not IS_PY38_OR_GREATER): USING_FRAME_EVAL = False # i.e gevent and frame eval mode don't get along very well. # https://github.com/microsoft/debugpy/issues/189 # Same problem with Stackless. # https://github.com/stackless-dev/stackless/issues/240 elif PYDEVD_USE_FRAME_EVAL in ENV_TRUE_LOWER_VALUES: # Fail if unable to use from _pydevd_frame_eval.pydevd_frame_eval_cython_wrapper import frame_eval_func, stop_frame_eval, dummy_trace_dispatch, clear_thread_local_info USING_FRAME_EVAL = True else: USING_FRAME_EVAL = False # Try to use if possible if IS_PY36_OR_GREATER: try: from _pydevd_frame_eval.pydevd_frame_eval_cython_wrapper import frame_eval_func, stop_frame_eval, dummy_trace_dispatch, clear_thread_local_info USING_FRAME_EVAL = True except ImportError: pydev_log.show_compile_cython_command_line()
2,105
Python
41.979591
155
0.717815
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/pydevd_fix_code.py
def _fix_contents(filename, contents): import re contents = re.sub( r"from bytecode", r'from _pydevd_frame_eval.vendored.bytecode', contents, flags=re.MULTILINE ) contents = re.sub( r"import bytecode", r'from _pydevd_frame_eval.vendored import bytecode', contents, flags=re.MULTILINE ) # This test will import the wrong setup (we're not interested in it). contents = re.sub( r"def test_version\(self\):", r'def skip_test_version(self):', contents, flags=re.MULTILINE ) if filename.startswith('test_'): if 'pytestmark' not in contents: pytest_mark = ''' import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') ''' contents = pytest_mark + contents return contents def main(): import os # traverse root directory, and list directories as dirs and files as files for root, dirs, files in os.walk(os.path.dirname(__file__)): path = root.split(os.sep) for filename in files: if filename.endswith('.py') and filename != 'pydevd_fix_code.py': with open(os.path.join(root, filename), 'r') as stream: contents = stream.read() new_contents = _fix_contents(filename, contents) if contents != new_contents: print('fixed ', os.path.join(root, filename)) with open(os.path.join(root, filename), 'w') as stream: stream.write(new_contents) # print(len(path) * '---', filename) if __name__ == '__main__': main()
1,801
Python
35.039999
126
0.612438
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/flags.py
# alias to keep the 'bytecode' variable free import sys from enum import IntFlag from _pydevd_frame_eval.vendored import bytecode as _bytecode class CompilerFlags(IntFlag): """Possible values of the co_flags attribute of Code object. Note: We do not rely on inspect values here as some of them are missing and furthermore would be version dependent. """ OPTIMIZED = 0x00001 # noqa NEWLOCALS = 0x00002 # noqa VARARGS = 0x00004 # noqa VARKEYWORDS = 0x00008 # noqa NESTED = 0x00010 # noqa GENERATOR = 0x00020 # noqa NOFREE = 0x00040 # noqa # New in Python 3.5 # Used for coroutines defined using async def ie native coroutine COROUTINE = 0x00080 # noqa # Used for coroutines defined as a generator and then decorated using # types.coroutine ITERABLE_COROUTINE = 0x00100 # noqa # New in Python 3.6 # Generator defined in an async def function ASYNC_GENERATOR = 0x00200 # noqa # __future__ flags # future flags changed in Python 3.9 if sys.version_info < (3, 9): FUTURE_GENERATOR_STOP = 0x80000 # noqa if sys.version_info > (3, 6): FUTURE_ANNOTATIONS = 0x100000 else: FUTURE_GENERATOR_STOP = 0x800000 # noqa FUTURE_ANNOTATIONS = 0x1000000 def infer_flags(bytecode, is_async=None): """Infer the proper flags for a bytecode based on the instructions. Because the bytecode does not have enough context to guess if a function is asynchronous the algorithm tries to be conservative and will never turn a previously async code into a sync one. Parameters ---------- bytecode : Bytecode | ConcreteBytecode | ControlFlowGraph Bytecode for which to infer the proper flags is_async : bool | None, optional Force the code to be marked as asynchronous if True, prevent it from being marked as asynchronous if False and simply infer the best solution based on the opcode and the existing flag if None. """ flags = CompilerFlags(0) if not isinstance( bytecode, (_bytecode.Bytecode, _bytecode.ConcreteBytecode, _bytecode.ControlFlowGraph), ): msg = ( "Expected a Bytecode, ConcreteBytecode or ControlFlowGraph " "instance not %s" ) raise ValueError(msg % bytecode) instructions = ( bytecode.get_instructions() if isinstance(bytecode, _bytecode.ControlFlowGraph) else bytecode ) instr_names = { i.name for i in instructions if not isinstance(i, (_bytecode.SetLineno, _bytecode.Label)) } # Identify optimized code if not (instr_names & {"STORE_NAME", "LOAD_NAME", "DELETE_NAME"}): flags |= CompilerFlags.OPTIMIZED # Check for free variables if not ( instr_names & { "LOAD_CLOSURE", "LOAD_DEREF", "STORE_DEREF", "DELETE_DEREF", "LOAD_CLASSDEREF", } ): flags |= CompilerFlags.NOFREE # Copy flags for which we cannot infer the right value flags |= bytecode.flags & ( CompilerFlags.NEWLOCALS | CompilerFlags.VARARGS | CompilerFlags.VARKEYWORDS | CompilerFlags.NESTED ) sure_generator = instr_names & {"YIELD_VALUE"} maybe_generator = instr_names & {"YIELD_VALUE", "YIELD_FROM"} sure_async = instr_names & { "GET_AWAITABLE", "GET_AITER", "GET_ANEXT", "BEFORE_ASYNC_WITH", "SETUP_ASYNC_WITH", "END_ASYNC_FOR", } # If performing inference or forcing an async behavior, first inspect # the flags since this is the only way to identify iterable coroutines if is_async in (None, True): if bytecode.flags & CompilerFlags.COROUTINE: if sure_generator: flags |= CompilerFlags.ASYNC_GENERATOR else: flags |= CompilerFlags.COROUTINE elif bytecode.flags & CompilerFlags.ITERABLE_COROUTINE: if sure_async: msg = ( "The ITERABLE_COROUTINE flag is set but bytecode that" "can only be used in async functions have been " "detected. Please unset that flag before performing " "inference." ) raise ValueError(msg) flags |= CompilerFlags.ITERABLE_COROUTINE elif bytecode.flags & CompilerFlags.ASYNC_GENERATOR: if not sure_generator: flags |= CompilerFlags.COROUTINE else: flags |= CompilerFlags.ASYNC_GENERATOR # If the code was not asynchronous before determine if it should now be # asynchronous based on the opcode and the is_async argument. else: if sure_async: # YIELD_FROM is not allowed in async generator if sure_generator: flags |= CompilerFlags.ASYNC_GENERATOR else: flags |= CompilerFlags.COROUTINE elif maybe_generator: if is_async: if sure_generator: flags |= CompilerFlags.ASYNC_GENERATOR else: flags |= CompilerFlags.COROUTINE else: flags |= CompilerFlags.GENERATOR elif is_async: flags |= CompilerFlags.COROUTINE # If the code should not be asynchronous, check first it is possible and # next set the GENERATOR flag if relevant else: if sure_async: raise ValueError( "The is_async argument is False but bytecodes " "that can only be used in async functions have " "been detected." ) if maybe_generator: flags |= CompilerFlags.GENERATOR flags |= bytecode.flags & CompilerFlags.FUTURE_GENERATOR_STOP return flags
6,020
Python
32.082417
85
0.598173
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/peephole_opt.py
""" Peephole optimizer of CPython 3.6 reimplemented in pure Python using the bytecode module. """ import opcode import operator import sys from _pydevd_frame_eval.vendored.bytecode import Instr, Bytecode, ControlFlowGraph, BasicBlock, Compare JUMPS_ON_TRUE = frozenset( ( "POP_JUMP_IF_TRUE", "JUMP_IF_TRUE_OR_POP", ) ) NOT_COMPARE = { Compare.IN: Compare.NOT_IN, Compare.NOT_IN: Compare.IN, Compare.IS: Compare.IS_NOT, Compare.IS_NOT: Compare.IS, } MAX_SIZE = 20 class ExitUnchanged(Exception): """Exception used to skip the peephole optimizer""" pass class PeepholeOptimizer: """Python reimplementation of the peephole optimizer. Copy of the C comment: Perform basic peephole optimizations to components of a code object. The consts object should still be in list form to allow new constants to be appended. To keep the optimizer simple, it bails out (does nothing) for code that has a length over 32,700, and does not calculate extended arguments. That allows us to avoid overflow and sign issues. Likewise, it bails when the lineno table has complex encoding for gaps >= 255. EXTENDED_ARG can appear before MAKE_FUNCTION; in this case both opcodes are skipped. EXTENDED_ARG preceding any other opcode causes the optimizer to bail. Optimizations are restricted to simple transformations occuring within a single basic block. All transformations keep the code size the same or smaller. For those that reduce size, the gaps are initially filled with NOPs. Later those NOPs are removed and the jump addresses retargeted in a single pass. Code offset is adjusted accordingly. """ def __init__(self): # bytecode.ControlFlowGraph instance self.code = None self.const_stack = None self.block_index = None self.block = None # index of the current instruction in self.block instructions self.index = None # whether we are in a LOAD_CONST sequence self.in_consts = False def check_result(self, value): try: size = len(value) except TypeError: return True return size <= MAX_SIZE def replace_load_const(self, nconst, instr, result): # FIXME: remove temporary computed constants? # FIXME: or at least reuse existing constants? self.in_consts = True load_const = Instr("LOAD_CONST", result, lineno=instr.lineno) start = self.index - nconst - 1 self.block[start : self.index] = (load_const,) self.index -= nconst if nconst: del self.const_stack[-nconst:] self.const_stack.append(result) self.in_consts = True def eval_LOAD_CONST(self, instr): self.in_consts = True value = instr.arg self.const_stack.append(value) self.in_consts = True def unaryop(self, op, instr): try: value = self.const_stack[-1] result = op(value) except IndexError: return if not self.check_result(result): return self.replace_load_const(1, instr, result) def eval_UNARY_POSITIVE(self, instr): return self.unaryop(operator.pos, instr) def eval_UNARY_NEGATIVE(self, instr): return self.unaryop(operator.neg, instr) def eval_UNARY_INVERT(self, instr): return self.unaryop(operator.invert, instr) def get_next_instr(self, name): try: next_instr = self.block[self.index] except IndexError: return None if next_instr.name == name: return next_instr return None def eval_UNARY_NOT(self, instr): # Note: UNARY_NOT <const> is not optimized next_instr = self.get_next_instr("POP_JUMP_IF_FALSE") if next_instr is None: return None # Replace UNARY_NOT+POP_JUMP_IF_FALSE with POP_JUMP_IF_TRUE instr.set("POP_JUMP_IF_TRUE", next_instr.arg) del self.block[self.index] def binop(self, op, instr): try: left = self.const_stack[-2] right = self.const_stack[-1] except IndexError: return try: result = op(left, right) except Exception: return if not self.check_result(result): return self.replace_load_const(2, instr, result) def eval_BINARY_ADD(self, instr): return self.binop(operator.add, instr) def eval_BINARY_SUBTRACT(self, instr): return self.binop(operator.sub, instr) def eval_BINARY_MULTIPLY(self, instr): return self.binop(operator.mul, instr) def eval_BINARY_TRUE_DIVIDE(self, instr): return self.binop(operator.truediv, instr) def eval_BINARY_FLOOR_DIVIDE(self, instr): return self.binop(operator.floordiv, instr) def eval_BINARY_MODULO(self, instr): return self.binop(operator.mod, instr) def eval_BINARY_POWER(self, instr): return self.binop(operator.pow, instr) def eval_BINARY_LSHIFT(self, instr): return self.binop(operator.lshift, instr) def eval_BINARY_RSHIFT(self, instr): return self.binop(operator.rshift, instr) def eval_BINARY_AND(self, instr): return self.binop(operator.and_, instr) def eval_BINARY_OR(self, instr): return self.binop(operator.or_, instr) def eval_BINARY_XOR(self, instr): return self.binop(operator.xor, instr) def eval_BINARY_SUBSCR(self, instr): return self.binop(operator.getitem, instr) def replace_container_of_consts(self, instr, container_type): items = self.const_stack[-instr.arg :] value = container_type(items) self.replace_load_const(instr.arg, instr, value) def build_tuple_unpack_seq(self, instr): next_instr = self.get_next_instr("UNPACK_SEQUENCE") if next_instr is None or next_instr.arg != instr.arg: return if instr.arg < 1: return if self.const_stack and instr.arg <= len(self.const_stack): nconst = instr.arg start = self.index - 1 # Rewrite LOAD_CONST instructions in the reverse order load_consts = self.block[start - nconst : start] self.block[start - nconst : start] = reversed(load_consts) # Remove BUILD_TUPLE+UNPACK_SEQUENCE self.block[start : start + 2] = () self.index -= 2 self.const_stack.clear() return if instr.arg == 1: # Replace BUILD_TUPLE 1 + UNPACK_SEQUENCE 1 with NOP del self.block[self.index - 1 : self.index + 1] elif instr.arg == 2: # Replace BUILD_TUPLE 2 + UNPACK_SEQUENCE 2 with ROT_TWO rot2 = Instr("ROT_TWO", lineno=instr.lineno) self.block[self.index - 1 : self.index + 1] = (rot2,) self.index -= 1 self.const_stack.clear() elif instr.arg == 3: # Replace BUILD_TUPLE 3 + UNPACK_SEQUENCE 3 # with ROT_THREE + ROT_TWO rot3 = Instr("ROT_THREE", lineno=instr.lineno) rot2 = Instr("ROT_TWO", lineno=instr.lineno) self.block[self.index - 1 : self.index + 1] = (rot3, rot2) self.index -= 1 self.const_stack.clear() def build_tuple(self, instr, container_type): if instr.arg > len(self.const_stack): return next_instr = self.get_next_instr("COMPARE_OP") if next_instr is None or next_instr.arg not in (Compare.IN, Compare.NOT_IN): return self.replace_container_of_consts(instr, container_type) return True def eval_BUILD_TUPLE(self, instr): if not instr.arg: return if instr.arg <= len(self.const_stack): self.replace_container_of_consts(instr, tuple) else: self.build_tuple_unpack_seq(instr) def eval_BUILD_LIST(self, instr): if not instr.arg: return if not self.build_tuple(instr, tuple): self.build_tuple_unpack_seq(instr) def eval_BUILD_SET(self, instr): if not instr.arg: return self.build_tuple(instr, frozenset) # Note: BUILD_SLICE is not optimized def eval_COMPARE_OP(self, instr): # Note: COMPARE_OP: 2 < 3 is not optimized try: new_arg = NOT_COMPARE[instr.arg] except KeyError: return if self.get_next_instr("UNARY_NOT") is None: return # not (a is b) --> a is not b # not (a in b) --> a not in b # not (a is not b) --> a is b # not (a not in b) --> a in b instr.arg = new_arg self.block[self.index - 1 : self.index + 1] = (instr,) def jump_if_or_pop(self, instr): # Simplify conditional jump to conditional jump where the # result of the first test implies the success of a similar # test or the failure of the opposite test. # # Arises in code like: # "if a and b:" # "if a or b:" # "a and b or c" # "(a and b) and c" # # x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_FALSE_OR_POP z # --> x:JUMP_IF_FALSE_OR_POP z # # x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_TRUE_OR_POP z # --> x:POP_JUMP_IF_FALSE y+3 # where y+3 is the instruction following the second test. target_block = instr.arg try: target_instr = target_block[0] except IndexError: return if not target_instr.is_cond_jump(): self.optimize_jump_to_cond_jump(instr) return if (target_instr.name in JUMPS_ON_TRUE) == (instr.name in JUMPS_ON_TRUE): # The second jump will be taken iff the first is. target2 = target_instr.arg # The current opcode inherits its target's stack behaviour instr.name = target_instr.name instr.arg = target2 self.block[self.index - 1] = instr self.index -= 1 else: # The second jump is not taken if the first is (so jump past it), # and all conditional jumps pop their argument when they're not # taken (so change the first jump to pop its argument when it's # taken). if instr.name in JUMPS_ON_TRUE: name = "POP_JUMP_IF_TRUE" else: name = "POP_JUMP_IF_FALSE" new_label = self.code.split_block(target_block, 1) instr.name = name instr.arg = new_label self.block[self.index - 1] = instr self.index -= 1 def eval_JUMP_IF_FALSE_OR_POP(self, instr): self.jump_if_or_pop(instr) def eval_JUMP_IF_TRUE_OR_POP(self, instr): self.jump_if_or_pop(instr) def eval_NOP(self, instr): # Remove NOP del self.block[self.index - 1] self.index -= 1 def optimize_jump_to_cond_jump(self, instr): # Replace jumps to unconditional jumps jump_label = instr.arg assert isinstance(jump_label, BasicBlock), jump_label try: target_instr = jump_label[0] except IndexError: return if instr.is_uncond_jump() and target_instr.name == "RETURN_VALUE": # Replace JUMP_ABSOLUTE => RETURN_VALUE with RETURN_VALUE self.block[self.index - 1] = target_instr elif target_instr.is_uncond_jump(): # Replace JUMP_FORWARD t1 jumping to JUMP_FORWARD t2 # with JUMP_ABSOLUTE t2 jump_target2 = target_instr.arg name = instr.name if instr.name == "JUMP_FORWARD": name = "JUMP_ABSOLUTE" else: # FIXME: reimplement this check # if jump_target2 < 0: # # No backward relative jumps # return # FIXME: remove this workaround and implement comment code ^^ if instr.opcode in opcode.hasjrel: return instr.name = name instr.arg = jump_target2 self.block[self.index - 1] = instr def optimize_jump(self, instr): if instr.is_uncond_jump() and self.index == len(self.block): # JUMP_ABSOLUTE at the end of a block which points to the # following block: remove the jump, link the current block # to the following block block_index = self.block_index target_block = instr.arg target_block_index = self.code.get_block_index(target_block) if target_block_index == block_index: del self.block[self.index - 1] self.block.next_block = target_block return self.optimize_jump_to_cond_jump(instr) def iterblock(self, block): self.block = block self.index = 0 while self.index < len(block): instr = self.block[self.index] self.index += 1 yield instr def optimize_block(self, block): self.const_stack.clear() self.in_consts = False for instr in self.iterblock(block): if not self.in_consts: self.const_stack.clear() self.in_consts = False meth_name = "eval_%s" % instr.name meth = getattr(self, meth_name, None) if meth is not None: meth(instr) elif instr.has_jump(): self.optimize_jump(instr) # Note: Skipping over LOAD_CONST trueconst; POP_JUMP_IF_FALSE # <target> is not implemented, since it looks like the optimization # is never trigerred in practice. The compiler already optimizes if # and while statements. def remove_dead_blocks(self): # FIXME: remove empty blocks? used_blocks = {id(self.code[0])} for block in self.code: if block.next_block is not None: used_blocks.add(id(block.next_block)) for instr in block: if isinstance(instr, Instr) and isinstance(instr.arg, BasicBlock): used_blocks.add(id(instr.arg)) block_index = 0 while block_index < len(self.code): block = self.code[block_index] if id(block) not in used_blocks: del self.code[block_index] else: block_index += 1 # FIXME: merge following blocks if block1 does not contain any # jump and block1.next_block is block2 def optimize_cfg(self, cfg): self.code = cfg self.const_stack = [] self.remove_dead_blocks() self.block_index = 0 while self.block_index < len(self.code): block = self.code[self.block_index] self.block_index += 1 self.optimize_block(block) def optimize(self, code_obj): bytecode = Bytecode.from_code(code_obj) cfg = ControlFlowGraph.from_bytecode(bytecode) self.optimize_cfg(cfg) bytecode = cfg.to_bytecode() code = bytecode.to_code() return code # Code transformer for the PEP 511 class CodeTransformer: name = "pyopt" def code_transformer(self, code, context): if sys.flags.verbose: print( "Optimize %s:%s: %s" % (code.co_filename, code.co_firstlineno, code.co_name) ) optimizer = PeepholeOptimizer() return optimizer.optimize(code)
15,740
Python
30.993902
103
0.581004
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/instr.py
import enum import dis import opcode as _opcode import sys from marshal import dumps as _dumps from _pydevd_frame_eval.vendored import bytecode as _bytecode @enum.unique class Compare(enum.IntEnum): LT = 0 LE = 1 EQ = 2 NE = 3 GT = 4 GE = 5 IN = 6 NOT_IN = 7 IS = 8 IS_NOT = 9 EXC_MATCH = 10 UNSET = object() def const_key(obj): try: return _dumps(obj) except ValueError: # For other types, we use the object identifier as an unique identifier # to ensure that they are seen as unequal. return (type(obj), id(obj)) def _pushes_back(opname): if opname in ["CALL_FINALLY"]: # CALL_FINALLY pushes the address of the "finally" block instead of a # value, hence we don't treat it as pushing back op return False return ( opname.startswith("UNARY_") or opname.startswith("GET_") # BUILD_XXX_UNPACK have been removed in 3.9 or opname.startswith("BINARY_") or opname.startswith("INPLACE_") or opname.startswith("BUILD_") or opname.startswith("CALL_") ) or opname in ( "LIST_TO_TUPLE", "LIST_EXTEND", "SET_UPDATE", "DICT_UPDATE", "DICT_MERGE", "IS_OP", "CONTAINS_OP", "FORMAT_VALUE", "MAKE_FUNCTION", "IMPORT_NAME", # technically, these three do not push back, but leave the container # object on TOS "SET_ADD", "LIST_APPEND", "MAP_ADD", "LOAD_ATTR", ) def _check_lineno(lineno): if not isinstance(lineno, int): raise TypeError("lineno must be an int") if lineno < 1: raise ValueError("invalid lineno") class SetLineno: __slots__ = ("_lineno",) def __init__(self, lineno): _check_lineno(lineno) self._lineno = lineno @property def lineno(self): return self._lineno def __eq__(self, other): if not isinstance(other, SetLineno): return False return self._lineno == other._lineno class Label: __slots__ = () class _Variable: __slots__ = ("name",) def __init__(self, name): self.name = name def __eq__(self, other): if type(self) != type(other): return False return self.name == other.name def __str__(self): return self.name def __repr__(self): return "<%s %r>" % (self.__class__.__name__, self.name) class CellVar(_Variable): __slots__ = () class FreeVar(_Variable): __slots__ = () def _check_arg_int(name, arg): if not isinstance(arg, int): raise TypeError( "operation %s argument must be an int, " "got %s" % (name, type(arg).__name__) ) if not (0 <= arg <= 2147483647): raise ValueError( "operation %s argument must be in " "the range 0..2,147,483,647" % name ) if sys.version_info < (3, 8): _stack_effects = { # NOTE: the entries are all 2-tuples. Entry[0/False] is non-taken jumps. # Entry[1/True] is for taken jumps. # opcodes not in dis.stack_effect _opcode.opmap["EXTENDED_ARG"]: (0, 0), _opcode.opmap["NOP"]: (0, 0), # Jump taken/not-taken are different: _opcode.opmap["JUMP_IF_TRUE_OR_POP"]: (-1, 0), _opcode.opmap["JUMP_IF_FALSE_OR_POP"]: (-1, 0), _opcode.opmap["FOR_ITER"]: (1, -1), _opcode.opmap["SETUP_WITH"]: (1, 6), _opcode.opmap["SETUP_ASYNC_WITH"]: (0, 5), _opcode.opmap["SETUP_EXCEPT"]: (0, 6), # as of 3.7, below for <=3.6 _opcode.opmap["SETUP_FINALLY"]: (0, 6), # as of 3.7, below for <=3.6 } # More stack effect values that are unique to the version of Python. if sys.version_info < (3, 7): _stack_effects.update( { _opcode.opmap["SETUP_WITH"]: (7, 7), _opcode.opmap["SETUP_EXCEPT"]: (6, 9), _opcode.opmap["SETUP_FINALLY"]: (6, 9), } ) class Instr: """Abstract instruction.""" __slots__ = ("_name", "_opcode", "_arg", "_lineno", "offset") def __init__(self, name, arg=UNSET, *, lineno=None, offset=None): self._set(name, arg, lineno) self.offset = offset def _check_arg(self, name, opcode, arg): if name == "EXTENDED_ARG": raise ValueError( "only concrete instruction can contain EXTENDED_ARG, " "highlevel instruction can represent arbitrary argument without it" ) if opcode >= _opcode.HAVE_ARGUMENT: if arg is UNSET: raise ValueError("operation %s requires an argument" % name) else: if arg is not UNSET: raise ValueError("operation %s has no argument" % name) if self._has_jump(opcode): if not isinstance(arg, (Label, _bytecode.BasicBlock)): raise TypeError( "operation %s argument type must be " "Label or BasicBlock, got %s" % (name, type(arg).__name__) ) elif opcode in _opcode.hasfree: if not isinstance(arg, (CellVar, FreeVar)): raise TypeError( "operation %s argument must be CellVar " "or FreeVar, got %s" % (name, type(arg).__name__) ) elif opcode in _opcode.haslocal or opcode in _opcode.hasname: if not isinstance(arg, str): raise TypeError( "operation %s argument must be a str, " "got %s" % (name, type(arg).__name__) ) elif opcode in _opcode.hasconst: if isinstance(arg, Label): raise ValueError( "label argument cannot be used " "in %s operation" % name ) if isinstance(arg, _bytecode.BasicBlock): raise ValueError( "block argument cannot be used " "in %s operation" % name ) elif opcode in _opcode.hascompare: if not isinstance(arg, Compare): raise TypeError( "operation %s argument type must be " "Compare, got %s" % (name, type(arg).__name__) ) elif opcode >= _opcode.HAVE_ARGUMENT: _check_arg_int(name, arg) def _set(self, name, arg, lineno): if not isinstance(name, str): raise TypeError("operation name must be a str") try: opcode = _opcode.opmap[name] except KeyError: raise ValueError("invalid operation name") # check lineno if lineno is not None: _check_lineno(lineno) self._check_arg(name, opcode, arg) self._name = name self._opcode = opcode self._arg = arg self._lineno = lineno def set(self, name, arg=UNSET): """Modify the instruction in-place. Replace name and arg attributes. Don't modify lineno. """ self._set(name, arg, self._lineno) def require_arg(self): """Does the instruction require an argument?""" return self._opcode >= _opcode.HAVE_ARGUMENT @property def name(self): return self._name @name.setter def name(self, name): self._set(name, self._arg, self._lineno) @property def opcode(self): return self._opcode @opcode.setter def opcode(self, op): if not isinstance(op, int): raise TypeError("operator code must be an int") if 0 <= op <= 255: name = _opcode.opname[op] valid = name != "<%r>" % op else: valid = False if not valid: raise ValueError("invalid operator code") self._set(name, self._arg, self._lineno) @property def arg(self): return self._arg @arg.setter def arg(self, arg): self._set(self._name, arg, self._lineno) @property def lineno(self): return self._lineno @lineno.setter def lineno(self, lineno): self._set(self._name, self._arg, lineno) def stack_effect(self, jump=None): if self._opcode < _opcode.HAVE_ARGUMENT: arg = None elif not isinstance(self._arg, int) or self._opcode in _opcode.hasconst: # Argument is either a non-integer or an integer constant, # not oparg. arg = 0 else: arg = self._arg if sys.version_info < (3, 8): effect = _stack_effects.get(self._opcode, None) if effect is not None: return max(effect) if jump is None else effect[jump] return dis.stack_effect(self._opcode, arg) else: return dis.stack_effect(self._opcode, arg, jump=jump) def pre_and_post_stack_effect(self, jump=None): _effect = self.stack_effect(jump=jump) # To compute pre size and post size to avoid segfault cause by not enough # stack element _opname = _opcode.opname[self._opcode] if _opname.startswith("DUP_TOP"): return _effect * -1, _effect * 2 if _pushes_back(_opname): # if the op pushes value back to the stack, then the stack effect given # by dis.stack_effect actually equals pre + post effect, therefore we need # -1 from the stack effect as a pre condition return _effect - 1, 1 if _opname.startswith("UNPACK_"): # Instr(UNPACK_* , n) pops 1 and pushes n # _effect = n - 1 # hence we return -1, _effect + 1 return -1, _effect + 1 if _opname == "FOR_ITER" and not jump: # Since FOR_ITER needs TOS to be an iterator, which basically means # a prerequisite of 1 on the stack return -1, 2 if _opname == "ROT_N": return (-self._arg, self._arg) return {"ROT_TWO": (-2, 2), "ROT_THREE": (-3, 3), "ROT_FOUR": (-4, 4)}.get( _opname, (_effect, 0) ) def copy(self): return self.__class__(self._name, self._arg, lineno=self._lineno, offset=self.offset) def __repr__(self): if self._arg is not UNSET: return "<%s arg=%r lineno=%s>" % (self._name, self._arg, self._lineno) else: return "<%s lineno=%s>" % (self._name, self._lineno) def _cmp_key(self, labels=None): arg = self._arg if self._opcode in _opcode.hasconst: arg = const_key(arg) elif isinstance(arg, Label) and labels is not None: arg = labels[arg] return (self._lineno, self._name, arg) def __eq__(self, other): if type(self) != type(other): return False return self._cmp_key() == other._cmp_key() @staticmethod def _has_jump(opcode): return opcode in _opcode.hasjrel or opcode in _opcode.hasjabs def has_jump(self): return self._has_jump(self._opcode) def is_cond_jump(self): """Is a conditional jump?""" # Ex: POP_JUMP_IF_TRUE, JUMP_IF_FALSE_OR_POP return "JUMP_IF_" in self._name def is_uncond_jump(self): """Is an unconditional jump?""" return self.name in {"JUMP_FORWARD", "JUMP_ABSOLUTE"} def is_final(self): if self._name in { "RETURN_VALUE", "RAISE_VARARGS", "RERAISE", "BREAK_LOOP", "CONTINUE_LOOP", }: return True if self.is_uncond_jump(): return True return False
11,721
Python
28.526448
93
0.534255
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/concrete.py
import dis import inspect import opcode as _opcode import struct import sys import types # alias to keep the 'bytecode' variable free from _pydevd_frame_eval.vendored import bytecode as _bytecode from _pydevd_frame_eval.vendored.bytecode.instr import ( UNSET, Instr, Label, SetLineno, FreeVar, CellVar, Compare, const_key, _check_arg_int, ) # - jumps use instruction # - lineno use bytes (dis.findlinestarts(code)) # - dis displays bytes OFFSET_AS_INSTRUCTION = sys.version_info >= (3, 10) def _set_docstring(code, consts): if not consts: return first_const = consts[0] if isinstance(first_const, str) or first_const is None: code.docstring = first_const class ConcreteInstr(Instr): """Concrete instruction. arg must be an integer in the range 0..2147483647. It has a read-only size attribute. """ __slots__ = ("_size", "_extended_args", "offset") def __init__(self, name, arg=UNSET, *, lineno=None, extended_args=None, offset=None): # Allow to remember a potentially meaningless EXTENDED_ARG emitted by # Python to properly compute the size and avoid messing up the jump # targets self._extended_args = extended_args self._set(name, arg, lineno) self.offset = offset def _check_arg(self, name, opcode, arg): if opcode >= _opcode.HAVE_ARGUMENT: if arg is UNSET: raise ValueError("operation %s requires an argument" % name) _check_arg_int(name, arg) else: if arg is not UNSET: raise ValueError("operation %s has no argument" % name) def _set(self, name, arg, lineno): super()._set(name, arg, lineno) size = 2 if arg is not UNSET: while arg > 0xFF: size += 2 arg >>= 8 if self._extended_args is not None: size = 2 + 2 * self._extended_args self._size = size @property def size(self): return self._size def _cmp_key(self, labels=None): return (self._lineno, self._name, self._arg) def get_jump_target(self, instr_offset): if self._opcode in _opcode.hasjrel: s = (self._size // 2) if OFFSET_AS_INSTRUCTION else self._size return instr_offset + s + self._arg if self._opcode in _opcode.hasjabs: return self._arg return None def assemble(self): if self._arg is UNSET: return bytes((self._opcode, 0)) arg = self._arg b = [self._opcode, arg & 0xFF] while arg > 0xFF: arg >>= 8 b[:0] = [_opcode.EXTENDED_ARG, arg & 0xFF] if self._extended_args: while len(b) < self._size: b[:0] = [_opcode.EXTENDED_ARG, 0x00] return bytes(b) @classmethod def disassemble(cls, lineno, code, offset): index = 2 * offset if OFFSET_AS_INSTRUCTION else offset op = code[index] if op >= _opcode.HAVE_ARGUMENT: arg = code[index + 1] else: arg = UNSET name = _opcode.opname[op] # fabioz: added offset to ConcreteBytecode # Need to keep an eye on https://github.com/MatthieuDartiailh/bytecode/issues/48 in # case the library decides to add this in some other way. return cls(name, arg, lineno=lineno, offset=index) class ConcreteBytecode(_bytecode._BaseBytecodeList): def __init__(self, instructions=(), *, consts=(), names=(), varnames=()): super().__init__() self.consts = list(consts) self.names = list(names) self.varnames = list(varnames) for instr in instructions: self._check_instr(instr) self.extend(instructions) def __iter__(self): instructions = super().__iter__() for instr in instructions: self._check_instr(instr) yield instr def _check_instr(self, instr): if not isinstance(instr, (ConcreteInstr, SetLineno)): raise ValueError( "ConcreteBytecode must only contain " "ConcreteInstr and SetLineno objects, " "but %s was found" % type(instr).__name__ ) def _copy_attr_from(self, bytecode): super()._copy_attr_from(bytecode) if isinstance(bytecode, ConcreteBytecode): self.consts = bytecode.consts self.names = bytecode.names self.varnames = bytecode.varnames def __repr__(self): return "<ConcreteBytecode instr#=%s>" % len(self) def __eq__(self, other): if type(self) != type(other): return False const_keys1 = list(map(const_key, self.consts)) const_keys2 = list(map(const_key, other.consts)) if const_keys1 != const_keys2: return False if self.names != other.names: return False if self.varnames != other.varnames: return False return super().__eq__(other) @staticmethod def from_code(code, *, extended_arg=False): line_starts = dict(dis.findlinestarts(code)) # find block starts instructions = [] offset = 0 lineno = code.co_firstlineno while offset < (len(code.co_code) // (2 if OFFSET_AS_INSTRUCTION else 1)): lineno_off = (2 * offset) if OFFSET_AS_INSTRUCTION else offset if lineno_off in line_starts: lineno = line_starts[lineno_off] instr = ConcreteInstr.disassemble(lineno, code.co_code, offset) instructions.append(instr) offset += (instr.size // 2) if OFFSET_AS_INSTRUCTION else instr.size bytecode = ConcreteBytecode() # replace jump targets with blocks # HINT : in some cases Python generate useless EXTENDED_ARG opcode # with a value of zero. Such opcodes do not increases the size of the # following opcode the way a normal EXTENDED_ARG does. As a # consequence, they need to be tracked manually as otherwise the # offsets in jump targets can end up being wrong. if not extended_arg: # The list is modified in place bytecode._remove_extended_args(instructions) bytecode.name = code.co_name bytecode.filename = code.co_filename bytecode.flags = code.co_flags bytecode.argcount = code.co_argcount if sys.version_info >= (3, 8): bytecode.posonlyargcount = code.co_posonlyargcount bytecode.kwonlyargcount = code.co_kwonlyargcount bytecode.first_lineno = code.co_firstlineno bytecode.names = list(code.co_names) bytecode.consts = list(code.co_consts) bytecode.varnames = list(code.co_varnames) bytecode.freevars = list(code.co_freevars) bytecode.cellvars = list(code.co_cellvars) _set_docstring(bytecode, code.co_consts) bytecode[:] = instructions return bytecode @staticmethod def _normalize_lineno(instructions, first_lineno): lineno = first_lineno for instr in instructions: # if instr.lineno is not set, it's inherited from the previous # instruction, or from self.first_lineno if instr.lineno is not None: lineno = instr.lineno if isinstance(instr, ConcreteInstr): yield (lineno, instr) def _assemble_code(self): offset = 0 code_str = [] linenos = [] for lineno, instr in self._normalize_lineno(self, self.first_lineno): code_str.append(instr.assemble()) i_size = instr.size linenos.append( ((offset * 2) if OFFSET_AS_INSTRUCTION else offset, i_size, lineno) ) offset += (i_size // 2) if OFFSET_AS_INSTRUCTION else i_size code_str = b"".join(code_str) return (code_str, linenos) @staticmethod def _assemble_lnotab(first_lineno, linenos): lnotab = [] old_offset = 0 old_lineno = first_lineno for offset, _, lineno in linenos: dlineno = lineno - old_lineno if dlineno == 0: continue # FIXME: be kind, force monotonic line numbers? add an option? if dlineno < 0 and sys.version_info < (3, 6): raise ValueError( "negative line number delta is not supported " "on Python < 3.6" ) old_lineno = lineno doff = offset - old_offset old_offset = offset while doff > 255: lnotab.append(b"\xff\x00") doff -= 255 while dlineno < -128: lnotab.append(struct.pack("Bb", doff, -128)) doff = 0 dlineno -= -128 while dlineno > 127: lnotab.append(struct.pack("Bb", doff, 127)) doff = 0 dlineno -= 127 assert 0 <= doff <= 255 assert -128 <= dlineno <= 127 lnotab.append(struct.pack("Bb", doff, dlineno)) return b"".join(lnotab) @staticmethod def _pack_linetable(doff, dlineno, linetable): while dlineno < -127: linetable.append(struct.pack("Bb", 0, -127)) dlineno -= -127 while dlineno > 127: linetable.append(struct.pack("Bb", 0, 127)) dlineno -= 127 if doff > 254: linetable.append(struct.pack("Bb", 254, dlineno)) doff -= 254 while doff > 254: linetable.append(b"\xfe\x00") doff -= 254 linetable.append(struct.pack("Bb", doff, 0)) else: linetable.append(struct.pack("Bb", doff, dlineno)) assert 0 <= doff <= 254 assert -127 <= dlineno <= 127 def _assemble_linestable(self, first_lineno, linenos): if not linenos: return b"" linetable = [] old_offset = 0 iter_in = iter(linenos) offset, i_size, old_lineno = next(iter_in) old_dlineno = old_lineno - first_lineno for offset, i_size, lineno in iter_in: dlineno = lineno - old_lineno if dlineno == 0: continue old_lineno = lineno doff = offset - old_offset old_offset = offset self._pack_linetable(doff, old_dlineno, linetable) old_dlineno = dlineno # Pack the line of the last instruction. doff = offset + i_size - old_offset self._pack_linetable(doff, old_dlineno, linetable) return b"".join(linetable) @staticmethod def _remove_extended_args(instructions): # replace jump targets with blocks # HINT : in some cases Python generate useless EXTENDED_ARG opcode # with a value of zero. Such opcodes do not increases the size of the # following opcode the way a normal EXTENDED_ARG does. As a # consequence, they need to be tracked manually as otherwise the # offsets in jump targets can end up being wrong. nb_extended_args = 0 extended_arg = None index = 0 while index < len(instructions): instr = instructions[index] # Skip SetLineno meta instruction if isinstance(instr, SetLineno): index += 1 continue if instr.name == "EXTENDED_ARG": nb_extended_args += 1 if extended_arg is not None: extended_arg = (extended_arg << 8) + instr.arg else: extended_arg = instr.arg del instructions[index] continue if extended_arg is not None: arg = (extended_arg << 8) + instr.arg extended_arg = None instr = ConcreteInstr( instr.name, arg, lineno=instr.lineno, extended_args=nb_extended_args, offset=instr.offset, ) instructions[index] = instr nb_extended_args = 0 index += 1 if extended_arg is not None: raise ValueError("EXTENDED_ARG at the end of the code") def compute_stacksize(self, *, check_pre_and_post=True): bytecode = self.to_bytecode() cfg = _bytecode.ControlFlowGraph.from_bytecode(bytecode) return cfg.compute_stacksize(check_pre_and_post=check_pre_and_post) def to_code(self, stacksize=None, *, check_pre_and_post=True): code_str, linenos = self._assemble_code() lnotab = ( self._assemble_linestable(self.first_lineno, linenos) if sys.version_info >= (3, 10) else self._assemble_lnotab(self.first_lineno, linenos) ) nlocals = len(self.varnames) if stacksize is None: stacksize = self.compute_stacksize(check_pre_and_post=check_pre_and_post) if sys.version_info < (3, 8): return types.CodeType( self.argcount, self.kwonlyargcount, nlocals, stacksize, int(self.flags), code_str, tuple(self.consts), tuple(self.names), tuple(self.varnames), self.filename, self.name, self.first_lineno, lnotab, tuple(self.freevars), tuple(self.cellvars), ) else: return types.CodeType( self.argcount, self.posonlyargcount, self.kwonlyargcount, nlocals, stacksize, int(self.flags), code_str, tuple(self.consts), tuple(self.names), tuple(self.varnames), self.filename, self.name, self.first_lineno, lnotab, tuple(self.freevars), tuple(self.cellvars), ) def to_bytecode(self): # Copy instruction and remove extended args if any (in-place) c_instructions = self[:] self._remove_extended_args(c_instructions) # find jump targets jump_targets = set() offset = 0 for instr in c_instructions: if isinstance(instr, SetLineno): continue target = instr.get_jump_target(offset) if target is not None: jump_targets.add(target) offset += (instr.size // 2) if OFFSET_AS_INSTRUCTION else instr.size # create labels jumps = [] instructions = [] labels = {} offset = 0 ncells = len(self.cellvars) for lineno, instr in self._normalize_lineno(c_instructions, self.first_lineno): if offset in jump_targets: label = Label() labels[offset] = label instructions.append(label) jump_target = instr.get_jump_target(offset) size = instr.size arg = instr.arg # FIXME: better error reporting if instr.opcode in _opcode.hasconst: arg = self.consts[arg] elif instr.opcode in _opcode.haslocal: arg = self.varnames[arg] elif instr.opcode in _opcode.hasname: arg = self.names[arg] elif instr.opcode in _opcode.hasfree: if arg < ncells: name = self.cellvars[arg] arg = CellVar(name) else: name = self.freevars[arg - ncells] arg = FreeVar(name) elif instr.opcode in _opcode.hascompare: arg = Compare(arg) if jump_target is None: instr = Instr(instr.name, arg, lineno=lineno, offset=instr.offset) else: instr_index = len(instructions) instructions.append(instr) offset += (size // 2) if OFFSET_AS_INSTRUCTION else size if jump_target is not None: jumps.append((instr_index, jump_target)) # replace jump targets with labels for index, jump_target in jumps: instr = instructions[index] # FIXME: better error reporting on missing label label = labels[jump_target] instructions[index] = Instr(instr.name, label, lineno=instr.lineno, offset=instr.offset) bytecode = _bytecode.Bytecode() bytecode._copy_attr_from(self) nargs = bytecode.argcount + bytecode.kwonlyargcount if sys.version_info > (3, 8): nargs += bytecode.posonlyargcount if bytecode.flags & inspect.CO_VARARGS: nargs += 1 if bytecode.flags & inspect.CO_VARKEYWORDS: nargs += 1 bytecode.argnames = self.varnames[:nargs] _set_docstring(bytecode, self.consts) bytecode.extend(instructions) return bytecode class _ConvertBytecodeToConcrete: # Default number of passes of compute_jumps() before giving up. Refer to # assemble_jump_offsets() in compile.c for background. _compute_jumps_passes = 10 def __init__(self, code): assert isinstance(code, _bytecode.Bytecode) self.bytecode = code # temporary variables self.instructions = [] self.jumps = [] self.labels = {} # used to build ConcreteBytecode() object self.consts_indices = {} self.consts_list = [] self.names = [] self.varnames = [] def add_const(self, value): key = const_key(value) if key in self.consts_indices: return self.consts_indices[key] index = len(self.consts_indices) self.consts_indices[key] = index self.consts_list.append(value) return index @staticmethod def add(names, name): try: index = names.index(name) except ValueError: index = len(names) names.append(name) return index def concrete_instructions(self): ncells = len(self.bytecode.cellvars) lineno = self.bytecode.first_lineno for instr in self.bytecode: if isinstance(instr, Label): self.labels[instr] = len(self.instructions) continue if isinstance(instr, SetLineno): lineno = instr.lineno continue if isinstance(instr, ConcreteInstr): instr = instr.copy() else: assert isinstance(instr, Instr) if instr.lineno is not None: lineno = instr.lineno arg = instr.arg is_jump = isinstance(arg, Label) if is_jump: label = arg # fake value, real value is set in compute_jumps() arg = 0 elif instr.opcode in _opcode.hasconst: arg = self.add_const(arg) elif instr.opcode in _opcode.haslocal: arg = self.add(self.varnames, arg) elif instr.opcode in _opcode.hasname: arg = self.add(self.names, arg) elif instr.opcode in _opcode.hasfree: if isinstance(arg, CellVar): arg = self.bytecode.cellvars.index(arg.name) else: assert isinstance(arg, FreeVar) arg = ncells + self.bytecode.freevars.index(arg.name) elif instr.opcode in _opcode.hascompare: if isinstance(arg, Compare): arg = arg.value instr = ConcreteInstr(instr.name, arg, lineno=lineno) if is_jump: self.jumps.append((len(self.instructions), label, instr)) self.instructions.append(instr) def compute_jumps(self): offsets = [] offset = 0 for index, instr in enumerate(self.instructions): offsets.append(offset) offset += instr.size // 2 if OFFSET_AS_INSTRUCTION else instr.size # needed if a label is at the end offsets.append(offset) # fix argument of jump instructions: resolve labels modified = False for index, label, instr in self.jumps: target_index = self.labels[label] target_offset = offsets[target_index] if instr.opcode in _opcode.hasjrel: instr_offset = offsets[index] target_offset -= instr_offset + ( instr.size // 2 if OFFSET_AS_INSTRUCTION else instr.size ) old_size = instr.size # FIXME: better error report if target_offset is negative instr.arg = target_offset if instr.size != old_size: modified = True return modified def to_concrete_bytecode(self, compute_jumps_passes=None): if compute_jumps_passes is None: compute_jumps_passes = self._compute_jumps_passes first_const = self.bytecode.docstring if first_const is not UNSET: self.add_const(first_const) self.varnames.extend(self.bytecode.argnames) self.concrete_instructions() for pas in range(0, compute_jumps_passes): modified = self.compute_jumps() if not modified: break else: raise RuntimeError( "compute_jumps() failed to converge after" " %d passes" % (pas + 1) ) concrete = ConcreteBytecode( self.instructions, consts=self.consts_list.copy(), names=self.names, varnames=self.varnames, ) concrete._copy_attr_from(self.bytecode) return concrete
22,299
Python
32.086053
100
0.546033
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/__init__.py
__version__ = "0.13.0.dev" __all__ = [ "Label", "Instr", "SetLineno", "Bytecode", "ConcreteInstr", "ConcreteBytecode", "ControlFlowGraph", "CompilerFlags", "Compare", ] from _pydevd_frame_eval.vendored.bytecode.flags import CompilerFlags from _pydevd_frame_eval.vendored.bytecode.instr import ( UNSET, Label, SetLineno, Instr, CellVar, FreeVar, # noqa Compare, ) from _pydevd_frame_eval.vendored.bytecode.bytecode import ( BaseBytecode, _BaseBytecodeList, _InstrList, Bytecode, ) # noqa from _pydevd_frame_eval.vendored.bytecode.concrete import ( ConcreteInstr, ConcreteBytecode, # noqa # import needed to use it in bytecode.py _ConvertBytecodeToConcrete, ) from _pydevd_frame_eval.vendored.bytecode.cfg import BasicBlock, ControlFlowGraph # noqa import sys def dump_bytecode(bytecode, *, lineno=False, stream=sys.stdout): def format_line(index, line): nonlocal cur_lineno, prev_lineno if lineno: if cur_lineno != prev_lineno: line = "L.% 3s % 3s: %s" % (cur_lineno, index, line) prev_lineno = cur_lineno else: line = " % 3s: %s" % (index, line) else: line = line return line def format_instr(instr, labels=None): text = instr.name arg = instr._arg if arg is not UNSET: if isinstance(arg, Label): try: arg = "<%s>" % labels[arg] except KeyError: arg = "<error: unknown label>" elif isinstance(arg, BasicBlock): try: arg = "<%s>" % labels[id(arg)] except KeyError: arg = "<error: unknown block>" else: arg = repr(arg) text = "%s %s" % (text, arg) return text indent = " " * 4 cur_lineno = bytecode.first_lineno prev_lineno = None if isinstance(bytecode, ConcreteBytecode): offset = 0 for instr in bytecode: fields = [] if instr.lineno is not None: cur_lineno = instr.lineno if lineno: fields.append(format_instr(instr)) line = "".join(fields) line = format_line(offset, line) else: fields.append("% 3s %s" % (offset, format_instr(instr))) line = "".join(fields) print(line, file=stream) offset += instr.size elif isinstance(bytecode, Bytecode): labels = {} for index, instr in enumerate(bytecode): if isinstance(instr, Label): labels[instr] = "label_instr%s" % index for index, instr in enumerate(bytecode): if isinstance(instr, Label): label = labels[instr] line = "%s:" % label if index != 0: print(file=stream) else: if instr.lineno is not None: cur_lineno = instr.lineno line = format_instr(instr, labels) line = indent + format_line(index, line) print(line, file=stream) print(file=stream) elif isinstance(bytecode, ControlFlowGraph): labels = {} for block_index, block in enumerate(bytecode, 1): labels[id(block)] = "block%s" % block_index for block_index, block in enumerate(bytecode, 1): print("%s:" % labels[id(block)], file=stream) prev_lineno = None for index, instr in enumerate(block): if instr.lineno is not None: cur_lineno = instr.lineno line = format_instr(instr, labels) line = indent + format_line(index, line) print(line, file=stream) if block.next_block is not None: print(indent + "-> %s" % labels[id(block.next_block)], file=stream) print(file=stream) else: raise TypeError("unknown bytecode class")
4,152
Python
30.70229
89
0.526734
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/bytecode.py
# alias to keep the 'bytecode' variable free import sys from _pydevd_frame_eval.vendored import bytecode as _bytecode from _pydevd_frame_eval.vendored.bytecode.instr import UNSET, Label, SetLineno, Instr from _pydevd_frame_eval.vendored.bytecode.flags import infer_flags class BaseBytecode: def __init__(self): self.argcount = 0 if sys.version_info > (3, 8): self.posonlyargcount = 0 self.kwonlyargcount = 0 self.first_lineno = 1 self.name = "<module>" self.filename = "<string>" self.docstring = UNSET self.cellvars = [] # we cannot recreate freevars from instructions because of super() # special-case self.freevars = [] self._flags = _bytecode.CompilerFlags(0) def _copy_attr_from(self, bytecode): self.argcount = bytecode.argcount if sys.version_info > (3, 8): self.posonlyargcount = bytecode.posonlyargcount self.kwonlyargcount = bytecode.kwonlyargcount self.flags = bytecode.flags self.first_lineno = bytecode.first_lineno self.name = bytecode.name self.filename = bytecode.filename self.docstring = bytecode.docstring self.cellvars = list(bytecode.cellvars) self.freevars = list(bytecode.freevars) def __eq__(self, other): if type(self) != type(other): return False if self.argcount != other.argcount: return False if sys.version_info > (3, 8): if self.posonlyargcount != other.posonlyargcount: return False if self.kwonlyargcount != other.kwonlyargcount: return False if self.flags != other.flags: return False if self.first_lineno != other.first_lineno: return False if self.filename != other.filename: return False if self.name != other.name: return False if self.docstring != other.docstring: return False if self.cellvars != other.cellvars: return False if self.freevars != other.freevars: return False if self.compute_stacksize() != other.compute_stacksize(): return False return True @property def flags(self): return self._flags @flags.setter def flags(self, value): if not isinstance(value, _bytecode.CompilerFlags): value = _bytecode.CompilerFlags(value) self._flags = value def update_flags(self, *, is_async=None): self.flags = infer_flags(self, is_async) class _BaseBytecodeList(BaseBytecode, list): """List subclass providing type stable slicing and copying.""" def __getitem__(self, index): value = super().__getitem__(index) if isinstance(index, slice): value = type(self)(value) value._copy_attr_from(self) return value def copy(self): new = type(self)(super().copy()) new._copy_attr_from(self) return new def legalize(self): """Check that all the element of the list are valid and remove SetLineno.""" lineno_pos = [] set_lineno = None current_lineno = self.first_lineno for pos, instr in enumerate(self): if isinstance(instr, SetLineno): set_lineno = instr.lineno lineno_pos.append(pos) continue # Filter out Labels if not isinstance(instr, Instr): continue if set_lineno is not None: instr.lineno = set_lineno elif instr.lineno is None: instr.lineno = current_lineno else: current_lineno = instr.lineno for i in reversed(lineno_pos): del self[i] def __iter__(self): instructions = super().__iter__() for instr in instructions: self._check_instr(instr) yield instr def _check_instr(self, instr): raise NotImplementedError() class _InstrList(list): def _flat(self): instructions = [] labels = {} jumps = [] offset = 0 for index, instr in enumerate(self): if isinstance(instr, Label): instructions.append("label_instr%s" % index) labels[instr] = offset else: if isinstance(instr, Instr) and isinstance(instr.arg, Label): target_label = instr.arg instr = _bytecode.ConcreteInstr(instr.name, 0, lineno=instr.lineno) jumps.append((target_label, instr)) instructions.append(instr) offset += 1 for target_label, instr in jumps: instr.arg = labels[target_label] return instructions def __eq__(self, other): if not isinstance(other, _InstrList): other = _InstrList(other) return self._flat() == other._flat() class Bytecode(_InstrList, _BaseBytecodeList): def __init__(self, instructions=()): BaseBytecode.__init__(self) self.argnames = [] for instr in instructions: self._check_instr(instr) self.extend(instructions) def __iter__(self): instructions = super().__iter__() for instr in instructions: self._check_instr(instr) yield instr def _check_instr(self, instr): if not isinstance(instr, (Label, SetLineno, Instr)): raise ValueError( "Bytecode must only contain Label, " "SetLineno, and Instr objects, " "but %s was found" % type(instr).__name__ ) def _copy_attr_from(self, bytecode): super()._copy_attr_from(bytecode) if isinstance(bytecode, Bytecode): self.argnames = bytecode.argnames @staticmethod def from_code(code): concrete = _bytecode.ConcreteBytecode.from_code(code) return concrete.to_bytecode() def compute_stacksize(self, *, check_pre_and_post=True): cfg = _bytecode.ControlFlowGraph.from_bytecode(self) return cfg.compute_stacksize(check_pre_and_post=check_pre_and_post) def to_code( self, compute_jumps_passes=None, stacksize=None, *, check_pre_and_post=True ): # Prevent reconverting the concrete bytecode to bytecode and cfg to do the # calculation if we need to do it. if stacksize is None: stacksize = self.compute_stacksize(check_pre_and_post=check_pre_and_post) bc = self.to_concrete_bytecode(compute_jumps_passes=compute_jumps_passes) return bc.to_code(stacksize=stacksize) def to_concrete_bytecode(self, compute_jumps_passes=None): converter = _bytecode._ConvertBytecodeToConcrete(self) return converter.to_concrete_bytecode(compute_jumps_passes=compute_jumps_passes)
6,983
Python
32.099526
88
0.587427
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/cfg.py
import sys # alias to keep the 'bytecode' variable free from _pydevd_frame_eval.vendored import bytecode as _bytecode from _pydevd_frame_eval.vendored.bytecode.concrete import ConcreteInstr from _pydevd_frame_eval.vendored.bytecode.flags import CompilerFlags from _pydevd_frame_eval.vendored.bytecode.instr import Label, SetLineno, Instr class BasicBlock(_bytecode._InstrList): def __init__(self, instructions=None): # a BasicBlock object, or None self.next_block = None if instructions: super().__init__(instructions) def __iter__(self): index = 0 while index < len(self): instr = self[index] index += 1 if not isinstance(instr, (SetLineno, Instr)): raise ValueError( "BasicBlock must only contain SetLineno and Instr objects, " "but %s was found" % instr.__class__.__name__ ) if isinstance(instr, Instr) and instr.has_jump(): if index < len(self): raise ValueError( "Only the last instruction of a basic " "block can be a jump" ) if not isinstance(instr.arg, BasicBlock): raise ValueError( "Jump target must a BasicBlock, got %s", type(instr.arg).__name__, ) yield instr def __getitem__(self, index): value = super().__getitem__(index) if isinstance(index, slice): value = type(self)(value) value.next_block = self.next_block return value def copy(self): new = type(self)(super().copy()) new.next_block = self.next_block return new def legalize(self, first_lineno): """Check that all the element of the list are valid and remove SetLineno.""" lineno_pos = [] set_lineno = None current_lineno = first_lineno for pos, instr in enumerate(self): if isinstance(instr, SetLineno): set_lineno = current_lineno = instr.lineno lineno_pos.append(pos) continue if set_lineno is not None: instr.lineno = set_lineno elif instr.lineno is None: instr.lineno = current_lineno else: current_lineno = instr.lineno for i in reversed(lineno_pos): del self[i] return current_lineno def get_jump(self): if not self: return None last_instr = self[-1] if not (isinstance(last_instr, Instr) and last_instr.has_jump()): return None target_block = last_instr.arg assert isinstance(target_block, BasicBlock) return target_block def _compute_stack_size(block, size, maxsize, *, check_pre_and_post=True): """Generator used to reduce the use of function stacks. This allows to avoid nested recursion and allow to treat more cases. HOW-TO: Following the methods of Trampoline (see https://en.wikipedia.org/wiki/Trampoline_(computing)), We yield either: - the arguments that would be used in the recursive calls, i.e, 'yield block, size, maxsize' instead of making a recursive call '_compute_stack_size(block, size, maxsize)', if we encounter an instruction jumping to another block or if the block is linked to another one (ie `next_block` is set) - the required stack from the stack if we went through all the instructions or encountered an unconditional jump. In the first case, the calling function is then responsible for creating a new generator with those arguments, iterating over it till exhaustion to determine the stacksize required by the block and resuming this function with the determined stacksize. """ # If the block is currently being visited (seen = True) or if it was visited # previously by using a larger starting size than the one in use, return the # maxsize. if block.seen or block.startsize >= size: yield maxsize def update_size(pre_delta, post_delta, size, maxsize): size += pre_delta if size < 0: msg = "Failed to compute stacksize, got negative size" raise RuntimeError(msg) size += post_delta maxsize = max(maxsize, size) return size, maxsize # Prevent recursive visit of block if two blocks are nested (jump from one # to the other). block.seen = True block.startsize = size for instr in block: # Ignore SetLineno if isinstance(instr, SetLineno): continue # For instructions with a jump first compute the stacksize required when the # jump is taken. if instr.has_jump(): effect = ( instr.pre_and_post_stack_effect(jump=True) if check_pre_and_post else (instr.stack_effect(jump=True), 0) ) taken_size, maxsize = update_size(*effect, size, maxsize) # Yield the parameters required to compute the stacksize required # by the block to which the jumnp points to and resume when we now # the maxsize. maxsize = yield instr.arg, taken_size, maxsize # For unconditional jumps abort early since the other instruction will # never be seen. if instr.is_uncond_jump(): block.seen = False yield maxsize # jump=False: non-taken path of jumps, or any non-jump effect = ( instr.pre_and_post_stack_effect(jump=False) if check_pre_and_post else (instr.stack_effect(jump=False), 0) ) size, maxsize = update_size(*effect, size, maxsize) if block.next_block: maxsize = yield block.next_block, size, maxsize block.seen = False yield maxsize class ControlFlowGraph(_bytecode.BaseBytecode): def __init__(self): super().__init__() self._blocks = [] self._block_index = {} self.argnames = [] self.add_block() def legalize(self): """Legalize all blocks.""" current_lineno = self.first_lineno for block in self._blocks: current_lineno = block.legalize(current_lineno) def get_block_index(self, block): try: return self._block_index[id(block)] except KeyError: raise ValueError("the block is not part of this bytecode") def _add_block(self, block): block_index = len(self._blocks) self._blocks.append(block) self._block_index[id(block)] = block_index def add_block(self, instructions=None): block = BasicBlock(instructions) self._add_block(block) return block def compute_stacksize(self, *, check_pre_and_post=True): """Compute the stack size by iterating through the blocks The implementation make use of a generator function to avoid issue with deeply nested recursions. """ # In the absence of any block return 0 if not self: return 0 # Ensure that previous calculation do not impact this one. for block in self: block.seen = False block.startsize = -32768 # INT_MIN # Starting with Python 3.10, generator and coroutines start with one object # on the stack (None, anything is an error). initial_stack_size = 0 if sys.version_info >= (3, 10) and self.flags & ( CompilerFlags.GENERATOR | CompilerFlags.COROUTINE | CompilerFlags.ASYNC_GENERATOR ): initial_stack_size = 1 # Create a generator/coroutine responsible of dealing with the first block coro = _compute_stack_size( self[0], initial_stack_size, 0, check_pre_and_post=check_pre_and_post ) # Create a list of generator that have not yet been exhausted coroutines = [] push_coroutine = coroutines.append pop_coroutine = coroutines.pop args = None try: while True: args = coro.send(None) # Consume the stored generators as long as they return a simple # interger that is to be used to resume the last stored generator. while isinstance(args, int): coro = pop_coroutine() args = coro.send(args) # Otherwise we enter a new block and we store the generator under # use and create a new one to process the new block push_coroutine(coro) coro = _compute_stack_size(*args, check_pre_and_post=check_pre_and_post) except IndexError: # The exception occurs when all the generators have been exhausted # in which case teh last yielded value is the stacksize. assert args is not None return args def __repr__(self): return "<ControlFlowGraph block#=%s>" % len(self._blocks) def get_instructions(self): instructions = [] jumps = [] for block in self: target_block = block.get_jump() if target_block is not None: instr = block[-1] instr = ConcreteInstr(instr.name, 0, lineno=instr.lineno) jumps.append((target_block, instr)) instructions.extend(block[:-1]) instructions.append(instr) else: instructions.extend(block) for target_block, instr in jumps: instr.arg = self.get_block_index(target_block) return instructions def __eq__(self, other): if type(self) != type(other): return False if self.argnames != other.argnames: return False instrs1 = self.get_instructions() instrs2 = other.get_instructions() if instrs1 != instrs2: return False # FIXME: compare block.next_block return super().__eq__(other) def __len__(self): return len(self._blocks) def __iter__(self): return iter(self._blocks) def __getitem__(self, index): if isinstance(index, BasicBlock): index = self.get_block_index(index) return self._blocks[index] def __delitem__(self, index): if isinstance(index, BasicBlock): index = self.get_block_index(index) block = self._blocks[index] del self._blocks[index] del self._block_index[id(block)] for index in range(index, len(self)): block = self._blocks[index] self._block_index[id(block)] -= 1 def split_block(self, block, index): if not isinstance(block, BasicBlock): raise TypeError("expected block") block_index = self.get_block_index(block) if index < 0: raise ValueError("index must be positive") block = self._blocks[block_index] if index == 0: return block if index > len(block): raise ValueError("index out of the block") instructions = block[index:] if not instructions: if block_index + 1 < len(self): return self[block_index + 1] del block[index:] block2 = BasicBlock(instructions) block.next_block = block2 for block in self[block_index + 1 :]: self._block_index[id(block)] += 1 self._blocks.insert(block_index + 1, block2) self._block_index[id(block2)] = block_index + 1 return block2 @staticmethod def from_bytecode(bytecode): # label => instruction index label_to_block_index = {} jumps = [] block_starts = {} for index, instr in enumerate(bytecode): if isinstance(instr, Label): label_to_block_index[instr] = index else: if isinstance(instr, Instr) and isinstance(instr.arg, Label): jumps.append((index, instr.arg)) for target_index, target_label in jumps: target_index = label_to_block_index[target_label] block_starts[target_index] = target_label bytecode_blocks = _bytecode.ControlFlowGraph() bytecode_blocks._copy_attr_from(bytecode) bytecode_blocks.argnames = list(bytecode.argnames) # copy instructions, convert labels to block labels block = bytecode_blocks[0] labels = {} jumps = [] for index, instr in enumerate(bytecode): if index in block_starts: old_label = block_starts[index] if index != 0: new_block = bytecode_blocks.add_block() if not block[-1].is_final(): block.next_block = new_block block = new_block if old_label is not None: labels[old_label] = block elif block and isinstance(block[-1], Instr): if block[-1].is_final(): block = bytecode_blocks.add_block() elif block[-1].has_jump(): new_block = bytecode_blocks.add_block() block.next_block = new_block block = new_block if isinstance(instr, Label): continue # don't copy SetLineno objects if isinstance(instr, Instr): instr = instr.copy() if isinstance(instr.arg, Label): jumps.append(instr) block.append(instr) for instr in jumps: label = instr.arg instr.arg = labels[label] return bytecode_blocks def to_bytecode(self): """Convert to Bytecode.""" used_blocks = set() for block in self: target_block = block.get_jump() if target_block is not None: used_blocks.add(id(target_block)) labels = {} jumps = [] instructions = [] for block in self: if id(block) in used_blocks: new_label = Label() labels[id(block)] = new_label instructions.append(new_label) for instr in block: # don't copy SetLineno objects if isinstance(instr, Instr): instr = instr.copy() if isinstance(instr.arg, BasicBlock): jumps.append(instr) instructions.append(instr) # Map to new labels for instr in jumps: instr.arg = labels[id(instr.arg)] bytecode = _bytecode.Bytecode() bytecode._copy_attr_from(self) bytecode.argnames = list(self.argnames) bytecode[:] = instructions return bytecode def to_code(self, stacksize=None): """Convert to code.""" if stacksize is None: stacksize = self.compute_stacksize() bc = self.to_bytecode() return bc.to_code(stacksize=stacksize)
15,391
Python
32.172414
88
0.563316
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_concrete.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') #!/usr/bin/env python3 import opcode import sys import textwrap import types import unittest from _pydevd_frame_eval.vendored.bytecode import ( UNSET, Label, Instr, SetLineno, Bytecode, CellVar, FreeVar, CompilerFlags, ConcreteInstr, ConcreteBytecode, ) from _pydevd_frame_eval.vendored.bytecode.concrete import OFFSET_AS_INSTRUCTION from _pydevd_frame_eval.vendored.bytecode.tests import get_code, TestCase class ConcreteInstrTests(TestCase): def test_constructor(self): with self.assertRaises(ValueError): # need an argument ConcreteInstr("LOAD_CONST") with self.assertRaises(ValueError): # must not have an argument ConcreteInstr("ROT_TWO", 33) # invalid argument with self.assertRaises(TypeError): ConcreteInstr("LOAD_CONST", 1.0) with self.assertRaises(ValueError): ConcreteInstr("LOAD_CONST", -1) with self.assertRaises(TypeError): ConcreteInstr("LOAD_CONST", 5, lineno=1.0) with self.assertRaises(ValueError): ConcreteInstr("LOAD_CONST", 5, lineno=-1) # test maximum argument with self.assertRaises(ValueError): ConcreteInstr("LOAD_CONST", 2147483647 + 1) instr = ConcreteInstr("LOAD_CONST", 2147483647) self.assertEqual(instr.arg, 2147483647) # test meaningless extended args instr = ConcreteInstr("LOAD_FAST", 8, lineno=3, extended_args=1) self.assertEqual(instr.name, "LOAD_FAST") self.assertEqual(instr.arg, 8) self.assertEqual(instr.lineno, 3) self.assertEqual(instr.size, 4) def test_attr(self): instr = ConcreteInstr("LOAD_CONST", 5, lineno=12) self.assertEqual(instr.name, "LOAD_CONST") self.assertEqual(instr.opcode, 100) self.assertEqual(instr.arg, 5) self.assertEqual(instr.lineno, 12) self.assertEqual(instr.size, 2) def test_set(self): instr = ConcreteInstr("LOAD_CONST", 5, lineno=3) instr.set("NOP") self.assertEqual(instr.name, "NOP") self.assertIs(instr.arg, UNSET) self.assertEqual(instr.lineno, 3) instr.set("LOAD_FAST", 8) self.assertEqual(instr.name, "LOAD_FAST") self.assertEqual(instr.arg, 8) self.assertEqual(instr.lineno, 3) # invalid with self.assertRaises(ValueError): instr.set("LOAD_CONST") with self.assertRaises(ValueError): instr.set("NOP", 5) def test_set_attr(self): instr = ConcreteInstr("LOAD_CONST", 5, lineno=12) # operator name instr.name = "LOAD_FAST" self.assertEqual(instr.name, "LOAD_FAST") self.assertEqual(instr.opcode, 124) self.assertRaises(TypeError, setattr, instr, "name", 3) self.assertRaises(ValueError, setattr, instr, "name", "xxx") # operator code instr.opcode = 100 self.assertEqual(instr.name, "LOAD_CONST") self.assertEqual(instr.opcode, 100) self.assertRaises(ValueError, setattr, instr, "opcode", -12) self.assertRaises(TypeError, setattr, instr, "opcode", "abc") # extended argument instr.arg = 0x1234ABCD self.assertEqual(instr.arg, 0x1234ABCD) self.assertEqual(instr.size, 8) # small argument instr.arg = 0 self.assertEqual(instr.arg, 0) self.assertEqual(instr.size, 2) # invalid argument self.assertRaises(ValueError, setattr, instr, "arg", -1) self.assertRaises(ValueError, setattr, instr, "arg", 2147483647 + 1) # size attribute is read-only self.assertRaises(AttributeError, setattr, instr, "size", 3) # lineno instr.lineno = 33 self.assertEqual(instr.lineno, 33) self.assertRaises(TypeError, setattr, instr, "lineno", 1.0) self.assertRaises(ValueError, setattr, instr, "lineno", -1) def test_size(self): self.assertEqual(ConcreteInstr("ROT_TWO").size, 2) self.assertEqual(ConcreteInstr("LOAD_CONST", 3).size, 2) self.assertEqual(ConcreteInstr("LOAD_CONST", 0x1234ABCD).size, 8) def test_disassemble(self): code = b"\t\x00d\x03" instr = ConcreteInstr.disassemble(1, code, 0) self.assertEqual(instr, ConcreteInstr("NOP", lineno=1)) instr = ConcreteInstr.disassemble(2, code, 1 if OFFSET_AS_INSTRUCTION else 2) self.assertEqual(instr, ConcreteInstr("LOAD_CONST", 3, lineno=2)) code = b"\x90\x12\x904\x90\xabd\xcd" instr = ConcreteInstr.disassemble(3, code, 0) self.assertEqual(instr, ConcreteInstr("EXTENDED_ARG", 0x12, lineno=3)) def test_assemble(self): instr = ConcreteInstr("NOP") self.assertEqual(instr.assemble(), b"\t\x00") instr = ConcreteInstr("LOAD_CONST", 3) self.assertEqual(instr.assemble(), b"d\x03") instr = ConcreteInstr("LOAD_CONST", 0x1234ABCD) self.assertEqual( instr.assemble(), (b"\x90\x12\x904\x90\xabd\xcd"), ) instr = ConcreteInstr("LOAD_CONST", 3, extended_args=1) self.assertEqual( instr.assemble(), (b"\x90\x00d\x03"), ) def test_get_jump_target(self): jump_abs = ConcreteInstr("JUMP_ABSOLUTE", 3) self.assertEqual(jump_abs.get_jump_target(100), 3) jump_forward = ConcreteInstr("JUMP_FORWARD", 5) self.assertEqual( jump_forward.get_jump_target(10), 16 if OFFSET_AS_INSTRUCTION else 17 ) class ConcreteBytecodeTests(TestCase): def test_repr(self): r = repr(ConcreteBytecode()) self.assertIn("ConcreteBytecode", r) self.assertIn("0", r) def test_eq(self): code = ConcreteBytecode() self.assertFalse(code == 1) for name, val in ( ("names", ["a"]), ("varnames", ["a"]), ("consts", [1]), ("argcount", 1), ("kwonlyargcount", 2), ("flags", CompilerFlags(CompilerFlags.GENERATOR)), ("first_lineno", 10), ("filename", "xxxx.py"), ("name", "__x"), ("docstring", "x-x-x"), ("cellvars", [CellVar("x")]), ("freevars", [FreeVar("x")]), ): c = ConcreteBytecode() setattr(c, name, val) # For obscure reasons using assertNotEqual here fail self.assertFalse(code == c) if sys.version_info > (3, 8): c = ConcreteBytecode() c.posonlyargcount = 10 self.assertFalse(code == c) c = ConcreteBytecode() c.consts = [1] code.consts = [1] c.append(ConcreteInstr("LOAD_CONST", 0)) self.assertFalse(code == c) def test_attr(self): code_obj = get_code("x = 5") code = ConcreteBytecode.from_code(code_obj) self.assertEqual(code.consts, [5, None]) self.assertEqual(code.names, ["x"]) self.assertEqual(code.varnames, []) self.assertEqual(code.freevars, []) self.assertListEqual( list(code), [ ConcreteInstr("LOAD_CONST", 0, lineno=1), ConcreteInstr("STORE_NAME", 0, lineno=1), ConcreteInstr("LOAD_CONST", 1, lineno=1), ConcreteInstr("RETURN_VALUE", lineno=1), ], ) # FIXME: test other attributes def test_invalid_types(self): code = ConcreteBytecode() code.append(Label()) with self.assertRaises(ValueError): list(code) with self.assertRaises(ValueError): code.legalize() with self.assertRaises(ValueError): ConcreteBytecode([Label()]) def test_to_code_lnotab(self): # We use an actual function for the simple case to # ensure we get lnotab right def f(): # # x = 7 # noqa y = 8 # noqa z = 9 # noqa fl = f.__code__.co_firstlineno concrete = ConcreteBytecode() concrete.consts = [None, 7, 8, 9] concrete.varnames = ["x", "y", "z"] concrete.first_lineno = fl concrete.extend( [ SetLineno(fl + 3), ConcreteInstr("LOAD_CONST", 1), ConcreteInstr("STORE_FAST", 0), SetLineno(fl + 4), ConcreteInstr("LOAD_CONST", 2), ConcreteInstr("STORE_FAST", 1), SetLineno(fl + 5), ConcreteInstr("LOAD_CONST", 3), ConcreteInstr("STORE_FAST", 2), ConcreteInstr("LOAD_CONST", 0), ConcreteInstr("RETURN_VALUE"), ] ) code = concrete.to_code() self.assertEqual(code.co_code, f.__code__.co_code) self.assertEqual(code.co_lnotab, f.__code__.co_lnotab) if sys.version_info >= (3, 10): self.assertEqual(code.co_linetable, f.__code__.co_linetable) def test_negative_lnotab(self): # x = 7 # y = 8 concrete = ConcreteBytecode( [ ConcreteInstr("LOAD_CONST", 0), ConcreteInstr("STORE_NAME", 0), # line number goes backward! SetLineno(2), ConcreteInstr("LOAD_CONST", 1), ConcreteInstr("STORE_NAME", 1), ] ) concrete.consts = [7, 8] concrete.names = ["x", "y"] concrete.first_lineno = 5 code = concrete.to_code() expected = b"d\x00Z\x00d\x01Z\x01" self.assertEqual(code.co_code, expected) self.assertEqual(code.co_firstlineno, 5) self.assertEqual(code.co_lnotab, b"\x04\xfd") def test_extended_lnotab(self): # x = 7 # 200 blank lines # y = 8 concrete = ConcreteBytecode( [ ConcreteInstr("LOAD_CONST", 0), SetLineno(1 + 128), ConcreteInstr("STORE_NAME", 0), # line number goes backward! SetLineno(1 + 129), ConcreteInstr("LOAD_CONST", 1), SetLineno(1), ConcreteInstr("STORE_NAME", 1), ] ) concrete.consts = [7, 8] concrete.names = ["x", "y"] concrete.first_lineno = 1 code = concrete.to_code() expected = b"d\x00Z\x00d\x01Z\x01" self.assertEqual(code.co_code, expected) self.assertEqual(code.co_firstlineno, 1) self.assertEqual(code.co_lnotab, b"\x02\x7f\x00\x01\x02\x01\x02\x80\x00\xff") def test_extended_lnotab2(self): # x = 7 # 200 blank lines # y = 8 base_code = compile("x = 7" + "\n" * 200 + "y = 8", "", "exec") concrete = ConcreteBytecode( [ ConcreteInstr("LOAD_CONST", 0), ConcreteInstr("STORE_NAME", 0), SetLineno(201), ConcreteInstr("LOAD_CONST", 1), ConcreteInstr("STORE_NAME", 1), ConcreteInstr("LOAD_CONST", 2), ConcreteInstr("RETURN_VALUE"), ] ) concrete.consts = [None, 7, 8] concrete.names = ["x", "y"] concrete.first_lineno = 1 code = concrete.to_code() self.assertEqual(code.co_code, base_code.co_code) self.assertEqual(code.co_firstlineno, base_code.co_firstlineno) self.assertEqual(code.co_lnotab, base_code.co_lnotab) if sys.version_info >= (3, 10): self.assertEqual(code.co_linetable, base_code.co_linetable) def test_to_bytecode_consts(self): # x = -0.0 # x = +0.0 # # code optimized by the CPython 3.6 peephole optimizer which emits # duplicated constants (0.0 is twice in consts). code = ConcreteBytecode() code.consts = [0.0, None, -0.0, 0.0] code.names = ["x", "y"] code.extend( [ ConcreteInstr("LOAD_CONST", 2, lineno=1), ConcreteInstr("STORE_NAME", 0, lineno=1), ConcreteInstr("LOAD_CONST", 3, lineno=2), ConcreteInstr("STORE_NAME", 1, lineno=2), ConcreteInstr("LOAD_CONST", 1, lineno=2), ConcreteInstr("RETURN_VALUE", lineno=2), ] ) code = code.to_bytecode().to_concrete_bytecode() # the conversion changes the constant order: the order comes from # the order of LOAD_CONST instructions self.assertEqual(code.consts, [-0.0, 0.0, None]) code.names = ["x", "y"] self.assertListEqual( list(code), [ ConcreteInstr("LOAD_CONST", 0, lineno=1), ConcreteInstr("STORE_NAME", 0, lineno=1), ConcreteInstr("LOAD_CONST", 1, lineno=2), ConcreteInstr("STORE_NAME", 1, lineno=2), ConcreteInstr("LOAD_CONST", 2, lineno=2), ConcreteInstr("RETURN_VALUE", lineno=2), ], ) def test_cellvar(self): concrete = ConcreteBytecode() concrete.cellvars = ["x"] concrete.append(ConcreteInstr("LOAD_DEREF", 0)) code = concrete.to_code() concrete = ConcreteBytecode.from_code(code) self.assertEqual(concrete.cellvars, ["x"]) self.assertEqual(concrete.freevars, []) self.assertEqual(list(concrete), [ConcreteInstr("LOAD_DEREF", 0, lineno=1)]) bytecode = concrete.to_bytecode() self.assertEqual(bytecode.cellvars, ["x"]) self.assertEqual(list(bytecode), [Instr("LOAD_DEREF", CellVar("x"), lineno=1)]) def test_freevar(self): concrete = ConcreteBytecode() concrete.freevars = ["x"] concrete.append(ConcreteInstr("LOAD_DEREF", 0)) code = concrete.to_code() concrete = ConcreteBytecode.from_code(code) self.assertEqual(concrete.cellvars, []) self.assertEqual(concrete.freevars, ["x"]) self.assertEqual(list(concrete), [ConcreteInstr("LOAD_DEREF", 0, lineno=1)]) bytecode = concrete.to_bytecode() self.assertEqual(bytecode.cellvars, []) self.assertEqual(list(bytecode), [Instr("LOAD_DEREF", FreeVar("x"), lineno=1)]) def test_cellvar_freevar(self): concrete = ConcreteBytecode() concrete.cellvars = ["cell"] concrete.freevars = ["free"] concrete.append(ConcreteInstr("LOAD_DEREF", 0)) concrete.append(ConcreteInstr("LOAD_DEREF", 1)) code = concrete.to_code() concrete = ConcreteBytecode.from_code(code) self.assertEqual(concrete.cellvars, ["cell"]) self.assertEqual(concrete.freevars, ["free"]) self.assertEqual( list(concrete), [ ConcreteInstr("LOAD_DEREF", 0, lineno=1), ConcreteInstr("LOAD_DEREF", 1, lineno=1), ], ) bytecode = concrete.to_bytecode() self.assertEqual(bytecode.cellvars, ["cell"]) self.assertEqual( list(bytecode), [ Instr("LOAD_DEREF", CellVar("cell"), lineno=1), Instr("LOAD_DEREF", FreeVar("free"), lineno=1), ], ) def test_load_classderef(self): concrete = ConcreteBytecode() concrete.cellvars = ["__class__"] concrete.freevars = ["__class__"] concrete.extend( [ConcreteInstr("LOAD_CLASSDEREF", 1), ConcreteInstr("STORE_DEREF", 1)] ) bytecode = concrete.to_bytecode() self.assertEqual(bytecode.freevars, ["__class__"]) self.assertEqual(bytecode.cellvars, ["__class__"]) self.assertEqual( list(bytecode), [ Instr("LOAD_CLASSDEREF", FreeVar("__class__"), lineno=1), Instr("STORE_DEREF", FreeVar("__class__"), lineno=1), ], ) concrete = bytecode.to_concrete_bytecode() self.assertEqual(concrete.freevars, ["__class__"]) self.assertEqual(concrete.cellvars, ["__class__"]) self.assertEqual( list(concrete), [ ConcreteInstr("LOAD_CLASSDEREF", 1, lineno=1), ConcreteInstr("STORE_DEREF", 1, lineno=1), ], ) code = concrete.to_code() self.assertEqual(code.co_freevars, ("__class__",)) self.assertEqual(code.co_cellvars, ("__class__",)) self.assertEqual( code.co_code, b"\x94\x01\x89\x01", ) def test_explicit_stacksize(self): # Passing stacksize=... to ConcreteBytecode.to_code should result in a # code object with the specified stacksize. We pass some silly values # and assert that they are honored. code_obj = get_code("print('%s' % (a,b,c))") original_stacksize = code_obj.co_stacksize concrete = ConcreteBytecode.from_code(code_obj) # First with something bigger than necessary. explicit_stacksize = original_stacksize + 42 new_code_obj = concrete.to_code(stacksize=explicit_stacksize) self.assertEqual(new_code_obj.co_stacksize, explicit_stacksize) # Then with something bogus. We probably don't want to advertise this # in the documentation. If this fails then decide if it's for good # reason, and remove if so. explicit_stacksize = 0 new_code_obj = concrete.to_code(stacksize=explicit_stacksize) self.assertEqual(new_code_obj.co_stacksize, explicit_stacksize) def test_legalize(self): concrete = ConcreteBytecode() concrete.first_lineno = 3 concrete.consts = [7, 8, 9] concrete.names = ["x", "y", "z"] concrete.extend( [ ConcreteInstr("LOAD_CONST", 0), ConcreteInstr("STORE_NAME", 0), ConcreteInstr("LOAD_CONST", 1, lineno=4), ConcreteInstr("STORE_NAME", 1), SetLineno(5), ConcreteInstr("LOAD_CONST", 2, lineno=6), ConcreteInstr("STORE_NAME", 2), ] ) concrete.legalize() self.assertListEqual( list(concrete), [ ConcreteInstr("LOAD_CONST", 0, lineno=3), ConcreteInstr("STORE_NAME", 0, lineno=3), ConcreteInstr("LOAD_CONST", 1, lineno=4), ConcreteInstr("STORE_NAME", 1, lineno=4), ConcreteInstr("LOAD_CONST", 2, lineno=5), ConcreteInstr("STORE_NAME", 2, lineno=5), ], ) def test_slice(self): concrete = ConcreteBytecode() concrete.first_lineno = 3 concrete.consts = [7, 8, 9] concrete.names = ["x", "y", "z"] concrete.extend( [ ConcreteInstr("LOAD_CONST", 0), ConcreteInstr("STORE_NAME", 0), SetLineno(4), ConcreteInstr("LOAD_CONST", 1), ConcreteInstr("STORE_NAME", 1), SetLineno(5), ConcreteInstr("LOAD_CONST", 2), ConcreteInstr("STORE_NAME", 2), ] ) self.assertEqual(concrete, concrete[:]) def test_copy(self): concrete = ConcreteBytecode() concrete.first_lineno = 3 concrete.consts = [7, 8, 9] concrete.names = ["x", "y", "z"] concrete.extend( [ ConcreteInstr("LOAD_CONST", 0), ConcreteInstr("STORE_NAME", 0), SetLineno(4), ConcreteInstr("LOAD_CONST", 1), ConcreteInstr("STORE_NAME", 1), SetLineno(5), ConcreteInstr("LOAD_CONST", 2), ConcreteInstr("STORE_NAME", 2), ] ) self.assertEqual(concrete, concrete.copy()) class ConcreteFromCodeTests(TestCase): def test_extended_arg(self): # Create a code object from arbitrary bytecode co_code = b"\x90\x12\x904\x90\xabd\xcd" code = get_code("x=1") args = ( (code.co_argcount,) if sys.version_info < (3, 8) else (code.co_argcount, code.co_posonlyargcount) ) args += ( code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize, code.co_flags, co_code, code.co_consts, code.co_names, code.co_varnames, code.co_filename, code.co_name, code.co_firstlineno, code.co_linetable if sys.version_info >= (3, 10) else code.co_lnotab, code.co_freevars, code.co_cellvars, ) code = types.CodeType(*args) # without EXTENDED_ARG opcode bytecode = ConcreteBytecode.from_code(code) self.assertListEqual( list(bytecode), [ConcreteInstr("LOAD_CONST", 0x1234ABCD, lineno=1)] ) # with EXTENDED_ARG opcode bytecode = ConcreteBytecode.from_code(code, extended_arg=True) expected = [ ConcreteInstr("EXTENDED_ARG", 0x12, lineno=1), ConcreteInstr("EXTENDED_ARG", 0x34, lineno=1), ConcreteInstr("EXTENDED_ARG", 0xAB, lineno=1), ConcreteInstr("LOAD_CONST", 0xCD, lineno=1), ] self.assertListEqual(list(bytecode), expected) def test_extended_arg_make_function(self): if (3, 9) <= sys.version_info < (3, 10): from _pydevd_frame_eval.vendored.bytecode.tests.util_annotation import get_code as get_code_future code_obj = get_code_future( """ def foo(x: int, y: int): pass """ ) else: code_obj = get_code( """ def foo(x: int, y: int): pass """ ) # without EXTENDED_ARG concrete = ConcreteBytecode.from_code(code_obj) if sys.version_info >= (3, 10): func_code = concrete.consts[2] names = ["int", "foo"] consts = ["x", "y", func_code, "foo", None] const_offset = 1 name_offset = 1 first_instrs = [ ConcreteInstr("LOAD_CONST", 0, lineno=1), ConcreteInstr("LOAD_NAME", 0, lineno=1), ConcreteInstr("LOAD_CONST", 1, lineno=1), ConcreteInstr("LOAD_NAME", 0, lineno=1), ConcreteInstr("BUILD_TUPLE", 4, lineno=1), ] elif ( sys.version_info >= (3, 7) and concrete.flags & CompilerFlags.FUTURE_ANNOTATIONS ): func_code = concrete.consts[2] names = ["foo"] consts = ["int", ("x", "y"), func_code, "foo", None] const_offset = 1 name_offset = 0 first_instrs = [ ConcreteInstr("LOAD_CONST", 0, lineno=1), ConcreteInstr("LOAD_CONST", 0, lineno=1), ConcreteInstr("LOAD_CONST", 0 + const_offset, lineno=1), ConcreteInstr("BUILD_CONST_KEY_MAP", 2, lineno=1), ] else: func_code = concrete.consts[1] names = ["int", "foo"] consts = [("x", "y"), func_code, "foo", None] const_offset = 0 name_offset = 1 first_instrs = [ ConcreteInstr("LOAD_NAME", 0, lineno=1), ConcreteInstr("LOAD_NAME", 0, lineno=1), ConcreteInstr("LOAD_CONST", 0 + const_offset, lineno=1), ConcreteInstr("BUILD_CONST_KEY_MAP", 2, lineno=1), ] self.assertEqual(concrete.names, names) self.assertEqual(concrete.consts, consts) expected = first_instrs + [ ConcreteInstr("LOAD_CONST", 1 + const_offset, lineno=1), ConcreteInstr("LOAD_CONST", 2 + const_offset, lineno=1), ConcreteInstr("MAKE_FUNCTION", 4, lineno=1), ConcreteInstr("STORE_NAME", name_offset, lineno=1), ConcreteInstr("LOAD_CONST", 3 + const_offset, lineno=1), ConcreteInstr("RETURN_VALUE", lineno=1), ] self.assertListEqual(list(concrete), expected) # with EXTENDED_ARG concrete = ConcreteBytecode.from_code(code_obj, extended_arg=True) # With future annotation the int annotation is stringified and # stored as constant this the default behavior under Python 3.10 if sys.version_info >= (3, 10): func_code = concrete.consts[2] names = ["int", "foo"] consts = ["x", "y", func_code, "foo", None] elif concrete.flags & CompilerFlags.FUTURE_ANNOTATIONS: func_code = concrete.consts[2] names = ["foo"] consts = ["int", ("x", "y"), func_code, "foo", None] else: func_code = concrete.consts[1] names = ["int", "foo"] consts = [("x", "y"), func_code, "foo", None] self.assertEqual(concrete.names, names) self.assertEqual(concrete.consts, consts) self.assertListEqual(list(concrete), expected) # The next three tests ensure we can round trip ConcreteBytecode generated # with extended_args=True def test_extended_arg_unpack_ex(self): def test(): p = [1, 2, 3, 4, 5, 6] q, r, *s, t = p return q, r, s, t cpython_stacksize = test.__code__.co_stacksize test.__code__ = ConcreteBytecode.from_code( test.__code__, extended_arg=True ).to_code() self.assertEqual(test.__code__.co_stacksize, cpython_stacksize) self.assertEqual(test(), (1, 2, [3, 4, 5], 6)) def test_expected_arg_with_many_consts(self): def test(): var = 0 var = 1 var = 2 var = 3 var = 4 var = 5 var = 6 var = 7 var = 8 var = 9 var = 10 var = 11 var = 12 var = 13 var = 14 var = 15 var = 16 var = 17 var = 18 var = 19 var = 20 var = 21 var = 22 var = 23 var = 24 var = 25 var = 26 var = 27 var = 28 var = 29 var = 30 var = 31 var = 32 var = 33 var = 34 var = 35 var = 36 var = 37 var = 38 var = 39 var = 40 var = 41 var = 42 var = 43 var = 44 var = 45 var = 46 var = 47 var = 48 var = 49 var = 50 var = 51 var = 52 var = 53 var = 54 var = 55 var = 56 var = 57 var = 58 var = 59 var = 60 var = 61 var = 62 var = 63 var = 64 var = 65 var = 66 var = 67 var = 68 var = 69 var = 70 var = 71 var = 72 var = 73 var = 74 var = 75 var = 76 var = 77 var = 78 var = 79 var = 80 var = 81 var = 82 var = 83 var = 84 var = 85 var = 86 var = 87 var = 88 var = 89 var = 90 var = 91 var = 92 var = 93 var = 94 var = 95 var = 96 var = 97 var = 98 var = 99 var = 100 var = 101 var = 102 var = 103 var = 104 var = 105 var = 106 var = 107 var = 108 var = 109 var = 110 var = 111 var = 112 var = 113 var = 114 var = 115 var = 116 var = 117 var = 118 var = 119 var = 120 var = 121 var = 122 var = 123 var = 124 var = 125 var = 126 var = 127 var = 128 var = 129 var = 130 var = 131 var = 132 var = 133 var = 134 var = 135 var = 136 var = 137 var = 138 var = 139 var = 140 var = 141 var = 142 var = 143 var = 144 var = 145 var = 146 var = 147 var = 148 var = 149 var = 150 var = 151 var = 152 var = 153 var = 154 var = 155 var = 156 var = 157 var = 158 var = 159 var = 160 var = 161 var = 162 var = 163 var = 164 var = 165 var = 166 var = 167 var = 168 var = 169 var = 170 var = 171 var = 172 var = 173 var = 174 var = 175 var = 176 var = 177 var = 178 var = 179 var = 180 var = 181 var = 182 var = 183 var = 184 var = 185 var = 186 var = 187 var = 188 var = 189 var = 190 var = 191 var = 192 var = 193 var = 194 var = 195 var = 196 var = 197 var = 198 var = 199 var = 200 var = 201 var = 202 var = 203 var = 204 var = 205 var = 206 var = 207 var = 208 var = 209 var = 210 var = 211 var = 212 var = 213 var = 214 var = 215 var = 216 var = 217 var = 218 var = 219 var = 220 var = 221 var = 222 var = 223 var = 224 var = 225 var = 226 var = 227 var = 228 var = 229 var = 230 var = 231 var = 232 var = 233 var = 234 var = 235 var = 236 var = 237 var = 238 var = 239 var = 240 var = 241 var = 242 var = 243 var = 244 var = 245 var = 246 var = 247 var = 248 var = 249 var = 250 var = 251 var = 252 var = 253 var = 254 var = 255 var = 256 var = 257 var = 258 var = 259 return var test.__code__ = ConcreteBytecode.from_code( test.__code__, extended_arg=True ).to_code() self.assertEqual(test.__code__.co_stacksize, 1) self.assertEqual(test(), 259) if sys.version_info >= (3, 6): def test_fail_extended_arg_jump(self): def test(): var = None for _ in range(0, 1): var = 0 var = 1 var = 2 var = 3 var = 4 var = 5 var = 6 var = 7 var = 8 var = 9 var = 10 var = 11 var = 12 var = 13 var = 14 var = 15 var = 16 var = 17 var = 18 var = 19 var = 20 var = 21 var = 22 var = 23 var = 24 var = 25 var = 26 var = 27 var = 28 var = 29 var = 30 var = 31 var = 32 var = 33 var = 34 var = 35 var = 36 var = 37 var = 38 var = 39 var = 40 var = 41 var = 42 var = 43 var = 44 var = 45 var = 46 var = 47 var = 48 var = 49 var = 50 var = 51 var = 52 var = 53 var = 54 var = 55 var = 56 var = 57 var = 58 var = 59 var = 60 var = 61 var = 62 var = 63 var = 64 var = 65 var = 66 var = 67 var = 68 var = 69 var = 70 return var # Generate the bytecode with extended arguments bytecode = ConcreteBytecode.from_code(test.__code__, extended_arg=True) bytecode.to_code() class BytecodeToConcreteTests(TestCase): def test_label(self): code = Bytecode() label = Label() code.extend( [ Instr("LOAD_CONST", "hello", lineno=1), Instr("JUMP_FORWARD", label, lineno=1), label, Instr("POP_TOP", lineno=1), ] ) code = code.to_concrete_bytecode() expected = [ ConcreteInstr("LOAD_CONST", 0, lineno=1), ConcreteInstr("JUMP_FORWARD", 0, lineno=1), ConcreteInstr("POP_TOP", lineno=1), ] self.assertListEqual(list(code), expected) self.assertListEqual(code.consts, ["hello"]) def test_label2(self): bytecode = Bytecode() label = Label() bytecode.extend( [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", label), Instr("LOAD_CONST", 5, lineno=2), Instr("STORE_NAME", "x"), Instr("JUMP_FORWARD", label), Instr("LOAD_CONST", 7, lineno=4), Instr("STORE_NAME", "x"), label, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) concrete = bytecode.to_concrete_bytecode() expected = [ ConcreteInstr("LOAD_NAME", 0, lineno=1), ConcreteInstr( "POP_JUMP_IF_FALSE", 7 if OFFSET_AS_INSTRUCTION else 14, lineno=1 ), ConcreteInstr("LOAD_CONST", 0, lineno=2), ConcreteInstr("STORE_NAME", 1, lineno=2), ConcreteInstr("JUMP_FORWARD", 2 if OFFSET_AS_INSTRUCTION else 4, lineno=2), ConcreteInstr("LOAD_CONST", 1, lineno=4), ConcreteInstr("STORE_NAME", 1, lineno=4), ConcreteInstr("LOAD_CONST", 2, lineno=4), ConcreteInstr("RETURN_VALUE", lineno=4), ] self.assertListEqual(list(concrete), expected) self.assertListEqual(concrete.consts, [5, 7, None]) self.assertListEqual(concrete.names, ["test", "x"]) self.assertListEqual(concrete.varnames, []) def test_label3(self): """ CPython generates useless EXTENDED_ARG 0 in some cases. We need to properly track them as otherwise we can end up with broken offset for jumps. """ source = """ def func(x): if x == 1: return x + 0 elif x == 2: return x + 1 elif x == 3: return x + 2 elif x == 4: return x + 3 elif x == 5: return x + 4 elif x == 6: return x + 5 elif x == 7: return x + 6 elif x == 8: return x + 7 elif x == 9: return x + 8 elif x == 10: return x + 9 elif x == 11: return x + 10 elif x == 12: return x + 11 elif x == 13: return x + 12 elif x == 14: return x + 13 elif x == 15: return x + 14 elif x == 16: return x + 15 elif x == 17: return x + 16 return -1 """ code = get_code(source, function=True) bcode = Bytecode.from_code(code) concrete = bcode.to_concrete_bytecode() self.assertIsInstance(concrete, ConcreteBytecode) # Ensure that we do not generate broken code loc = {} exec(textwrap.dedent(source), loc) func = loc["func"] func.__code__ = bcode.to_code() for i, x in enumerate(range(1, 18)): self.assertEqual(func(x), x + i) self.assertEqual(func(18), -1) # Ensure that we properly round trip in such cases self.assertEqual( ConcreteBytecode.from_code(code).to_code().co_code, code.co_code ) def test_setlineno(self): # x = 7 # y = 8 # z = 9 concrete = ConcreteBytecode() concrete.consts = [7, 8, 9] concrete.names = ["x", "y", "z"] concrete.first_lineno = 3 concrete.extend( [ ConcreteInstr("LOAD_CONST", 0), ConcreteInstr("STORE_NAME", 0), SetLineno(4), ConcreteInstr("LOAD_CONST", 1), ConcreteInstr("STORE_NAME", 1), SetLineno(5), ConcreteInstr("LOAD_CONST", 2), ConcreteInstr("STORE_NAME", 2), ] ) code = concrete.to_bytecode() self.assertEqual( code, [ Instr("LOAD_CONST", 7, lineno=3), Instr("STORE_NAME", "x", lineno=3), Instr("LOAD_CONST", 8, lineno=4), Instr("STORE_NAME", "y", lineno=4), Instr("LOAD_CONST", 9, lineno=5), Instr("STORE_NAME", "z", lineno=5), ], ) def test_extended_jump(self): NOP = bytes((opcode.opmap["NOP"],)) class BigInstr(ConcreteInstr): def __init__(self, size): super().__init__("NOP") self._size = size def copy(self): return self def assemble(self): return NOP * self._size # (invalid) code using jumps > 0xffff to test extended arg label = Label() nb_nop = 2 ** 16 code = Bytecode( [ Instr("JUMP_ABSOLUTE", label), BigInstr(nb_nop), label, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) code_obj = code.to_code() if OFFSET_AS_INSTRUCTION: expected = b"\x90\x80q\x02" + NOP * nb_nop + b"d\x00S\x00" else: expected = b"\x90\x01\x90\x00q\x06" + NOP * nb_nop + b"d\x00S\x00" self.assertEqual(code_obj.co_code, expected) def test_jumps(self): # if test: # x = 12 # else: # x = 37 code = Bytecode() label_else = Label() label_return = Label() code.extend( [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", label_else), Instr("LOAD_CONST", 12, lineno=2), Instr("STORE_NAME", "x"), Instr("JUMP_FORWARD", label_return), label_else, Instr("LOAD_CONST", 37, lineno=4), Instr("STORE_NAME", "x"), label_return, Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE"), ] ) code = code.to_concrete_bytecode() expected = [ ConcreteInstr("LOAD_NAME", 0, lineno=1), ConcreteInstr( "POP_JUMP_IF_FALSE", 5 if OFFSET_AS_INSTRUCTION else 10, lineno=1 ), ConcreteInstr("LOAD_CONST", 0, lineno=2), ConcreteInstr("STORE_NAME", 1, lineno=2), ConcreteInstr("JUMP_FORWARD", 2 if OFFSET_AS_INSTRUCTION else 4, lineno=2), ConcreteInstr("LOAD_CONST", 1, lineno=4), ConcreteInstr("STORE_NAME", 1, lineno=4), ConcreteInstr("LOAD_CONST", 2, lineno=4), ConcreteInstr("RETURN_VALUE", lineno=4), ] self.assertListEqual(list(code), expected) self.assertListEqual(code.consts, [12, 37, None]) self.assertListEqual(code.names, ["test", "x"]) self.assertListEqual(code.varnames, []) def test_dont_merge_constants(self): # test two constants which are equal but have a different type code = Bytecode() code.extend( [ Instr("LOAD_CONST", 5, lineno=1), Instr("LOAD_CONST", 5.0, lineno=1), Instr("LOAD_CONST", -0.0, lineno=1), Instr("LOAD_CONST", +0.0, lineno=1), ] ) code = code.to_concrete_bytecode() expected = [ ConcreteInstr("LOAD_CONST", 0, lineno=1), ConcreteInstr("LOAD_CONST", 1, lineno=1), ConcreteInstr("LOAD_CONST", 2, lineno=1), ConcreteInstr("LOAD_CONST", 3, lineno=1), ] self.assertListEqual(list(code), expected) self.assertListEqual(code.consts, [5, 5.0, -0.0, +0.0]) def test_cellvars(self): code = Bytecode() code.cellvars = ["x"] code.freevars = ["y"] code.extend( [ Instr("LOAD_DEREF", CellVar("x"), lineno=1), Instr("LOAD_DEREF", FreeVar("y"), lineno=1), ] ) concrete = code.to_concrete_bytecode() self.assertEqual(concrete.cellvars, ["x"]) self.assertEqual(concrete.freevars, ["y"]) code.extend( [ ConcreteInstr("LOAD_DEREF", 0, lineno=1), ConcreteInstr("LOAD_DEREF", 1, lineno=1), ] ) def test_compute_jumps_convergence(self): # Consider the following sequence of instructions: # # JUMP_ABSOLUTE Label1 # JUMP_ABSOLUTE Label2 # ...126 instructions... # Label1: Offset 254 on first pass, 256 second pass # NOP # ... many more instructions ... # Label2: Offset > 256 on first pass # # On first pass of compute_jumps(), Label2 will be at address 254, so # that value encodes into the single byte arg of JUMP_ABSOLUTE. # # On second pass compute_jumps() the instr at Label1 will have offset # of 256 so will also be given an EXTENDED_ARG. # # Thus we need to make an additional pass. This test only verifies # case where 2 passes is insufficient but three is enough. # # On Python > 3.10 we need to double the number since the offset is now # in term of instructions and not bytes. # Create code from comment above. code = Bytecode() label1 = Label() label2 = Label() nop = "NOP" code.append(Instr("JUMP_ABSOLUTE", label1)) code.append(Instr("JUMP_ABSOLUTE", label2)) # Need 254 * 2 + 2 since the arg will change by 1 instruction rather than 2 # bytes. for x in range(4, 510 if OFFSET_AS_INSTRUCTION else 254, 2): code.append(Instr(nop)) code.append(label1) code.append(Instr(nop)) for x in range( 514 if OFFSET_AS_INSTRUCTION else 256, 600 if OFFSET_AS_INSTRUCTION else 300, 2, ): code.append(Instr(nop)) code.append(label2) code.append(Instr(nop)) # This should pass by default. code.to_code() # Try with max of two passes: it should raise with self.assertRaises(RuntimeError): code.to_code(compute_jumps_passes=2) def test_extreme_compute_jumps_convergence(self): """Test of compute_jumps() requiring absurd number of passes. NOTE: This test also serves to demonstrate that there is no worst case: the number of passes can be unlimited (or, actually, limited by the size of the provided code). This is an extension of test_compute_jumps_convergence. Instead of two jumps, where the earlier gets extended after the latter, we instead generate a series of many jumps. Each pass of compute_jumps() extends one more instruction, which in turn causes the one behind it to be extended on the next pass. """ # N: the number of unextended instructions that can be squeezed into a # set of bytes adressable by the arg of an unextended instruction. # The answer is "128", but here's how we arrive at it. max_unextended_offset = 1 << 8 unextended_branch_instr_size = 2 N = max_unextended_offset // unextended_branch_instr_size # When using instruction rather than bytes in the offset multiply by 2 if OFFSET_AS_INSTRUCTION: N *= 2 nop = "UNARY_POSITIVE" # don't use NOP, dis.stack_effect will raise # The number of jumps will be equal to the number of labels. The # number of passes of compute_jumps() required will be one greater # than this. labels = [Label() for x in range(0, 3 * N)] code = Bytecode() code.extend( Instr("JUMP_FORWARD", labels[len(labels) - x - 1]) for x in range(0, len(labels)) ) end_of_jumps = len(code) code.extend(Instr(nop) for x in range(0, N)) # Now insert the labels. The first is N instructions (i.e. 256 # bytes) after the last jump. Then they proceed to earlier positions # 4 bytes at a time. While the targets are in the range of the nop # instructions, 4 bytes is two instructions. When the targets are in # the range of JUMP_FORWARD instructions we have to allow for the fact # that the instructions will have been extended to four bytes each, so # working backwards 4 bytes per label means just one instruction per # label. offset = end_of_jumps + N for index in range(0, len(labels)): code.insert(offset, labels[index]) if offset <= end_of_jumps: offset -= 1 else: offset -= 2 code.insert(0, Instr("LOAD_CONST", 0)) del end_of_jumps code.append(Instr("RETURN_VALUE")) code.to_code(compute_jumps_passes=(len(labels) + 1)) def test_general_constants(self): """Test if general object could be linked as constants.""" class CustomObject: pass class UnHashableCustomObject: __hash__ = None obj1 = [1, 2, 3] obj2 = {1, 2, 3} obj3 = CustomObject() obj4 = UnHashableCustomObject() code = Bytecode( [ Instr("LOAD_CONST", obj1, lineno=1), Instr("LOAD_CONST", obj2, lineno=1), Instr("LOAD_CONST", obj3, lineno=1), Instr("LOAD_CONST", obj4, lineno=1), Instr("BUILD_TUPLE", 4, lineno=1), Instr("RETURN_VALUE", lineno=1), ] ) self.assertEqual(code.to_code().co_consts, (obj1, obj2, obj3, obj4)) def f(): return # pragma: no cover f.__code__ = code.to_code() self.assertEqual(f(), (obj1, obj2, obj3, obj4)) if __name__ == "__main__": unittest.main() # pragma: no cover
49,634
Python
31.784016
126
0.486219
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_instr.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') #!/usr/bin/env python3 import opcode import unittest from _pydevd_frame_eval.vendored.bytecode import ( UNSET, Label, Instr, CellVar, FreeVar, BasicBlock, SetLineno, Compare, ) from _pydevd_frame_eval.vendored.bytecode.tests import TestCase class SetLinenoTests(TestCase): def test_lineno(self): lineno = SetLineno(1) self.assertEqual(lineno.lineno, 1) def test_equality(self): lineno = SetLineno(1) self.assertNotEqual(lineno, 1) self.assertEqual(lineno, SetLineno(1)) self.assertNotEqual(lineno, SetLineno(2)) class VariableTests(TestCase): def test_str(self): for cls in (CellVar, FreeVar): var = cls("a") self.assertEqual(str(var), "a") def test_repr(self): for cls in (CellVar, FreeVar): var = cls("_a_x_a_") r = repr(var) self.assertIn("_a_x_a_", r) self.assertIn(cls.__name__, r) def test_eq(self): f1 = FreeVar("a") f2 = FreeVar("b") c1 = CellVar("a") c2 = CellVar("b") for v1, v2, eq in ( (f1, f1, True), (f1, f2, False), (f1, c1, False), (c1, c1, True), (c1, c2, False), ): if eq: self.assertEqual(v1, v2) else: self.assertNotEqual(v1, v2) class InstrTests(TestCase): def test_constructor(self): # invalid line number with self.assertRaises(TypeError): Instr("NOP", lineno="x") with self.assertRaises(ValueError): Instr("NOP", lineno=0) # invalid name with self.assertRaises(TypeError): Instr(1) with self.assertRaises(ValueError): Instr("xxx") def test_repr(self): # No arg r = repr(Instr("NOP", lineno=10)) self.assertIn("NOP", r) self.assertIn("10", r) self.assertIn("lineno", r) # Arg r = repr(Instr("LOAD_FAST", "_x_", lineno=10)) self.assertIn("LOAD_FAST", r) self.assertIn("lineno", r) self.assertIn("10", r) self.assertIn("arg", r) self.assertIn("_x_", r) def test_invalid_arg(self): label = Label() block = BasicBlock() # EXTENDED_ARG self.assertRaises(ValueError, Instr, "EXTENDED_ARG", 0) # has_jump() self.assertRaises(TypeError, Instr, "JUMP_ABSOLUTE", 1) self.assertRaises(TypeError, Instr, "JUMP_ABSOLUTE", 1.0) Instr("JUMP_ABSOLUTE", label) Instr("JUMP_ABSOLUTE", block) # hasfree self.assertRaises(TypeError, Instr, "LOAD_DEREF", "x") Instr("LOAD_DEREF", CellVar("x")) Instr("LOAD_DEREF", FreeVar("x")) # haslocal self.assertRaises(TypeError, Instr, "LOAD_FAST", 1) Instr("LOAD_FAST", "x") # hasname self.assertRaises(TypeError, Instr, "LOAD_NAME", 1) Instr("LOAD_NAME", "x") # hasconst self.assertRaises(ValueError, Instr, "LOAD_CONST") # UNSET self.assertRaises(ValueError, Instr, "LOAD_CONST", label) self.assertRaises(ValueError, Instr, "LOAD_CONST", block) Instr("LOAD_CONST", 1.0) Instr("LOAD_CONST", object()) # hascompare self.assertRaises(TypeError, Instr, "COMPARE_OP", 1) Instr("COMPARE_OP", Compare.EQ) # HAVE_ARGUMENT self.assertRaises(ValueError, Instr, "CALL_FUNCTION", -1) self.assertRaises(TypeError, Instr, "CALL_FUNCTION", 3.0) Instr("CALL_FUNCTION", 3) # test maximum argument self.assertRaises(ValueError, Instr, "CALL_FUNCTION", 2147483647 + 1) instr = Instr("CALL_FUNCTION", 2147483647) self.assertEqual(instr.arg, 2147483647) # not HAVE_ARGUMENT self.assertRaises(ValueError, Instr, "NOP", 0) Instr("NOP") def test_require_arg(self): i = Instr("CALL_FUNCTION", 3) self.assertTrue(i.require_arg()) i = Instr("NOP") self.assertFalse(i.require_arg()) def test_attr(self): instr = Instr("LOAD_CONST", 3, lineno=5) self.assertEqual(instr.name, "LOAD_CONST") self.assertEqual(instr.opcode, 100) self.assertEqual(instr.arg, 3) self.assertEqual(instr.lineno, 5) # invalid values/types self.assertRaises(ValueError, setattr, instr, "lineno", 0) self.assertRaises(TypeError, setattr, instr, "lineno", 1.0) self.assertRaises(TypeError, setattr, instr, "name", 5) self.assertRaises(TypeError, setattr, instr, "opcode", 1.0) self.assertRaises(ValueError, setattr, instr, "opcode", -1) self.assertRaises(ValueError, setattr, instr, "opcode", 255) # arg can take any attribute but cannot be deleted instr.arg = -8 instr.arg = object() self.assertRaises(AttributeError, delattr, instr, "arg") # no argument instr = Instr("ROT_TWO") self.assertIs(instr.arg, UNSET) def test_modify_op(self): instr = Instr("LOAD_NAME", "x") load_fast = opcode.opmap["LOAD_FAST"] instr.opcode = load_fast self.assertEqual(instr.name, "LOAD_FAST") self.assertEqual(instr.opcode, load_fast) def test_extended_arg(self): instr = Instr("LOAD_CONST", 0x1234ABCD) self.assertEqual(instr.arg, 0x1234ABCD) def test_slots(self): instr = Instr("NOP") with self.assertRaises(AttributeError): instr.myattr = 1 def test_compare(self): instr = Instr("LOAD_CONST", 3, lineno=7) self.assertEqual(instr, Instr("LOAD_CONST", 3, lineno=7)) self.assertNotEqual(instr, 1) # different lineno self.assertNotEqual(instr, Instr("LOAD_CONST", 3)) self.assertNotEqual(instr, Instr("LOAD_CONST", 3, lineno=6)) # different op self.assertNotEqual(instr, Instr("LOAD_FAST", "x", lineno=7)) # different arg self.assertNotEqual(instr, Instr("LOAD_CONST", 4, lineno=7)) def test_has_jump(self): label = Label() jump = Instr("JUMP_ABSOLUTE", label) self.assertTrue(jump.has_jump()) instr = Instr("LOAD_FAST", "x") self.assertFalse(instr.has_jump()) def test_is_cond_jump(self): label = Label() jump = Instr("POP_JUMP_IF_TRUE", label) self.assertTrue(jump.is_cond_jump()) instr = Instr("LOAD_FAST", "x") self.assertFalse(instr.is_cond_jump()) def test_is_uncond_jump(self): label = Label() jump = Instr("JUMP_ABSOLUTE", label) self.assertTrue(jump.is_uncond_jump()) instr = Instr("POP_JUMP_IF_TRUE", label) self.assertFalse(instr.is_uncond_jump()) def test_const_key_not_equal(self): def check(value): self.assertEqual(Instr("LOAD_CONST", value), Instr("LOAD_CONST", value)) def func(): pass check(None) check(0) check(0.0) check(b"bytes") check("text") check(Ellipsis) check((1, 2, 3)) check(frozenset({1, 2, 3})) check(func.__code__) check(object()) def test_const_key_equal(self): neg_zero = -0.0 pos_zero = +0.0 # int and float: 0 == 0.0 self.assertNotEqual(Instr("LOAD_CONST", 0), Instr("LOAD_CONST", 0.0)) # float: -0.0 == +0.0 self.assertNotEqual( Instr("LOAD_CONST", neg_zero), Instr("LOAD_CONST", pos_zero) ) # complex self.assertNotEqual( Instr("LOAD_CONST", complex(neg_zero, 1.0)), Instr("LOAD_CONST", complex(pos_zero, 1.0)), ) self.assertNotEqual( Instr("LOAD_CONST", complex(1.0, neg_zero)), Instr("LOAD_CONST", complex(1.0, pos_zero)), ) # tuple self.assertNotEqual(Instr("LOAD_CONST", (0,)), Instr("LOAD_CONST", (0.0,))) nested_tuple1 = (0,) nested_tuple1 = (nested_tuple1,) nested_tuple2 = (0.0,) nested_tuple2 = (nested_tuple2,) self.assertNotEqual( Instr("LOAD_CONST", nested_tuple1), Instr("LOAD_CONST", nested_tuple2) ) # frozenset self.assertNotEqual( Instr("LOAD_CONST", frozenset({0})), Instr("LOAD_CONST", frozenset({0.0})) ) def test_stack_effects(self): # Verify all opcodes are handled and that "jump=None" really returns # the max of the other cases. from _pydevd_frame_eval.vendored.bytecode.concrete import ConcreteInstr def check(instr): jump = instr.stack_effect(jump=True) no_jump = instr.stack_effect(jump=False) max_effect = instr.stack_effect(jump=None) self.assertEqual(instr.stack_effect(), max_effect) self.assertEqual(max_effect, max(jump, no_jump)) if not instr.has_jump(): self.assertEqual(jump, no_jump) for name, op in opcode.opmap.items(): with self.subTest(name): # Use ConcreteInstr instead of Instr because it doesn't care # what kind of argument it is constructed with. if op < opcode.HAVE_ARGUMENT: check(ConcreteInstr(name)) else: for arg in range(256): check(ConcreteInstr(name, arg)) # LOAD_CONST uses a concrete python object as its oparg, however, in # dis.stack_effect(opcode.opmap['LOAD_CONST'], oparg), # oparg should be the index of that python object in the constants. # # Fortunately, for an instruction whose oparg isn't equivalent to its # form in binary files(pyc format), the stack effect is a # constant which does not depend on its oparg. # # The second argument of dis.stack_effect cannot be # more than 2**31 - 1. If stack effect of an instruction is # independent of its oparg, we pass 0 as the second argument # of dis.stack_effect. # (As a result we can calculate stack_effect for # any LOAD_CONST instructions, even for large integers) for arg in 2 ** 31, 2 ** 32, 2 ** 63, 2 ** 64, -1: self.assertEqual(Instr("LOAD_CONST", arg).stack_effect(), 1) def test_code_object_containing_mutable_data(self): from _pydevd_frame_eval.vendored.bytecode import Bytecode, Instr from types import CodeType def f(): def g(): return "value" return g f_code = Bytecode.from_code(f.__code__) instr_load_code = None mutable_datum = [4, 2] for each in f_code: if ( isinstance(each, Instr) and each.name == "LOAD_CONST" and isinstance(each.arg, CodeType) ): instr_load_code = each break self.assertIsNotNone(instr_load_code) g_code = Bytecode.from_code(instr_load_code.arg) g_code[0].arg = mutable_datum instr_load_code.arg = g_code.to_code() f.__code__ = f_code.to_code() self.assertIs(f()(), mutable_datum) if __name__ == "__main__": unittest.main() # pragma: no cover
11,676
Python
31.168044
126
0.569544
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_peephole_opt.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') import sys import unittest from _pydevd_frame_eval.vendored.bytecode import Label, Instr, Compare, Bytecode, ControlFlowGraph from _pydevd_frame_eval.vendored.bytecode import peephole_opt from _pydevd_frame_eval.vendored.bytecode.tests import TestCase, dump_bytecode from unittest import mock class Tests(TestCase): maxDiff = 80 * 100 def optimize_blocks(self, code): if isinstance(code, Bytecode): code = ControlFlowGraph.from_bytecode(code) optimizer = peephole_opt.PeepholeOptimizer() optimizer.optimize_cfg(code) return code def check(self, code, *expected): if isinstance(code, Bytecode): code = ControlFlowGraph.from_bytecode(code) optimizer = peephole_opt.PeepholeOptimizer() optimizer.optimize_cfg(code) code = code.to_bytecode() try: self.assertEqual(code, expected) except AssertionError: print("Optimized code:") dump_bytecode(code) print("Expected code:") for instr in expected: print(instr) raise def check_dont_optimize(self, code): code = ControlFlowGraph.from_bytecode(code) noopt = code.to_bytecode() optim = self.optimize_blocks(code) optim = optim.to_bytecode() self.assertEqual(optim, noopt) def test_unary_op(self): def check_unary_op(op, value, result): code = Bytecode( [Instr("LOAD_CONST", value), Instr(op), Instr("STORE_NAME", "x")] ) self.check(code, Instr("LOAD_CONST", result), Instr("STORE_NAME", "x")) check_unary_op("UNARY_POSITIVE", 2, 2) check_unary_op("UNARY_NEGATIVE", 3, -3) check_unary_op("UNARY_INVERT", 5, -6) def test_binary_op(self): def check_bin_op(left, op, right, result): code = Bytecode( [ Instr("LOAD_CONST", left), Instr("LOAD_CONST", right), Instr(op), Instr("STORE_NAME", "x"), ] ) self.check(code, Instr("LOAD_CONST", result), Instr("STORE_NAME", "x")) check_bin_op(10, "BINARY_ADD", 20, 30) check_bin_op(5, "BINARY_SUBTRACT", 1, 4) check_bin_op(5, "BINARY_MULTIPLY", 3, 15) check_bin_op(10, "BINARY_TRUE_DIVIDE", 3, 10 / 3) check_bin_op(10, "BINARY_FLOOR_DIVIDE", 3, 3) check_bin_op(10, "BINARY_MODULO", 3, 1) check_bin_op(2, "BINARY_POWER", 8, 256) check_bin_op(1, "BINARY_LSHIFT", 3, 8) check_bin_op(16, "BINARY_RSHIFT", 3, 2) check_bin_op(10, "BINARY_AND", 3, 2) check_bin_op(2, "BINARY_OR", 3, 3) check_bin_op(2, "BINARY_XOR", 3, 1) def test_combined_unary_bin_ops(self): # x = 1 + 3 + 7 code = Bytecode( [ Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 3), Instr("BINARY_ADD"), Instr("LOAD_CONST", 7), Instr("BINARY_ADD"), Instr("STORE_NAME", "x"), ] ) self.check(code, Instr("LOAD_CONST", 11), Instr("STORE_NAME", "x")) # x = ~(~(5)) code = Bytecode( [ Instr("LOAD_CONST", 5), Instr("UNARY_INVERT"), Instr("UNARY_INVERT"), Instr("STORE_NAME", "x"), ] ) self.check(code, Instr("LOAD_CONST", 5), Instr("STORE_NAME", "x")) # "events = [(0, 'call'), (1, 'line'), (-(3), 'call')]" code = Bytecode( [ Instr("LOAD_CONST", 0), Instr("LOAD_CONST", "call"), Instr("BUILD_TUPLE", 2), Instr("LOAD_CONST", 1), Instr("LOAD_CONST", "line"), Instr("BUILD_TUPLE", 2), Instr("LOAD_CONST", 3), Instr("UNARY_NEGATIVE"), Instr("LOAD_CONST", "call"), Instr("BUILD_TUPLE", 2), Instr("BUILD_LIST", 3), Instr("STORE_NAME", "events"), ] ) self.check( code, Instr("LOAD_CONST", (0, "call")), Instr("LOAD_CONST", (1, "line")), Instr("LOAD_CONST", (-3, "call")), Instr("BUILD_LIST", 3), Instr("STORE_NAME", "events"), ) # 'x = (1,) + (0,) * 8' code = Bytecode( [ Instr("LOAD_CONST", 1), Instr("BUILD_TUPLE", 1), Instr("LOAD_CONST", 0), Instr("BUILD_TUPLE", 1), Instr("LOAD_CONST", 8), Instr("BINARY_MULTIPLY"), Instr("BINARY_ADD"), Instr("STORE_NAME", "x"), ] ) zeros = (0,) * 8 result = (1,) + zeros self.check(code, Instr("LOAD_CONST", result), Instr("STORE_NAME", "x")) def test_max_size(self): max_size = 3 with mock.patch.object(peephole_opt, "MAX_SIZE", max_size): # optimized binary operation: size <= maximum size # # (9,) * size size = max_size result = (9,) * size code = Bytecode( [ Instr("LOAD_CONST", 9), Instr("BUILD_TUPLE", 1), Instr("LOAD_CONST", size), Instr("BINARY_MULTIPLY"), Instr("STORE_NAME", "x"), ] ) self.check(code, Instr("LOAD_CONST", result), Instr("STORE_NAME", "x")) # don't optimize binary operation: size > maximum size # # x = (9,) * size size = max_size + 1 code = Bytecode( [ Instr("LOAD_CONST", 9), Instr("BUILD_TUPLE", 1), Instr("LOAD_CONST", size), Instr("BINARY_MULTIPLY"), Instr("STORE_NAME", "x"), ] ) self.check( code, Instr("LOAD_CONST", (9,)), Instr("LOAD_CONST", size), Instr("BINARY_MULTIPLY"), Instr("STORE_NAME", "x"), ) def test_bin_op_dont_optimize(self): # 1 / 0 code = Bytecode( [ Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 0), Instr("BINARY_TRUE_DIVIDE"), Instr("POP_TOP"), Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) self.check_dont_optimize(code) # 1 // 0 code = Bytecode( [ Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 0), Instr("BINARY_FLOOR_DIVIDE"), Instr("POP_TOP"), Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) self.check_dont_optimize(code) # 1 % 0 code = Bytecode( [ Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 0), Instr("BINARY_MODULO"), Instr("POP_TOP"), Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) self.check_dont_optimize(code) # 1 % 1j code = Bytecode( [ Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 1j), Instr("BINARY_MODULO"), Instr("POP_TOP"), Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) self.check_dont_optimize(code) def test_build_tuple(self): # x = (1, 2, 3) code = Bytecode( [ Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 2), Instr("LOAD_CONST", 3), Instr("BUILD_TUPLE", 3), Instr("STORE_NAME", "x"), ] ) self.check(code, Instr("LOAD_CONST", (1, 2, 3)), Instr("STORE_NAME", "x")) def test_build_list(self): # test = x in [1, 2, 3] code = Bytecode( [ Instr("LOAD_NAME", "x"), Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 2), Instr("LOAD_CONST", 3), Instr("BUILD_LIST", 3), Instr("COMPARE_OP", Compare.IN), Instr("STORE_NAME", "test"), ] ) self.check( code, Instr("LOAD_NAME", "x"), Instr("LOAD_CONST", (1, 2, 3)), Instr("COMPARE_OP", Compare.IN), Instr("STORE_NAME", "test"), ) def test_build_list_unpack_seq(self): for build_list in ("BUILD_TUPLE", "BUILD_LIST"): # x, = [a] code = Bytecode( [ Instr("LOAD_NAME", "a"), Instr(build_list, 1), Instr("UNPACK_SEQUENCE", 1), Instr("STORE_NAME", "x"), ] ) self.check(code, Instr("LOAD_NAME", "a"), Instr("STORE_NAME", "x")) # x, y = [a, b] code = Bytecode( [ Instr("LOAD_NAME", "a"), Instr("LOAD_NAME", "b"), Instr(build_list, 2), Instr("UNPACK_SEQUENCE", 2), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), ] ) self.check( code, Instr("LOAD_NAME", "a"), Instr("LOAD_NAME", "b"), Instr("ROT_TWO"), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), ) # x, y, z = [a, b, c] code = Bytecode( [ Instr("LOAD_NAME", "a"), Instr("LOAD_NAME", "b"), Instr("LOAD_NAME", "c"), Instr(build_list, 3), Instr("UNPACK_SEQUENCE", 3), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), Instr("STORE_NAME", "z"), ] ) self.check( code, Instr("LOAD_NAME", "a"), Instr("LOAD_NAME", "b"), Instr("LOAD_NAME", "c"), Instr("ROT_THREE"), Instr("ROT_TWO"), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), Instr("STORE_NAME", "z"), ) def test_build_tuple_unpack_seq_const(self): # x, y = (3, 4) code = Bytecode( [ Instr("LOAD_CONST", 3), Instr("LOAD_CONST", 4), Instr("BUILD_TUPLE", 2), Instr("UNPACK_SEQUENCE", 2), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), ] ) self.check( code, Instr("LOAD_CONST", (3, 4)), Instr("UNPACK_SEQUENCE", 2), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), ) def test_build_list_unpack_seq_const(self): # x, y, z = [3, 4, 5] code = Bytecode( [ Instr("LOAD_CONST", 3), Instr("LOAD_CONST", 4), Instr("LOAD_CONST", 5), Instr("BUILD_LIST", 3), Instr("UNPACK_SEQUENCE", 3), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), Instr("STORE_NAME", "z"), ] ) self.check( code, Instr("LOAD_CONST", 5), Instr("LOAD_CONST", 4), Instr("LOAD_CONST", 3), Instr("STORE_NAME", "x"), Instr("STORE_NAME", "y"), Instr("STORE_NAME", "z"), ) def test_build_set(self): # test = x in {1, 2, 3} code = Bytecode( [ Instr("LOAD_NAME", "x"), Instr("LOAD_CONST", 1), Instr("LOAD_CONST", 2), Instr("LOAD_CONST", 3), Instr("BUILD_SET", 3), Instr("COMPARE_OP", Compare.IN), Instr("STORE_NAME", "test"), ] ) self.check( code, Instr("LOAD_NAME", "x"), Instr("LOAD_CONST", frozenset((1, 2, 3))), Instr("COMPARE_OP", Compare.IN), Instr("STORE_NAME", "test"), ) def test_compare_op_unary_not(self): for op, not_op in ( (Compare.IN, Compare.NOT_IN), # in => not in (Compare.NOT_IN, Compare.IN), # not in => in (Compare.IS, Compare.IS_NOT), # is => is not (Compare.IS_NOT, Compare.IS), # is not => is ): code = Bytecode( [ Instr("LOAD_NAME", "a"), Instr("LOAD_NAME", "b"), Instr("COMPARE_OP", op), Instr("UNARY_NOT"), Instr("STORE_NAME", "x"), ] ) self.check( code, Instr("LOAD_NAME", "a"), Instr("LOAD_NAME", "b"), Instr("COMPARE_OP", not_op), Instr("STORE_NAME", "x"), ) # don't optimize: # x = not (a and b is True) label_instr5 = Label() code = Bytecode( [ Instr("LOAD_NAME", "a"), Instr("JUMP_IF_FALSE_OR_POP", label_instr5), Instr("LOAD_NAME", "b"), Instr("LOAD_CONST", True), Instr("COMPARE_OP", Compare.IS), label_instr5, Instr("UNARY_NOT"), Instr("STORE_NAME", "x"), Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) self.check_dont_optimize(code) def test_dont_optimize(self): # x = 3 < 5 code = Bytecode( [ Instr("LOAD_CONST", 3), Instr("LOAD_CONST", 5), Instr("COMPARE_OP", Compare.LT), Instr("STORE_NAME", "x"), Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) self.check_dont_optimize(code) # x = (10, 20, 30)[1:] code = Bytecode( [ Instr("LOAD_CONST", (10, 20, 30)), Instr("LOAD_CONST", 1), Instr("LOAD_CONST", None), Instr("BUILD_SLICE", 2), Instr("BINARY_SUBSCR"), Instr("STORE_NAME", "x"), ] ) self.check_dont_optimize(code) def test_optimize_code_obj(self): # Test optimize() method with a code object # # x = 3 + 5 => x = 8 noopt = Bytecode( [ Instr("LOAD_CONST", 3), Instr("LOAD_CONST", 5), Instr("BINARY_ADD"), Instr("STORE_NAME", "x"), Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) noopt = noopt.to_code() optimizer = peephole_opt.PeepholeOptimizer() optim = optimizer.optimize(noopt) code = Bytecode.from_code(optim) self.assertEqual( code, [ Instr("LOAD_CONST", 8, lineno=1), Instr("STORE_NAME", "x", lineno=1), Instr("LOAD_CONST", None, lineno=1), Instr("RETURN_VALUE", lineno=1), ], ) def test_return_value(self): # return+return: remove second return # # def func(): # return 4 # return 5 code = Bytecode( [ Instr("LOAD_CONST", 4, lineno=2), Instr("RETURN_VALUE", lineno=2), Instr("LOAD_CONST", 5, lineno=3), Instr("RETURN_VALUE", lineno=3), ] ) code = ControlFlowGraph.from_bytecode(code) self.check( code, Instr("LOAD_CONST", 4, lineno=2), Instr("RETURN_VALUE", lineno=2) ) # return+return + return+return: remove second and fourth return # # def func(): # return 4 # return 5 # return 6 # return 7 code = Bytecode( [ Instr("LOAD_CONST", 4, lineno=2), Instr("RETURN_VALUE", lineno=2), Instr("LOAD_CONST", 5, lineno=3), Instr("RETURN_VALUE", lineno=3), Instr("LOAD_CONST", 6, lineno=4), Instr("RETURN_VALUE", lineno=4), Instr("LOAD_CONST", 7, lineno=5), Instr("RETURN_VALUE", lineno=5), ] ) code = ControlFlowGraph.from_bytecode(code) self.check( code, Instr("LOAD_CONST", 4, lineno=2), Instr("RETURN_VALUE", lineno=2) ) # return + JUMP_ABSOLUTE: remove JUMP_ABSOLUTE # while 1: # return 7 if sys.version_info < (3, 8): setup_loop = Label() return_label = Label() code = Bytecode( [ setup_loop, Instr("SETUP_LOOP", return_label, lineno=2), Instr("LOAD_CONST", 7, lineno=3), Instr("RETURN_VALUE", lineno=3), Instr("JUMP_ABSOLUTE", setup_loop, lineno=3), Instr("POP_BLOCK", lineno=3), return_label, Instr("LOAD_CONST", None, lineno=3), Instr("RETURN_VALUE", lineno=3), ] ) code = ControlFlowGraph.from_bytecode(code) end_loop = Label() self.check( code, Instr("SETUP_LOOP", end_loop, lineno=2), Instr("LOAD_CONST", 7, lineno=3), Instr("RETURN_VALUE", lineno=3), end_loop, Instr("LOAD_CONST", None, lineno=3), Instr("RETURN_VALUE", lineno=3), ) else: setup_loop = Label() return_label = Label() code = Bytecode( [ setup_loop, Instr("LOAD_CONST", 7, lineno=3), Instr("RETURN_VALUE", lineno=3), Instr("JUMP_ABSOLUTE", setup_loop, lineno=3), Instr("LOAD_CONST", None, lineno=3), Instr("RETURN_VALUE", lineno=3), ] ) code = ControlFlowGraph.from_bytecode(code) self.check( code, Instr("LOAD_CONST", 7, lineno=3), Instr("RETURN_VALUE", lineno=3) ) def test_not_jump_if_false(self): # Replace UNARY_NOT+POP_JUMP_IF_FALSE with POP_JUMP_IF_TRUE # # if not x: # y = 9 label = Label() code = Bytecode( [ Instr("LOAD_NAME", "x"), Instr("UNARY_NOT"), Instr("POP_JUMP_IF_FALSE", label), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "y"), label, ] ) code = self.optimize_blocks(code) label = Label() self.check( code, Instr("LOAD_NAME", "x"), Instr("POP_JUMP_IF_TRUE", label), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "y"), label, ) def test_unconditional_jump_to_return(self): # def func(): # if test: # if test2: # x = 10 # else: # x = 20 # else: # x = 30 label_instr11 = Label() label_instr14 = Label() label_instr7 = Label() code = Bytecode( [ Instr("LOAD_GLOBAL", "test", lineno=2), Instr("POP_JUMP_IF_FALSE", label_instr11, lineno=2), Instr("LOAD_GLOBAL", "test2", lineno=3), Instr("POP_JUMP_IF_FALSE", label_instr7, lineno=3), Instr("LOAD_CONST", 10, lineno=4), Instr("STORE_FAST", "x", lineno=4), Instr("JUMP_ABSOLUTE", label_instr14, lineno=4), label_instr7, Instr("LOAD_CONST", 20, lineno=6), Instr("STORE_FAST", "x", lineno=6), Instr("JUMP_FORWARD", label_instr14, lineno=6), label_instr11, Instr("LOAD_CONST", 30, lineno=8), Instr("STORE_FAST", "x", lineno=8), label_instr14, Instr("LOAD_CONST", None, lineno=8), Instr("RETURN_VALUE", lineno=8), ] ) label1 = Label() label3 = Label() label4 = Label() self.check( code, Instr("LOAD_GLOBAL", "test", lineno=2), Instr("POP_JUMP_IF_FALSE", label3, lineno=2), Instr("LOAD_GLOBAL", "test2", lineno=3), Instr("POP_JUMP_IF_FALSE", label1, lineno=3), Instr("LOAD_CONST", 10, lineno=4), Instr("STORE_FAST", "x", lineno=4), Instr("JUMP_ABSOLUTE", label4, lineno=4), label1, Instr("LOAD_CONST", 20, lineno=6), Instr("STORE_FAST", "x", lineno=6), Instr("JUMP_FORWARD", label4, lineno=6), label3, Instr("LOAD_CONST", 30, lineno=8), Instr("STORE_FAST", "x", lineno=8), label4, Instr("LOAD_CONST", None, lineno=8), Instr("RETURN_VALUE", lineno=8), ) def test_unconditional_jumps(self): # def func(): # if x: # if y: # func() label_instr7 = Label() code = Bytecode( [ Instr("LOAD_GLOBAL", "x", lineno=2), Instr("POP_JUMP_IF_FALSE", label_instr7, lineno=2), Instr("LOAD_GLOBAL", "y", lineno=3), Instr("POP_JUMP_IF_FALSE", label_instr7, lineno=3), Instr("LOAD_GLOBAL", "func", lineno=4), Instr("CALL_FUNCTION", 0, lineno=4), Instr("POP_TOP", lineno=4), label_instr7, Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4), ] ) label_return = Label() self.check( code, Instr("LOAD_GLOBAL", "x", lineno=2), Instr("POP_JUMP_IF_FALSE", label_return, lineno=2), Instr("LOAD_GLOBAL", "y", lineno=3), Instr("POP_JUMP_IF_FALSE", label_return, lineno=3), Instr("LOAD_GLOBAL", "func", lineno=4), Instr("CALL_FUNCTION", 0, lineno=4), Instr("POP_TOP", lineno=4), label_return, Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4), ) def test_jump_to_return(self): # def func(condition): # return 'yes' if condition else 'no' label_instr4 = Label() label_instr6 = Label() code = Bytecode( [ Instr("LOAD_FAST", "condition"), Instr("POP_JUMP_IF_FALSE", label_instr4), Instr("LOAD_CONST", "yes"), Instr("JUMP_FORWARD", label_instr6), label_instr4, Instr("LOAD_CONST", "no"), label_instr6, Instr("RETURN_VALUE"), ] ) label = Label() self.check( code, Instr("LOAD_FAST", "condition"), Instr("POP_JUMP_IF_FALSE", label), Instr("LOAD_CONST", "yes"), Instr("RETURN_VALUE"), label, Instr("LOAD_CONST", "no"), Instr("RETURN_VALUE"), ) def test_jump_if_true_to_jump_if_false(self): # Replace JUMP_IF_TRUE_OR_POP jumping to POP_JUMP_IF_FALSE <target> # with POP_JUMP_IF_TRUE <offset after the second POP_JUMP_IF_FALSE> # # if x or y: # z = 1 label_instr3 = Label() label_instr7 = Label() code = Bytecode( [ Instr("LOAD_NAME", "x"), Instr("JUMP_IF_TRUE_OR_POP", label_instr3), Instr("LOAD_NAME", "y"), label_instr3, Instr("POP_JUMP_IF_FALSE", label_instr7), Instr("LOAD_CONST", 1), Instr("STORE_NAME", "z"), label_instr7, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) label_instr4 = Label() label_instr7 = Label() self.check( code, Instr("LOAD_NAME", "x"), Instr("POP_JUMP_IF_TRUE", label_instr4), Instr("LOAD_NAME", "y"), Instr("POP_JUMP_IF_FALSE", label_instr7), label_instr4, Instr("LOAD_CONST", 1), Instr("STORE_NAME", "z"), label_instr7, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ) def test_jump_if_false_to_jump_if_false(self): # Replace JUMP_IF_FALSE_OR_POP jumping to POP_JUMP_IF_FALSE <label> # with POP_JUMP_IF_FALSE <label> # # while n > 0 and start > 3: # func() if sys.version_info < (3, 8): label_instr1 = Label() label_instr15 = Label() label_instr17 = Label() label_instr9 = Label() code = Bytecode( [ Instr("SETUP_LOOP", label_instr17), label_instr1, Instr("LOAD_NAME", "n"), Instr("LOAD_CONST", 0), Instr("COMPARE_OP", Compare.GT), # JUMP_IF_FALSE_OR_POP jumps to POP_JUMP_IF_FALSE # which jumps to label_instr15 Instr("JUMP_IF_FALSE_OR_POP", label_instr9), Instr("LOAD_NAME", "start"), Instr("LOAD_CONST", 3), Instr("COMPARE_OP", Compare.GT), label_instr9, Instr("POP_JUMP_IF_FALSE", label_instr15), Instr("LOAD_NAME", "func"), Instr("CALL_FUNCTION", 0), Instr("POP_TOP"), Instr("JUMP_ABSOLUTE", label_instr1), label_instr15, Instr("POP_BLOCK"), label_instr17, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) label_instr1 = Label() label_instr14 = Label() label_instr16 = Label() self.check( code, Instr("SETUP_LOOP", label_instr16), label_instr1, Instr("LOAD_NAME", "n"), Instr("LOAD_CONST", 0), Instr("COMPARE_OP", Compare.GT), Instr("POP_JUMP_IF_FALSE", label_instr14), Instr("LOAD_NAME", "start"), Instr("LOAD_CONST", 3), Instr("COMPARE_OP", Compare.GT), Instr("POP_JUMP_IF_FALSE", label_instr14), Instr("LOAD_NAME", "func"), Instr("CALL_FUNCTION", 0), Instr("POP_TOP"), Instr("JUMP_ABSOLUTE", label_instr1), label_instr14, Instr("POP_BLOCK"), label_instr16, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ) else: label_instr1 = Label() label_instr15 = Label() label_instr9 = Label() code = Bytecode( [ label_instr1, Instr("LOAD_NAME", "n"), Instr("LOAD_CONST", 0), Instr("COMPARE_OP", Compare.GT), # JUMP_IF_FALSE_OR_POP jumps to POP_JUMP_IF_FALSE # which jumps to label_instr15 Instr("JUMP_IF_FALSE_OR_POP", label_instr9), Instr("LOAD_NAME", "start"), Instr("LOAD_CONST", 3), Instr("COMPARE_OP", Compare.GT), label_instr9, Instr("POP_JUMP_IF_FALSE", label_instr15), Instr("LOAD_NAME", "func"), Instr("CALL_FUNCTION", 0), Instr("POP_TOP"), Instr("JUMP_ABSOLUTE", label_instr1), label_instr15, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) label_instr1 = Label() label_instr14 = Label() self.check( code, label_instr1, Instr("LOAD_NAME", "n"), Instr("LOAD_CONST", 0), Instr("COMPARE_OP", Compare.GT), Instr("POP_JUMP_IF_FALSE", label_instr14), Instr("LOAD_NAME", "start"), Instr("LOAD_CONST", 3), Instr("COMPARE_OP", Compare.GT), Instr("POP_JUMP_IF_FALSE", label_instr14), Instr("LOAD_NAME", "func"), Instr("CALL_FUNCTION", 0), Instr("POP_TOP"), Instr("JUMP_ABSOLUTE", label_instr1), label_instr14, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ) def test_nop(self): code = Bytecode( [Instr("LOAD_NAME", "x"), Instr("NOP"), Instr("STORE_NAME", "test")] ) self.check(code, Instr("LOAD_NAME", "x"), Instr("STORE_NAME", "test")) def test_dead_code_jump(self): label = Label() code = Bytecode( [ Instr("LOAD_NAME", "x"), Instr("JUMP_ABSOLUTE", label), # dead code Instr("LOAD_NAME", "y"), Instr("STORE_NAME", "test"), label, Instr("STORE_NAME", "test"), ] ) self.check(code, Instr("LOAD_NAME", "x"), Instr("STORE_NAME", "test")) def test_uncond_jump_to_uncond_jump(self): # Replace JUMP_FORWARD t1 jumping to JUMP_FORWARD t2 # with JUMP_ABSOLUTE t2 label = Label() label2 = Label() label3 = Label() label4 = Label() code = Bytecode( [ Instr("LOAD_NAME", "test"), Instr("POP_JUMP_IF_TRUE", label), # redundant jump Instr("JUMP_FORWARD", label2), label, Instr("LOAD_CONST", 1), Instr("STORE_NAME", "x"), Instr("LOAD_NAME", "test"), Instr("POP_JUMP_IF_TRUE", label3), label2, Instr("JUMP_FORWARD", label4), label3, Instr("LOAD_CONST", 1), Instr("STORE_NAME", "x"), label4, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ] ) label = Label() label3 = Label() label4 = Label() self.check( code, Instr("LOAD_NAME", "test"), Instr("POP_JUMP_IF_TRUE", label), # JUMP_FORWARD label2 was replaced with JUMP_ABSOLUTE label4 Instr("JUMP_ABSOLUTE", label4), label, Instr("LOAD_CONST", 1), Instr("STORE_NAME", "x"), Instr("LOAD_NAME", "test"), Instr("POP_JUMP_IF_TRUE", label3), Instr("JUMP_FORWARD", label4), label3, Instr("LOAD_CONST", 1), Instr("STORE_NAME", "x"), label4, Instr("LOAD_CONST", None), Instr("RETURN_VALUE"), ) if __name__ == "__main__": unittest.main() # pragma: no cover
32,993
Python
32.462475
126
0.423453
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/__init__.py
import sys import textwrap import types import unittest from _pydevd_frame_eval.vendored.bytecode import ( UNSET, Label, Instr, ConcreteInstr, BasicBlock, # noqa Bytecode, ControlFlowGraph, ConcreteBytecode, ) def _format_instr_list(block, labels, lineno): instr_list = [] for instr in block: if not isinstance(instr, Label): if isinstance(instr, ConcreteInstr): cls_name = "ConcreteInstr" else: cls_name = "Instr" arg = instr.arg if arg is not UNSET: if isinstance(arg, Label): arg = labels[arg] elif isinstance(arg, BasicBlock): arg = labels[id(arg)] else: arg = repr(arg) if lineno: text = "%s(%r, %s, lineno=%s)" % ( cls_name, instr.name, arg, instr.lineno, ) else: text = "%s(%r, %s)" % (cls_name, instr.name, arg) else: if lineno: text = "%s(%r, lineno=%s)" % (cls_name, instr.name, instr.lineno) else: text = "%s(%r)" % (cls_name, instr.name) else: text = labels[instr] instr_list.append(text) return "[%s]" % ",\n ".join(instr_list) def dump_bytecode(code, lineno=False): """ Use this function to write unit tests: copy/paste its output to write a self.assertBlocksEqual() check. """ print() if isinstance(code, (Bytecode, ConcreteBytecode)): is_concrete = isinstance(code, ConcreteBytecode) if is_concrete: block = list(code) else: block = code indent = " " * 8 labels = {} for index, instr in enumerate(block): if isinstance(instr, Label): name = "label_instr%s" % index labels[instr] = name if is_concrete: name = "ConcreteBytecode" print(indent + "code = %s()" % name) if code.argcount: print(indent + "code.argcount = %s" % code.argcount) if sys.version_info > (3, 8): if code.posonlyargcount: print(indent + "code.posonlyargcount = %s" % code.posonlyargcount) if code.kwonlyargcount: print(indent + "code.kwargonlycount = %s" % code.kwonlyargcount) print(indent + "code.flags = %#x" % code.flags) if code.consts: print(indent + "code.consts = %r" % code.consts) if code.names: print(indent + "code.names = %r" % code.names) if code.varnames: print(indent + "code.varnames = %r" % code.varnames) for name in sorted(labels.values()): print(indent + "%s = Label()" % name) if is_concrete: text = indent + "code.extend(" indent = " " * len(text) else: text = indent + "code = Bytecode(" indent = " " * len(text) lines = _format_instr_list(code, labels, lineno).splitlines() last_line = len(lines) - 1 for index, line in enumerate(lines): if index == 0: print(text + lines[0]) elif index == last_line: print(indent + line + ")") else: print(indent + line) print() else: assert isinstance(code, ControlFlowGraph) labels = {} for block_index, block in enumerate(code): labels[id(block)] = "code[%s]" % block_index for block_index, block in enumerate(code): text = _format_instr_list(block, labels, lineno) if block_index != len(code) - 1: text += "," print(text) print() def get_code(source, *, filename="<string>", function=False): source = textwrap.dedent(source).strip() code = compile(source, filename, "exec") if function: sub_code = [ const for const in code.co_consts if isinstance(const, types.CodeType) ] if len(sub_code) != 1: raise ValueError("unable to find function code") code = sub_code[0] return code def disassemble(source, *, filename="<string>", function=False): code = get_code(source, filename=filename, function=function) return Bytecode.from_code(code) class TestCase(unittest.TestCase): def assertBlocksEqual(self, code, *expected_blocks): self.assertEqual(len(code), len(expected_blocks)) for block1, block2 in zip(code, expected_blocks): block_index = code.get_block_index(block1) self.assertListEqual( list(block1), block2, "Block #%s is different" % block_index )
4,996
Python
31.238709
86
0.509207
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/util_annotation.py
from __future__ import annotations import textwrap import types def get_code(source, *, filename="<string>", function=False): source = textwrap.dedent(source).strip() code = compile(source, filename, "exec") if function: sub_code = [ const for const in code.co_consts if isinstance(const, types.CodeType) ] if len(sub_code) != 1: raise ValueError("unable to find function code") code = sub_code[0] return code
485
Python
25.999999
82
0.624742
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_flags.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') #!/usr/bin/env python3 import unittest from _pydevd_frame_eval.vendored.bytecode import ( CompilerFlags, ConcreteBytecode, ConcreteInstr, Bytecode, ControlFlowGraph, ) from _pydevd_frame_eval.vendored.bytecode.flags import infer_flags class FlagsTests(unittest.TestCase): def test_type_validation_on_inference(self): with self.assertRaises(ValueError): infer_flags(1) def test_flag_inference(self): # Check no loss of non-infered flags code = ControlFlowGraph() code.flags |= ( CompilerFlags.NEWLOCALS | CompilerFlags.VARARGS | CompilerFlags.VARKEYWORDS | CompilerFlags.NESTED | CompilerFlags.FUTURE_GENERATOR_STOP ) code.update_flags() for f in ( CompilerFlags.NEWLOCALS, CompilerFlags.VARARGS, CompilerFlags.VARKEYWORDS, CompilerFlags.NESTED, CompilerFlags.NOFREE, CompilerFlags.OPTIMIZED, CompilerFlags.FUTURE_GENERATOR_STOP, ): self.assertTrue(bool(code.flags & f)) # Infer optimized and nofree code = Bytecode() flags = infer_flags(code) self.assertTrue(bool(flags & CompilerFlags.OPTIMIZED)) self.assertTrue(bool(flags & CompilerFlags.NOFREE)) code.append(ConcreteInstr("STORE_NAME", 1)) flags = infer_flags(code) self.assertFalse(bool(flags & CompilerFlags.OPTIMIZED)) self.assertTrue(bool(flags & CompilerFlags.NOFREE)) code.append(ConcreteInstr("STORE_DEREF", 2)) code.update_flags() self.assertFalse(bool(code.flags & CompilerFlags.OPTIMIZED)) self.assertFalse(bool(code.flags & CompilerFlags.NOFREE)) def test_async_gen_no_flag_is_async_None(self): # Test inference in the absence of any flag set on the bytecode # Infer generator code = ConcreteBytecode() code.append(ConcreteInstr("YIELD_VALUE")) code.update_flags() self.assertTrue(bool(code.flags & CompilerFlags.GENERATOR)) # Infer coroutine code = ConcreteBytecode() code.append(ConcreteInstr("GET_AWAITABLE")) code.update_flags() self.assertTrue(bool(code.flags & CompilerFlags.COROUTINE)) # Infer coroutine or async generator for i, expected in ( ("YIELD_VALUE", CompilerFlags.ASYNC_GENERATOR), ("YIELD_FROM", CompilerFlags.COROUTINE), ): code = ConcreteBytecode() code.append(ConcreteInstr("GET_AWAITABLE")) code.append(ConcreteInstr(i)) code.update_flags() self.assertTrue(bool(code.flags & expected)) def test_async_gen_no_flag_is_async_True(self): # Test inference when we request an async function # Force coroutine code = ConcreteBytecode() code.update_flags(is_async=True) self.assertTrue(bool(code.flags & CompilerFlags.COROUTINE)) # Infer coroutine or async generator for i, expected in ( ("YIELD_VALUE", CompilerFlags.ASYNC_GENERATOR), ("YIELD_FROM", CompilerFlags.COROUTINE), ): code = ConcreteBytecode() code.append(ConcreteInstr(i)) code.update_flags(is_async=True) self.assertTrue(bool(code.flags & expected)) def test_async_gen_no_flag_is_async_False(self): # Test inference when we request a non-async function # Infer generator code = ConcreteBytecode() code.append(ConcreteInstr("YIELD_VALUE")) code.flags = CompilerFlags(CompilerFlags.COROUTINE) code.update_flags(is_async=False) self.assertTrue(bool(code.flags & CompilerFlags.GENERATOR)) # Abort on coroutine code = ConcreteBytecode() code.append(ConcreteInstr("GET_AWAITABLE")) code.flags = CompilerFlags(CompilerFlags.COROUTINE) with self.assertRaises(ValueError): code.update_flags(is_async=False) def test_async_gen_flags(self): # Test inference in the presence of pre-existing flags for is_async in (None, True): # Infer generator code = ConcreteBytecode() code.append(ConcreteInstr("YIELD_VALUE")) for f, expected in ( (CompilerFlags.COROUTINE, CompilerFlags.ASYNC_GENERATOR), (CompilerFlags.ASYNC_GENERATOR, CompilerFlags.ASYNC_GENERATOR), (CompilerFlags.ITERABLE_COROUTINE, CompilerFlags.ITERABLE_COROUTINE), ): code.flags = CompilerFlags(f) code.update_flags(is_async=is_async) self.assertTrue(bool(code.flags & expected)) # Infer coroutine code = ConcreteBytecode() code.append(ConcreteInstr("YIELD_FROM")) for f, expected in ( (CompilerFlags.COROUTINE, CompilerFlags.COROUTINE), (CompilerFlags.ASYNC_GENERATOR, CompilerFlags.COROUTINE), (CompilerFlags.ITERABLE_COROUTINE, CompilerFlags.ITERABLE_COROUTINE), ): code.flags = CompilerFlags(f) code.update_flags(is_async=is_async) self.assertTrue(bool(code.flags & expected)) # Crash on ITERABLE_COROUTINE with async bytecode code = ConcreteBytecode() code.append(ConcreteInstr("GET_AWAITABLE")) code.flags = CompilerFlags(CompilerFlags.ITERABLE_COROUTINE) with self.assertRaises(ValueError): code.update_flags(is_async=is_async) if __name__ == "__main__": unittest.main() # pragma: no cover
6,009
Python
36.5625
126
0.625894
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_misc.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') #!/usr/bin/env python3 import contextlib import io import sys import textwrap import unittest from _pydevd_frame_eval.vendored import bytecode from _pydevd_frame_eval.vendored.bytecode import Label, Instr, Bytecode, BasicBlock, ControlFlowGraph from _pydevd_frame_eval.vendored.bytecode.concrete import OFFSET_AS_INSTRUCTION from _pydevd_frame_eval.vendored.bytecode.tests import disassemble class DumpCodeTests(unittest.TestCase): maxDiff = 80 * 100 def check_dump_bytecode(self, code, expected, lineno=None): with contextlib.redirect_stdout(io.StringIO()) as stderr: if lineno is not None: bytecode.dump_bytecode(code, lineno=True) else: bytecode.dump_bytecode(code) output = stderr.getvalue() self.assertEqual(output, expected) def test_bytecode(self): source = """ def func(test): if test == 1: return 1 elif test == 2: return 2 return 3 """ code = disassemble(source, function=True) # without line numbers enum_repr = "<Compare.EQ: 2>" expected = f""" LOAD_FAST 'test' LOAD_CONST 1 COMPARE_OP {enum_repr} POP_JUMP_IF_FALSE <label_instr6> LOAD_CONST 1 RETURN_VALUE label_instr6: LOAD_FAST 'test' LOAD_CONST 2 COMPARE_OP {enum_repr} POP_JUMP_IF_FALSE <label_instr13> LOAD_CONST 2 RETURN_VALUE label_instr13: LOAD_CONST 3 RETURN_VALUE """[ 1: ].rstrip( " " ) self.check_dump_bytecode(code, expected) # with line numbers expected = f""" L. 2 0: LOAD_FAST 'test' 1: LOAD_CONST 1 2: COMPARE_OP {enum_repr} 3: POP_JUMP_IF_FALSE <label_instr6> L. 3 4: LOAD_CONST 1 5: RETURN_VALUE label_instr6: L. 4 7: LOAD_FAST 'test' 8: LOAD_CONST 2 9: COMPARE_OP {enum_repr} 10: POP_JUMP_IF_FALSE <label_instr13> L. 5 11: LOAD_CONST 2 12: RETURN_VALUE label_instr13: L. 6 14: LOAD_CONST 3 15: RETURN_VALUE """[ 1: ].rstrip( " " ) self.check_dump_bytecode(code, expected, lineno=True) def test_bytecode_broken_label(self): label = Label() code = Bytecode([Instr("JUMP_ABSOLUTE", label)]) expected = " JUMP_ABSOLUTE <error: unknown label>\n\n" self.check_dump_bytecode(code, expected) def test_blocks_broken_jump(self): block = BasicBlock() code = ControlFlowGraph() code[0].append(Instr("JUMP_ABSOLUTE", block)) expected = textwrap.dedent( """ block1: JUMP_ABSOLUTE <error: unknown block> """ ).lstrip("\n") self.check_dump_bytecode(code, expected) def test_bytecode_blocks(self): source = """ def func(test): if test == 1: return 1 elif test == 2: return 2 return 3 """ code = disassemble(source, function=True) code = ControlFlowGraph.from_bytecode(code) # without line numbers enum_repr = "<Compare.EQ: 2>" expected = textwrap.dedent( f""" block1: LOAD_FAST 'test' LOAD_CONST 1 COMPARE_OP {enum_repr} POP_JUMP_IF_FALSE <block3> -> block2 block2: LOAD_CONST 1 RETURN_VALUE block3: LOAD_FAST 'test' LOAD_CONST 2 COMPARE_OP {enum_repr} POP_JUMP_IF_FALSE <block5> -> block4 block4: LOAD_CONST 2 RETURN_VALUE block5: LOAD_CONST 3 RETURN_VALUE """ ).lstrip() self.check_dump_bytecode(code, expected) # with line numbers expected = textwrap.dedent( f""" block1: L. 2 0: LOAD_FAST 'test' 1: LOAD_CONST 1 2: COMPARE_OP {enum_repr} 3: POP_JUMP_IF_FALSE <block3> -> block2 block2: L. 3 0: LOAD_CONST 1 1: RETURN_VALUE block3: L. 4 0: LOAD_FAST 'test' 1: LOAD_CONST 2 2: COMPARE_OP {enum_repr} 3: POP_JUMP_IF_FALSE <block5> -> block4 block4: L. 5 0: LOAD_CONST 2 1: RETURN_VALUE block5: L. 6 0: LOAD_CONST 3 1: RETURN_VALUE """ ).lstrip() self.check_dump_bytecode(code, expected, lineno=True) def test_concrete_bytecode(self): source = """ def func(test): if test == 1: return 1 elif test == 2: return 2 return 3 """ code = disassemble(source, function=True) code = code.to_concrete_bytecode() # without line numbers expected = f""" 0 LOAD_FAST 0 2 LOAD_CONST 1 4 COMPARE_OP 2 6 POP_JUMP_IF_FALSE {6 if OFFSET_AS_INSTRUCTION else 12} 8 LOAD_CONST 1 10 RETURN_VALUE 12 LOAD_FAST 0 14 LOAD_CONST 2 16 COMPARE_OP 2 18 POP_JUMP_IF_FALSE {12 if OFFSET_AS_INSTRUCTION else 24} 20 LOAD_CONST 2 22 RETURN_VALUE 24 LOAD_CONST 3 26 RETURN_VALUE """.lstrip( "\n" ) self.check_dump_bytecode(code, expected) # with line numbers expected = f""" L. 2 0: LOAD_FAST 0 2: LOAD_CONST 1 4: COMPARE_OP 2 6: POP_JUMP_IF_FALSE {6 if OFFSET_AS_INSTRUCTION else 12} L. 3 8: LOAD_CONST 1 10: RETURN_VALUE L. 4 12: LOAD_FAST 0 14: LOAD_CONST 2 16: COMPARE_OP 2 18: POP_JUMP_IF_FALSE {12 if OFFSET_AS_INSTRUCTION else 24} L. 5 20: LOAD_CONST 2 22: RETURN_VALUE L. 6 24: LOAD_CONST 3 26: RETURN_VALUE """.lstrip( "\n" ) self.check_dump_bytecode(code, expected, lineno=True) def test_type_validation(self): class T: first_lineno = 1 with self.assertRaises(TypeError): bytecode.dump_bytecode(T()) class MiscTests(unittest.TestCase): def skip_test_version(self): import setup self.assertEqual(bytecode.__version__, setup.VERSION) if __name__ == "__main__": unittest.main() # pragma: no cover
7,149
Python
25.383764
126
0.51126
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_cfg.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') #!/usr/bin/env python3 import io import sys import unittest import contextlib from _pydevd_frame_eval.vendored.bytecode import ( Label, Compare, SetLineno, Instr, Bytecode, BasicBlock, ControlFlowGraph, ) from _pydevd_frame_eval.vendored.bytecode.concrete import OFFSET_AS_INSTRUCTION from _pydevd_frame_eval.vendored.bytecode.tests import disassemble as _disassemble, TestCase def disassemble( source, *, filename="<string>", function=False, remove_last_return_none=False ): code = _disassemble(source, filename=filename, function=function) blocks = ControlFlowGraph.from_bytecode(code) if remove_last_return_none: # drop LOAD_CONST+RETURN_VALUE to only keep 2 instructions, # to make unit tests shorter block = blocks[-1] test = ( block[-2].name == "LOAD_CONST" and block[-2].arg is None and block[-1].name == "RETURN_VALUE" ) if not test: raise ValueError( "unable to find implicit RETURN_VALUE <None>: %s" % block[-2:] ) del block[-2:] return blocks class BlockTests(unittest.TestCase): def test_iter_invalid_types(self): # Labels are not allowed in basic blocks block = BasicBlock() block.append(Label()) with self.assertRaises(ValueError): list(block) with self.assertRaises(ValueError): block.legalize(1) # Only one jump allowed and only at the end block = BasicBlock() block2 = BasicBlock() block.extend([Instr("JUMP_ABSOLUTE", block2), Instr("NOP")]) with self.assertRaises(ValueError): list(block) with self.assertRaises(ValueError): block.legalize(1) # jump target must be a BasicBlock block = BasicBlock() label = Label() block.extend([Instr("JUMP_ABSOLUTE", label)]) with self.assertRaises(ValueError): list(block) with self.assertRaises(ValueError): block.legalize(1) def test_slice(self): block = BasicBlock([Instr("NOP")]) next_block = BasicBlock() block.next_block = next_block self.assertEqual(block, block[:]) self.assertIs(next_block, block[:].next_block) def test_copy(self): block = BasicBlock([Instr("NOP")]) next_block = BasicBlock() block.next_block = next_block self.assertEqual(block, block.copy()) self.assertIs(next_block, block.copy().next_block) class BytecodeBlocksTests(TestCase): maxDiff = 80 * 100 def test_constructor(self): code = ControlFlowGraph() self.assertEqual(code.name, "<module>") self.assertEqual(code.filename, "<string>") self.assertEqual(code.flags, 0) self.assertBlocksEqual(code, []) def test_attr(self): source = """ first_line = 1 def func(arg1, arg2, *, arg3): x = 1 y = 2 return arg1 """ code = disassemble(source, filename="hello.py", function=True) self.assertEqual(code.argcount, 2) self.assertEqual(code.filename, "hello.py") self.assertEqual(code.first_lineno, 3) if sys.version_info > (3, 8): self.assertEqual(code.posonlyargcount, 0) self.assertEqual(code.kwonlyargcount, 1) self.assertEqual(code.name, "func") self.assertEqual(code.cellvars, []) code.name = "name" code.filename = "filename" code.flags = 123 self.assertEqual(code.name, "name") self.assertEqual(code.filename, "filename") self.assertEqual(code.flags, 123) # FIXME: test non-empty cellvars def test_add_del_block(self): code = ControlFlowGraph() code[0].append(Instr("LOAD_CONST", 0)) block = code.add_block() self.assertEqual(len(code), 2) self.assertIs(block, code[1]) code[1].append(Instr("LOAD_CONST", 2)) self.assertBlocksEqual(code, [Instr("LOAD_CONST", 0)], [Instr("LOAD_CONST", 2)]) del code[0] self.assertBlocksEqual(code, [Instr("LOAD_CONST", 2)]) del code[0] self.assertEqual(len(code), 0) def test_setlineno(self): # x = 7 # y = 8 # z = 9 code = Bytecode() code.first_lineno = 3 code.extend( [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), SetLineno(4), Instr("LOAD_CONST", 8), Instr("STORE_NAME", "y"), SetLineno(5), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "z"), ] ) blocks = ControlFlowGraph.from_bytecode(code) self.assertBlocksEqual( blocks, [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), SetLineno(4), Instr("LOAD_CONST", 8), Instr("STORE_NAME", "y"), SetLineno(5), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "z"), ], ) def test_legalize(self): code = Bytecode() code.first_lineno = 3 code.extend( [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), Instr("LOAD_CONST", 8, lineno=4), Instr("STORE_NAME", "y"), SetLineno(5), Instr("LOAD_CONST", 9, lineno=6), Instr("STORE_NAME", "z"), ] ) blocks = ControlFlowGraph.from_bytecode(code) blocks.legalize() self.assertBlocksEqual( blocks, [ Instr("LOAD_CONST", 7, lineno=3), Instr("STORE_NAME", "x", lineno=3), Instr("LOAD_CONST", 8, lineno=4), Instr("STORE_NAME", "y", lineno=4), Instr("LOAD_CONST", 9, lineno=5), Instr("STORE_NAME", "z", lineno=5), ], ) def test_repr(self): r = repr(ControlFlowGraph()) self.assertIn("ControlFlowGraph", r) self.assertIn("1", r) def test_to_bytecode(self): # if test: # x = 2 # x = 5 blocks = ControlFlowGraph() blocks.add_block() blocks.add_block() blocks[0].extend( [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", blocks[2], lineno=1), ] ) blocks[1].extend( [ Instr("LOAD_CONST", 5, lineno=2), Instr("STORE_NAME", "x", lineno=2), Instr("JUMP_FORWARD", blocks[2], lineno=2), ] ) blocks[2].extend( [ Instr("LOAD_CONST", 7, lineno=3), Instr("STORE_NAME", "x", lineno=3), Instr("LOAD_CONST", None, lineno=3), Instr("RETURN_VALUE", lineno=3), ] ) bytecode = blocks.to_bytecode() label = Label() self.assertEqual( bytecode, [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", label, lineno=1), Instr("LOAD_CONST", 5, lineno=2), Instr("STORE_NAME", "x", lineno=2), Instr("JUMP_FORWARD", label, lineno=2), label, Instr("LOAD_CONST", 7, lineno=3), Instr("STORE_NAME", "x", lineno=3), Instr("LOAD_CONST", None, lineno=3), Instr("RETURN_VALUE", lineno=3), ], ) # FIXME: test other attributes def test_label_at_the_end(self): label = Label() code = Bytecode( [ Instr("LOAD_NAME", "x"), Instr("UNARY_NOT"), Instr("POP_JUMP_IF_FALSE", label), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "y"), label, ] ) cfg = ControlFlowGraph.from_bytecode(code) self.assertBlocksEqual( cfg, [ Instr("LOAD_NAME", "x"), Instr("UNARY_NOT"), Instr("POP_JUMP_IF_FALSE", cfg[2]), ], [Instr("LOAD_CONST", 9), Instr("STORE_NAME", "y")], [], ) def test_from_bytecode(self): bytecode = Bytecode() label = Label() bytecode.extend( [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", label, lineno=1), Instr("LOAD_CONST", 5, lineno=2), Instr("STORE_NAME", "x", lineno=2), Instr("JUMP_FORWARD", label, lineno=2), # dead code! Instr("LOAD_CONST", 7, lineno=4), Instr("STORE_NAME", "x", lineno=4), Label(), # unused label label, Label(), # unused label Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4), ] ) blocks = ControlFlowGraph.from_bytecode(bytecode) label2 = blocks[3] self.assertBlocksEqual( blocks, [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", label2, lineno=1), ], [ Instr("LOAD_CONST", 5, lineno=2), Instr("STORE_NAME", "x", lineno=2), Instr("JUMP_FORWARD", label2, lineno=2), ], [Instr("LOAD_CONST", 7, lineno=4), Instr("STORE_NAME", "x", lineno=4)], [Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4)], ) # FIXME: test other attributes def test_from_bytecode_loop(self): # for x in (1, 2, 3): # if x == 2: # break # continue if sys.version_info < (3, 8): label_loop_start = Label() label_loop_exit = Label() label_loop_end = Label() code = Bytecode() code.extend( ( Instr("SETUP_LOOP", label_loop_end, lineno=1), Instr("LOAD_CONST", (1, 2, 3), lineno=1), Instr("GET_ITER", lineno=1), label_loop_start, Instr("FOR_ITER", label_loop_exit, lineno=1), Instr("STORE_NAME", "x", lineno=1), Instr("LOAD_NAME", "x", lineno=2), Instr("LOAD_CONST", 2, lineno=2), Instr("COMPARE_OP", Compare.EQ, lineno=2), Instr("POP_JUMP_IF_FALSE", label_loop_start, lineno=2), Instr("BREAK_LOOP", lineno=3), Instr("JUMP_ABSOLUTE", label_loop_start, lineno=4), Instr("JUMP_ABSOLUTE", label_loop_start, lineno=4), label_loop_exit, Instr("POP_BLOCK", lineno=4), label_loop_end, Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4), ) ) blocks = ControlFlowGraph.from_bytecode(code) expected = [ [Instr("SETUP_LOOP", blocks[8], lineno=1)], [Instr("LOAD_CONST", (1, 2, 3), lineno=1), Instr("GET_ITER", lineno=1)], [Instr("FOR_ITER", blocks[7], lineno=1)], [ Instr("STORE_NAME", "x", lineno=1), Instr("LOAD_NAME", "x", lineno=2), Instr("LOAD_CONST", 2, lineno=2), Instr("COMPARE_OP", Compare.EQ, lineno=2), Instr("POP_JUMP_IF_FALSE", blocks[2], lineno=2), ], [Instr("BREAK_LOOP", lineno=3)], [Instr("JUMP_ABSOLUTE", blocks[2], lineno=4)], [Instr("JUMP_ABSOLUTE", blocks[2], lineno=4)], [Instr("POP_BLOCK", lineno=4)], [Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4)], ] self.assertBlocksEqual(blocks, *expected) else: label_loop_start = Label() label_loop_exit = Label() code = Bytecode() code.extend( ( Instr("LOAD_CONST", (1, 2, 3), lineno=1), Instr("GET_ITER", lineno=1), label_loop_start, Instr("FOR_ITER", label_loop_exit, lineno=1), Instr("STORE_NAME", "x", lineno=1), Instr("LOAD_NAME", "x", lineno=2), Instr("LOAD_CONST", 2, lineno=2), Instr("COMPARE_OP", Compare.EQ, lineno=2), Instr("POP_JUMP_IF_FALSE", label_loop_start, lineno=2), Instr("JUMP_ABSOLUTE", label_loop_exit, lineno=3), Instr("JUMP_ABSOLUTE", label_loop_start, lineno=4), Instr("JUMP_ABSOLUTE", label_loop_start, lineno=4), label_loop_exit, Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4), ) ) blocks = ControlFlowGraph.from_bytecode(code) expected = [ [Instr("LOAD_CONST", (1, 2, 3), lineno=1), Instr("GET_ITER", lineno=1)], [Instr("FOR_ITER", blocks[6], lineno=1)], [ Instr("STORE_NAME", "x", lineno=1), Instr("LOAD_NAME", "x", lineno=2), Instr("LOAD_CONST", 2, lineno=2), Instr("COMPARE_OP", Compare.EQ, lineno=2), Instr("POP_JUMP_IF_FALSE", blocks[1], lineno=2), ], [Instr("JUMP_ABSOLUTE", blocks[6], lineno=3)], [Instr("JUMP_ABSOLUTE", blocks[1], lineno=4)], [Instr("JUMP_ABSOLUTE", blocks[1], lineno=4)], [Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4)], ] self.assertBlocksEqual(blocks, *expected) class BytecodeBlocksFunctionalTests(TestCase): def test_eq(self): # compare codes with multiple blocks and labels, # Code.__eq__() renumbers labels to get equal labels source = "x = 1 if test else 2" code1 = disassemble(source) code2 = disassemble(source) self.assertEqual(code1, code2) # Type mismatch self.assertFalse(code1 == 1) # argnames mismatch cfg = ControlFlowGraph() cfg.argnames = 10 self.assertFalse(code1 == cfg) # instr mismatch cfg = ControlFlowGraph() cfg.argnames = code1.argnames self.assertFalse(code1 == cfg) def check_getitem(self, code): # check internal Code block indexes (index by index, index by label) for block_index, block in enumerate(code): self.assertIs(code[block_index], block) self.assertIs(code[block], block) self.assertEqual(code.get_block_index(block), block_index) def test_delitem(self): cfg = ControlFlowGraph() b = cfg.add_block() del cfg[b] self.assertEqual(len(cfg.get_instructions()), 0) def sample_code(self): code = disassemble("x = 1", remove_last_return_none=True) self.assertBlocksEqual( code, [Instr("LOAD_CONST", 1, lineno=1), Instr("STORE_NAME", "x", lineno=1)] ) return code def test_split_block(self): code = self.sample_code() code[0].append(Instr("NOP", lineno=1)) label = code.split_block(code[0], 2) self.assertIs(label, code[1]) self.assertBlocksEqual( code, [Instr("LOAD_CONST", 1, lineno=1), Instr("STORE_NAME", "x", lineno=1)], [Instr("NOP", lineno=1)], ) self.check_getitem(code) label2 = code.split_block(code[0], 1) self.assertIs(label2, code[1]) self.assertBlocksEqual( code, [Instr("LOAD_CONST", 1, lineno=1)], [Instr("STORE_NAME", "x", lineno=1)], [Instr("NOP", lineno=1)], ) self.check_getitem(code) with self.assertRaises(TypeError): code.split_block(1, 1) with self.assertRaises(ValueError) as e: code.split_block(code[0], -2) self.assertIn("positive", e.exception.args[0]) def test_split_block_end(self): code = self.sample_code() # split at the end of the last block requires to add a new empty block label = code.split_block(code[0], 2) self.assertIs(label, code[1]) self.assertBlocksEqual( code, [Instr("LOAD_CONST", 1, lineno=1), Instr("STORE_NAME", "x", lineno=1)], [], ) self.check_getitem(code) # split at the end of a block which is not the end doesn't require to # add a new block label = code.split_block(code[0], 2) self.assertIs(label, code[1]) self.assertBlocksEqual( code, [Instr("LOAD_CONST", 1, lineno=1), Instr("STORE_NAME", "x", lineno=1)], [], ) def test_split_block_dont_split(self): code = self.sample_code() # FIXME: is it really useful to support that? block = code.split_block(code[0], 0) self.assertIs(block, code[0]) self.assertBlocksEqual( code, [Instr("LOAD_CONST", 1, lineno=1), Instr("STORE_NAME", "x", lineno=1)] ) def test_split_block_error(self): code = self.sample_code() with self.assertRaises(ValueError): # invalid index code.split_block(code[0], 3) def test_to_code(self): # test resolution of jump labels bytecode = ControlFlowGraph() bytecode.first_lineno = 3 bytecode.argcount = 3 if sys.version_info > (3, 8): bytecode.posonlyargcount = 0 bytecode.kwonlyargcount = 2 bytecode.name = "func" bytecode.filename = "hello.py" bytecode.flags = 0x43 bytecode.argnames = ("arg", "arg2", "arg3", "kwonly", "kwonly2") bytecode.docstring = None block0 = bytecode[0] block1 = bytecode.add_block() block2 = bytecode.add_block() block0.extend( [ Instr("LOAD_FAST", "x", lineno=4), Instr("POP_JUMP_IF_FALSE", block2, lineno=4), ] ) block1.extend( [Instr("LOAD_FAST", "arg", lineno=5), Instr("STORE_FAST", "x", lineno=5)] ) block2.extend( [ Instr("LOAD_CONST", 3, lineno=6), Instr("STORE_FAST", "x", lineno=6), Instr("LOAD_FAST", "x", lineno=7), Instr("RETURN_VALUE", lineno=7), ] ) if OFFSET_AS_INSTRUCTION: # The argument of the jump is divided by 2 expected = ( b"|\x05" b"r\x04" b"|\x00" b"}\x05" b"d\x01" b"}\x05" b"|\x05" b"S\x00" ) else: expected = ( b"|\x05" b"r\x08" b"|\x00" b"}\x05" b"d\x01" b"}\x05" b"|\x05" b"S\x00" ) code = bytecode.to_code() self.assertEqual(code.co_consts, (None, 3)) self.assertEqual(code.co_argcount, 3) if sys.version_info > (3, 8): self.assertEqual(code.co_posonlyargcount, 0) self.assertEqual(code.co_kwonlyargcount, 2) self.assertEqual(code.co_nlocals, 6) self.assertEqual(code.co_stacksize, 1) # FIXME: don't use hardcoded constants self.assertEqual(code.co_flags, 0x43) self.assertEqual(code.co_code, expected) self.assertEqual(code.co_names, ()) self.assertEqual( code.co_varnames, ("arg", "arg2", "arg3", "kwonly", "kwonly2", "x") ) self.assertEqual(code.co_filename, "hello.py") self.assertEqual(code.co_name, "func") self.assertEqual(code.co_firstlineno, 3) # verify stacksize argument is honored explicit_stacksize = code.co_stacksize + 42 code = bytecode.to_code(stacksize=explicit_stacksize) self.assertEqual(code.co_stacksize, explicit_stacksize) def test_get_block_index(self): blocks = ControlFlowGraph() block0 = blocks[0] block1 = blocks.add_block() block2 = blocks.add_block() self.assertEqual(blocks.get_block_index(block0), 0) self.assertEqual(blocks.get_block_index(block1), 1) self.assertEqual(blocks.get_block_index(block2), 2) other_block = BasicBlock() self.assertRaises(ValueError, blocks.get_block_index, other_block) class CFGStacksizeComputationTests(TestCase): def check_stack_size(self, func): code = func.__code__ bytecode = Bytecode.from_code(code) cfg = ControlFlowGraph.from_bytecode(bytecode) self.assertEqual(code.co_stacksize, cfg.compute_stacksize()) def test_empty_code(self): cfg = ControlFlowGraph() del cfg[0] self.assertEqual(cfg.compute_stacksize(), 0) def test_handling_of_set_lineno(self): code = Bytecode() code.first_lineno = 3 code.extend( [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), SetLineno(4), Instr("LOAD_CONST", 8), Instr("STORE_NAME", "y"), SetLineno(5), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "z"), ] ) self.assertEqual(code.compute_stacksize(), 1) def test_invalid_stacksize(self): code = Bytecode() code.extend([Instr("STORE_NAME", "x")]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_stack_size_computation_and(self): def test(arg1, *args, **kwargs): # pragma: no cover return arg1 and args # Test JUMP_IF_FALSE_OR_POP self.check_stack_size(test) def test_stack_size_computation_or(self): def test(arg1, *args, **kwargs): # pragma: no cover return arg1 or args # Test JUMP_IF_TRUE_OR_POP self.check_stack_size(test) def test_stack_size_computation_if_else(self): def test(arg1, *args, **kwargs): # pragma: no cover if args: return 0 elif kwargs: return 1 else: return 2 self.check_stack_size(test) def test_stack_size_computation_for_loop_continue(self): def test(arg1, *args, **kwargs): # pragma: no cover for k in kwargs: if k in args: continue else: return 1 self.check_stack_size(test) def test_stack_size_computation_while_loop_break(self): def test(arg1, *args, **kwargs): # pragma: no cover while True: if arg1: break self.check_stack_size(test) def test_stack_size_computation_with(self): def test(arg1, *args, **kwargs): # pragma: no cover with open(arg1) as f: return f.read() self.check_stack_size(test) def test_stack_size_computation_try_except(self): def test(arg1, *args, **kwargs): # pragma: no cover try: return args[0] except Exception: return 2 self.check_stack_size(test) def test_stack_size_computation_try_finally(self): def test(arg1, *args, **kwargs): # pragma: no cover try: return args[0] finally: return 2 self.check_stack_size(test) def test_stack_size_computation_try_except_finally(self): def test(arg1, *args, **kwargs): # pragma: no cover try: return args[0] except Exception: return 2 finally: print("Interrupt") self.check_stack_size(test) def test_stack_size_computation_try_except_else_finally(self): def test(arg1, *args, **kwargs): # pragma: no cover try: return args[0] except Exception: return 2 else: return arg1 finally: print("Interrupt") self.check_stack_size(test) def test_stack_size_computation_nested_try_except_finally(self): def test(arg1, *args, **kwargs): # pragma: no cover k = 1 try: getattr(arg1, k) except AttributeError: pass except Exception: try: assert False except Exception: return 2 finally: print("unexpected") finally: print("attempted to get {}".format(k)) self.check_stack_size(test) def test_stack_size_computation_nested_try_except_else_finally(self): def test(*args, **kwargs): try: v = args[1] except IndexError: try: w = kwargs["value"] except KeyError: return -1 else: return w finally: print("second finally") else: return v finally: print("first finally") # A direct comparison of the stack depth fails because CPython # generate dead code that is used in stack computation. cpython_stacksize = test.__code__.co_stacksize test.__code__ = Bytecode.from_code(test.__code__).to_code() self.assertLessEqual(test.__code__.co_stacksize, cpython_stacksize) with contextlib.redirect_stdout(io.StringIO()) as stdout: self.assertEqual(test(1, 4), 4) self.assertEqual(stdout.getvalue(), "first finally\n") with contextlib.redirect_stdout(io.StringIO()) as stdout: self.assertEqual(test([], value=3), 3) self.assertEqual(stdout.getvalue(), "second finally\nfirst finally\n") with contextlib.redirect_stdout(io.StringIO()) as stdout: self.assertEqual(test([], name=None), -1) self.assertEqual(stdout.getvalue(), "second finally\nfirst finally\n") def test_stack_size_with_dead_code(self): # Simply demonstrate more directly the previously mentioned issue. def test(*args): # pragma: no cover return 0 try: a = args[0] except IndexError: return -1 else: return a test.__code__ = Bytecode.from_code(test.__code__).to_code() self.assertEqual(test.__code__.co_stacksize, 1) self.assertEqual(test(1), 0) def test_huge_code_with_numerous_blocks(self): def base_func(x): pass def mk_if_then_else(depth): instructions = [] for i in range(depth): label_else = Label() instructions.extend( [ Instr("LOAD_FAST", "x"), Instr("POP_JUMP_IF_FALSE", label_else), Instr("LOAD_GLOBAL", "f{}".format(i)), Instr("RETURN_VALUE"), label_else, ] ) instructions.extend([Instr("LOAD_CONST", None), Instr("RETURN_VALUE")]) return instructions bytecode = Bytecode(mk_if_then_else(5000)) bytecode.compute_stacksize() if __name__ == "__main__": unittest.main() # pragma: no cover
28,547
Python
33.107527
126
0.507374
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_code.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') import unittest from _pydevd_frame_eval.vendored.bytecode import ConcreteBytecode, Bytecode, ControlFlowGraph from _pydevd_frame_eval.vendored.bytecode.tests import get_code class CodeTests(unittest.TestCase): """Check that bytecode.from_code(code).to_code() returns code.""" def check(self, source, function=False): ref_code = get_code(source, function=function) code = ConcreteBytecode.from_code(ref_code).to_code() self.assertEqual(code, ref_code) code = Bytecode.from_code(ref_code).to_code() self.assertEqual(code, ref_code) bytecode = Bytecode.from_code(ref_code) blocks = ControlFlowGraph.from_bytecode(bytecode) code = blocks.to_bytecode().to_code() self.assertEqual(code, ref_code) def test_loop(self): self.check( """ for x in range(1, 10): x += 1 if x == 3: continue x -= 1 if x > 7: break x = 0 print(x) """ ) def test_varargs(self): self.check( """ def func(a, b, *varargs): pass """, function=True, ) def test_kwargs(self): self.check( """ def func(a, b, **kwargs): pass """, function=True, ) def test_kwonlyargs(self): self.check( """ def func(*, arg, arg2): pass """, function=True, ) # Added because Python 3.10 added some special beahavior with respect to # generators in term of stack size def test_generator_func(self): self.check( """ def func(arg, arg2): yield """, function=True, ) def test_async_func(self): self.check( """ async def func(arg, arg2): pass """, function=True, ) if __name__ == "__main__": unittest.main() # pragma: no cover
2,425
Python
24.80851
126
0.516289
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_bytecode.py
import pytest from tests_python.debugger_unittest import IS_PY36_OR_GREATER, IS_CPYTHON from tests_python.debug_constants import TEST_CYTHON pytestmark = pytest.mark.skipif(not IS_PY36_OR_GREATER or not IS_CPYTHON or not TEST_CYTHON, reason='Requires CPython >= 3.6') #!/usr/bin/env python3 import sys import textwrap import unittest from _pydevd_frame_eval.vendored.bytecode import Label, Instr, FreeVar, Bytecode, SetLineno, ConcreteInstr from _pydevd_frame_eval.vendored.bytecode.tests import TestCase, get_code class BytecodeTests(TestCase): maxDiff = 80 * 100 def test_constructor(self): code = Bytecode() self.assertEqual(code.name, "<module>") self.assertEqual(code.filename, "<string>") self.assertEqual(code.flags, 0) self.assertEqual(code, []) def test_invalid_types(self): code = Bytecode() code.append(123) with self.assertRaises(ValueError): list(code) with self.assertRaises(ValueError): code.legalize() with self.assertRaises(ValueError): Bytecode([123]) def test_legalize(self): code = Bytecode() code.first_lineno = 3 code.extend( [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), Instr("LOAD_CONST", 8, lineno=4), Instr("STORE_NAME", "y"), Label(), SetLineno(5), Instr("LOAD_CONST", 9, lineno=6), Instr("STORE_NAME", "z"), ] ) code.legalize() self.assertListEqual( code, [ Instr("LOAD_CONST", 7, lineno=3), Instr("STORE_NAME", "x", lineno=3), Instr("LOAD_CONST", 8, lineno=4), Instr("STORE_NAME", "y", lineno=4), Label(), Instr("LOAD_CONST", 9, lineno=5), Instr("STORE_NAME", "z", lineno=5), ], ) def test_slice(self): code = Bytecode() code.first_lineno = 3 code.extend( [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), SetLineno(4), Instr("LOAD_CONST", 8), Instr("STORE_NAME", "y"), SetLineno(5), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "z"), ] ) sliced_code = code[:] self.assertEqual(code, sliced_code) for name in ( "argcount", "posonlyargcount", "kwonlyargcount", "first_lineno", "name", "filename", "docstring", "cellvars", "freevars", "argnames", ): self.assertEqual( getattr(code, name, None), getattr(sliced_code, name, None) ) def test_copy(self): code = Bytecode() code.first_lineno = 3 code.extend( [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), SetLineno(4), Instr("LOAD_CONST", 8), Instr("STORE_NAME", "y"), SetLineno(5), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "z"), ] ) copy_code = code.copy() self.assertEqual(code, copy_code) for name in ( "argcount", "posonlyargcount", "kwonlyargcount", "first_lineno", "name", "filename", "docstring", "cellvars", "freevars", "argnames", ): self.assertEqual(getattr(code, name, None), getattr(copy_code, name, None)) def test_from_code(self): code = get_code( """ if test: x = 1 else: x = 2 """ ) bytecode = Bytecode.from_code(code) label_else = Label() label_exit = Label() if sys.version_info < (3, 10): self.assertEqual( bytecode, [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", label_else, lineno=1), Instr("LOAD_CONST", 1, lineno=2), Instr("STORE_NAME", "x", lineno=2), Instr("JUMP_FORWARD", label_exit, lineno=2), label_else, Instr("LOAD_CONST", 2, lineno=4), Instr("STORE_NAME", "x", lineno=4), label_exit, Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4), ], ) # Control flow handling appears to have changed under Python 3.10 else: self.assertEqual( bytecode, [ Instr("LOAD_NAME", "test", lineno=1), Instr("POP_JUMP_IF_FALSE", label_else, lineno=1), Instr("LOAD_CONST", 1, lineno=2), Instr("STORE_NAME", "x", lineno=2), Instr("LOAD_CONST", None, lineno=2), Instr("RETURN_VALUE", lineno=2), label_else, Instr("LOAD_CONST", 2, lineno=4), Instr("STORE_NAME", "x", lineno=4), Instr("LOAD_CONST", None, lineno=4), Instr("RETURN_VALUE", lineno=4), ], ) def test_from_code_freevars(self): ns = {} exec( textwrap.dedent( """ def create_func(): x = 1 def func(): return x return func func = create_func() """ ), ns, ns, ) code = ns["func"].__code__ bytecode = Bytecode.from_code(code) self.assertEqual( bytecode, [ Instr("LOAD_DEREF", FreeVar("x"), lineno=5), Instr("RETURN_VALUE", lineno=5), ], ) def test_from_code_load_fast(self): code = get_code( """ def func(): x = 33 y = x """, function=True, ) code = Bytecode.from_code(code) self.assertEqual( code, [ Instr("LOAD_CONST", 33, lineno=2), Instr("STORE_FAST", "x", lineno=2), Instr("LOAD_FAST", "x", lineno=3), Instr("STORE_FAST", "y", lineno=3), Instr("LOAD_CONST", None, lineno=3), Instr("RETURN_VALUE", lineno=3), ], ) def test_setlineno(self): # x = 7 # y = 8 # z = 9 code = Bytecode() code.first_lineno = 3 code.extend( [ Instr("LOAD_CONST", 7), Instr("STORE_NAME", "x"), SetLineno(4), Instr("LOAD_CONST", 8), Instr("STORE_NAME", "y"), SetLineno(5), Instr("LOAD_CONST", 9), Instr("STORE_NAME", "z"), ] ) concrete = code.to_concrete_bytecode() self.assertEqual(concrete.consts, [7, 8, 9]) self.assertEqual(concrete.names, ["x", "y", "z"]) self.assertListEqual( list(concrete), [ ConcreteInstr("LOAD_CONST", 0, lineno=3), ConcreteInstr("STORE_NAME", 0, lineno=3), ConcreteInstr("LOAD_CONST", 1, lineno=4), ConcreteInstr("STORE_NAME", 1, lineno=4), ConcreteInstr("LOAD_CONST", 2, lineno=5), ConcreteInstr("STORE_NAME", 2, lineno=5), ], ) def test_to_code(self): code = Bytecode() code.first_lineno = 50 code.extend( [ Instr("LOAD_NAME", "print"), Instr("LOAD_CONST", "%s"), Instr("LOAD_GLOBAL", "a"), Instr("BINARY_MODULO"), Instr("CALL_FUNCTION", 1), Instr("RETURN_VALUE"), ] ) co = code.to_code() # hopefully this is obvious from inspection? :-) self.assertEqual(co.co_stacksize, 3) co = code.to_code(stacksize=42) self.assertEqual(co.co_stacksize, 42) def test_negative_size_unary(self): opnames = ( "UNARY_POSITIVE", "UNARY_NEGATIVE", "UNARY_NOT", "UNARY_INVERT", ) for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr(opname)]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_negative_size_unary_with_disable_check_of_pre_and_post(self): opnames = ( "UNARY_POSITIVE", "UNARY_NEGATIVE", "UNARY_NOT", "UNARY_INVERT", ) for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr(opname)]) co = code.to_code(check_pre_and_post=False) self.assertEqual(co.co_stacksize, 0) def test_negative_size_binary(self): opnames = ( "BINARY_POWER", "BINARY_MULTIPLY", "BINARY_MATRIX_MULTIPLY", "BINARY_FLOOR_DIVIDE", "BINARY_TRUE_DIVIDE", "BINARY_MODULO", "BINARY_ADD", "BINARY_SUBTRACT", "BINARY_SUBSCR", "BINARY_LSHIFT", "BINARY_RSHIFT", "BINARY_AND", "BINARY_XOR", "BINARY_OR", ) for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", 1), Instr(opname)]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_negative_size_binary_with_disable_check_of_pre_and_post(self): opnames = ( "BINARY_POWER", "BINARY_MULTIPLY", "BINARY_MATRIX_MULTIPLY", "BINARY_FLOOR_DIVIDE", "BINARY_TRUE_DIVIDE", "BINARY_MODULO", "BINARY_ADD", "BINARY_SUBTRACT", "BINARY_SUBSCR", "BINARY_LSHIFT", "BINARY_RSHIFT", "BINARY_AND", "BINARY_XOR", "BINARY_OR", ) for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", 1), Instr(opname)]) co = code.to_code(check_pre_and_post=False) self.assertEqual(co.co_stacksize, 1) def test_negative_size_call(self): code = Bytecode() code.first_lineno = 1 code.extend([Instr("CALL_FUNCTION", 0)]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_negative_size_unpack(self): opnames = ( "UNPACK_SEQUENCE", "UNPACK_EX", ) for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr(opname, 1)]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_negative_size_build(self): opnames = ( "BUILD_TUPLE", "BUILD_LIST", "BUILD_SET", ) if sys.version_info >= (3, 6): opnames = (*opnames, "BUILD_STRING") for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr(opname, 1)]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_negative_size_build_map(self): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", 1), Instr("BUILD_MAP", 1)]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_negative_size_build_map_with_disable_check_of_pre_and_post(self): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", 1), Instr("BUILD_MAP", 1)]) co = code.to_code(check_pre_and_post=False) self.assertEqual(co.co_stacksize, 1) @unittest.skipIf(sys.version_info < (3, 6), "Inexistent opcode") def test_negative_size_build_const_map(self): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", ("a",)), Instr("BUILD_CONST_KEY_MAP", 1)]) with self.assertRaises(RuntimeError): code.compute_stacksize() @unittest.skipIf(sys.version_info < (3, 6), "Inexistent opcode") def test_negative_size_build_const_map_with_disable_check_of_pre_and_post(self): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", ("a",)), Instr("BUILD_CONST_KEY_MAP", 1)]) co = code.to_code(check_pre_and_post=False) self.assertEqual(co.co_stacksize, 1) def test_empty_dup(self): code = Bytecode() code.first_lineno = 1 code.extend([Instr("DUP_TOP")]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_not_enough_dup(self): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", 1), Instr("DUP_TOP_TWO")]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_not_enough_rot(self): opnames = ["ROT_TWO", "ROT_THREE"] if sys.version_info >= (3, 8): opnames.append("ROT_FOUR") for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", 1), Instr(opname)]) with self.assertRaises(RuntimeError): code.compute_stacksize() def test_not_enough_rot_with_disable_check_of_pre_and_post(self): opnames = ["ROT_TWO", "ROT_THREE"] if sys.version_info >= (3, 8): opnames.append("ROT_FOUR") for opname in opnames: with self.subTest(): code = Bytecode() code.first_lineno = 1 code.extend([Instr("LOAD_CONST", 1), Instr(opname)]) co = code.to_code(check_pre_and_post=False) self.assertEqual(co.co_stacksize, 1) def test_for_iter_stack_effect_computation(self): with self.subTest(): code = Bytecode() code.first_lineno = 1 lab1 = Label() lab2 = Label() code.extend( [ lab1, Instr("FOR_ITER", lab2), Instr("STORE_FAST", "i"), Instr("JUMP_ABSOLUTE", lab1), lab2, ] ) with self.assertRaises(RuntimeError): # Use compute_stacksize since the code is so broken that conversion # to from concrete is actually broken code.compute_stacksize(check_pre_and_post=False) if __name__ == "__main__": unittest.main() # pragma: no cover
15,909
Python
31.535787
126
0.471117
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py
from _pydev_bundle import pydev_log from _pydevd_bundle.pydevd_utils import hasattr_checked, DAPGrouper, Timer from io import StringIO import traceback from os.path import basename from functools import partial from _pydevd_bundle.pydevd_constants import IS_PY36_OR_GREATER, \ MethodWrapperType, RETURN_VALUES_DICT, DebugInfoHolder, IS_PYPY, GENERATED_LEN_ATTR_NAME from _pydevd_bundle.pydevd_safe_repr import SafeRepr # Note: 300 is already a lot to see in the outline (after that the user should really use the shell to get things) # and this also means we'll pass less information to the client side (which makes debugging faster). MAX_ITEMS_TO_HANDLE = 300 TOO_LARGE_MSG = 'Too large to show contents. Max items to show: ' + str(MAX_ITEMS_TO_HANDLE) TOO_LARGE_ATTR = 'Unable to handle:' #======================================================================================================================= # UnableToResolveVariableException #======================================================================================================================= class UnableToResolveVariableException(Exception): pass try: from collections import OrderedDict except: OrderedDict = dict try: import java.lang # @UnresolvedImport except: pass #======================================================================================================================= # See: pydevd_extension_api module for resolver interface #======================================================================================================================= def sorted_attributes_key(attr_name): if attr_name.startswith('__'): if attr_name.endswith('__'): # __ double under before and after __ return (3, attr_name) else: # __ double under before return (2, attr_name) elif attr_name.startswith('_'): # _ single under return (1, attr_name) else: # Regular (Before anything) return (0, attr_name) #======================================================================================================================= # DefaultResolver #======================================================================================================================= class DefaultResolver: ''' DefaultResolver is the class that'll actually resolve how to show some variable. ''' def resolve(self, var, attribute): return getattr(var, attribute) def get_contents_debug_adapter_protocol(self, obj, fmt=None): if MethodWrapperType: dct, used___dict__ = self._get_py_dictionary(obj) else: dct = self._get_jy_dictionary(obj)[0] lst = sorted(dct.items(), key=lambda tup: sorted_attributes_key(tup[0])) if used___dict__: eval_name = '.__dict__[%s]' else: eval_name = '.%s' ret = [] for attr_name, attr_value in lst: entry = (attr_name, attr_value, eval_name % attr_name) ret.append(entry) return ret def get_dictionary(self, var, names=None, used___dict__=False): if MethodWrapperType: return self._get_py_dictionary(var, names, used___dict__=used___dict__)[0] else: return self._get_jy_dictionary(var)[0] def _get_jy_dictionary(self, obj): ret = {} found = java.util.HashMap() original = obj if hasattr_checked(obj, '__class__') and obj.__class__ == java.lang.Class: # get info about superclasses classes = [] classes.append(obj) c = obj.getSuperclass() while c != None: classes.append(c) c = c.getSuperclass() # get info about interfaces interfs = [] for obj in classes: interfs.extend(obj.getInterfaces()) classes.extend(interfs) # now is the time when we actually get info on the declared methods and fields for obj in classes: declaredMethods = obj.getDeclaredMethods() declaredFields = obj.getDeclaredFields() for i in range(len(declaredMethods)): name = declaredMethods[i].getName() ret[name] = declaredMethods[i].toString() found.put(name, 1) for i in range(len(declaredFields)): name = declaredFields[i].getName() found.put(name, 1) # if declaredFields[i].isAccessible(): declaredFields[i].setAccessible(True) # ret[name] = declaredFields[i].get( declaredFields[i] ) try: ret[name] = declaredFields[i].get(original) except: ret[name] = declaredFields[i].toString() # this simple dir does not always get all the info, that's why we have the part before # (e.g.: if we do a dir on String, some methods that are from other interfaces such as # charAt don't appear) try: d = dir(original) for name in d: if found.get(name) != 1: ret[name] = getattr(original, name) except: # sometimes we're unable to do a dir pass return ret def get_names(self, var): used___dict__ = False try: names = dir(var) except Exception: names = [] if not names: if hasattr_checked(var, '__dict__'): names = list(var.__dict__) used___dict__ = True return names, used___dict__ def _get_py_dictionary(self, var, names=None, used___dict__=False): ''' :return tuple(names, used___dict__), where used___dict__ means we have to access using obj.__dict__[name] instead of getattr(obj, name) ''' # On PyPy we never show functions. This is because of a corner case where PyPy becomes # absurdly slow -- it takes almost half a second to introspect a single numpy function (so, # the related test, "test_case_16_resolve_numpy_array", times out... this probably isn't # specific to numpy, but to any library where the CPython bridge is used, but as we # can't be sure in the debugger, we play it safe and don't show it at all). filter_function = IS_PYPY if not names: names, used___dict__ = self.get_names(var) d = {} # Be aware that the order in which the filters are applied attempts to # optimize the operation by removing as many items as possible in the # first filters, leaving fewer items for later filters timer = Timer() cls = type(var) for name in names: try: name_as_str = name if name_as_str.__class__ != str: name_as_str = '%r' % (name_as_str,) if not used___dict__: attr = getattr(var, name) else: attr = var.__dict__[name] # filter functions? if filter_function: if inspect.isroutine(attr) or isinstance(attr, MethodWrapperType): continue except: # if some error occurs getting it, let's put it to the user. strIO = StringIO() traceback.print_exc(file=strIO) attr = strIO.getvalue() finally: timer.report_if_getting_attr_slow(cls, name_as_str) d[name_as_str] = attr return d, used___dict__ class DAPGrouperResolver: def get_contents_debug_adapter_protocol(self, obj, fmt=None): return obj.get_contents_debug_adapter_protocol() _basic_immutable_types = (int, float, complex, str, bytes, type(None), bool, frozenset) def _does_obj_repr_evaluate_to_obj(obj): ''' If obj is an object where evaluating its representation leads to the same object, return True, otherwise, return False. ''' try: if isinstance(obj, tuple): for o in obj: if not _does_obj_repr_evaluate_to_obj(o): return False return True else: return isinstance(obj, _basic_immutable_types) except: return False #======================================================================================================================= # DictResolver #======================================================================================================================= class DictResolver: sort_keys = not IS_PY36_OR_GREATER def resolve(self, dct, key): if key in (GENERATED_LEN_ATTR_NAME, TOO_LARGE_ATTR): return None if '(' not in key: # we have to treat that because the dict resolver is also used to directly resolve the global and local # scopes (which already have the items directly) try: return dct[key] except: return getattr(dct, key) # ok, we have to iterate over the items to find the one that matches the id, because that's the only way # to actually find the reference from the string we have before. expected_id = int(key.split('(')[-1][:-1]) for key, val in dct.items(): if id(key) == expected_id: return val raise UnableToResolveVariableException() def key_to_str(self, key, fmt=None): if fmt is not None: if fmt.get('hex', False): safe_repr = SafeRepr() safe_repr.convert_to_hex = True return safe_repr(key) return '%r' % (key,) def init_dict(self): return {} def get_contents_debug_adapter_protocol(self, dct, fmt=None): ''' This method is to be used in the case where the variables are all saved by its id (and as such don't need to have the `resolve` method called later on, so, keys don't need to embed the reference in the key). Note that the return should be ordered. :return list(tuple(name:str, value:object, evaluateName:str)) ''' ret = [] i = 0 found_representations = set() for key, val in dct.items(): i += 1 key_as_str = self.key_to_str(key, fmt) if key_as_str not in found_representations: found_representations.add(key_as_str) else: # If the key would be a duplicate, add the key id (otherwise # VSCode won't show all keys correctly). # See: https://github.com/microsoft/debugpy/issues/148 key_as_str = '%s (id: %s)' % (key_as_str, id(key)) found_representations.add(key_as_str) if _does_obj_repr_evaluate_to_obj(key): s = self.key_to_str(key) # do not format the key eval_key_str = '[%s]' % (s,) else: eval_key_str = None ret.append((key_as_str, val, eval_key_str)) if i > MAX_ITEMS_TO_HANDLE: ret.append((TOO_LARGE_ATTR, TOO_LARGE_MSG, None)) break # in case the class extends built-in type and has some additional fields from_default_resolver = defaultResolver.get_contents_debug_adapter_protocol(dct, fmt) if from_default_resolver: ret = from_default_resolver + ret if self.sort_keys: ret = sorted(ret, key=lambda tup: sorted_attributes_key(tup[0])) ret.append((GENERATED_LEN_ATTR_NAME, len(dct), partial(_apply_evaluate_name, evaluate_name='len(%s)'))) return ret def get_dictionary(self, dct): ret = self.init_dict() i = 0 for key, val in dct.items(): i += 1 # we need to add the id because otherwise we cannot find the real object to get its contents later on. key = '%s (%s)' % (self.key_to_str(key), id(key)) ret[key] = val if i > MAX_ITEMS_TO_HANDLE: ret[TOO_LARGE_ATTR] = TOO_LARGE_MSG break # in case if the class extends built-in type and has some additional fields additional_fields = defaultResolver.get_dictionary(dct) ret.update(additional_fields) ret[GENERATED_LEN_ATTR_NAME] = len(dct) return ret def _apply_evaluate_name(parent_name, evaluate_name): return evaluate_name % (parent_name,) #======================================================================================================================= # TupleResolver #======================================================================================================================= class TupleResolver: # to enumerate tuples and lists def resolve(self, var, attribute): ''' @param var: that's the original attribute @param attribute: that's the key passed in the dict (as a string) ''' if attribute in (GENERATED_LEN_ATTR_NAME, TOO_LARGE_ATTR): return None try: return var[int(attribute)] except: return getattr(var, attribute) def get_contents_debug_adapter_protocol(self, lst, fmt=None): ''' This method is to be used in the case where the variables are all saved by its id (and as such don't need to have the `resolve` method called later on, so, keys don't need to embed the reference in the key). Note that the return should be ordered. :return list(tuple(name:str, value:object, evaluateName:str)) ''' l = len(lst) ret = [] format_str = '%0' + str(int(len(str(l - 1)))) + 'd' if fmt is not None and fmt.get('hex', False): format_str = '0x%0' + str(int(len(hex(l).lstrip('0x')))) + 'x' for i, item in enumerate(lst): ret.append((format_str % i, item, '[%s]' % i)) if i > MAX_ITEMS_TO_HANDLE: ret.append((TOO_LARGE_ATTR, TOO_LARGE_MSG, None)) break # Needed in case the class extends the built-in type and has some additional fields. from_default_resolver = defaultResolver.get_contents_debug_adapter_protocol(lst, fmt=fmt) if from_default_resolver: ret = from_default_resolver + ret ret.append((GENERATED_LEN_ATTR_NAME, len(lst), partial(_apply_evaluate_name, evaluate_name='len(%s)'))) return ret def get_dictionary(self, var, fmt={}): l = len(var) d = {} format_str = '%0' + str(int(len(str(l - 1)))) + 'd' if fmt is not None and fmt.get('hex', False): format_str = '0x%0' + str(int(len(hex(l).lstrip('0x')))) + 'x' for i, item in enumerate(var): d[format_str % i] = item if i > MAX_ITEMS_TO_HANDLE: d[TOO_LARGE_ATTR] = TOO_LARGE_MSG break # in case if the class extends built-in type and has some additional fields additional_fields = defaultResolver.get_dictionary(var) d.update(additional_fields) d[GENERATED_LEN_ATTR_NAME] = len(var) return d #======================================================================================================================= # SetResolver #======================================================================================================================= class SetResolver: ''' Resolves a set as dict id(object)->object ''' def get_contents_debug_adapter_protocol(self, obj, fmt=None): ret = [] for i, item in enumerate(obj): ret.append((str(id(item)), item, None)) if i > MAX_ITEMS_TO_HANDLE: ret.append((TOO_LARGE_ATTR, TOO_LARGE_MSG, None)) break # Needed in case the class extends the built-in type and has some additional fields. from_default_resolver = defaultResolver.get_contents_debug_adapter_protocol(obj, fmt=fmt) if from_default_resolver: ret = from_default_resolver + ret ret.append((GENERATED_LEN_ATTR_NAME, len(obj), partial(_apply_evaluate_name, evaluate_name='len(%s)'))) return ret def resolve(self, var, attribute): if attribute in (GENERATED_LEN_ATTR_NAME, TOO_LARGE_ATTR): return None try: attribute = int(attribute) except: return getattr(var, attribute) for v in var: if id(v) == attribute: return v raise UnableToResolveVariableException('Unable to resolve %s in %s' % (attribute, var)) def get_dictionary(self, var): d = {} for i, item in enumerate(var): d[str(id(item))] = item if i > MAX_ITEMS_TO_HANDLE: d[TOO_LARGE_ATTR] = TOO_LARGE_MSG break # in case if the class extends built-in type and has some additional fields additional_fields = defaultResolver.get_dictionary(var) d.update(additional_fields) d[GENERATED_LEN_ATTR_NAME] = len(var) return d def change_var_from_name(self, container, name, new_value): # The name given in this case must be the id(item), so, we can actually # iterate in the set and see which item matches the given id. try: # Check that the new value can actually be added to a set (i.e.: it's hashable/comparable). set().add(new_value) except: return None for item in container: if str(id(item)) == name: container.remove(item) container.add(new_value) return str(id(new_value)) return None #======================================================================================================================= # InstanceResolver #======================================================================================================================= class InstanceResolver: def resolve(self, var, attribute): field = var.__class__.getDeclaredField(attribute) field.setAccessible(True) return field.get(var) def get_dictionary(self, obj): ret = {} declaredFields = obj.__class__.getDeclaredFields() for i in range(len(declaredFields)): name = declaredFields[i].getName() try: declaredFields[i].setAccessible(True) ret[name] = declaredFields[i].get(obj) except: pydev_log.exception() return ret #======================================================================================================================= # JyArrayResolver #======================================================================================================================= class JyArrayResolver: ''' This resolves a regular Object[] array from java ''' def resolve(self, var, attribute): if attribute == GENERATED_LEN_ATTR_NAME: return None return var[int(attribute)] def get_dictionary(self, obj): ret = {} for i in range(len(obj)): ret[ i ] = obj[i] ret[GENERATED_LEN_ATTR_NAME] = len(obj) return ret #======================================================================================================================= # MultiValueDictResolver #======================================================================================================================= class MultiValueDictResolver(DictResolver): def resolve(self, dct, key): if key in (GENERATED_LEN_ATTR_NAME, TOO_LARGE_ATTR): return None # ok, we have to iterate over the items to find the one that matches the id, because that's the only way # to actually find the reference from the string we have before. expected_id = int(key.split('(')[-1][:-1]) for key in list(dct.keys()): val = dct.getlist(key) if id(key) == expected_id: return val raise UnableToResolveVariableException() #======================================================================================================================= # DjangoFormResolver #======================================================================================================================= class DjangoFormResolver(DefaultResolver): def get_dictionary(self, var, names=None): # Do not call self.errors because it is a property and has side effects. names, used___dict__ = self.get_names(var) has_errors_attr = False if "errors" in names: has_errors_attr = True names.remove("errors") d = defaultResolver.get_dictionary(var, names=names, used___dict__=used___dict__) if has_errors_attr: try: errors_attr = getattr(var, "_errors") except: errors_attr = None d["errors"] = errors_attr return d #======================================================================================================================= # DequeResolver #======================================================================================================================= class DequeResolver(TupleResolver): def get_dictionary(self, var): d = TupleResolver.get_dictionary(self, var) d['maxlen'] = getattr(var, 'maxlen', None) return d #======================================================================================================================= # OrderedDictResolver #======================================================================================================================= class OrderedDictResolver(DictResolver): sort_keys = False def init_dict(self): return OrderedDict() #======================================================================================================================= # FrameResolver #======================================================================================================================= class FrameResolver: ''' This resolves a frame. ''' def resolve(self, obj, attribute): if attribute == '__internals__': return defaultResolver.get_dictionary(obj) if attribute == 'stack': return self.get_frame_stack(obj) if attribute == 'f_locals': return obj.f_locals return None def get_dictionary(self, obj): ret = {} ret['__internals__'] = defaultResolver.get_dictionary(obj) ret['stack'] = self.get_frame_stack(obj) ret['f_locals'] = obj.f_locals return ret def get_frame_stack(self, frame): ret = [] if frame is not None: ret.append(self.get_frame_name(frame)) while frame.f_back: frame = frame.f_back ret.append(self.get_frame_name(frame)) return ret def get_frame_name(self, frame): if frame is None: return 'None' try: name = basename(frame.f_code.co_filename) return 'frame: %s [%s:%s] id:%s' % (frame.f_code.co_name, name, frame.f_lineno, id(frame)) except: return 'frame object' defaultResolver = DefaultResolver() dictResolver = DictResolver() tupleResolver = TupleResolver() instanceResolver = InstanceResolver() jyArrayResolver = JyArrayResolver() setResolver = SetResolver() multiValueDictResolver = MultiValueDictResolver() djangoFormResolver = DjangoFormResolver() dequeResolver = DequeResolver() orderedDictResolver = OrderedDictResolver() frameResolver = FrameResolver() dapGrouperResolver = DAPGrouperResolver() class InspectStub: def isbuiltin(self, _args): return False def isroutine(self, object): return False try: import inspect except: inspect = InspectStub() def get_var_scope(attr_name, attr_value, evaluate_name, handle_return_values): if attr_name.startswith("'"): if attr_name.endswith("'"): attr_name = attr_name[1:-1] else: i = attr_name.find("__' (") if i >= 0: # Handle attr_name such as: >>'__name__' (1732494379184)<< attr_name = attr_name[1: i + 2] if handle_return_values and attr_name == RETURN_VALUES_DICT: return '' elif attr_name == GENERATED_LEN_ATTR_NAME: return '' if attr_name.startswith('__') and attr_name.endswith('__'): return DAPGrouper.SCOPE_SPECIAL_VARS if attr_name.startswith('_') or attr_name.endswith('__'): return DAPGrouper.SCOPE_PROTECTED_VARS try: if inspect.isroutine(attr_value) or isinstance(attr_value, MethodWrapperType): return DAPGrouper.SCOPE_FUNCTION_VARS elif inspect.isclass(attr_value): return DAPGrouper.SCOPE_CLASS_VARS except: # It's possible that isinstance throws an exception when dealing with user-code. if DebugInfoHolder.DEBUG_TRACE_LEVEL > 0: pydev_log.exception() return ''
25,500
Python
34.222376
120
0.504549
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_console.py
'''An helper file for the pydev debugger (REPL) console ''' import sys import traceback from _pydevd_bundle.pydevconsole_code import InteractiveConsole, _EvalAwaitInNewEventLoop from _pydev_bundle import _pydev_completer from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface, BaseStdIn from _pydev_bundle.pydev_imports import Exec from _pydev_bundle.pydev_override import overrides from _pydevd_bundle import pydevd_save_locals from _pydevd_bundle.pydevd_io import IOBuf from pydevd_tracing import get_exception_traceback_str from _pydevd_bundle.pydevd_xml import make_valid_xml_value import inspect from _pydevd_bundle.pydevd_save_locals import update_globals_and_locals CONSOLE_OUTPUT = "output" CONSOLE_ERROR = "error" #======================================================================================================================= # ConsoleMessage #======================================================================================================================= class ConsoleMessage: """Console Messages """ def __init__(self): self.more = False # List of tuple [('error', 'error_message'), ('message_list', 'output_message')] self.console_messages = [] def add_console_message(self, message_type, message): """add messages in the console_messages list """ for m in message.split("\n"): if m.strip(): self.console_messages.append((message_type, m)) def update_more(self, more): """more is set to true if further input is required from the user else more is set to false """ self.more = more def to_xml(self): """Create an XML for console message_list, error and more (true/false) <xml> <message_list>console message_list</message_list> <error>console error</error> <more>true/false</more> </xml> """ makeValid = make_valid_xml_value xml = '<xml><more>%s</more>' % (self.more) for message_type, message in self.console_messages: xml += '<%s message="%s"></%s>' % (message_type, makeValid(message), message_type) xml += '</xml>' return xml #======================================================================================================================= # _DebugConsoleStdIn #======================================================================================================================= class _DebugConsoleStdIn(BaseStdIn): @overrides(BaseStdIn.readline) def readline(self, *args, **kwargs): sys.stderr.write('Warning: Reading from stdin is still not supported in this console.\n') return '\n' #======================================================================================================================= # DebugConsole #======================================================================================================================= class DebugConsole(InteractiveConsole, BaseInterpreterInterface): """Wrapper around code.InteractiveConsole, in order to send errors and outputs to the debug console """ @overrides(BaseInterpreterInterface.create_std_in) def create_std_in(self, *args, **kwargs): try: if not self.__buffer_output: return sys.stdin except: pass return _DebugConsoleStdIn() # If buffered, raw_input is not supported in this console. @overrides(InteractiveConsole.push) def push(self, line, frame, buffer_output=True): """Change built-in stdout and stderr methods by the new custom StdMessage. execute the InteractiveConsole.push. Change the stdout and stderr back be the original built-ins :param buffer_output: if False won't redirect the output. Return boolean (True if more input is required else False), output_messages and input_messages """ self.__buffer_output = buffer_output more = False if buffer_output: original_stdout = sys.stdout original_stderr = sys.stderr try: try: self.frame = frame if buffer_output: out = sys.stdout = IOBuf() err = sys.stderr = IOBuf() more = self.add_exec(line) except Exception: exc = get_exception_traceback_str() if buffer_output: err.buflist.append("Internal Error: %s" % (exc,)) else: sys.stderr.write("Internal Error: %s\n" % (exc,)) finally: # Remove frame references. self.frame = None frame = None if buffer_output: sys.stdout = original_stdout sys.stderr = original_stderr if buffer_output: return more, out.buflist, err.buflist else: return more, [], [] @overrides(BaseInterpreterInterface.do_add_exec) def do_add_exec(self, line): return InteractiveConsole.push(self, line) @overrides(InteractiveConsole.runcode) def runcode(self, code): """Execute a code object. When an exception occurs, self.showtraceback() is called to display a traceback. All exceptions are caught except SystemExit, which is reraised. A note about KeyboardInterrupt: this exception may occur elsewhere in this code, and may not always be caught. The caller should be prepared to deal with it. """ try: updated_globals = self.get_namespace() initial_globals = updated_globals.copy() updated_locals = None is_async = False if hasattr(inspect, 'CO_COROUTINE'): is_async = inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE if is_async: t = _EvalAwaitInNewEventLoop(code, updated_globals, updated_locals) t.start() t.join() update_globals_and_locals(updated_globals, initial_globals, self.frame) if t.exc: raise t.exc[1].with_traceback(t.exc[2]) else: try: exec(code, updated_globals, updated_locals) finally: update_globals_and_locals(updated_globals, initial_globals, self.frame) except SystemExit: raise except: # In case sys.excepthook called, use original excepthook #PyDev-877: Debug console freezes with Python 3.5+ # (showtraceback does it on python 3.5 onwards) sys.excepthook = sys.__excepthook__ try: self.showtraceback() finally: sys.__excepthook__ = sys.excepthook def get_namespace(self): dbg_namespace = {} dbg_namespace.update(self.frame.f_globals) dbg_namespace.update(self.frame.f_locals) # locals later because it has precedence over the actual globals return dbg_namespace #======================================================================================================================= # InteractiveConsoleCache #======================================================================================================================= class InteractiveConsoleCache: thread_id = None frame_id = None interactive_console_instance = None # Note: On Jython 2.1 we can't use classmethod or staticmethod, so, just make the functions below free-functions. def get_interactive_console(thread_id, frame_id, frame, console_message): """returns the global interactive console. interactive console should have been initialized by this time :rtype: DebugConsole """ if InteractiveConsoleCache.thread_id == thread_id and InteractiveConsoleCache.frame_id == frame_id: return InteractiveConsoleCache.interactive_console_instance InteractiveConsoleCache.interactive_console_instance = DebugConsole() InteractiveConsoleCache.thread_id = thread_id InteractiveConsoleCache.frame_id = frame_id console_stacktrace = traceback.extract_stack(frame, limit=1) if console_stacktrace: current_context = console_stacktrace[0] # top entry from stacktrace context_message = 'File "%s", line %s, in %s' % (current_context[0], current_context[1], current_context[2]) console_message.add_console_message(CONSOLE_OUTPUT, "[Current context]: %s" % (context_message,)) return InteractiveConsoleCache.interactive_console_instance def clear_interactive_console(): InteractiveConsoleCache.thread_id = None InteractiveConsoleCache.frame_id = None InteractiveConsoleCache.interactive_console_instance = None def execute_console_command(frame, thread_id, frame_id, line, buffer_output=True): """fetch an interactive console instance from the cache and push the received command to the console. create and return an instance of console_message """ console_message = ConsoleMessage() interpreter = get_interactive_console(thread_id, frame_id, frame, console_message) more, output_messages, error_messages = interpreter.push(line, frame, buffer_output) console_message.update_more(more) for message in output_messages: console_message.add_console_message(CONSOLE_OUTPUT, message) for message in error_messages: console_message.add_console_message(CONSOLE_ERROR, message) return console_message def get_description(frame, thread_id, frame_id, expression): console_message = ConsoleMessage() interpreter = get_interactive_console(thread_id, frame_id, frame, console_message) try: interpreter.frame = frame return interpreter.getDescription(expression) finally: interpreter.frame = None def get_completions(frame, act_tok): """ fetch all completions, create xml for the same return the completions xml """ return _pydev_completer.generate_completions_as_xml(frame, act_tok)
10,179
Python
36.564576
120
0.580411
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py
''' This module holds the constants used for specifying the states of the debugger. ''' from __future__ import nested_scopes import platform import weakref import struct import warnings import functools from contextlib import contextmanager STATE_RUN = 1 STATE_SUSPEND = 2 PYTHON_SUSPEND = 1 DJANGO_SUSPEND = 2 JINJA2_SUSPEND = 3 int_types = (int,) # types does not include a MethodWrapperType try: MethodWrapperType = type([].__str__) except: MethodWrapperType = None import sys # Note: the sys import must be here anyways (others depend on it) # Preload codecs to avoid imports to them later on which can potentially halt the debugger. import codecs as _codecs for _codec in ["ascii", "utf8", "utf-8", "latin1", "latin-1", "idna"]: _codecs.lookup(_codec) class DebugInfoHolder: # we have to put it here because it can be set through the command line (so, the # already imported references would not have it). # General information DEBUG_TRACE_LEVEL = 0 # 0 = critical, 1 = info, 2 = debug, 3 = verbose # Flags to debug specific points of the code. DEBUG_RECORD_SOCKET_READS = False DEBUG_TRACE_BREAKPOINTS = -1 PYDEVD_DEBUG_FILE = None # Any filename that starts with these strings is not traced nor shown to the user. # In Python 3.7 "<frozen ..." appears multiple times during import and should be ignored for the user. # In PyPy "<builtin> ..." can appear and should be ignored for the user. # <attrs is used internally by attrs # <__array_function__ is used by numpy IGNORE_BASENAMES_STARTING_WITH = ('<frozen ', '<builtin', '<attrs', '<__array_function__') # Note: <string> has special heuristics to know whether it should be traced or not (it's part of # user code when it's the <string> used in python -c and part of the library otherwise). # Any filename that starts with these strings is considered user (project) code. Note # that files for which we have a source mapping are also considered as a part of the project. USER_CODE_BASENAMES_STARTING_WITH = ('<ipython',) # Any filename that starts with these strings is considered library code (note: checked after USER_CODE_BASENAMES_STARTING_WITH). LIBRARY_CODE_BASENAMES_STARTING_WITH = ('<',) IS_CPYTHON = platform.python_implementation() == 'CPython' # Hold a reference to the original _getframe (because psyco will change that as soon as it's imported) IS_IRONPYTHON = sys.platform == 'cli' try: get_frame = sys._getframe if IS_IRONPYTHON: def get_frame(): try: return sys._getframe() except ValueError: pass except AttributeError: def get_frame(): raise AssertionError('sys._getframe not available (possible causes: enable -X:Frames on IronPython?)') # Used to determine the maximum size of each variable passed to eclipse -- having a big value here may make # the communication slower -- as the variables are being gathered lazily in the latest version of eclipse, # this value was raised from 200 to 1000. MAXIMUM_VARIABLE_REPRESENTATION_SIZE = 1000 # Prefix for saving functions return values in locals RETURN_VALUES_DICT = '__pydevd_ret_val_dict' GENERATED_LEN_ATTR_NAME = 'len()' import os from _pydevd_bundle import pydevd_vm_type # Constant detects when running on Jython/windows properly later on. IS_WINDOWS = sys.platform == 'win32' IS_LINUX = sys.platform in ('linux', 'linux2') IS_MAC = sys.platform == 'darwin' IS_64BIT_PROCESS = sys.maxsize > (2 ** 32) IS_JYTHON = pydevd_vm_type.get_vm_type() == pydevd_vm_type.PydevdVmType.JYTHON IS_PYPY = platform.python_implementation() == 'PyPy' if IS_JYTHON: import java.lang.System # @UnresolvedImport IS_WINDOWS = java.lang.System.getProperty("os.name").lower().startswith("windows") USE_CUSTOM_SYS_CURRENT_FRAMES = not hasattr(sys, '_current_frames') or IS_PYPY USE_CUSTOM_SYS_CURRENT_FRAMES_MAP = USE_CUSTOM_SYS_CURRENT_FRAMES and (IS_PYPY or IS_IRONPYTHON) if USE_CUSTOM_SYS_CURRENT_FRAMES: # Some versions of Jython don't have it (but we can provide a replacement) if IS_JYTHON: from java.lang import NoSuchFieldException from org.python.core import ThreadStateMapping try: cachedThreadState = ThreadStateMapping.getDeclaredField('globalThreadStates') # Dev version except NoSuchFieldException: cachedThreadState = ThreadStateMapping.getDeclaredField('cachedThreadState') # Release Jython 2.7.0 cachedThreadState.accessible = True thread_states = cachedThreadState.get(ThreadStateMapping) def _current_frames(): as_array = thread_states.entrySet().toArray() ret = {} for thread_to_state in as_array: thread = thread_to_state.getKey() if thread is None: continue thread_state = thread_to_state.getValue() if thread_state is None: continue frame = thread_state.frame if frame is None: continue ret[thread.getId()] = frame return ret elif USE_CUSTOM_SYS_CURRENT_FRAMES_MAP: constructed_tid_to_last_frame = {} # IronPython doesn't have it. Let's use our workaround... def _current_frames(): return constructed_tid_to_last_frame else: raise RuntimeError('Unable to proceed (sys._current_frames not available in this Python implementation).') else: _current_frames = sys._current_frames IS_PYTHON_STACKLESS = "stackless" in sys.version.lower() CYTHON_SUPPORTED = False python_implementation = platform.python_implementation() if python_implementation == 'CPython': # Only available for CPython! CYTHON_SUPPORTED = True #======================================================================================================================= # Python 3? #======================================================================================================================= IS_PY36_OR_GREATER = sys.version_info >= (3, 6) IS_PY37_OR_GREATER = sys.version_info >= (3, 7) IS_PY38_OR_GREATER = sys.version_info >= (3, 8) IS_PY39_OR_GREATER = sys.version_info >= (3, 9) IS_PY310_OR_GREATER = sys.version_info >= (3, 10) IS_PY311_OR_GREATER = sys.version_info >= (3, 11) def version_str(v): return '.'.join((str(x) for x in v[:3])) + ''.join((str(x) for x in v[3:])) PY_VERSION_STR = version_str(sys.version_info) try: PY_IMPL_VERSION_STR = version_str(sys.implementation.version) except AttributeError: PY_IMPL_VERSION_STR = '' try: PY_IMPL_NAME = sys.implementation.name except AttributeError: PY_IMPL_NAME = '' ENV_TRUE_LOWER_VALUES = ('yes', 'true', '1') ENV_FALSE_LOWER_VALUES = ('no', 'false', '0') def is_true_in_env(env_key): if isinstance(env_key, tuple): # If a tuple, return True if any of those ends up being true. for v in env_key: if is_true_in_env(v): return True return False else: return os.getenv(env_key, '').lower() in ENV_TRUE_LOWER_VALUES def as_float_in_env(env_key, default): value = os.getenv(env_key) if value is None: return default try: return float(value) except Exception: raise RuntimeError( 'Error: expected the env variable: %s to be set to a float value. Found: %s' % ( env_key, value)) def as_int_in_env(env_key, default): value = os.getenv(env_key) if value is None: return default try: return int(value) except Exception: raise RuntimeError( 'Error: expected the env variable: %s to be set to a int value. Found: %s' % ( env_key, value)) # If true in env, use gevent mode. SUPPORT_GEVENT = is_true_in_env('GEVENT_SUPPORT') # Opt-in support to show gevent paused greenlets. False by default because if too many greenlets are # paused the UI can slow-down (i.e.: if 1000 greenlets are paused, each one would be shown separate # as a different thread, but if the UI isn't optimized for that the experience is lacking...). GEVENT_SHOW_PAUSED_GREENLETS = is_true_in_env('GEVENT_SHOW_PAUSED_GREENLETS') DISABLE_FILE_VALIDATION = is_true_in_env('PYDEVD_DISABLE_FILE_VALIDATION') GEVENT_SUPPORT_NOT_SET_MSG = os.getenv( 'GEVENT_SUPPORT_NOT_SET_MSG', 'It seems that the gevent monkey-patching is being used.\n' 'Please set an environment variable with:\n' 'GEVENT_SUPPORT=True\n' 'to enable gevent support in the debugger.' ) USE_LIB_COPY = SUPPORT_GEVENT INTERACTIVE_MODE_AVAILABLE = sys.platform in ('darwin', 'win32') or os.getenv('DISPLAY') is not None # If true in env, forces cython to be used (raises error if not available). # If false in env, disables it. # If not specified, uses default heuristic to determine if it should be loaded. USE_CYTHON_FLAG = os.getenv('PYDEVD_USE_CYTHON') if USE_CYTHON_FLAG is not None: USE_CYTHON_FLAG = USE_CYTHON_FLAG.lower() if USE_CYTHON_FLAG not in ENV_TRUE_LOWER_VALUES and USE_CYTHON_FLAG not in ENV_FALSE_LOWER_VALUES: raise RuntimeError('Unexpected value for PYDEVD_USE_CYTHON: %s (enable with one of: %s, disable with one of: %s)' % ( USE_CYTHON_FLAG, ENV_TRUE_LOWER_VALUES, ENV_FALSE_LOWER_VALUES)) else: if not CYTHON_SUPPORTED: USE_CYTHON_FLAG = 'no' # If true in env, forces frame eval to be used (raises error if not available). # If false in env, disables it. # If not specified, uses default heuristic to determine if it should be loaded. PYDEVD_USE_FRAME_EVAL = os.getenv('PYDEVD_USE_FRAME_EVAL', '').lower() PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING = is_true_in_env('PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING') # If specified in PYDEVD_IPYTHON_CONTEXT it must be a string with the basename # and then the name of 2 methods in which the evaluate is done. PYDEVD_IPYTHON_CONTEXT = ('interactiveshell.py', 'run_code', 'run_ast_nodes') _ipython_ctx = os.getenv('PYDEVD_IPYTHON_CONTEXT') if _ipython_ctx: PYDEVD_IPYTHON_CONTEXT = tuple(x.strip() for x in _ipython_ctx.split(',')) assert len(PYDEVD_IPYTHON_CONTEXT) == 3, 'Invalid PYDEVD_IPYTHON_CONTEXT: %s' % (_ipython_ctx,) # Use to disable loading the lib to set tracing to all threads (default is using heuristics based on where we're running). LOAD_NATIVE_LIB_FLAG = os.getenv('PYDEVD_LOAD_NATIVE_LIB', '').lower() LOG_TIME = os.getenv('PYDEVD_LOG_TIME', 'true').lower() in ENV_TRUE_LOWER_VALUES SHOW_COMPILE_CYTHON_COMMAND_LINE = is_true_in_env('PYDEVD_SHOW_COMPILE_CYTHON_COMMAND_LINE') LOAD_VALUES_ASYNC = is_true_in_env('PYDEVD_LOAD_VALUES_ASYNC') DEFAULT_VALUE = "__pydevd_value_async" ASYNC_EVAL_TIMEOUT_SEC = 60 NEXT_VALUE_SEPARATOR = "__pydev_val__" BUILTINS_MODULE_NAME = 'builtins' SHOW_DEBUG_INFO_ENV = is_true_in_env(('PYCHARM_DEBUG', 'PYDEV_DEBUG', 'PYDEVD_DEBUG')) # Pandas customization. PANDAS_MAX_ROWS = as_int_in_env('PYDEVD_PANDAS_MAX_ROWS', 60) PANDAS_MAX_COLS = as_int_in_env('PYDEVD_PANDAS_MAX_COLS', 10) PANDAS_MAX_COLWIDTH = as_int_in_env('PYDEVD_PANDAS_MAX_COLWIDTH', 50) # If getting an attribute or computing some value is too slow, let the user know if the given timeout elapses. PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT = as_float_in_env('PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT', 0.15) # This timeout is used to track the time to send a message saying that the evaluation # is taking too long and possible mitigations. PYDEVD_WARN_EVALUATION_TIMEOUT = as_float_in_env('PYDEVD_WARN_EVALUATION_TIMEOUT', 3.) # If True in env shows a thread dump when the evaluation times out. PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT = is_true_in_env('PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT') # This timeout is used only when the mode that all threads are stopped/resumed at once is used # (i.e.: multi_threads_single_notification) # # In this mode, if some evaluation doesn't finish until this timeout, we notify the user # and then resume all threads until the evaluation finishes. # # A negative value will disable the timeout and a value of 0 will automatically run all threads # (without any notification) when the evaluation is started and pause all threads when the # evaluation is finished. A positive value will run run all threads after the timeout # elapses. PYDEVD_UNBLOCK_THREADS_TIMEOUT = as_float_in_env('PYDEVD_UNBLOCK_THREADS_TIMEOUT', -1.) # Timeout to interrupt a thread (so, if some evaluation doesn't finish until this # timeout, the thread doing the evaluation is interrupted). # A value <= 0 means this is disabled. # See: _pydevd_bundle.pydevd_timeout.create_interrupt_this_thread_callback for details # on how the thread interruption works (there are some caveats related to it). PYDEVD_INTERRUPT_THREAD_TIMEOUT = as_float_in_env('PYDEVD_INTERRUPT_THREAD_TIMEOUT', -1) # If PYDEVD_APPLY_PATCHING_TO_HIDE_PYDEVD_THREADS is set to False, the patching to hide pydevd threads won't be applied. PYDEVD_APPLY_PATCHING_TO_HIDE_PYDEVD_THREADS = os.getenv('PYDEVD_APPLY_PATCHING_TO_HIDE_PYDEVD_THREADS', 'true').lower() in ENV_TRUE_LOWER_VALUES EXCEPTION_TYPE_UNHANDLED = 'UNHANDLED' EXCEPTION_TYPE_USER_UNHANDLED = 'USER_UNHANDLED' EXCEPTION_TYPE_HANDLED = 'HANDLED' if SHOW_DEBUG_INFO_ENV: # show debug info before the debugger start DebugInfoHolder.DEBUG_RECORD_SOCKET_READS = True DebugInfoHolder.DEBUG_TRACE_LEVEL = 3 DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS = 1 DebugInfoHolder.PYDEVD_DEBUG_FILE = os.getenv('PYDEVD_DEBUG_FILE') def protect_libraries_from_patching(): """ In this function we delete some modules from `sys.modules` dictionary and import them again inside `_pydev_saved_modules` in order to save their original copies there. After that we can use these saved modules within the debugger to protect them from patching by external libraries (e.g. gevent). """ patched = ['threading', 'thread', '_thread', 'time', 'socket', 'queue', 'select', 'xmlrpclib', 'SimpleXMLRPCServer', 'BaseHTTPServer', 'SocketServer', 'xmlrpc.client', 'xmlrpc.server', 'http.server', 'socketserver'] for name in patched: try: __import__(name) except: pass patched_modules = dict([(k, v) for k, v in sys.modules.items() if k in patched]) for name in patched_modules: del sys.modules[name] # import for side effects import _pydev_bundle._pydev_saved_modules for name in patched_modules: sys.modules[name] = patched_modules[name] if USE_LIB_COPY: protect_libraries_from_patching() from _pydev_bundle._pydev_saved_modules import thread, threading _fork_safe_locks = [] if IS_JYTHON: def ForkSafeLock(rlock=False): if rlock: return threading.RLock() else: return threading.Lock() else: class ForkSafeLock(object): ''' A lock which is fork-safe (when a fork is done, `pydevd_constants.after_fork()` should be called to reset the locks in the new process to avoid deadlocks from a lock which was locked during the fork). Note: Unlike `threading.Lock` this class is not completely atomic, so, doing: lock = ForkSafeLock() with lock: ... is different than using `threading.Lock` directly because the tracing may find an additional function call on `__enter__` and on `__exit__`, so, it's not recommended to use this in all places, only where the forking may be important (so, for instance, the locks on PyDB should not be changed to this lock because of that -- and those should all be collected in the new process because PyDB itself should be completely cleared anyways). It's possible to overcome this limitation by using `ForkSafeLock.acquire` and `ForkSafeLock.release` instead of the context manager (as acquire/release are bound to the original implementation, whereas __enter__/__exit__ is not due to Python limitations). ''' def __init__(self, rlock=False): self._rlock = rlock self._init() _fork_safe_locks.append(weakref.ref(self)) def __enter__(self): return self._lock.__enter__() def __exit__(self, exc_type, exc_val, exc_tb): return self._lock.__exit__(exc_type, exc_val, exc_tb) def _init(self): if self._rlock: self._lock = threading.RLock() else: self._lock = thread.allocate_lock() self.acquire = self._lock.acquire self.release = self._lock.release _fork_safe_locks.append(weakref.ref(self)) def after_fork(): ''' Must be called after a fork operation (will reset the ForkSafeLock). ''' global _fork_safe_locks locks = _fork_safe_locks[:] _fork_safe_locks = [] for lock in locks: lock = lock() if lock is not None: lock._init() _thread_id_lock = ForkSafeLock() thread_get_ident = thread.get_ident def as_str(s): assert isinstance(s, str) return s @contextmanager def filter_all_warnings(): with warnings.catch_warnings(): warnings.filterwarnings("ignore") yield def silence_warnings_decorator(func): @functools.wraps(func) def new_func(*args, **kwargs): with filter_all_warnings(): return func(*args, **kwargs) return new_func def sorted_dict_repr(d): s = sorted(d.items(), key=lambda x:str(x[0])) return '{' + ', '.join(('%r: %r' % x) for x in s) + '}' def iter_chars(b): # In Python 2, we can iterate bytes or str with individual characters, but Python 3 onwards # changed that behavior so that when iterating bytes we actually get ints! if isinstance(b, bytes): # i.e.: do something as struct.unpack('3c', b) return iter(struct.unpack(str(len(b)) + 'c', b)) return iter(b) if IS_JYTHON: def NO_FTRACE(frame, event, arg): return None else: _curr_trace = sys.gettrace() # Set a temporary trace which does nothing for us to test (otherwise setting frame.f_trace has no # effect). def _temp_trace(frame, event, arg): return None sys.settrace(_temp_trace) def _check_ftrace_set_none(): ''' Will throw an error when executing a line event ''' sys._getframe().f_trace = None _line_event = 1 _line_event = 2 try: _check_ftrace_set_none() def NO_FTRACE(frame, event, arg): frame.f_trace = None return None except TypeError: def NO_FTRACE(frame, event, arg): # In Python <= 2.6 and <= 3.4, if we're tracing a method, frame.f_trace may not be set # to None, it must always be set to a tracing function. # See: tests_python.test_tracing_gotchas.test_tracing_gotchas # # Note: Python 2.7 sometimes works and sometimes it doesn't depending on the minor # version because of https://bugs.python.org/issue20041 (although bug reports didn't # include the minor version, so, mark for any Python 2.7 as I'm not completely sure # the fix in later 2.7 versions is the same one we're dealing with). return None sys.settrace(_curr_trace) #======================================================================================================================= # get_pid #======================================================================================================================= def get_pid(): try: return os.getpid() except AttributeError: try: # Jython does not have it! import java.lang.management.ManagementFactory # @UnresolvedImport -- just for jython pid = java.lang.management.ManagementFactory.getRuntimeMXBean().getName() return pid.replace('@', '_') except: # ok, no pid available (will be unable to debug multiple processes) return '000001' def clear_cached_thread_id(thread): with _thread_id_lock: try: if thread.__pydevd_id__ != 'console_main': # The console_main is a special thread id used in the console and its id should never be reset # (otherwise we may no longer be able to get its variables -- see: https://www.brainwy.com/tracker/PyDev/776). del thread.__pydevd_id__ except AttributeError: pass # Don't let threads be collected (so that id(thread) is guaranteed to be unique). _thread_id_to_thread_found = {} def _get_or_compute_thread_id_with_lock(thread, is_current_thread): with _thread_id_lock: # We do a new check with the lock in place just to be sure that nothing changed tid = getattr(thread, '__pydevd_id__', None) if tid is not None: return tid _thread_id_to_thread_found[id(thread)] = thread # Note: don't use thread.ident because a new thread may have the # same id from an old thread. pid = get_pid() tid = 'pid_%s_id_%s' % (pid, id(thread)) thread.__pydevd_id__ = tid return tid def get_current_thread_id(thread): ''' Note: the difference from get_current_thread_id to get_thread_id is that for the current thread we can get the thread id while the thread.ident is still not set in the Thread instance. ''' try: # Fast path without getting lock. tid = thread.__pydevd_id__ if tid is None: # Fix for https://www.brainwy.com/tracker/PyDev/645 # if __pydevd_id__ is None, recalculate it... also, use an heuristic # that gives us always the same id for the thread (using thread.ident or id(thread)). raise AttributeError() except AttributeError: tid = _get_or_compute_thread_id_with_lock(thread, is_current_thread=True) return tid def get_thread_id(thread): try: # Fast path without getting lock. tid = thread.__pydevd_id__ if tid is None: # Fix for https://www.brainwy.com/tracker/PyDev/645 # if __pydevd_id__ is None, recalculate it... also, use an heuristic # that gives us always the same id for the thread (using thread.ident or id(thread)). raise AttributeError() except AttributeError: tid = _get_or_compute_thread_id_with_lock(thread, is_current_thread=False) return tid def set_thread_id(thread, thread_id): with _thread_id_lock: thread.__pydevd_id__ = thread_id #======================================================================================================================= # Null #======================================================================================================================= class Null: """ Gotten from: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68205 """ def __init__(self, *args, **kwargs): return None def __call__(self, *args, **kwargs): return self def __enter__(self, *args, **kwargs): return self def __exit__(self, *args, **kwargs): return self def __getattr__(self, mname): if len(mname) > 4 and mname[:2] == '__' and mname[-2:] == '__': # Don't pretend to implement special method names. raise AttributeError(mname) return self def __setattr__(self, name, value): return self def __delattr__(self, name): return self def __repr__(self): return "<Null>" def __str__(self): return "Null" def __len__(self): return 0 def __getitem__(self): return self def __setitem__(self, *args, **kwargs): pass def write(self, *args, **kwargs): pass def __nonzero__(self): return 0 def __iter__(self): return iter(()) # Default instance NULL = Null() class KeyifyList(object): def __init__(self, inner, key): self.inner = inner self.key = key def __len__(self): return len(self.inner) def __getitem__(self, k): return self.key(self.inner[k]) def call_only_once(func): ''' To be used as a decorator @call_only_once def func(): print 'Calling func only this time' Actually, in PyDev it must be called as: func = call_only_once(func) to support older versions of Python. ''' def new_func(*args, **kwargs): if not new_func._called: new_func._called = True return func(*args, **kwargs) new_func._called = False return new_func # Protocol where each line is a new message (text is quoted to prevent new lines). # payload is xml QUOTED_LINE_PROTOCOL = 'quoted-line' ARGUMENT_QUOTED_LINE_PROTOCOL = 'protocol-quoted-line' # Uses http protocol to provide a new message. # i.e.: Content-Length:xxx\r\n\r\npayload # payload is xml HTTP_PROTOCOL = 'http' ARGUMENT_HTTP_PROTOCOL = 'protocol-http' # Message is sent without any header. # payload is json JSON_PROTOCOL = 'json' ARGUMENT_JSON_PROTOCOL = 'json-dap' # Same header as the HTTP_PROTOCOL # payload is json HTTP_JSON_PROTOCOL = 'http_json' ARGUMENT_HTTP_JSON_PROTOCOL = 'json-dap-http' ARGUMENT_PPID = 'ppid' class _GlobalSettings: protocol = QUOTED_LINE_PROTOCOL def set_protocol(protocol): expected = (HTTP_PROTOCOL, QUOTED_LINE_PROTOCOL, JSON_PROTOCOL, HTTP_JSON_PROTOCOL) assert protocol in expected, 'Protocol (%s) should be one of: %s' % ( protocol, expected) _GlobalSettings.protocol = protocol def get_protocol(): return _GlobalSettings.protocol def is_json_protocol(): return _GlobalSettings.protocol in (JSON_PROTOCOL, HTTP_JSON_PROTOCOL) class GlobalDebuggerHolder: ''' Holder for the global debugger. ''' global_dbg = None # Note: don't rename (the name is used in our attach to process) def get_global_debugger(): return GlobalDebuggerHolder.global_dbg GetGlobalDebugger = get_global_debugger # Backward-compatibility def set_global_debugger(dbg): GlobalDebuggerHolder.global_dbg = dbg if __name__ == '__main__': if Null(): sys.stdout.write('here\n')
26,450
Python
32.355612
145
0.637883
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_extension_api.py
import abc # borrowed from from six def _with_metaclass(meta, *bases): """Create a base class with a metaclass.""" class metaclass(meta): def __new__(cls, name, this_bases, d): return meta(name, bases, d) return type.__new__(metaclass, 'temporary_class', (), {}) # ======================================================================================================================= # AbstractResolver # ======================================================================================================================= class _AbstractResolver(_with_metaclass(abc.ABCMeta)): """ This class exists only for documentation purposes to explain how to create a resolver. Some examples on how to resolve things: - list: get_dictionary could return a dict with index->item and use the index to resolve it later - set: get_dictionary could return a dict with id(object)->object and reiterate in that array to resolve it later - arbitrary instance: get_dictionary could return dict with attr_name->attr and use getattr to resolve it later """ @abc.abstractmethod def resolve(self, var, attribute): """ In this method, we'll resolve some child item given the string representation of the item in the key representing the previously asked dictionary. @param var: this is the actual variable to be resolved. @param attribute: this is the string representation of a key previously returned in get_dictionary. """ raise NotImplementedError @abc.abstractmethod def get_dictionary(self, var): """ @param var: this is the variable that should have its children gotten. @return: a dictionary where each pair key, value should be shown to the user as children items in the variables view for the given var. """ raise NotImplementedError class _AbstractProvider(_with_metaclass(abc.ABCMeta)): @abc.abstractmethod def can_provide(self, type_object, type_name): raise NotImplementedError # ======================================================================================================================= # API CLASSES: # ======================================================================================================================= class TypeResolveProvider(_AbstractResolver, _AbstractProvider): """ Implement this in an extension to provide a custom resolver, see _AbstractResolver """ class StrPresentationProvider(_AbstractProvider): """ Implement this in an extension to provide a str presentation for a type """ @abc.abstractmethod def get_str(self, val): raise NotImplementedError class DebuggerEventHandler(_with_metaclass(abc.ABCMeta)): """ Implement this to receive lifecycle events from the debugger """ def on_debugger_modules_loaded(self, **kwargs): """ This method invoked after all debugger modules are loaded. Useful for importing and/or patching debugger modules at a safe time :param kwargs: This is intended to be flexible dict passed from the debugger. Currently passes the debugger version """
3,288
Python
36.375
121
0.575122
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_suspended_frames.py
from contextlib import contextmanager import sys from _pydevd_bundle.pydevd_constants import get_frame, RETURN_VALUES_DICT, \ ForkSafeLock, GENERATED_LEN_ATTR_NAME, silence_warnings_decorator from _pydevd_bundle.pydevd_xml import get_variable_details, get_type from _pydev_bundle.pydev_override import overrides from _pydevd_bundle.pydevd_resolver import sorted_attributes_key, TOO_LARGE_ATTR, get_var_scope from _pydevd_bundle.pydevd_safe_repr import SafeRepr from _pydev_bundle import pydev_log from _pydevd_bundle import pydevd_vars from _pydev_bundle.pydev_imports import Exec from _pydevd_bundle.pydevd_frame_utils import FramesList from _pydevd_bundle.pydevd_utils import ScopeRequest, DAPGrouper, Timer class _AbstractVariable(object): # Default attributes in class, set in instance. name = None value = None evaluate_name = None def __init__(self, py_db): assert py_db is not None self.py_db = py_db def get_name(self): return self.name def get_value(self): return self.value def get_variable_reference(self): return id(self.value) def get_var_data(self, fmt=None, **safe_repr_custom_attrs): ''' :param dict fmt: Format expected by the DAP (keys: 'hex': bool, 'rawString': bool) ''' timer = Timer() safe_repr = SafeRepr() if fmt is not None: safe_repr.convert_to_hex = fmt.get('hex', False) safe_repr.raw_value = fmt.get('rawString', False) for key, val in safe_repr_custom_attrs.items(): setattr(safe_repr, key, val) type_name, _type_qualifier, _is_exception_on_eval, resolver, value = get_variable_details( self.value, to_string=safe_repr) is_raw_string = type_name in ('str', 'bytes', 'bytearray') attributes = [] if is_raw_string: attributes.append('rawString') name = self.name if self._is_return_value: attributes.append('readOnly') name = '(return) %s' % (name,) elif name in (TOO_LARGE_ATTR, GENERATED_LEN_ATTR_NAME): attributes.append('readOnly') try: if self.value.__class__ == DAPGrouper: type_name = '' except: pass # Ignore errors accessing __class__. var_data = { 'name': name, 'value': value, 'type': type_name, } if self.evaluate_name is not None: var_data['evaluateName'] = self.evaluate_name if resolver is not None: # I.e.: it's a container var_data['variablesReference'] = self.get_variable_reference() else: var_data['variablesReference'] = 0 # It's mandatory (although if == 0 it doesn't have children). if len(attributes) > 0: var_data['presentationHint'] = {'attributes': attributes} timer.report_if_compute_repr_attr_slow('', name, type_name) return var_data def get_children_variables(self, fmt=None, scope=None): raise NotImplementedError() def get_child_variable_named(self, name, fmt=None, scope=None): for child_var in self.get_children_variables(fmt=fmt, scope=scope): if child_var.get_name() == name: return child_var return None def _group_entries(self, lst, handle_return_values): scope_to_grouper = {} group_entries = [] if isinstance(self.value, DAPGrouper): new_lst = lst else: new_lst = [] get_presentation = self.py_db.variable_presentation.get_presentation # Now that we have the contents, group items. for attr_name, attr_value, evaluate_name in lst: scope = get_var_scope(attr_name, attr_value, evaluate_name, handle_return_values) entry = (attr_name, attr_value, evaluate_name) if scope: presentation = get_presentation(scope) if presentation == 'hide': continue elif presentation == 'inline': new_lst.append(entry) else: # group if scope not in scope_to_grouper: grouper = DAPGrouper(scope) scope_to_grouper[scope] = grouper else: grouper = scope_to_grouper[scope] grouper.contents_debug_adapter_protocol.append(entry) else: new_lst.append(entry) for scope in DAPGrouper.SCOPES_SORTED: grouper = scope_to_grouper.get(scope) if grouper is not None: group_entries.append((scope, grouper, None)) return new_lst, group_entries class _ObjectVariable(_AbstractVariable): def __init__(self, py_db, name, value, register_variable, is_return_value=False, evaluate_name=None, frame=None): _AbstractVariable.__init__(self, py_db) self.frame = frame self.name = name self.value = value self._register_variable = register_variable self._register_variable(self) self._is_return_value = is_return_value self.evaluate_name = evaluate_name @silence_warnings_decorator @overrides(_AbstractVariable.get_children_variables) def get_children_variables(self, fmt=None, scope=None): _type, _type_name, resolver = get_type(self.value) children_variables = [] if resolver is not None: # i.e.: it's a container. if hasattr(resolver, 'get_contents_debug_adapter_protocol'): # The get_contents_debug_adapter_protocol needs to return sorted. lst = resolver.get_contents_debug_adapter_protocol(self.value, fmt=fmt) else: # If there's no special implementation, the default is sorting the keys. dct = resolver.get_dictionary(self.value) lst = sorted(dct.items(), key=lambda tup: sorted_attributes_key(tup[0])) # No evaluate name in this case. lst = [(key, value, None) for (key, value) in lst] lst, group_entries = self._group_entries(lst, handle_return_values=False) if group_entries: lst = group_entries + lst parent_evaluate_name = self.evaluate_name if parent_evaluate_name: for key, val, evaluate_name in lst: if evaluate_name is not None: if callable(evaluate_name): evaluate_name = evaluate_name(parent_evaluate_name) else: evaluate_name = parent_evaluate_name + evaluate_name variable = _ObjectVariable( self.py_db, key, val, self._register_variable, evaluate_name=evaluate_name, frame=self.frame) children_variables.append(variable) else: for key, val, evaluate_name in lst: # No evaluate name variable = _ObjectVariable(self.py_db, key, val, self._register_variable, frame=self.frame) children_variables.append(variable) return children_variables def change_variable(self, name, value, py_db, fmt=None): children_variable = self.get_child_variable_named(name) if children_variable is None: return None var_data = children_variable.get_var_data() evaluate_name = var_data.get('evaluateName') if not evaluate_name: # Note: right now we only pass control to the resolver in the cases where # there's no evaluate name (the idea being that if we can evaluate it, # we can use that evaluation to set the value too -- if in the future # a case where this isn't true is found this logic may need to be changed). _type, _type_name, container_resolver = get_type(self.value) if hasattr(container_resolver, 'change_var_from_name'): try: new_value = eval(value) except: return None new_key = container_resolver.change_var_from_name(self.value, name, new_value) if new_key is not None: return _ObjectVariable( self.py_db, new_key, new_value, self._register_variable, evaluate_name=None, frame=self.frame) return None else: return None frame = self.frame if frame is None: return None try: # This handles the simple cases (such as dict, list, object) Exec('%s=%s' % (evaluate_name, value), frame.f_globals, frame.f_locals) except: return None return self.get_child_variable_named(name, fmt=fmt) def sorted_variables_key(obj): return sorted_attributes_key(obj.name) class _FrameVariable(_AbstractVariable): def __init__(self, py_db, frame, register_variable): _AbstractVariable.__init__(self, py_db) self.frame = frame self.name = self.frame.f_code.co_name self.value = frame self._register_variable = register_variable self._register_variable(self) def change_variable(self, name, value, py_db, fmt=None): frame = self.frame pydevd_vars.change_attr_expression(frame, name, value, py_db) return self.get_child_variable_named(name, fmt=fmt) @silence_warnings_decorator @overrides(_AbstractVariable.get_children_variables) def get_children_variables(self, fmt=None, scope=None): children_variables = [] if scope is not None: assert isinstance(scope, ScopeRequest) scope = scope.scope if scope in ('locals', None): dct = self.frame.f_locals elif scope == 'globals': dct = self.frame.f_globals else: raise AssertionError('Unexpected scope: %s' % (scope,)) lst, group_entries = self._group_entries([(x[0], x[1], None) for x in list(dct.items()) if x[0] != '_pydev_stop_at_break'], handle_return_values=True) group_variables = [] for key, val, _ in group_entries: # Make sure that the contents in the group are also sorted. val.contents_debug_adapter_protocol.sort(key=lambda v:sorted_attributes_key(v[0])) variable = _ObjectVariable(self.py_db, key, val, self._register_variable, False, key, frame=self.frame) group_variables.append(variable) for key, val, _ in lst: is_return_value = key == RETURN_VALUES_DICT if is_return_value: for return_key, return_value in val.items(): variable = _ObjectVariable( self.py_db, return_key, return_value, self._register_variable, is_return_value, '%s[%r]' % (key, return_key), frame=self.frame) children_variables.append(variable) else: variable = _ObjectVariable(self.py_db, key, val, self._register_variable, is_return_value, key, frame=self.frame) children_variables.append(variable) # Frame variables always sorted. children_variables.sort(key=sorted_variables_key) if group_variables: # Groups have priority over other variables. children_variables = group_variables + children_variables return children_variables class _FramesTracker(object): ''' This is a helper class to be used to track frames when a thread becomes suspended. ''' def __init__(self, suspended_frames_manager, py_db): self._suspended_frames_manager = suspended_frames_manager self.py_db = py_db self._frame_id_to_frame = {} # Note that a given frame may appear in multiple threads when we have custom # frames added, but as those are coroutines, this map will point to the actual # main thread (which is the one that needs to be suspended for us to get the # variables). self._frame_id_to_main_thread_id = {} # A map of the suspended thread id -> list(frames ids) -- note that # frame ids are kept in order (the first one is the suspended frame). self._thread_id_to_frame_ids = {} self._thread_id_to_frames_list = {} # The main suspended thread (if this is a coroutine this isn't the id of the # coroutine thread, it's the id of the actual suspended thread). self._main_thread_id = None # Helper to know if it was already untracked. self._untracked = False # We need to be thread-safe! self._lock = ForkSafeLock() self._variable_reference_to_variable = {} def _register_variable(self, variable): variable_reference = variable.get_variable_reference() self._variable_reference_to_variable[variable_reference] = variable def obtain_as_variable(self, name, value, evaluate_name=None, frame=None): if evaluate_name is None: evaluate_name = name variable_reference = id(value) variable = self._variable_reference_to_variable.get(variable_reference) if variable is not None: return variable # Still not created, let's do it now. return _ObjectVariable( self.py_db, name, value, self._register_variable, is_return_value=False, evaluate_name=evaluate_name, frame=frame) def get_main_thread_id(self): return self._main_thread_id def get_variable(self, variable_reference): return self._variable_reference_to_variable[variable_reference] def track(self, thread_id, frames_list, frame_custom_thread_id=None): ''' :param thread_id: The thread id to be used for this frame. :param FramesList frames_list: A list of frames to be tracked (the first is the topmost frame which is suspended at the given thread). :param frame_custom_thread_id: If None this this is the id of the thread id for the custom frame (i.e.: coroutine). ''' assert frames_list.__class__ == FramesList with self._lock: coroutine_or_main_thread_id = frame_custom_thread_id or thread_id if coroutine_or_main_thread_id in self._suspended_frames_manager._thread_id_to_tracker: sys.stderr.write('pydevd: Something is wrong. Tracker being added twice to the same thread id.\n') self._suspended_frames_manager._thread_id_to_tracker[coroutine_or_main_thread_id] = self self._main_thread_id = thread_id frame_ids_from_thread = self._thread_id_to_frame_ids.setdefault( coroutine_or_main_thread_id, []) self._thread_id_to_frames_list[coroutine_or_main_thread_id] = frames_list for frame in frames_list: frame_id = id(frame) self._frame_id_to_frame[frame_id] = frame _FrameVariable(self.py_db, frame, self._register_variable) # Instancing is enough to register. self._suspended_frames_manager._variable_reference_to_frames_tracker[frame_id] = self frame_ids_from_thread.append(frame_id) self._frame_id_to_main_thread_id[frame_id] = thread_id frame = None def untrack_all(self): with self._lock: if self._untracked: # Calling multiple times is expected for the set next statement. return self._untracked = True for thread_id in self._thread_id_to_frame_ids: self._suspended_frames_manager._thread_id_to_tracker.pop(thread_id, None) for frame_id in self._frame_id_to_frame: del self._suspended_frames_manager._variable_reference_to_frames_tracker[frame_id] self._frame_id_to_frame.clear() self._frame_id_to_main_thread_id.clear() self._thread_id_to_frame_ids.clear() self._thread_id_to_frames_list.clear() self._main_thread_id = None self._suspended_frames_manager = None self._variable_reference_to_variable.clear() def get_frames_list(self, thread_id): with self._lock: return self._thread_id_to_frames_list.get(thread_id) def find_frame(self, thread_id, frame_id): with self._lock: return self._frame_id_to_frame.get(frame_id) def create_thread_suspend_command(self, thread_id, stop_reason, message, suspend_type): with self._lock: # First one is topmost frame suspended. frames_list = self._thread_id_to_frames_list[thread_id] cmd = self.py_db.cmd_factory.make_thread_suspend_message( self.py_db, thread_id, frames_list, stop_reason, message, suspend_type) frames_list = None return cmd class SuspendedFramesManager(object): def __init__(self): self._thread_id_to_fake_frames = {} self._thread_id_to_tracker = {} # Mappings self._variable_reference_to_frames_tracker = {} def _get_tracker_for_variable_reference(self, variable_reference): tracker = self._variable_reference_to_frames_tracker.get(variable_reference) if tracker is not None: return tracker for _thread_id, tracker in self._thread_id_to_tracker.items(): try: tracker.get_variable(variable_reference) except KeyError: pass else: return tracker return None def get_thread_id_for_variable_reference(self, variable_reference): ''' We can't evaluate variable references values on any thread, only in the suspended thread (the main reason for this is that in UI frameworks inspecting a UI object from a different thread can potentially crash the application). :param int variable_reference: The variable reference (can be either a frame id or a reference to a previously gotten variable). :return str: The thread id for the thread to be used to inspect the given variable reference or None if the thread was already resumed. ''' frames_tracker = self._get_tracker_for_variable_reference(variable_reference) if frames_tracker is not None: return frames_tracker.get_main_thread_id() return None def get_frame_tracker(self, thread_id): return self._thread_id_to_tracker.get(thread_id) def get_variable(self, variable_reference): ''' :raises KeyError ''' frames_tracker = self._get_tracker_for_variable_reference(variable_reference) if frames_tracker is None: raise KeyError() return frames_tracker.get_variable(variable_reference) def get_frames_list(self, thread_id): tracker = self._thread_id_to_tracker.get(thread_id) if tracker is None: return None return tracker.get_frames_list(thread_id) @contextmanager def track_frames(self, py_db): tracker = _FramesTracker(self, py_db) try: yield tracker finally: tracker.untrack_all() def add_fake_frame(self, thread_id, frame_id, frame): self._thread_id_to_fake_frames.setdefault(thread_id, {})[int(frame_id)] = frame def find_frame(self, thread_id, frame_id): try: if frame_id == "*": return get_frame() # any frame is specified with "*" frame_id = int(frame_id) fake_frames = self._thread_id_to_fake_frames.get(thread_id) if fake_frames is not None: frame = fake_frames.get(frame_id) if frame is not None: return frame frames_tracker = self._thread_id_to_tracker.get(thread_id) if frames_tracker is not None: frame = frames_tracker.find_frame(thread_id, frame_id) if frame is not None: return frame return None except: pydev_log.exception() return None
20,559
Python
37.501873
158
0.594776
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_cython_wrapper.py
import sys try: try: from _pydevd_bundle_ext import pydevd_cython as mod except ImportError: from _pydevd_bundle import pydevd_cython as mod except ImportError: import struct try: is_python_64bit = (struct.calcsize('P') == 8) except: # In Jython this call fails, but this is Ok, we don't support Jython for speedups anyways. raise ImportError plat = '32' if is_python_64bit: plat = '64' # We also accept things as: # # _pydevd_bundle.pydevd_cython_win32_27_32 # _pydevd_bundle.pydevd_cython_win32_34_64 # # to have multiple pre-compiled pyds distributed along the IDE # (generated by build_tools/build_binaries_windows.py). mod_name = 'pydevd_cython_%s_%s%s_%s' % (sys.platform, sys.version_info[0], sys.version_info[1], plat) check_name = '_pydevd_bundle.%s' % (mod_name,) mod = getattr(__import__(check_name), mod_name) # Regardless of how it was found, make sure it's later available as the # initial name so that the expected types from cython in frame eval # are valid. sys.modules['_pydevd_bundle.pydevd_cython'] = mod trace_dispatch = mod.trace_dispatch PyDBAdditionalThreadInfo = mod.PyDBAdditionalThreadInfo set_additional_thread_info = mod.set_additional_thread_info global_cache_skips = mod.global_cache_skips global_cache_frame_skips = mod.global_cache_frame_skips _set_additional_thread_info_lock = mod._set_additional_thread_info_lock fix_top_level_trace_and_get_trace_func = mod.fix_top_level_trace_and_get_trace_func version = getattr(mod, 'version', 0)
1,600
Python
29.207547
106
0.694375
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_stackless.py
from __future__ import nested_scopes import weakref import sys from _pydevd_bundle.pydevd_comm import get_global_debugger from _pydevd_bundle.pydevd_constants import call_only_once from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle.pydevd_custom_frames import update_custom_frame, remove_custom_frame, add_custom_frame import stackless # @UnresolvedImport from _pydev_bundle import pydev_log # Used so that we don't loose the id (because we'll remove when it's not alive and would generate a new id for the # same tasklet). class TaskletToLastId: ''' So, why not a WeakKeyDictionary? The problem is that removals from the WeakKeyDictionary will create a new tasklet (as it adds a callback to remove the key when it's garbage-collected), so, we can get into a recursion. ''' def __init__(self): self.tasklet_ref_to_last_id = {} self._i = 0 def get(self, tasklet): return self.tasklet_ref_to_last_id.get(weakref.ref(tasklet)) def __setitem__(self, tasklet, last_id): self.tasklet_ref_to_last_id[weakref.ref(tasklet)] = last_id self._i += 1 if self._i % 100 == 0: # Collect at each 100 additions to the dict (no need to rush). for tasklet_ref in list(self.tasklet_ref_to_last_id.keys()): if tasklet_ref() is None: del self.tasklet_ref_to_last_id[tasklet_ref] _tasklet_to_last_id = TaskletToLastId() #======================================================================================================================= # _TaskletInfo #======================================================================================================================= class _TaskletInfo: _last_id = 0 def __init__(self, tasklet_weakref, tasklet): self.frame_id = None self.tasklet_weakref = tasklet_weakref last_id = _tasklet_to_last_id.get(tasklet) if last_id is None: _TaskletInfo._last_id += 1 last_id = _TaskletInfo._last_id _tasklet_to_last_id[tasklet] = last_id self._tasklet_id = last_id self.update_name() def update_name(self): tasklet = self.tasklet_weakref() if tasklet: if tasklet.blocked: state = 'blocked' elif tasklet.paused: state = 'paused' elif tasklet.scheduled: state = 'scheduled' else: state = '<UNEXPECTED>' try: name = tasklet.name except AttributeError: if tasklet.is_main: name = 'MainTasklet' else: name = 'Tasklet-%s' % (self._tasklet_id,) thread_id = tasklet.thread_id if thread_id != -1: for thread in threading.enumerate(): if thread.ident == thread_id: if thread.name: thread_name = "of %s" % (thread.name,) else: thread_name = "of Thread-%s" % (thread.name or str(thread_id),) break else: # should not happen. thread_name = "of Thread-%s" % (str(thread_id),) thread = None else: # tasklet is no longer bound to a thread, because its thread ended thread_name = "without thread" tid = id(tasklet) tasklet = None else: state = 'dead' name = 'Tasklet-%s' % (self._tasklet_id,) thread_name = "" tid = '-' self.tasklet_name = '%s %s %s (%s)' % (state, name, thread_name, tid) if not hasattr(stackless.tasklet, "trace_function"): # bug https://bitbucket.org/stackless-dev/stackless/issue/42 # is not fixed. Stackless releases before 2014 def update_name(self): tasklet = self.tasklet_weakref() if tasklet: try: name = tasklet.name except AttributeError: if tasklet.is_main: name = 'MainTasklet' else: name = 'Tasklet-%s' % (self._tasklet_id,) thread_id = tasklet.thread_id for thread in threading.enumerate(): if thread.ident == thread_id: if thread.name: thread_name = "of %s" % (thread.name,) else: thread_name = "of Thread-%s" % (thread.name or str(thread_id),) break else: # should not happen. thread_name = "of Thread-%s" % (str(thread_id),) thread = None tid = id(tasklet) tasklet = None else: name = 'Tasklet-%s' % (self._tasklet_id,) thread_name = "" tid = '-' self.tasklet_name = '%s %s (%s)' % (name, thread_name, tid) _weak_tasklet_registered_to_info = {} #======================================================================================================================= # get_tasklet_info #======================================================================================================================= def get_tasklet_info(tasklet): return register_tasklet_info(tasklet) #======================================================================================================================= # register_tasklet_info #======================================================================================================================= def register_tasklet_info(tasklet): r = weakref.ref(tasklet) info = _weak_tasklet_registered_to_info.get(r) if info is None: info = _weak_tasklet_registered_to_info[r] = _TaskletInfo(r, tasklet) return info _application_set_schedule_callback = None #======================================================================================================================= # _schedule_callback #======================================================================================================================= def _schedule_callback(prev, next): ''' Called when a context is stopped or a new context is made runnable. ''' try: if not prev and not next: return current_frame = sys._getframe() if next: register_tasklet_info(next) # Ok, making next runnable: set the tracing facility in it. debugger = get_global_debugger() if debugger is not None: next.trace_function = debugger.get_thread_local_trace_func() frame = next.frame if frame is current_frame: frame = frame.f_back if hasattr(frame, 'f_trace'): # Note: can be None (but hasattr should cover for that too). frame.f_trace = debugger.get_thread_local_trace_func() debugger = None if prev: register_tasklet_info(prev) try: for tasklet_ref, tasklet_info in list(_weak_tasklet_registered_to_info.items()): # Make sure it's a copy! tasklet = tasklet_ref() if tasklet is None or not tasklet.alive: # Garbage-collected already! try: del _weak_tasklet_registered_to_info[tasklet_ref] except KeyError: pass if tasklet_info.frame_id is not None: remove_custom_frame(tasklet_info.frame_id) else: is_running = stackless.get_thread_info(tasklet.thread_id)[1] is tasklet if tasklet is prev or (tasklet is not next and not is_running): # the tasklet won't run after this scheduler action: # - the tasklet is the previous tasklet # - it is not the next tasklet and it is not an already running tasklet frame = tasklet.frame if frame is current_frame: frame = frame.f_back if frame is not None: # print >>sys.stderr, "SchedCB: %r, %d, '%s', '%s'" % (tasklet, frame.f_lineno, _filename, base) debugger = get_global_debugger() if debugger is not None and debugger.get_file_type(frame) is None: tasklet_info.update_name() if tasklet_info.frame_id is None: tasklet_info.frame_id = add_custom_frame(frame, tasklet_info.tasklet_name, tasklet.thread_id) else: update_custom_frame(tasklet_info.frame_id, frame, tasklet.thread_id, name=tasklet_info.tasklet_name) debugger = None elif tasklet is next or is_running: if tasklet_info.frame_id is not None: # Remove info about stackless suspended when it starts to run. remove_custom_frame(tasklet_info.frame_id) tasklet_info.frame_id = None finally: tasklet = None tasklet_info = None frame = None except: pydev_log.exception() if _application_set_schedule_callback is not None: return _application_set_schedule_callback(prev, next) if not hasattr(stackless.tasklet, "trace_function"): # Older versions of Stackless, released before 2014 # This code does not work reliable! It is affected by several # stackless bugs: Stackless issues #44, #42, #40 def _schedule_callback(prev, next): ''' Called when a context is stopped or a new context is made runnable. ''' try: if not prev and not next: return if next: register_tasklet_info(next) # Ok, making next runnable: set the tracing facility in it. debugger = get_global_debugger() if debugger is not None and next.frame: if hasattr(next.frame, 'f_trace'): next.frame.f_trace = debugger.get_thread_local_trace_func() debugger = None if prev: register_tasklet_info(prev) try: for tasklet_ref, tasklet_info in list(_weak_tasklet_registered_to_info.items()): # Make sure it's a copy! tasklet = tasklet_ref() if tasklet is None or not tasklet.alive: # Garbage-collected already! try: del _weak_tasklet_registered_to_info[tasklet_ref] except KeyError: pass if tasklet_info.frame_id is not None: remove_custom_frame(tasklet_info.frame_id) else: if tasklet.paused or tasklet.blocked or tasklet.scheduled: if tasklet.frame and tasklet.frame.f_back: f_back = tasklet.frame.f_back debugger = get_global_debugger() if debugger is not None and debugger.get_file_type(f_back) is None: if tasklet_info.frame_id is None: tasklet_info.frame_id = add_custom_frame(f_back, tasklet_info.tasklet_name, tasklet.thread_id) else: update_custom_frame(tasklet_info.frame_id, f_back, tasklet.thread_id) debugger = None elif tasklet.is_current: if tasklet_info.frame_id is not None: # Remove info about stackless suspended when it starts to run. remove_custom_frame(tasklet_info.frame_id) tasklet_info.frame_id = None finally: tasklet = None tasklet_info = None f_back = None except: pydev_log.exception() if _application_set_schedule_callback is not None: return _application_set_schedule_callback(prev, next) _original_setup = stackless.tasklet.setup #======================================================================================================================= # setup #======================================================================================================================= def setup(self, *args, **kwargs): ''' Called to run a new tasklet: rebind the creation so that we can trace it. ''' f = self.tempval def new_f(old_f, args, kwargs): debugger = get_global_debugger() if debugger is not None: debugger.enable_tracing() debugger = None # Remove our own traces :) self.tempval = old_f register_tasklet_info(self) # Hover old_f to see the stackless being created and *args and **kwargs to see its parameters. return old_f(*args, **kwargs) # This is the way to tell stackless that the function it should execute is our function, not the original one. Note: # setting tempval is the same as calling bind(new_f), but it seems that there's no other way to get the currently # bound function, so, keeping on using tempval instead of calling bind (which is actually the same thing in a better # API). self.tempval = new_f return _original_setup(self, f, args, kwargs) #======================================================================================================================= # __call__ #======================================================================================================================= def __call__(self, *args, **kwargs): ''' Called to run a new tasklet: rebind the creation so that we can trace it. ''' return setup(self, *args, **kwargs) _original_run = stackless.run #======================================================================================================================= # run #======================================================================================================================= def run(*args, **kwargs): debugger = get_global_debugger() if debugger is not None: debugger.enable_tracing() debugger = None return _original_run(*args, **kwargs) #======================================================================================================================= # patch_stackless #======================================================================================================================= def patch_stackless(): ''' This function should be called to patch the stackless module so that new tasklets are properly tracked in the debugger. ''' global _application_set_schedule_callback _application_set_schedule_callback = stackless.set_schedule_callback(_schedule_callback) def set_schedule_callback(callable): global _application_set_schedule_callback old = _application_set_schedule_callback _application_set_schedule_callback = callable return old def get_schedule_callback(): global _application_set_schedule_callback return _application_set_schedule_callback set_schedule_callback.__doc__ = stackless.set_schedule_callback.__doc__ if hasattr(stackless, "get_schedule_callback"): get_schedule_callback.__doc__ = stackless.get_schedule_callback.__doc__ stackless.set_schedule_callback = set_schedule_callback stackless.get_schedule_callback = get_schedule_callback if not hasattr(stackless.tasklet, "trace_function"): # Older versions of Stackless, released before 2014 __call__.__doc__ = stackless.tasklet.__call__.__doc__ stackless.tasklet.__call__ = __call__ setup.__doc__ = stackless.tasklet.setup.__doc__ stackless.tasklet.setup = setup run.__doc__ = stackless.run.__doc__ stackless.run = run patch_stackless = call_only_once(patch_stackless)
16,909
Python
39.551559
136
0.472411
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_trace_dispatch_regular.py
from _pydev_bundle.pydev_is_thread_alive import is_thread_alive from _pydev_bundle.pydev_log import exception as pydev_log_exception from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle.pydevd_constants import (get_current_thread_id, NO_FTRACE, USE_CUSTOM_SYS_CURRENT_FRAMES_MAP, ForkSafeLock) from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER # IFDEF CYTHON # from cpython.object cimport PyObject # from cpython.ref cimport Py_INCREF, Py_XDECREF # ELSE from _pydevd_bundle.pydevd_frame import PyDBFrame, is_unhandled_exception # ENDIF # IFDEF CYTHON # cdef dict _global_notify_skipped_step_in # cython_inline_constant: CMD_STEP_INTO = 107 # cython_inline_constant: CMD_STEP_INTO_MY_CODE = 144 # cython_inline_constant: CMD_STEP_RETURN = 109 # cython_inline_constant: CMD_STEP_RETURN_MY_CODE = 160 # ELSE # Note: those are now inlined on cython. CMD_STEP_INTO = 107 CMD_STEP_INTO_MY_CODE = 144 CMD_STEP_RETURN = 109 CMD_STEP_RETURN_MY_CODE = 160 # ENDIF # Cache where we should keep that we completely skipped entering some context. # It needs to be invalidated when: # - Breakpoints are changed # It can be used when running regularly (without step over/step in/step return) global_cache_skips = {} global_cache_frame_skips = {} _global_notify_skipped_step_in = False _global_notify_skipped_step_in_lock = ForkSafeLock() def notify_skipped_step_in_because_of_filters(py_db, frame): global _global_notify_skipped_step_in with _global_notify_skipped_step_in_lock: if _global_notify_skipped_step_in: # Check with lock in place (callers should actually have checked # before without the lock in place due to performance). return _global_notify_skipped_step_in = True py_db.notify_skipped_step_in_because_of_filters(frame) # IFDEF CYTHON # cdef class SafeCallWrapper: # cdef method_object # def __init__(self, method_object): # self.method_object = method_object # def __call__(self, *args): # #Cannot use 'self' once inside the delegate call since we are borrowing the self reference f_trace field # #in the frame, and that reference might get destroyed by set trace on frame and parents # cdef PyObject* method_obj = <PyObject*> self.method_object # Py_INCREF(<object>method_obj) # ret = (<object>method_obj)(*args) # Py_XDECREF (method_obj) # return SafeCallWrapper(ret) if ret is not None else None # def get_method_object(self): # return self.method_object # ELSE # ENDIF def fix_top_level_trace_and_get_trace_func(py_db, frame): # IFDEF CYTHON # cdef str filename; # cdef str name; # cdef tuple args; # ENDIF # Note: this is always the first entry-point in the tracing for any thread. # After entering here we'll set a new tracing function for this thread # where more information is cached (and will also setup the tracing for # frames where we should deal with unhandled exceptions). thread = None # Cache the frame which should be traced to deal with unhandled exceptions. # (i.e.: thread entry-points). f_unhandled = frame # print('called at', f_unhandled.f_code.co_name, f_unhandled.f_code.co_filename, f_unhandled.f_code.co_firstlineno) force_only_unhandled_tracer = False while f_unhandled is not None: # name = splitext(basename(f_unhandled.f_code.co_filename))[0] name = f_unhandled.f_code.co_filename # basename i = name.rfind('/') j = name.rfind('\\') if j > i: i = j if i >= 0: name = name[i + 1:] # remove ext i = name.rfind('.') if i >= 0: name = name[:i] if name == 'threading': if f_unhandled.f_code.co_name in ('__bootstrap', '_bootstrap'): # We need __bootstrap_inner, not __bootstrap. return None, False elif f_unhandled.f_code.co_name in ('__bootstrap_inner', '_bootstrap_inner'): # Note: be careful not to use threading.currentThread to avoid creating a dummy thread. t = f_unhandled.f_locals.get('self') force_only_unhandled_tracer = True if t is not None and isinstance(t, threading.Thread): thread = t break elif name == 'pydev_monkey': if f_unhandled.f_code.co_name == '__call__': force_only_unhandled_tracer = True break elif name == 'pydevd': if f_unhandled.f_code.co_name in ('run', 'main'): # We need to get to _exec return None, False if f_unhandled.f_code.co_name == '_exec': force_only_unhandled_tracer = True break elif name == 'pydevd_tracing': return None, False elif f_unhandled.f_back is None: break f_unhandled = f_unhandled.f_back if thread is None: # Important: don't call threadingCurrentThread if we're in the threading module # to avoid creating dummy threads. if py_db.threading_get_ident is not None: thread = py_db.threading_active.get(py_db.threading_get_ident()) if thread is None: return None, False else: # Jython does not have threading.get_ident(). thread = py_db.threading_current_thread() if getattr(thread, 'pydev_do_not_trace', None): py_db.disable_tracing() return None, False try: additional_info = thread.additional_info if additional_info is None: raise AttributeError() except: additional_info = py_db.set_additional_thread_info(thread) # print('enter thread tracer', thread, get_current_thread_id(thread)) args = (py_db, thread, additional_info, global_cache_skips, global_cache_frame_skips) if f_unhandled is not None: if f_unhandled.f_back is None and not force_only_unhandled_tracer: # Happens when we attach to a running program (cannot reuse instance because it's mutable). top_level_thread_tracer = TopLevelThreadTracerNoBackFrame(ThreadTracer(args), args) additional_info.top_level_thread_tracer_no_back_frames.append(top_level_thread_tracer) # Hack for cython to keep it alive while the thread is alive (just the method in the SetTrace is not enough). else: top_level_thread_tracer = additional_info.top_level_thread_tracer_unhandled if top_level_thread_tracer is None: # Stop in some internal place to report about unhandled exceptions top_level_thread_tracer = TopLevelThreadTracerOnlyUnhandledExceptions(args) additional_info.top_level_thread_tracer_unhandled = top_level_thread_tracer # Hack for cython to keep it alive while the thread is alive (just the method in the SetTrace is not enough). # print(' --> found to trace unhandled', f_unhandled.f_code.co_name, f_unhandled.f_code.co_filename, f_unhandled.f_code.co_firstlineno) f_trace = top_level_thread_tracer.get_trace_dispatch_func() # IFDEF CYTHON # f_trace = SafeCallWrapper(f_trace) # ENDIF f_unhandled.f_trace = f_trace if frame is f_unhandled: return f_trace, False thread_tracer = additional_info.thread_tracer if thread_tracer is None or thread_tracer._args[0] is not py_db: thread_tracer = ThreadTracer(args) additional_info.thread_tracer = thread_tracer # IFDEF CYTHON # return SafeCallWrapper(thread_tracer), True # ELSE return thread_tracer, True # ENDIF def trace_dispatch(py_db, frame, event, arg): thread_trace_func, apply_to_settrace = py_db.fix_top_level_trace_and_get_trace_func(py_db, frame) if thread_trace_func is None: return None if event == 'call' else NO_FTRACE if apply_to_settrace: py_db.enable_tracing(thread_trace_func) return thread_trace_func(frame, event, arg) # IFDEF CYTHON # cdef class TopLevelThreadTracerOnlyUnhandledExceptions: # cdef public tuple _args; # def __init__(self, tuple args): # self._args = args # ELSE class TopLevelThreadTracerOnlyUnhandledExceptions(object): def __init__(self, args): self._args = args # ENDIF def trace_unhandled_exceptions(self, frame, event, arg): # Note that we ignore the frame as this tracing method should only be put in topmost frames already. # print('trace_unhandled_exceptions', event, frame.f_code.co_name, frame.f_code.co_filename, frame.f_code.co_firstlineno) if event == 'exception' and arg is not None: py_db, t, additional_info = self._args[0:3] if arg is not None: if not additional_info.suspended_at_unhandled: additional_info.suspended_at_unhandled = True py_db.stop_on_unhandled_exception(py_db, t, additional_info, arg) # No need to reset frame.f_trace to keep the same trace function. return self.trace_unhandled_exceptions def get_trace_dispatch_func(self): return self.trace_unhandled_exceptions # IFDEF CYTHON # cdef class TopLevelThreadTracerNoBackFrame: # # cdef public object _frame_trace_dispatch; # cdef public tuple _args; # cdef public object try_except_infos; # cdef public object _last_exc_arg; # cdef public set _raise_lines; # cdef public int _last_raise_line; # # def __init__(self, frame_trace_dispatch, tuple args): # self._frame_trace_dispatch = frame_trace_dispatch # self._args = args # self.try_except_infos = None # self._last_exc_arg = None # self._raise_lines = set() # self._last_raise_line = -1 # ELSE class TopLevelThreadTracerNoBackFrame(object): ''' This tracer is pretty special in that it's dealing with a frame without f_back (i.e.: top frame on remote attach or QThread). This means that we have to carefully inspect exceptions to discover whether the exception will be unhandled or not (if we're dealing with an unhandled exception we need to stop as unhandled, otherwise we need to use the regular tracer -- unfortunately the debugger has little info to work with in the tracing -- see: https://bugs.python.org/issue34099, so, we inspect bytecode to determine if some exception will be traced or not... note that if this is not available -- such as on Jython -- we consider any top-level exception to be unnhandled). ''' def __init__(self, frame_trace_dispatch, args): self._frame_trace_dispatch = frame_trace_dispatch self._args = args self.try_except_infos = None self._last_exc_arg = None self._raise_lines = set() self._last_raise_line = -1 # ENDIF def trace_dispatch_and_unhandled_exceptions(self, frame, event, arg): # DEBUG = 'code_to_debug' in frame.f_code.co_filename # if DEBUG: print('trace_dispatch_and_unhandled_exceptions: %s %s %s %s %s %s' % (event, frame.f_code.co_name, frame.f_code.co_filename, frame.f_code.co_firstlineno, self._frame_trace_dispatch, frame.f_lineno)) frame_trace_dispatch = self._frame_trace_dispatch if frame_trace_dispatch is not None: self._frame_trace_dispatch = frame_trace_dispatch(frame, event, arg) if event == 'exception': self._last_exc_arg = arg self._raise_lines.add(frame.f_lineno) self._last_raise_line = frame.f_lineno elif event == 'return' and self._last_exc_arg is not None: # For unhandled exceptions we actually track the return when at the topmost level. try: py_db, t, additional_info = self._args[0:3] if not additional_info.suspended_at_unhandled: # Note: only check it here, don't set. if is_unhandled_exception(self, py_db, frame, self._last_raise_line, self._raise_lines): py_db.stop_on_unhandled_exception(py_db, t, additional_info, self._last_exc_arg) finally: # Remove reference to exception after handling it. self._last_exc_arg = None ret = self.trace_dispatch_and_unhandled_exceptions # Need to reset (the call to _frame_trace_dispatch may have changed it). # IFDEF CYTHON # frame.f_trace = SafeCallWrapper(ret) # ELSE frame.f_trace = ret # ENDIF return ret def get_trace_dispatch_func(self): return self.trace_dispatch_and_unhandled_exceptions # IFDEF CYTHON # cdef class ThreadTracer: # cdef public tuple _args; # def __init__(self, tuple args): # self._args = args # ELSE class ThreadTracer(object): def __init__(self, args): self._args = args # ENDIF def __call__(self, frame, event, arg): ''' This is the callback used when we enter some context in the debugger. We also decorate the thread we are in with info about the debugging. The attributes added are: pydev_state pydev_step_stop pydev_step_cmd pydev_notify_kill :param PyDB py_db: This is the global debugger (this method should actually be added as a method to it). ''' # IFDEF CYTHON # cdef str filename; # cdef str base; # cdef int pydev_step_cmd; # cdef object frame_cache_key; # cdef dict cache_skips; # cdef bint is_stepping; # cdef tuple abs_path_canonical_path_and_base; # cdef PyDBAdditionalThreadInfo additional_info; # ENDIF # DEBUG = 'code_to_debug' in frame.f_code.co_filename # if DEBUG: print('ENTER: trace_dispatch: %s %s %s %s' % (frame.f_code.co_filename, frame.f_lineno, event, frame.f_code.co_name)) py_db, t, additional_info, cache_skips, frame_skips_cache = self._args if additional_info.is_tracing: return None if event == 'call' else NO_FTRACE # we don't wan't to trace code invoked from pydevd_frame.trace_dispatch additional_info.is_tracing += 1 try: pydev_step_cmd = additional_info.pydev_step_cmd is_stepping = pydev_step_cmd != -1 if py_db.pydb_disposed: return None if event == 'call' else NO_FTRACE # if thread is not alive, cancel trace_dispatch processing if not is_thread_alive(t): py_db.notify_thread_not_alive(get_current_thread_id(t)) return None if event == 'call' else NO_FTRACE # Note: it's important that the context name is also given because we may hit something once # in the global context and another in the local context. frame_cache_key = frame.f_code if frame_cache_key in cache_skips: if not is_stepping: # if DEBUG: print('skipped: trace_dispatch (cache hit)', frame_cache_key, frame.f_lineno, event, frame.f_code.co_name) return None if event == 'call' else NO_FTRACE else: # When stepping we can't take into account caching based on the breakpoints (only global filtering). if cache_skips.get(frame_cache_key) == 1: if additional_info.pydev_original_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE) and not _global_notify_skipped_step_in: notify_skipped_step_in_because_of_filters(py_db, frame) back_frame = frame.f_back if back_frame is not None and pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_RETURN, CMD_STEP_RETURN_MY_CODE): back_frame_cache_key = back_frame.f_code if cache_skips.get(back_frame_cache_key) == 1: # if DEBUG: print('skipped: trace_dispatch (cache hit: 1)', frame_cache_key, frame.f_lineno, event, frame.f_code.co_name) return None if event == 'call' else NO_FTRACE else: # if DEBUG: print('skipped: trace_dispatch (cache hit: 2)', frame_cache_key, frame.f_lineno, event, frame.f_code.co_name) return None if event == 'call' else NO_FTRACE try: # Make fast path faster! abs_path_canonical_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] except: abs_path_canonical_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) file_type = py_db.get_file_type(frame, abs_path_canonical_path_and_base) # we don't want to debug threading or anything related to pydevd if file_type is not None: if file_type == 1: # inlining LIB_FILE = 1 if not py_db.in_project_scope(frame, abs_path_canonical_path_and_base[0]): # if DEBUG: print('skipped: trace_dispatch (not in scope)', abs_path_canonical_path_and_base[2], frame.f_lineno, event, frame.f_code.co_name, file_type) cache_skips[frame_cache_key] = 1 return None if event == 'call' else NO_FTRACE else: # if DEBUG: print('skipped: trace_dispatch', abs_path_canonical_path_and_base[2], frame.f_lineno, event, frame.f_code.co_name, file_type) cache_skips[frame_cache_key] = 1 return None if event == 'call' else NO_FTRACE if py_db.is_files_filter_enabled: if py_db.apply_files_filter(frame, abs_path_canonical_path_and_base[0], False): cache_skips[frame_cache_key] = 1 if is_stepping and additional_info.pydev_original_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE) and not _global_notify_skipped_step_in: notify_skipped_step_in_because_of_filters(py_db, frame) # A little gotcha, sometimes when we're stepping in we have to stop in a # return event showing the back frame as the current frame, so, we need # to check not only the current frame but the back frame too. back_frame = frame.f_back if back_frame is not None and pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_RETURN, CMD_STEP_RETURN_MY_CODE): if py_db.apply_files_filter(back_frame, back_frame.f_code.co_filename, False): back_frame_cache_key = back_frame.f_code cache_skips[back_frame_cache_key] = 1 # if DEBUG: print('skipped: trace_dispatch (filtered out: 1)', frame_cache_key, frame.f_lineno, event, frame.f_code.co_name) return None if event == 'call' else NO_FTRACE else: # if DEBUG: print('skipped: trace_dispatch (filtered out: 2)', frame_cache_key, frame.f_lineno, event, frame.f_code.co_name) return None if event == 'call' else NO_FTRACE # if DEBUG: print('trace_dispatch', filename, frame.f_lineno, event, frame.f_code.co_name, file_type) # Just create PyDBFrame directly (removed support for Python versions < 2.5, which required keeping a weak # reference to the frame). ret = PyDBFrame( ( py_db, abs_path_canonical_path_and_base, additional_info, t, frame_skips_cache, frame_cache_key, ) ).trace_dispatch(frame, event, arg) if ret is None: # 1 means skipped because of filters. # 2 means skipped because no breakpoints were hit. cache_skips[frame_cache_key] = 2 return None if event == 'call' else NO_FTRACE # IFDEF CYTHON # frame.f_trace = SafeCallWrapper(ret) # Make sure we keep the returned tracer. # ELSE frame.f_trace = ret # Make sure we keep the returned tracer. # ENDIF return ret except SystemExit: return None if event == 'call' else NO_FTRACE except Exception: if py_db.pydb_disposed: return None if event == 'call' else NO_FTRACE # Don't log errors when we're shutting down. # Log it try: if pydev_log_exception is not None: # This can actually happen during the interpreter shutdown in Python 2.7 pydev_log_exception() except: # Error logging? We're really in the interpreter shutdown... # (https://github.com/fabioz/PyDev.Debugger/issues/8) pass return None if event == 'call' else NO_FTRACE finally: additional_info.is_tracing -= 1 if USE_CUSTOM_SYS_CURRENT_FRAMES_MAP: # This is far from ideal, as we'll leak frames (we'll always have the last created frame, not really # the last topmost frame saved -- this should be Ok for our usage, but it may leak frames and things # may live longer... as IronPython is garbage-collected, things should live longer anyways, so, it # shouldn't be an issue as big as it's in CPython -- it may still be annoying, but this should # be a reasonable workaround until IronPython itself is able to provide that functionality). # # See: https://github.com/IronLanguages/main/issues/1630 from _pydevd_bundle.pydevd_constants import constructed_tid_to_last_frame _original_call = ThreadTracer.__call__ def __call__(self, frame, event, arg): constructed_tid_to_last_frame[self._args[1].ident] = frame return _original_call(self, frame, event, arg) ThreadTracer.__call__ = __call__
22,202
Python
44.219959
218
0.616836
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py
from __future__ import nested_scopes import traceback import warnings from _pydev_bundle import pydev_log from _pydev_bundle._pydev_saved_modules import thread, threading from _pydev_bundle import _pydev_saved_modules import signal import os import ctypes from importlib import import_module from urllib.parse import quote # @UnresolvedImport import time import inspect import sys from _pydevd_bundle.pydevd_constants import USE_CUSTOM_SYS_CURRENT_FRAMES, IS_PYPY, SUPPORT_GEVENT, \ GEVENT_SUPPORT_NOT_SET_MSG, GENERATED_LEN_ATTR_NAME, PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT, \ get_global_debugger def save_main_module(file, module_name): # patch provided by: Scott Schlesier - when script is run, it does not # use globals from pydevd: # This will prevent the pydevd script from contaminating the namespace for the script to be debugged # pretend pydevd is not the main module, and # convince the file to be debugged that it was loaded as main sys.modules[module_name] = sys.modules['__main__'] sys.modules[module_name].__name__ = module_name with warnings.catch_warnings(): warnings.simplefilter("ignore", category=DeprecationWarning) warnings.simplefilter("ignore", category=PendingDeprecationWarning) from imp import new_module m = new_module('__main__') sys.modules['__main__'] = m if hasattr(sys.modules[module_name], '__loader__'): m.__loader__ = getattr(sys.modules[module_name], '__loader__') m.__file__ = file return m def is_current_thread_main_thread(): if hasattr(threading, 'main_thread'): return threading.current_thread() is threading.main_thread() else: return isinstance(threading.current_thread(), threading._MainThread) def get_main_thread(): if hasattr(threading, 'main_thread'): return threading.main_thread() else: for t in threading.enumerate(): if isinstance(t, threading._MainThread): return t return None def to_number(x): if is_string(x): try: n = float(x) return n except ValueError: pass l = x.find('(') if l != -1: y = x[0:l - 1] # print y try: n = float(y) return n except ValueError: pass return None def compare_object_attrs_key(x): if GENERATED_LEN_ATTR_NAME == x: as_number = to_number(x) if as_number is None: as_number = 99999999 # len() should appear after other attributes in a list. return (1, as_number) else: return (-1, to_string(x)) def is_string(x): return isinstance(x, str) def to_string(x): if isinstance(x, str): return x else: return str(x) def print_exc(): if traceback: traceback.print_exc() def quote_smart(s, safe='/'): return quote(s, safe) def get_clsname_for_code(code, frame): clsname = None if len(code.co_varnames) > 0: # We are checking the first argument of the function # (`self` or `cls` for methods). first_arg_name = code.co_varnames[0] if first_arg_name in frame.f_locals: first_arg_obj = frame.f_locals[first_arg_name] if inspect.isclass(first_arg_obj): # class method first_arg_class = first_arg_obj else: # instance method if hasattr(first_arg_obj, "__class__"): first_arg_class = first_arg_obj.__class__ else: # old style class, fall back on type first_arg_class = type(first_arg_obj) func_name = code.co_name if hasattr(first_arg_class, func_name): method = getattr(first_arg_class, func_name) func_code = None if hasattr(method, 'func_code'): # Python2 func_code = method.func_code elif hasattr(method, '__code__'): # Python3 func_code = method.__code__ if func_code and func_code == code: clsname = first_arg_class.__name__ return clsname def get_non_pydevd_threads(): threads = threading.enumerate() return [t for t in threads if t and not getattr(t, 'is_pydev_daemon_thread', False)] if USE_CUSTOM_SYS_CURRENT_FRAMES and IS_PYPY: # On PyPy we can use its fake_frames to get the traceback # (instead of the actual real frames that need the tracing to be correct). _tid_to_frame_for_dump_threads = sys._current_frames else: from _pydevd_bundle.pydevd_constants import _current_frames as _tid_to_frame_for_dump_threads def dump_threads(stream=None, show_pydevd_threads=True): ''' Helper to dump thread info. ''' if stream is None: stream = sys.stderr thread_id_to_name_and_is_pydevd_thread = {} try: threading_enumerate = _pydev_saved_modules.pydevd_saved_threading_enumerate if threading_enumerate is None: threading_enumerate = threading.enumerate for t in threading_enumerate(): is_pydevd_thread = getattr(t, 'is_pydev_daemon_thread', False) thread_id_to_name_and_is_pydevd_thread[t.ident] = ( '%s (daemon: %s, pydevd thread: %s)' % (t.name, t.daemon, is_pydevd_thread), is_pydevd_thread ) except: pass stream.write('===============================================================================\n') stream.write('Threads running\n') stream.write('================================= Thread Dump =================================\n') stream.flush() for thread_id, frame in _tid_to_frame_for_dump_threads().items(): name, is_pydevd_thread = thread_id_to_name_and_is_pydevd_thread.get(thread_id, (thread_id, False)) if not show_pydevd_threads and is_pydevd_thread: continue stream.write('\n-------------------------------------------------------------------------------\n') stream.write(" Thread %s" % (name,)) stream.write('\n\n') for i, (filename, lineno, name, line) in enumerate(traceback.extract_stack(frame)): stream.write(' File "%s", line %d, in %s\n' % (filename, lineno, name)) if line: stream.write(" %s\n" % (line.strip())) if i == 0 and 'self' in frame.f_locals: stream.write(' self: ') try: stream.write(str(frame.f_locals['self'])) except: stream.write('Unable to get str of: %s' % (type(frame.f_locals['self']),)) stream.write('\n') stream.flush() stream.write('\n=============================== END Thread Dump ===============================') stream.flush() def _extract_variable_nested_braces(char_iter): expression = [] level = 0 for c in char_iter: if c == '{': level += 1 if c == '}': level -= 1 if level == -1: return ''.join(expression).strip() expression.append(c) raise SyntaxError('Unbalanced braces in expression.') def _extract_expression_list(log_message): # Note: not using re because of nested braces. expression = [] expression_vars = [] char_iter = iter(log_message) for c in char_iter: if c == '{': expression_var = _extract_variable_nested_braces(char_iter) if expression_var: expression.append('%s') expression_vars.append(expression_var) else: expression.append(c) expression = ''.join(expression) return expression, expression_vars def convert_dap_log_message_to_expression(log_message): try: expression, expression_vars = _extract_expression_list(log_message) except SyntaxError: return repr('Unbalanced braces in: %s' % (log_message)) if not expression_vars: return repr(expression) # Note: use '%' to be compatible with Python 2.6. return repr(expression) + ' % (' + ', '.join(str(x) for x in expression_vars) + ',)' def notify_about_gevent_if_needed(stream=None): ''' When debugging with gevent check that the gevent flag is used if the user uses the gevent monkey-patching. :return bool: Returns True if a message had to be shown to the user and False otherwise. ''' stream = stream if stream is not None else sys.stderr if not SUPPORT_GEVENT: gevent_monkey = sys.modules.get('gevent.monkey') if gevent_monkey is not None: try: saved = gevent_monkey.saved except AttributeError: pydev_log.exception_once('Error checking for gevent monkey-patching.') return False if saved: # Note: print to stderr as it may deadlock the debugger. sys.stderr.write('%s\n' % (GEVENT_SUPPORT_NOT_SET_MSG,)) return True return False def hasattr_checked(obj, name): try: getattr(obj, name) except: # i.e.: Handle any exception, not only AttributeError. return False else: return True def getattr_checked(obj, name): try: return getattr(obj, name) except: # i.e.: Handle any exception, not only AttributeError. return None def dir_checked(obj): try: return dir(obj) except: return [] def isinstance_checked(obj, cls): try: return isinstance(obj, cls) except: return False class ScopeRequest(object): __slots__ = ['variable_reference', 'scope'] def __init__(self, variable_reference, scope): assert scope in ('globals', 'locals') self.variable_reference = variable_reference self.scope = scope def __eq__(self, o): if isinstance(o, ScopeRequest): return self.variable_reference == o.variable_reference and self.scope == o.scope return False def __ne__(self, o): return not self == o def __hash__(self): return hash((self.variable_reference, self.scope)) class DAPGrouper(object): ''' Note: this is a helper class to group variables on the debug adapter protocol (DAP). For the xml protocol the type is just added to each variable and the UI can group/hide it as needed. ''' SCOPE_SPECIAL_VARS = 'special variables' SCOPE_PROTECTED_VARS = 'protected variables' SCOPE_FUNCTION_VARS = 'function variables' SCOPE_CLASS_VARS = 'class variables' SCOPES_SORTED = [ SCOPE_SPECIAL_VARS, SCOPE_PROTECTED_VARS, SCOPE_FUNCTION_VARS, SCOPE_CLASS_VARS, ] __slots__ = ['variable_reference', 'scope', 'contents_debug_adapter_protocol'] def __init__(self, scope): self.variable_reference = id(self) self.scope = scope self.contents_debug_adapter_protocol = [] def get_contents_debug_adapter_protocol(self): return self.contents_debug_adapter_protocol[:] def __eq__(self, o): if isinstance(o, ScopeRequest): return self.variable_reference == o.variable_reference and self.scope == o.scope return False def __ne__(self, o): return not self == o def __hash__(self): return hash((self.variable_reference, self.scope)) def __repr__(self): return '' def __str__(self): return '' def interrupt_main_thread(main_thread): ''' Generates a KeyboardInterrupt in the main thread by sending a Ctrl+C or by calling thread.interrupt_main(). :param main_thread: Needed because Jython needs main_thread._thread.interrupt() to be called. Note: if unable to send a Ctrl+C, the KeyboardInterrupt will only be raised when the next Python instruction is about to be executed (so, it won't interrupt a sleep(1000)). ''' pydev_log.debug('Interrupt main thread.') called = False try: if os.name == 'posix': # On Linux we can't interrupt 0 as in Windows because it's # actually owned by a process -- on the good side, signals # work much better on Linux! os.kill(os.getpid(), signal.SIGINT) called = True elif os.name == 'nt': # This generates a Ctrl+C only for the current process and not # to the process group! # Note: there doesn't seem to be any public documentation for this # function (although it seems to be present from Windows Server 2003 SP1 onwards # according to: https://www.geoffchappell.com/studies/windows/win32/kernel32/api/index.htm) ctypes.windll.kernel32.CtrlRoutine(0) # The code below is deprecated because it actually sends a Ctrl+C # to the process group, so, if this was a process created without # passing `CREATE_NEW_PROCESS_GROUP` the signal may be sent to the # parent process and to sub-processes too (which is not ideal -- # for instance, when using pytest-xdist, it'll actually stop the # testing, even when called in the subprocess). # if hasattr_checked(signal, 'CTRL_C_EVENT'): # os.kill(0, signal.CTRL_C_EVENT) # else: # # Python 2.6 # ctypes.windll.kernel32.GenerateConsoleCtrlEvent(0, 0) called = True except: # If something went wrong, fallback to interrupting when the next # Python instruction is being called. pydev_log.exception('Error interrupting main thread (using fallback).') if not called: try: # In this case, we don't really interrupt a sleep() nor IO operations # (this makes the KeyboardInterrupt be sent only when the next Python # instruction is about to be executed). if hasattr(thread, 'interrupt_main'): thread.interrupt_main() else: main_thread._thread.interrupt() # Jython except: pydev_log.exception('Error on interrupt main thread fallback.') class Timer(object): def __init__(self, min_diff=PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT): self.min_diff = min_diff self._curr_time = time.time() def print_time(self, msg='Elapsed:'): old = self._curr_time new = self._curr_time = time.time() diff = new - old if diff >= self.min_diff: print('%s: %.2fs' % (msg, diff)) def _report_slow(self, compute_msg, *args): old = self._curr_time new = self._curr_time = time.time() diff = new - old if diff >= self.min_diff: py_db = get_global_debugger() if py_db is not None: msg = compute_msg(diff, *args) py_db.writer.add_command(py_db.cmd_factory.make_warning_message(msg)) def report_if_compute_repr_attr_slow(self, attrs_tab_separated, attr_name, attr_type): self._report_slow(self._compute_repr_slow, attrs_tab_separated, attr_name, attr_type) def _compute_repr_slow(self, diff, attrs_tab_separated, attr_name, attr_type): try: attr_type = attr_type.__name__ except: pass if attrs_tab_separated: return 'pydevd warning: Computing repr of %s.%s (%s) was slow (took %.2fs)\n' % ( attrs_tab_separated.replace('\t', '.'), attr_name, attr_type, diff) else: return 'pydevd warning: Computing repr of %s (%s) was slow (took %.2fs)\n' % ( attr_name, attr_type, diff) def report_if_getting_attr_slow(self, cls, attr_name): self._report_slow(self._compute_get_attr_slow, cls, attr_name) def _compute_get_attr_slow(self, diff, cls, attr_name): try: cls = cls.__name__ except: pass return 'pydevd warning: Getting attribute %s.%s was slow (took %.2fs)\n' % (cls, attr_name, diff) def import_attr_from_module(import_with_attr_access): if '.' not in import_with_attr_access: # We need at least one '.' (we don't support just the module import, we need the attribute access too). raise ImportError('Unable to import module with attr access: %s' % (import_with_attr_access,)) module_name, attr_name = import_with_attr_access.rsplit('.', 1) while True: try: mod = import_module(module_name) except ImportError: if '.' not in module_name: raise ImportError('Unable to import module with attr access: %s' % (import_with_attr_access,)) module_name, new_attr_part = module_name.rsplit('.', 1) attr_name = new_attr_part + '.' + attr_name else: # Ok, we got the base module, now, get the attribute we need. try: for attr in attr_name.split('.'): mod = getattr(mod, attr) return mod except: raise ImportError('Unable to import module with attr access: %s' % (import_with_attr_access,))
17,289
Python
32.769531
111
0.583955
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py
""" pydevd_vars deals with variables: resolution/conversion to XML. """ import pickle from _pydevd_bundle.pydevd_constants import get_frame, get_current_thread_id, \ iter_chars, silence_warnings_decorator, get_global_debugger from _pydevd_bundle.pydevd_xml import ExceptionOnEvaluate, get_type, var_to_xml from _pydev_bundle import pydev_log import functools from _pydevd_bundle.pydevd_thread_lifecycle import resume_threads, mark_thread_suspended, suspend_all_threads from _pydevd_bundle.pydevd_comm_constants import CMD_SET_BREAK import sys # @Reimport from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle import pydevd_save_locals, pydevd_timeout, pydevd_constants from _pydev_bundle.pydev_imports import Exec, execfile from _pydevd_bundle.pydevd_utils import to_string import inspect from _pydevd_bundle.pydevd_daemon_thread import PyDBDaemonThread from _pydevd_bundle.pydevd_save_locals import update_globals_and_locals from functools import lru_cache SENTINEL_VALUE = [] class VariableError(RuntimeError): pass def iter_frames(frame): while frame is not None: yield frame frame = frame.f_back frame = None def dump_frames(thread_id): sys.stdout.write('dumping frames\n') if thread_id != get_current_thread_id(threading.current_thread()): raise VariableError("find_frame: must execute on same thread") frame = get_frame() for frame in iter_frames(frame): sys.stdout.write('%s\n' % pickle.dumps(frame)) @silence_warnings_decorator def getVariable(dbg, thread_id, frame_id, scope, attrs): """ returns the value of a variable :scope: can be BY_ID, EXPRESSION, GLOBAL, LOCAL, FRAME BY_ID means we'll traverse the list of all objects alive to get the object. :attrs: after reaching the proper scope, we have to get the attributes until we find the proper location (i.e.: obj\tattr1\tattr2) :note: when BY_ID is used, the frame_id is considered the id of the object to find and not the frame (as we don't care about the frame in this case). """ if scope == 'BY_ID': if thread_id != get_current_thread_id(threading.current_thread()): raise VariableError("getVariable: must execute on same thread") try: import gc objects = gc.get_objects() except: pass # Not all python variants have it. else: frame_id = int(frame_id) for var in objects: if id(var) == frame_id: if attrs is not None: attrList = attrs.split('\t') for k in attrList: _type, _type_name, resolver = get_type(var) var = resolver.resolve(var, k) return var # If it didn't return previously, we coudn't find it by id (i.e.: alrceady garbage collected). sys.stderr.write('Unable to find object with id: %s\n' % (frame_id,)) return None frame = dbg.find_frame(thread_id, frame_id) if frame is None: return {} if attrs is not None: attrList = attrs.split('\t') else: attrList = [] for attr in attrList: attr.replace("@_@TAB_CHAR@_@", '\t') if scope == 'EXPRESSION': for count in range(len(attrList)): if count == 0: # An Expression can be in any scope (globals/locals), therefore it needs to evaluated as an expression var = evaluate_expression(dbg, frame, attrList[count], False) else: _type, _type_name, resolver = get_type(var) var = resolver.resolve(var, attrList[count]) else: if scope == "GLOBAL": var = frame.f_globals del attrList[0] # globals are special, and they get a single dummy unused attribute else: # in a frame access both locals and globals as Python does var = {} var.update(frame.f_globals) var.update(frame.f_locals) for k in attrList: _type, _type_name, resolver = get_type(var) var = resolver.resolve(var, k) return var def resolve_compound_variable_fields(dbg, thread_id, frame_id, scope, attrs): """ Resolve compound variable in debugger scopes by its name and attributes :param thread_id: id of the variable's thread :param frame_id: id of the variable's frame :param scope: can be BY_ID, EXPRESSION, GLOBAL, LOCAL, FRAME :param attrs: after reaching the proper scope, we have to get the attributes until we find the proper location (i.e.: obj\tattr1\tattr2) :return: a dictionary of variables's fields """ var = getVariable(dbg, thread_id, frame_id, scope, attrs) try: _type, type_name, resolver = get_type(var) return type_name, resolver.get_dictionary(var) except: pydev_log.exception('Error evaluating: thread_id: %s\nframe_id: %s\nscope: %s\nattrs: %s.', thread_id, frame_id, scope, attrs) def resolve_var_object(var, attrs): """ Resolve variable's attribute :param var: an object of variable :param attrs: a sequence of variable's attributes separated by \t (i.e.: obj\tattr1\tattr2) :return: a value of resolved variable's attribute """ if attrs is not None: attr_list = attrs.split('\t') else: attr_list = [] for k in attr_list: type, _type_name, resolver = get_type(var) var = resolver.resolve(var, k) return var def resolve_compound_var_object_fields(var, attrs): """ Resolve compound variable by its object and attributes :param var: an object of variable :param attrs: a sequence of variable's attributes separated by \t (i.e.: obj\tattr1\tattr2) :return: a dictionary of variables's fields """ attr_list = attrs.split('\t') for k in attr_list: type, _type_name, resolver = get_type(var) var = resolver.resolve(var, k) try: type, _type_name, resolver = get_type(var) return resolver.get_dictionary(var) except: pydev_log.exception() def custom_operation(dbg, thread_id, frame_id, scope, attrs, style, code_or_file, operation_fn_name): """ We'll execute the code_or_file and then search in the namespace the operation_fn_name to execute with the given var. code_or_file: either some code (i.e.: from pprint import pprint) or a file to be executed. operation_fn_name: the name of the operation to execute after the exec (i.e.: pprint) """ expressionValue = getVariable(dbg, thread_id, frame_id, scope, attrs) try: namespace = {'__name__': '<custom_operation>'} if style == "EXECFILE": namespace['__file__'] = code_or_file execfile(code_or_file, namespace, namespace) else: # style == EXEC namespace['__file__'] = '<customOperationCode>' Exec(code_or_file, namespace, namespace) return str(namespace[operation_fn_name](expressionValue)) except: pydev_log.exception() @lru_cache(3) def _expression_to_evaluate(expression): keepends = True lines = expression.splitlines(keepends) # find first non-empty line chars_to_strip = 0 for line in lines: if line.strip(): # i.e.: check first non-empty line for c in iter_chars(line): if c.isspace(): chars_to_strip += 1 else: break break if chars_to_strip: # I.e.: check that the chars we'll remove are really only whitespaces. proceed = True new_lines = [] for line in lines: if not proceed: break for c in iter_chars(line[:chars_to_strip]): if not c.isspace(): proceed = False break new_lines.append(line[chars_to_strip:]) if proceed: if isinstance(expression, bytes): expression = b''.join(new_lines) else: expression = u''.join(new_lines) return expression def eval_in_context(expression, global_vars, local_vars, py_db=None): result = None try: compiled = compile_as_eval(expression) is_async = inspect.CO_COROUTINE & compiled.co_flags == inspect.CO_COROUTINE if is_async: if py_db is None: py_db = get_global_debugger() if py_db is None: raise RuntimeError('Cannot evaluate async without py_db.') t = _EvalAwaitInNewEventLoop(py_db, compiled, global_vars, local_vars) t.start() t.join() if t.exc: raise t.exc[1].with_traceback(t.exc[2]) else: result = t.evaluated_value else: result = eval(compiled, global_vars, local_vars) except (Exception, KeyboardInterrupt): etype, result, tb = sys.exc_info() result = ExceptionOnEvaluate(result, etype, tb) # Ok, we have the initial error message, but let's see if we're dealing with a name mangling error... try: if '.__' in expression: # Try to handle '__' name mangling (for simple cases such as self.__variable.__another_var). split = expression.split('.') entry = split[0] if local_vars is None: local_vars = global_vars curr = local_vars[entry] # Note: we want the KeyError if it's not there. for entry in split[1:]: if entry.startswith('__') and not hasattr(curr, entry): entry = '_%s%s' % (curr.__class__.__name__, entry) curr = getattr(curr, entry) result = curr except: pass return result def _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec): on_interrupt_threads = None timeout_tracker = py_db.timeout_tracker # : :type timeout_tracker: TimeoutTracker interrupt_thread_timeout = pydevd_constants.PYDEVD_INTERRUPT_THREAD_TIMEOUT if interrupt_thread_timeout > 0: on_interrupt_threads = pydevd_timeout.create_interrupt_this_thread_callback() pydev_log.info('Doing evaluate with interrupt threads timeout: %s.', interrupt_thread_timeout) if on_interrupt_threads is None: return original_func(py_db, frame, expression, is_exec) else: with timeout_tracker.call_on_timeout(interrupt_thread_timeout, on_interrupt_threads): return original_func(py_db, frame, expression, is_exec) def _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec): on_timeout_unblock_threads = None timeout_tracker = py_db.timeout_tracker # : :type timeout_tracker: TimeoutTracker if py_db.multi_threads_single_notification: unblock_threads_timeout = pydevd_constants.PYDEVD_UNBLOCK_THREADS_TIMEOUT else: unblock_threads_timeout = -1 # Don't use this if threads are managed individually. if unblock_threads_timeout >= 0: pydev_log.info('Doing evaluate with unblock threads timeout: %s.', unblock_threads_timeout) tid = get_current_thread_id(curr_thread) def on_timeout_unblock_threads(): on_timeout_unblock_threads.called = True pydev_log.info('Resuming threads after evaluate timeout.') resume_threads('*', except_thread=curr_thread) py_db.threads_suspended_single_notification.on_thread_resume(tid) on_timeout_unblock_threads.called = False try: if on_timeout_unblock_threads is None: return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec) else: with timeout_tracker.call_on_timeout(unblock_threads_timeout, on_timeout_unblock_threads): return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec) finally: if on_timeout_unblock_threads is not None and on_timeout_unblock_threads.called: mark_thread_suspended(curr_thread, CMD_SET_BREAK) py_db.threads_suspended_single_notification.increment_suspend_time() suspend_all_threads(py_db, except_thread=curr_thread) py_db.threads_suspended_single_notification.on_thread_suspend(tid, CMD_SET_BREAK) def _evaluate_with_timeouts(original_func): ''' Provides a decorator that wraps the original evaluate to deal with slow evaluates. If some evaluation is too slow, we may show a message, resume threads or interrupt them as needed (based on the related configurations). ''' @functools.wraps(original_func) def new_func(py_db, frame, expression, is_exec): if py_db is None: # Only for testing... pydev_log.critical('_evaluate_with_timeouts called without py_db!') return original_func(py_db, frame, expression, is_exec) warn_evaluation_timeout = pydevd_constants.PYDEVD_WARN_EVALUATION_TIMEOUT curr_thread = threading.current_thread() def on_warn_evaluation_timeout(): py_db.writer.add_command(py_db.cmd_factory.make_evaluation_timeout_msg( py_db, expression, curr_thread)) timeout_tracker = py_db.timeout_tracker # : :type timeout_tracker: TimeoutTracker with timeout_tracker.call_on_timeout(warn_evaluation_timeout, on_warn_evaluation_timeout): return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec) return new_func _ASYNC_COMPILE_FLAGS = None try: from ast import PyCF_ALLOW_TOP_LEVEL_AWAIT _ASYNC_COMPILE_FLAGS = PyCF_ALLOW_TOP_LEVEL_AWAIT except: pass def compile_as_eval(expression): ''' :param expression: The expression to be _compiled. :return: code object :raises Exception if the expression cannot be evaluated. ''' expression_to_evaluate = _expression_to_evaluate(expression) if _ASYNC_COMPILE_FLAGS is not None: return compile(expression_to_evaluate, '<string>', 'eval', _ASYNC_COMPILE_FLAGS) else: return compile(expression_to_evaluate, '<string>', 'eval') def _compile_as_exec(expression): ''' :param expression: The expression to be _compiled. :return: code object :raises Exception if the expression cannot be evaluated. ''' expression_to_evaluate = _expression_to_evaluate(expression) if _ASYNC_COMPILE_FLAGS is not None: return compile(expression_to_evaluate, '<string>', 'exec', _ASYNC_COMPILE_FLAGS) else: return compile(expression_to_evaluate, '<string>', 'exec') class _EvalAwaitInNewEventLoop(PyDBDaemonThread): def __init__(self, py_db, compiled, updated_globals, updated_locals): PyDBDaemonThread.__init__(self, py_db) self._compiled = compiled self._updated_globals = updated_globals self._updated_locals = updated_locals # Output self.evaluated_value = None self.exc = None async def _async_func(self): return await eval(self._compiled, self._updated_locals, self._updated_globals) def _on_run(self): try: import asyncio loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) self.evaluated_value = asyncio.run(self._async_func()) except: self.exc = sys.exc_info() @_evaluate_with_timeouts def evaluate_expression(py_db, frame, expression, is_exec): ''' :param str expression: The expression to be evaluated. Note that if the expression is indented it's automatically dedented (based on the indentation found on the first non-empty line). i.e.: something as: ` def method(): a = 1 ` becomes: ` def method(): a = 1 ` Also, it's possible to evaluate calls with a top-level await (currently this is done by creating a new event loop in a new thread and making the evaluate at that thread -- note that this is still done synchronously so the evaluation has to finish before this function returns). :param is_exec: determines if we should do an exec or an eval. There are some changes in this function depending on whether it's an exec or an eval. When it's an exec (i.e.: is_exec==True): This function returns None. Any exception that happens during the evaluation is reraised. If the expression could actually be evaluated, the variable is printed to the console if not None. When it's an eval (i.e.: is_exec==False): This function returns the result from the evaluation. If some exception happens in this case, the exception is caught and a ExceptionOnEvaluate is returned. Also, in this case we try to resolve name-mangling (i.e.: to be able to add a self.__my_var watch). :param py_db: The debugger. Only needed if some top-level await is detected (for creating a PyDBDaemonThread). ''' if frame is None: return # This is very tricky. Some statements can change locals and use them in the same # call (see https://github.com/microsoft/debugpy/issues/815), also, if locals and globals are # passed separately, it's possible that one gets updated but apparently Python will still # try to load from the other, so, what's done is that we merge all in a single dict and # then go on and update the frame with the results afterwards. # -- see tests in test_evaluate_expression.py # This doesn't work because the variables aren't updated in the locals in case the # evaluation tries to set a variable and use it in the same expression. # updated_globals = frame.f_globals # updated_locals = frame.f_locals # This doesn't work because the variables aren't updated in the locals in case the # evaluation tries to set a variable and use it in the same expression. # updated_globals = {} # updated_globals.update(frame.f_globals) # updated_globals.update(frame.f_locals) # # updated_locals = frame.f_locals # This doesn't work either in the case where the evaluation tries to set a variable and use # it in the same expression (I really don't know why as it seems like this *should* work # in theory but doesn't in practice). # updated_globals = {} # updated_globals.update(frame.f_globals) # # updated_locals = {} # updated_globals.update(frame.f_locals) # This is the only case that worked consistently to run the tests in test_evaluate_expression.py # It's a bit unfortunate because although the exec works in this case, we have to manually # put the updates in the frame locals afterwards. updated_globals = {} updated_globals.update(frame.f_globals) updated_globals.update(frame.f_locals) initial_globals = updated_globals.copy() updated_locals = None try: expression = expression.replace('@LINE@', '\n') if is_exec: try: # Try to make it an eval (if it is an eval we can print it, otherwise we'll exec it and # it will have whatever the user actually did) compiled = compile_as_eval(expression) except Exception: compiled = None if compiled is None: try: compiled = _compile_as_exec(expression) is_async = inspect.CO_COROUTINE & compiled.co_flags == inspect.CO_COROUTINE if is_async: t = _EvalAwaitInNewEventLoop(py_db, compiled, updated_globals, updated_locals) t.start() t.join() if t.exc: raise t.exc[1].with_traceback(t.exc[2]) else: Exec(compiled, updated_globals, updated_locals) finally: # Update the globals even if it errored as it may have partially worked. update_globals_and_locals(updated_globals, initial_globals, frame) else: is_async = inspect.CO_COROUTINE & compiled.co_flags == inspect.CO_COROUTINE if is_async: t = _EvalAwaitInNewEventLoop(py_db, compiled, updated_globals, updated_locals) t.start() t.join() if t.exc: raise t.exc[1].with_traceback(t.exc[2]) else: result = t.evaluated_value else: result = eval(compiled, updated_globals, updated_locals) if result is not None: # Only print if it's not None (as python does) sys.stdout.write('%s\n' % (result,)) return else: ret = eval_in_context(expression, updated_globals, updated_locals, py_db) try: is_exception_returned = ret.__class__ == ExceptionOnEvaluate except: pass else: if not is_exception_returned: # i.e.: by using a walrus assignment (:=), expressions can change the locals, # so, make sure that we save the locals back to the frame. update_globals_and_locals(updated_globals, initial_globals, frame) return ret finally: # Should not be kept alive if an exception happens and this frame is kept in the stack. del updated_globals del updated_locals del initial_globals del frame def change_attr_expression(frame, attr, expression, dbg, value=SENTINEL_VALUE): '''Changes some attribute in a given frame. ''' if frame is None: return try: expression = expression.replace('@LINE@', '\n') if dbg.plugin and value is SENTINEL_VALUE: result = dbg.plugin.change_variable(frame, attr, expression) if result: return result if attr[:7] == "Globals": attr = attr[8:] if attr in frame.f_globals: if value is SENTINEL_VALUE: value = eval(expression, frame.f_globals, frame.f_locals) frame.f_globals[attr] = value return frame.f_globals[attr] else: if '.' not in attr: # i.e.: if we have a '.', we're changing some attribute of a local var. if pydevd_save_locals.is_save_locals_available(): if value is SENTINEL_VALUE: value = eval(expression, frame.f_globals, frame.f_locals) frame.f_locals[attr] = value pydevd_save_locals.save_locals(frame) return frame.f_locals[attr] # i.e.: case with '.' or save locals not available (just exec the assignment in the frame). if value is SENTINEL_VALUE: value = eval(expression, frame.f_globals, frame.f_locals) result = value Exec('%s=%s' % (attr, expression), frame.f_globals, frame.f_locals) return result except Exception: pydev_log.exception() MAXIMUM_ARRAY_SIZE = 100 MAX_SLICE_SIZE = 1000 def table_like_struct_to_xml(array, name, roffset, coffset, rows, cols, format): _, type_name, _ = get_type(array) if type_name == 'ndarray': array, metaxml, r, c, f = array_to_meta_xml(array, name, format) xml = metaxml format = '%' + f if rows == -1 and cols == -1: rows = r cols = c xml += array_to_xml(array, roffset, coffset, rows, cols, format) elif type_name == 'DataFrame': xml = dataframe_to_xml(array, name, roffset, coffset, rows, cols, format) else: raise VariableError("Do not know how to convert type %s to table" % (type_name)) return "<xml>%s</xml>" % xml def array_to_xml(array, roffset, coffset, rows, cols, format): xml = "" rows = min(rows, MAXIMUM_ARRAY_SIZE) cols = min(cols, MAXIMUM_ARRAY_SIZE) # there is no obvious rule for slicing (at least 5 choices) if len(array) == 1 and (rows > 1 or cols > 1): array = array[0] if array.size > len(array): array = array[roffset:, coffset:] rows = min(rows, len(array)) cols = min(cols, len(array[0])) if len(array) == 1: array = array[0] elif array.size == len(array): if roffset == 0 and rows == 1: array = array[coffset:] cols = min(cols, len(array)) elif coffset == 0 and cols == 1: array = array[roffset:] rows = min(rows, len(array)) xml += "<arraydata rows=\"%s\" cols=\"%s\"/>" % (rows, cols) for row in range(rows): xml += "<row index=\"%s\"/>" % to_string(row) for col in range(cols): value = array if rows == 1 or cols == 1: if rows == 1 and cols == 1: value = array[0] else: if rows == 1: dim = col else: dim = row value = array[dim] if "ndarray" in str(type(value)): value = value[0] else: value = array[row][col] value = format % value xml += var_to_xml(value, '') return xml def array_to_meta_xml(array, name, format): type = array.dtype.kind slice = name l = len(array.shape) # initial load, compute slice if format == '%': if l > 2: slice += '[0]' * (l - 2) for r in range(l - 2): array = array[0] if type == 'f': format = '.5f' elif type == 'i' or type == 'u': format = 'd' else: format = 's' else: format = format.replace('%', '') l = len(array.shape) reslice = "" if l > 2: raise Exception("%s has more than 2 dimensions." % slice) elif l == 1: # special case with 1D arrays arr[i, :] - row, but arr[:, i] - column with equal shape and ndim # http://stackoverflow.com/questions/16837946/numpy-a-2-rows-1-column-file-loadtxt-returns-1row-2-columns # explanation: http://stackoverflow.com/questions/15165170/how-do-i-maintain-row-column-orientation-of-vectors-in-numpy?rq=1 # we use kind of a hack - get information about memory from C_CONTIGUOUS is_row = array.flags['C_CONTIGUOUS'] if is_row: rows = 1 cols = min(len(array), MAX_SLICE_SIZE) if cols < len(array): reslice = '[0:%s]' % (cols) array = array[0:cols] else: cols = 1 rows = min(len(array), MAX_SLICE_SIZE) if rows < len(array): reslice = '[0:%s]' % (rows) array = array[0:rows] elif l == 2: rows = min(array.shape[-2], MAX_SLICE_SIZE) cols = min(array.shape[-1], MAX_SLICE_SIZE) if cols < array.shape[-1] or rows < array.shape[-2]: reslice = '[0:%s, 0:%s]' % (rows, cols) array = array[0:rows, 0:cols] # avoid slice duplication if not slice.endswith(reslice): slice += reslice bounds = (0, 0) if type in "biufc": bounds = (array.min(), array.max()) xml = '<array slice=\"%s\" rows=\"%s\" cols=\"%s\" format=\"%s\" type=\"%s\" max=\"%s\" min=\"%s\"/>' % \ (slice, rows, cols, format, type, bounds[1], bounds[0]) return array, xml, rows, cols, format def dataframe_to_xml(df, name, roffset, coffset, rows, cols, format): """ :type df: pandas.core.frame.DataFrame :type name: str :type coffset: int :type roffset: int :type rows: int :type cols: int :type format: str """ num_rows = min(df.shape[0], MAX_SLICE_SIZE) num_cols = min(df.shape[1], MAX_SLICE_SIZE) if (num_rows, num_cols) != df.shape: df = df.iloc[0:num_rows, 0: num_cols] slice = '.iloc[0:%s, 0:%s]' % (num_rows, num_cols) else: slice = '' slice = name + slice xml = '<array slice=\"%s\" rows=\"%s\" cols=\"%s\" format=\"\" type=\"\" max=\"0\" min=\"0\"/>\n' % \ (slice, num_rows, num_cols) if (rows, cols) == (-1, -1): rows, cols = num_rows, num_cols rows = min(rows, MAXIMUM_ARRAY_SIZE) cols = min(min(cols, MAXIMUM_ARRAY_SIZE), num_cols) # need to precompute column bounds here before slicing! col_bounds = [None] * cols for col in range(cols): dtype = df.dtypes.iloc[coffset + col].kind if dtype in "biufc": cvalues = df.iloc[:, coffset + col] bounds = (cvalues.min(), cvalues.max()) else: bounds = (0, 0) col_bounds[col] = bounds df = df.iloc[roffset: roffset + rows, coffset: coffset + cols] rows, cols = df.shape xml += "<headerdata rows=\"%s\" cols=\"%s\">\n" % (rows, cols) format = format.replace('%', '') col_formats = [] get_label = lambda label: str(label) if not isinstance(label, tuple) else '/'.join(map(str, label)) for col in range(cols): dtype = df.dtypes.iloc[col].kind if dtype == 'f' and format: fmt = format elif dtype == 'f': fmt = '.5f' elif dtype == 'i' or dtype == 'u': fmt = 'd' else: fmt = 's' col_formats.append('%' + fmt) bounds = col_bounds[col] xml += '<colheader index=\"%s\" label=\"%s\" type=\"%s\" format=\"%s\" max=\"%s\" min=\"%s\" />\n' % \ (str(col), get_label(df.axes[1].values[col]), dtype, fmt, bounds[1], bounds[0]) for row, label in enumerate(iter(df.axes[0])): xml += "<rowheader index=\"%s\" label = \"%s\"/>\n" % \ (str(row), get_label(label)) xml += "</headerdata>\n" xml += "<arraydata rows=\"%s\" cols=\"%s\"/>\n" % (rows, cols) for row in range(rows): xml += "<row index=\"%s\"/>\n" % str(row) for col in range(cols): value = df.iat[row, col] value = col_formats[col] % value xml += var_to_xml(value, '') return xml
30,786
Python
35.65119
132
0.5878
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_defaults.py
''' This module holds the customization settings for the debugger. ''' from _pydevd_bundle.pydevd_constants import QUOTED_LINE_PROTOCOL class PydevdCustomization(object): DEFAULT_PROTOCOL = QUOTED_LINE_PROTOCOL
217
Python
23.22222
64
0.788018
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_signature.py
from _pydev_bundle import pydev_log try: import trace except ImportError: pass else: trace._warn = lambda *args: None # workaround for http://bugs.python.org/issue17143 (PY-8706) import os from _pydevd_bundle.pydevd_comm import CMD_SIGNATURE_CALL_TRACE, NetCommand from _pydevd_bundle import pydevd_xml from _pydevd_bundle.pydevd_utils import get_clsname_for_code class Signature(object): def __init__(self, file, name): self.file = file self.name = name self.args = [] self.args_str = [] self.return_type = None def add_arg(self, name, type): self.args.append((name, type)) self.args_str.append("%s:%s" % (name, type)) def set_args(self, frame, recursive=False): self.args = [] code = frame.f_code locals = frame.f_locals for i in range(0, code.co_argcount): name = code.co_varnames[i] class_name = get_type_of_value(locals[name], recursive=recursive) self.add_arg(name, class_name) def __str__(self): return "%s %s(%s)" % (self.file, self.name, ", ".join(self.args_str)) def get_type_of_value(value, ignore_module_name=('__main__', '__builtin__', 'builtins'), recursive=False): tp = type(value) class_name = tp.__name__ if class_name == 'instance': # old-style classes tp = value.__class__ class_name = tp.__name__ if hasattr(tp, '__module__') and tp.__module__ and tp.__module__ not in ignore_module_name: class_name = "%s.%s" % (tp.__module__, class_name) if class_name == 'list': class_name = 'List' if len(value) > 0 and recursive: class_name += '[%s]' % get_type_of_value(value[0], recursive=recursive) return class_name if class_name == 'dict': class_name = 'Dict' if len(value) > 0 and recursive: for (k, v) in value.items(): class_name += '[%s, %s]' % (get_type_of_value(k, recursive=recursive), get_type_of_value(v, recursive=recursive)) break return class_name if class_name == 'tuple': class_name = 'Tuple' if len(value) > 0 and recursive: class_name += '[' class_name += ', '.join(get_type_of_value(v, recursive=recursive) for v in value) class_name += ']' return class_name def _modname(path): """Return a plausible module name for the path""" base = os.path.basename(path) filename, ext = os.path.splitext(base) return filename class SignatureFactory(object): def __init__(self): self._caller_cache = {} self.cache = CallSignatureCache() def create_signature(self, frame, filename, with_args=True): try: _, modulename, funcname = self.file_module_function_of(frame) signature = Signature(filename, funcname) if with_args: signature.set_args(frame, recursive=True) return signature except: pydev_log.exception() def file_module_function_of(self, frame): # this code is take from trace module and fixed to work with new-style classes code = frame.f_code filename = code.co_filename if filename: modulename = _modname(filename) else: modulename = None funcname = code.co_name clsname = None if code in self._caller_cache: if self._caller_cache[code] is not None: clsname = self._caller_cache[code] else: self._caller_cache[code] = None clsname = get_clsname_for_code(code, frame) if clsname is not None: # cache the result - assumption is that new.* is # not called later to disturb this relationship # _caller_cache could be flushed if functions in # the new module get called. self._caller_cache[code] = clsname if clsname is not None: funcname = "%s.%s" % (clsname, funcname) return filename, modulename, funcname def get_signature_info(signature): return signature.file, signature.name, ' '.join([arg[1] for arg in signature.args]) def get_frame_info(frame): co = frame.f_code return co.co_name, frame.f_lineno, co.co_filename class CallSignatureCache(object): def __init__(self): self.cache = {} def add(self, signature): filename, name, args_type = get_signature_info(signature) calls_from_file = self.cache.setdefault(filename, {}) name_calls = calls_from_file.setdefault(name, {}) name_calls[args_type] = None def is_in_cache(self, signature): filename, name, args_type = get_signature_info(signature) if args_type in self.cache.get(filename, {}).get(name, {}): return True return False def create_signature_message(signature): cmdTextList = ["<xml>"] cmdTextList.append('<call_signature file="%s" name="%s">' % (pydevd_xml.make_valid_xml_value(signature.file), pydevd_xml.make_valid_xml_value(signature.name))) for arg in signature.args: cmdTextList.append('<arg name="%s" type="%s"></arg>' % (pydevd_xml.make_valid_xml_value(arg[0]), pydevd_xml.make_valid_xml_value(arg[1]))) if signature.return_type is not None: cmdTextList.append('<return type="%s"></return>' % (pydevd_xml.make_valid_xml_value(signature.return_type))) cmdTextList.append("</call_signature></xml>") cmdText = ''.join(cmdTextList) return NetCommand(CMD_SIGNATURE_CALL_TRACE, 0, cmdText) def send_signature_call_trace(dbg, frame, filename): if dbg.signature_factory and dbg.in_project_scope(frame): signature = dbg.signature_factory.create_signature(frame, filename) if signature is not None: if dbg.signature_factory.cache is not None: if not dbg.signature_factory.cache.is_in_cache(signature): dbg.signature_factory.cache.add(signature) dbg.writer.add_command(create_signature_message(signature)) return True else: # we don't send signature if it is cached return False else: dbg.writer.add_command(create_signature_message(signature)) return True return False def send_signature_return_trace(dbg, frame, filename, return_value): if dbg.signature_factory and dbg.in_project_scope(frame): signature = dbg.signature_factory.create_signature(frame, filename, with_args=False) signature.return_type = get_type_of_value(return_value, recursive=True) dbg.writer.add_command(create_signature_message(signature)) return True return False
6,883
Python
33.079208
163
0.599593
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_timeout.py
from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle.pydevd_daemon_thread import PyDBDaemonThread from _pydevd_bundle.pydevd_constants import thread_get_ident, IS_CPYTHON, NULL import ctypes import time from _pydev_bundle import pydev_log import weakref from _pydevd_bundle.pydevd_utils import is_current_thread_main_thread from _pydevd_bundle import pydevd_utils _DEBUG = False # Default should be False as this can be very verbose. class _TimeoutThread(PyDBDaemonThread): ''' The idea in this class is that it should be usually stopped waiting for the next event to be called (paused in a threading.Event.wait). When a new handle is added it sets the event so that it processes the handles and then keeps on waiting as needed again. This is done so that it's a bit more optimized than creating many Timer threads. ''' def __init__(self, py_db): PyDBDaemonThread.__init__(self, py_db) self._event = threading.Event() self._handles = [] # We could probably do things valid without this lock so that it's possible to add # handles while processing, but the implementation would also be harder to follow, # so, for now, we're either processing or adding handles, not both at the same time. self._lock = threading.Lock() def _on_run(self): wait_time = None while not self._kill_received: if _DEBUG: if wait_time is None: pydev_log.critical('pydevd_timeout: Wait until a new handle is added.') else: pydev_log.critical('pydevd_timeout: Next wait time: %s.', wait_time) self._event.wait(wait_time) if self._kill_received: self._handles = [] return wait_time = self.process_handles() def process_handles(self): ''' :return int: Returns the time we should be waiting for to process the next event properly. ''' with self._lock: if _DEBUG: pydev_log.critical('pydevd_timeout: Processing handles') self._event.clear() handles = self._handles new_handles = self._handles = [] # Do all the processing based on this time (we want to consider snapshots # of processing time -- anything not processed now may be processed at the # next snapshot). curtime = time.time() min_handle_timeout = None for handle in handles: if curtime < handle.abs_timeout and not handle.disposed: # It still didn't time out. if _DEBUG: pydev_log.critical('pydevd_timeout: Handle NOT processed: %s', handle) new_handles.append(handle) if min_handle_timeout is None: min_handle_timeout = handle.abs_timeout elif handle.abs_timeout < min_handle_timeout: min_handle_timeout = handle.abs_timeout else: if _DEBUG: pydev_log.critical('pydevd_timeout: Handle processed: %s', handle) # Timed out (or disposed), so, let's execute it (should be no-op if disposed). handle.exec_on_timeout() if min_handle_timeout is None: return None else: timeout = min_handle_timeout - curtime if timeout <= 0: pydev_log.critical('pydevd_timeout: Expected timeout to be > 0. Found: %s', timeout) return timeout def do_kill_pydev_thread(self): PyDBDaemonThread.do_kill_pydev_thread(self) with self._lock: self._event.set() def add_on_timeout_handle(self, handle): with self._lock: self._handles.append(handle) self._event.set() class _OnTimeoutHandle(object): def __init__(self, tracker, abs_timeout, on_timeout, kwargs): self._str = '_OnTimeoutHandle(%s)' % (on_timeout,) self._tracker = weakref.ref(tracker) self.abs_timeout = abs_timeout self.on_timeout = on_timeout if kwargs is None: kwargs = {} self.kwargs = kwargs self.disposed = False def exec_on_timeout(self): # Note: lock should already be obtained when executing this function. kwargs = self.kwargs on_timeout = self.on_timeout if not self.disposed: self.disposed = True self.kwargs = None self.on_timeout = None try: if _DEBUG: pydev_log.critical('pydevd_timeout: Calling on timeout: %s with kwargs: %s', on_timeout, kwargs) on_timeout(**kwargs) except Exception: pydev_log.exception('pydevd_timeout: Exception on callback timeout.') def __enter__(self): pass def __exit__(self, exc_type, exc_val, exc_tb): tracker = self._tracker() if tracker is None: lock = NULL else: lock = tracker._lock with lock: self.disposed = True self.kwargs = None self.on_timeout = None def __str__(self): return self._str __repr__ = __str__ class TimeoutTracker(object): ''' This is a helper class to track the timeout of something. ''' def __init__(self, py_db): self._thread = None self._lock = threading.Lock() self._py_db = weakref.ref(py_db) def call_on_timeout(self, timeout, on_timeout, kwargs=None): ''' This can be called regularly to always execute the given function after a given timeout: call_on_timeout(py_db, 10, on_timeout) Or as a context manager to stop the method from being called if it finishes before the timeout elapses: with call_on_timeout(py_db, 10, on_timeout): ... Note: the callback will be called from a PyDBDaemonThread. ''' with self._lock: if self._thread is None: if _DEBUG: pydev_log.critical('pydevd_timeout: Created _TimeoutThread.') self._thread = _TimeoutThread(self._py_db()) self._thread.start() curtime = time.time() handle = _OnTimeoutHandle(self, curtime + timeout, on_timeout, kwargs) if _DEBUG: pydev_log.critical('pydevd_timeout: Added handle: %s.', handle) self._thread.add_on_timeout_handle(handle) return handle def create_interrupt_this_thread_callback(): ''' The idea here is returning a callback that when called will generate a KeyboardInterrupt in the thread that called this function. If this is the main thread, this means that it'll emulate a Ctrl+C (which may stop I/O and sleep operations). For other threads, this will call PyThreadState_SetAsyncExc to raise a KeyboardInterrupt before the next instruction (so, it won't really interrupt I/O or sleep operations). :return callable: Returns a callback that will interrupt the current thread (this may be called from an auxiliary thread). ''' tid = thread_get_ident() if is_current_thread_main_thread(): main_thread = threading.current_thread() def raise_on_this_thread(): pydev_log.debug('Callback to interrupt main thread.') pydevd_utils.interrupt_main_thread(main_thread) else: # Note: this works in the sense that it can stop some cpu-intensive slow operation, # but we can't really interrupt the thread out of some sleep or I/O operation # (this will only be raised when Python is about to execute the next instruction). def raise_on_this_thread(): if IS_CPYTHON: pydev_log.debug('Interrupt thread: %s', tid) ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(KeyboardInterrupt)) else: pydev_log.debug('It is only possible to interrupt non-main threads in CPython.') return raise_on_this_thread
8,366
Python
33.8625
116
0.590485
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_plugin_utils.py
import types from _pydev_bundle import pydev_log from _pydevd_bundle import pydevd_trace_api try: from pydevd_plugins import django_debug except: django_debug = None pydev_log.debug('Unable to load django_debug plugin') try: from pydevd_plugins import jinja2_debug except: jinja2_debug = None pydev_log.debug('Unable to load jinja2_debug plugin') def load_plugins(): plugins = [] if django_debug is not None: plugins.append(django_debug) if jinja2_debug is not None: plugins.append(jinja2_debug) return plugins def bind_func_to_method(func, obj, method_name): bound_method = types.MethodType(func, obj) setattr(obj, method_name, bound_method) return bound_method class PluginManager(object): def __init__(self, main_debugger): self.plugins = load_plugins() self.active_plugins = [] self.main_debugger = main_debugger self.rebind_methods() def add_breakpoint(self, func_name, *args, **kwargs): # add breakpoint for plugin and remember which plugin to use in tracing for plugin in self.plugins: if hasattr(plugin, func_name): func = getattr(plugin, func_name) result = func(self, *args, **kwargs) if result: self.activate(plugin) return result return None def activate(self, plugin): if plugin not in self.active_plugins: self.active_plugins.append(plugin) self.rebind_methods() def rebind_methods(self): if len(self.active_plugins) == 0: self.bind_functions(pydevd_trace_api, getattr, pydevd_trace_api) elif len(self.active_plugins) == 1: self.bind_functions(pydevd_trace_api, getattr, self.active_plugins[0]) else: self.bind_functions(pydevd_trace_api, create_dispatch, self.active_plugins) def bind_functions(self, interface, function_factory, arg): for name in dir(interface): func = function_factory(arg, name) if type(func) == types.FunctionType: bind_func_to_method(func, self, name) def create_dispatch(obj, name): def dispatch(self, *args, **kwargs): result = None for p in self.active_plugins: r = getattr(p, name)(self, *args, **kwargs) if not result: result = r return result return dispatch
2,484
Python
26.010869
87
0.615539
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_extension_utils.py
import pkgutil import sys from _pydev_bundle import pydev_log try: import pydevd_plugins.extensions as extensions except: pydev_log.exception() extensions = None class ExtensionManager(object): def __init__(self): self.loaded_extensions = None self.type_to_instance = {} def _load_modules(self): self.loaded_extensions = [] if extensions: for module_loader, name, ispkg in pkgutil.walk_packages(extensions.__path__, extensions.__name__ + '.'): mod_name = name.split('.')[-1] if not ispkg and mod_name.startswith('pydevd_plugin'): try: __import__(name) module = sys.modules[name] self.loaded_extensions.append(module) except ImportError: pydev_log.critical('Unable to load extension: %s', name) def _ensure_loaded(self): if self.loaded_extensions is None: self._load_modules() def _iter_attr(self): for extension in self.loaded_extensions: dunder_all = getattr(extension, '__all__', None) for attr_name in dir(extension): if not attr_name.startswith('_'): if dunder_all is None or attr_name in dunder_all: yield attr_name, getattr(extension, attr_name) def get_extension_classes(self, extension_type): self._ensure_loaded() if extension_type in self.type_to_instance: return self.type_to_instance[extension_type] handlers = self.type_to_instance.setdefault(extension_type, []) for attr_name, attr in self._iter_attr(): if isinstance(attr, type) and issubclass(attr, extension_type) and attr is not extension_type: try: handlers.append(attr()) except: pydev_log.exception('Unable to load extension class: %s', attr_name) return handlers EXTENSION_MANAGER_INSTANCE = ExtensionManager() def extensions_of_type(extension_type): """ :param T extension_type: The type of the extension hook :rtype: list[T] """ return EXTENSION_MANAGER_INSTANCE.get_extension_classes(extension_type)
2,369
Python
33.852941
106
0.56775
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_command_line_handling.py
import os class ArgHandlerWithParam: ''' Handler for some arguments which needs a value ''' def __init__(self, arg_name, convert_val=None, default_val=None): self.arg_name = arg_name self.arg_v_rep = '--%s' % (arg_name,) self.convert_val = convert_val self.default_val = default_val def to_argv(self, lst, setup): v = setup.get(self.arg_name) if v is not None and v != self.default_val: lst.append(self.arg_v_rep) lst.append('%s' % (v,)) def handle_argv(self, argv, i, setup): assert argv[i] == self.arg_v_rep del argv[i] val = argv[i] if self.convert_val: val = self.convert_val(val) setup[self.arg_name] = val del argv[i] class ArgHandlerBool: ''' If a given flag is received, mark it as 'True' in setup. ''' def __init__(self, arg_name, default_val=False): self.arg_name = arg_name self.arg_v_rep = '--%s' % (arg_name,) self.default_val = default_val def to_argv(self, lst, setup): v = setup.get(self.arg_name) if v: lst.append(self.arg_v_rep) def handle_argv(self, argv, i, setup): assert argv[i] == self.arg_v_rep del argv[i] setup[self.arg_name] = True def convert_ppid(ppid): ret = int(ppid) if ret != 0: if ret == os.getpid(): raise AssertionError( 'ppid passed is the same as the current process pid (%s)!' % (ret,)) return ret ACCEPTED_ARG_HANDLERS = [ ArgHandlerWithParam('port', int, 0), ArgHandlerWithParam('ppid', convert_ppid, 0), ArgHandlerWithParam('vm_type'), ArgHandlerWithParam('client'), ArgHandlerWithParam('access-token'), ArgHandlerWithParam('client-access-token'), ArgHandlerBool('server'), ArgHandlerBool('DEBUG_RECORD_SOCKET_READS'), ArgHandlerBool('multiproc'), # Used by PyCharm (reuses connection: ssh tunneling) ArgHandlerBool('multiprocess'), # Used by PyDev (creates new connection to ide) ArgHandlerBool('save-signatures'), ArgHandlerBool('save-threading'), ArgHandlerBool('save-asyncio'), ArgHandlerBool('print-in-debugger-startup'), ArgHandlerBool('cmd-line'), ArgHandlerBool('module'), ArgHandlerBool('skip-notify-stdin'), # The ones below should've been just one setting to specify the protocol, but for compatibility # reasons they're passed as a flag but are mutually exclusive. ArgHandlerBool('json-dap'), # Protocol used by ptvsd to communicate with pydevd (a single json message in each read) ArgHandlerBool('json-dap-http'), # Actual DAP (json messages over http protocol). ArgHandlerBool('protocol-quoted-line'), # Custom protocol with quoted lines. ArgHandlerBool('protocol-http'), # Custom protocol with http. ] ARGV_REP_TO_HANDLER = {} for handler in ACCEPTED_ARG_HANDLERS: ARGV_REP_TO_HANDLER[handler.arg_v_rep] = handler def get_pydevd_file(): import pydevd f = pydevd.__file__ if f.endswith('.pyc'): f = f[:-1] elif f.endswith('$py.class'): f = f[:-len('$py.class')] + '.py' return f def setup_to_argv(setup, skip_names=None): ''' :param dict setup: A dict previously gotten from process_command_line. :param set skip_names: The names in the setup which shouldn't be converted to argv. :note: does not handle --file nor --DEBUG. ''' if skip_names is None: skip_names = set() ret = [get_pydevd_file()] for handler in ACCEPTED_ARG_HANDLERS: if handler.arg_name in setup and handler.arg_name not in skip_names: handler.to_argv(ret, setup) return ret def process_command_line(argv): """ parses the arguments. removes our arguments from the command line """ setup = {} for handler in ACCEPTED_ARG_HANDLERS: setup[handler.arg_name] = handler.default_val setup['file'] = '' setup['qt-support'] = '' i = 0 del argv[0] while i < len(argv): handler = ARGV_REP_TO_HANDLER.get(argv[i]) if handler is not None: handler.handle_argv(argv, i, setup) elif argv[i].startswith('--qt-support'): # The --qt-support is special because we want to keep backward compatibility: # Previously, just passing '--qt-support' meant that we should use the auto-discovery mode # whereas now, if --qt-support is passed, it should be passed as --qt-support=<mode>, where # mode can be one of 'auto', 'none', 'pyqt5', 'pyqt4', 'pyside', 'pyside2'. if argv[i] == '--qt-support': setup['qt-support'] = 'auto' elif argv[i].startswith('--qt-support='): qt_support = argv[i][len('--qt-support='):] valid_modes = ('none', 'auto', 'pyqt5', 'pyqt4', 'pyside', 'pyside2') if qt_support not in valid_modes: raise ValueError("qt-support mode invalid: " + qt_support) if qt_support == 'none': # On none, actually set an empty string to evaluate to False. setup['qt-support'] = '' else: setup['qt-support'] = qt_support else: raise ValueError("Unexpected definition for qt-support flag: " + argv[i]) del argv[i] elif argv[i] == '--file': # --file is special because it's the last one (so, no handler for it). del argv[i] setup['file'] = argv[i] i = len(argv) # pop out, file is our last argument elif argv[i] == '--DEBUG': from pydevd import set_debug del argv[i] set_debug(setup) else: raise ValueError("Unexpected option: " + argv[i]) return setup
5,906
Python
32
121
0.586861
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_traceproperty.py
'''For debug purpose we are replacing actual builtin property by the debug property ''' from _pydevd_bundle.pydevd_comm import get_global_debugger from _pydev_bundle import pydev_log #======================================================================================================================= # replace_builtin_property #======================================================================================================================= def replace_builtin_property(new_property=None): if new_property is None: new_property = DebugProperty original = property try: import builtins builtins.__dict__['property'] = new_property except: pydev_log.exception() # @Reimport return original #======================================================================================================================= # DebugProperty #======================================================================================================================= class DebugProperty(object): """A custom property which allows python property to get controlled by the debugger and selectively disable/re-enable the tracing. """ def __init__(self, fget=None, fset=None, fdel=None, doc=None): self.fget = fget self.fset = fset self.fdel = fdel self.__doc__ = doc def __get__(self, obj, objtype=None): if obj is None: return self global_debugger = get_global_debugger() try: if global_debugger is not None and global_debugger.disable_property_getter_trace: global_debugger.disable_tracing() if self.fget is None: raise AttributeError("unreadable attribute") return self.fget(obj) finally: if global_debugger is not None: global_debugger.enable_tracing() def __set__(self, obj, value): global_debugger = get_global_debugger() try: if global_debugger is not None and global_debugger.disable_property_setter_trace: global_debugger.disable_tracing() if self.fset is None: raise AttributeError("can't set attribute") self.fset(obj, value) finally: if global_debugger is not None: global_debugger.enable_tracing() def __delete__(self, obj): global_debugger = get_global_debugger() try: if global_debugger is not None and global_debugger.disable_property_deleter_trace: global_debugger.disable_tracing() if self.fdel is None: raise AttributeError("can't delete attribute") self.fdel(obj) finally: if global_debugger is not None: global_debugger.enable_tracing() def getter(self, fget): """Overriding getter decorator for the property """ self.fget = fget return self def setter(self, fset): """Overriding setter decorator for the property """ self.fset = fset return self def deleter(self, fdel): """Overriding deleter decorator for the property """ self.fdel = fdel return self
3,279
Python
34.268817
120
0.511741
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command.py
from _pydevd_bundle.pydevd_constants import DebugInfoHolder, \ get_global_debugger, GetGlobalDebugger, set_global_debugger # Keep for backward compatibility @UnusedImport from _pydevd_bundle.pydevd_utils import quote_smart as quote, to_string from _pydevd_bundle.pydevd_comm_constants import ID_TO_MEANING, CMD_EXIT from _pydevd_bundle.pydevd_constants import HTTP_PROTOCOL, HTTP_JSON_PROTOCOL, \ get_protocol, IS_JYTHON, ForkSafeLock import json from _pydev_bundle import pydev_log class _BaseNetCommand(object): # Command id. Should be set in instance. id = -1 # Dict representation of the command to be set in instance. Only set for json commands. as_dict = None def send(self, *args, **kwargs): pass def call_after_send(self, callback): pass class _NullNetCommand(_BaseNetCommand): pass class _NullExitCommand(_NullNetCommand): id = CMD_EXIT # Constant meant to be passed to the writer when the command is meant to be ignored. NULL_NET_COMMAND = _NullNetCommand() # Exit command -- only internal (we don't want/need to send this to the IDE). NULL_EXIT_COMMAND = _NullExitCommand() class NetCommand(_BaseNetCommand): """ Commands received/sent over the network. Command can represent command received from the debugger, or one to be sent by daemon. """ next_seq = 0 # sequence numbers _showing_debug_info = 0 _show_debug_info_lock = ForkSafeLock(rlock=True) _after_send = None def __init__(self, cmd_id, seq, text, is_json=False): """ If sequence is 0, new sequence will be generated (otherwise, this was the response to a command from the client). """ protocol = get_protocol() self.id = cmd_id if seq == 0: NetCommand.next_seq += 2 seq = NetCommand.next_seq self.seq = seq if is_json: if hasattr(text, 'to_dict'): as_dict = text.to_dict(update_ids_to_dap=True) else: assert isinstance(text, dict) as_dict = text as_dict['pydevd_cmd_id'] = cmd_id as_dict['seq'] = seq self.as_dict = as_dict text = json.dumps(as_dict) assert isinstance(text, str) if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1: self._show_debug_info(cmd_id, seq, text) if is_json: msg = text else: if protocol not in (HTTP_PROTOCOL, HTTP_JSON_PROTOCOL): encoded = quote(to_string(text), '/<>_=" \t') msg = '%s\t%s\t%s\n' % (cmd_id, seq, encoded) else: msg = '%s\t%s\t%s' % (cmd_id, seq, text) if isinstance(msg, str): msg = msg.encode('utf-8') assert isinstance(msg, bytes) as_bytes = msg self._as_bytes = as_bytes def send(self, sock): as_bytes = self._as_bytes try: if get_protocol() in (HTTP_PROTOCOL, HTTP_JSON_PROTOCOL): sock.sendall(('Content-Length: %s\r\n\r\n' % len(as_bytes)).encode('ascii')) sock.sendall(as_bytes) if self._after_send: for method in self._after_send: method(sock) except: if IS_JYTHON: # Ignore errors in sock.sendall in Jython (seems to be common for Jython to # give spurious exceptions at interpreter shutdown here). pass else: raise def call_after_send(self, callback): if not self._after_send: self._after_send = [callback] else: self._after_send.append(callback) @classmethod def _show_debug_info(cls, cmd_id, seq, text): with cls._show_debug_info_lock: # Only one thread each time (rlock). if cls._showing_debug_info: # avoid recursing in the same thread (just printing could create # a new command when redirecting output). return cls._showing_debug_info += 1 try: out_message = 'sending cmd (%s) --> ' % (get_protocol(),) out_message += "%20s" % ID_TO_MEANING.get(str(cmd_id), 'UNKNOWN') out_message += ' ' out_message += text.replace('\n', ' ') try: pydev_log.critical('%s\n', out_message) except: pass finally: cls._showing_debug_info -= 1
4,588
Python
30.217687
112
0.562772
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_exec2.py
def Exec(exp, global_vars, local_vars=None): if local_vars is not None: exec(exp, global_vars, local_vars) else: exec(exp, global_vars)
159
Python
30.999994
44
0.628931
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_xml.py
from _pydev_bundle import pydev_log from _pydevd_bundle import pydevd_extension_utils from _pydevd_bundle import pydevd_resolver import sys from _pydevd_bundle.pydevd_constants import BUILTINS_MODULE_NAME, MAXIMUM_VARIABLE_REPRESENTATION_SIZE, \ RETURN_VALUES_DICT, LOAD_VALUES_ASYNC, DEFAULT_VALUE from _pydev_bundle.pydev_imports import quote from _pydevd_bundle.pydevd_extension_api import TypeResolveProvider, StrPresentationProvider from _pydevd_bundle.pydevd_utils import isinstance_checked, hasattr_checked, DAPGrouper from _pydevd_bundle.pydevd_resolver import get_var_scope try: import types frame_type = types.FrameType except: frame_type = None def make_valid_xml_value(s): # Same thing as xml.sax.saxutils.escape but also escaping double quotes. return s.replace("&", "&amp;").replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;') class ExceptionOnEvaluate: def __init__(self, result, etype, tb): self.result = result self.etype = etype self.tb = tb _IS_JYTHON = sys.platform.startswith("java") def _create_default_type_map(): default_type_map = [ # None means that it should not be treated as a compound variable # isintance does not accept a tuple on some versions of python, so, we must declare it expanded (type(None), None,), (int, None), (float, None), (complex, None), (str, None), (tuple, pydevd_resolver.tupleResolver), (list, pydevd_resolver.tupleResolver), (dict, pydevd_resolver.dictResolver), ] try: from collections import OrderedDict default_type_map.insert(0, (OrderedDict, pydevd_resolver.orderedDictResolver)) # we should put it before dict except: pass try: default_type_map.append((long, None)) # @UndefinedVariable except: pass # not available on all python versions default_type_map.append((DAPGrouper, pydevd_resolver.dapGrouperResolver)) try: default_type_map.append((set, pydevd_resolver.setResolver)) except: pass # not available on all python versions try: default_type_map.append((frozenset, pydevd_resolver.setResolver)) except: pass # not available on all python versions try: from django.utils.datastructures import MultiValueDict default_type_map.insert(0, (MultiValueDict, pydevd_resolver.multiValueDictResolver)) # we should put it before dict except: pass # django may not be installed try: from django.forms import BaseForm default_type_map.insert(0, (BaseForm, pydevd_resolver.djangoFormResolver)) # we should put it before instance resolver except: pass # django may not be installed try: from collections import deque default_type_map.append((deque, pydevd_resolver.dequeResolver)) except: pass if frame_type is not None: default_type_map.append((frame_type, pydevd_resolver.frameResolver)) if _IS_JYTHON: from org.python import core # @UnresolvedImport default_type_map.append((core.PyNone, None)) default_type_map.append((core.PyInteger, None)) default_type_map.append((core.PyLong, None)) default_type_map.append((core.PyFloat, None)) default_type_map.append((core.PyComplex, None)) default_type_map.append((core.PyString, None)) default_type_map.append((core.PyTuple, pydevd_resolver.tupleResolver)) default_type_map.append((core.PyList, pydevd_resolver.tupleResolver)) default_type_map.append((core.PyDictionary, pydevd_resolver.dictResolver)) default_type_map.append((core.PyStringMap, pydevd_resolver.dictResolver)) if hasattr(core, 'PyJavaInstance'): # Jython 2.5b3 removed it. default_type_map.append((core.PyJavaInstance, pydevd_resolver.instanceResolver)) return default_type_map class TypeResolveHandler(object): NO_PROVIDER = [] # Sentinel value (any mutable object to be used as a constant would be valid). def __init__(self): # Note: don't initialize with the types we already know about so that the extensions can override # the default resolvers that are already available if they want. self._type_to_resolver_cache = {} self._type_to_str_provider_cache = {} self._initialized = False def _initialize(self): self._default_type_map = _create_default_type_map() self._resolve_providers = pydevd_extension_utils.extensions_of_type(TypeResolveProvider) self._str_providers = pydevd_extension_utils.extensions_of_type(StrPresentationProvider) self._initialized = True def get_type(self, o): try: try: # Faster than type(o) as we don't need the function call. type_object = o.__class__ # could fail here type_name = type_object.__name__ return self._get_type(o, type_object, type_name) # could fail here except: # Not all objects have __class__ (i.e.: there are bad bindings around). type_object = type(o) type_name = type_object.__name__ try: return self._get_type(o, type_object, type_name) except: if isinstance(type_object, type): # If it's still something manageable, use the default resolver, otherwise # fallback to saying that it wasn't possible to get any info on it. return type_object, str(type_name), pydevd_resolver.defaultResolver return 'Unable to get Type', 'Unable to get Type', None except: # This happens for org.python.core.InitModule return 'Unable to get Type', 'Unable to get Type', None def _get_type(self, o, type_object, type_name): # Note: we could have an exception here if the type_object is not hashable... resolver = self._type_to_resolver_cache.get(type_object) if resolver is not None: return type_object, type_name, resolver if not self._initialized: self._initialize() try: for resolver in self._resolve_providers: if resolver.can_provide(type_object, type_name): # Cache it self._type_to_resolver_cache[type_object] = resolver return type_object, type_name, resolver for t in self._default_type_map: if isinstance_checked(o, t[0]): # Cache it resolver = t[1] self._type_to_resolver_cache[type_object] = resolver return (type_object, type_name, resolver) except: pydev_log.exception() # No match return default (and cache it). resolver = pydevd_resolver.defaultResolver self._type_to_resolver_cache[type_object] = resolver return type_object, type_name, resolver if _IS_JYTHON: _base_get_type = _get_type def _get_type(self, o, type_object, type_name): if type_name == 'org.python.core.PyJavaInstance': return type_object, type_name, pydevd_resolver.instanceResolver if type_name == 'org.python.core.PyArray': return type_object, type_name, pydevd_resolver.jyArrayResolver return self._base_get_type(o, type_object, type_name) def str_from_providers(self, o, type_object, type_name): provider = self._type_to_str_provider_cache.get(type_object) if provider is self.NO_PROVIDER: return None if provider is not None: return provider.get_str(o) if not self._initialized: self._initialize() for provider in self._str_providers: if provider.can_provide(type_object, type_name): self._type_to_str_provider_cache[type_object] = provider try: return provider.get_str(o) except: pydev_log.exception("Error when getting str with custom provider: %s." % (provider,)) self._type_to_str_provider_cache[type_object] = self.NO_PROVIDER return None _TYPE_RESOLVE_HANDLER = TypeResolveHandler() """ def get_type(o): Receives object and returns a triple (type_object, type_string, resolver). resolver != None means that variable is a container, and should be displayed as a hierarchy. Use the resolver to get its attributes. All container objects (i.e.: dict, list, tuple, object, etc) should have a resolver. """ get_type = _TYPE_RESOLVE_HANDLER.get_type _str_from_providers = _TYPE_RESOLVE_HANDLER.str_from_providers def is_builtin(x): return getattr(x, '__module__', None) == BUILTINS_MODULE_NAME def should_evaluate_full_value(val): return not LOAD_VALUES_ASYNC or (is_builtin(type(val)) and not isinstance_checked(val, (list, tuple, dict))) def return_values_from_dict_to_xml(return_dict): res = [] for name, val in return_dict.items(): res.append(var_to_xml(val, name, additional_in_xml=' isRetVal="True"')) return ''.join(res) def frame_vars_to_xml(frame_f_locals, hidden_ns=None): """ dumps frame variables to XML <var name="var_name" scope="local" type="type" value="value"/> """ xml = [] keys = sorted(frame_f_locals) return_values_xml = [] for k in keys: try: v = frame_f_locals[k] eval_full_val = should_evaluate_full_value(v) if k == '_pydev_stop_at_break': continue if k == RETURN_VALUES_DICT: for name, val in v.items(): return_values_xml.append(var_to_xml(val, name, additional_in_xml=' isRetVal="True"')) else: if hidden_ns is not None and k in hidden_ns: xml.append(var_to_xml(v, str(k), additional_in_xml=' isIPythonHidden="True"', evaluate_full_value=eval_full_val)) else: xml.append(var_to_xml(v, str(k), evaluate_full_value=eval_full_val)) except Exception: pydev_log.exception("Unexpected error, recovered safely.") # Show return values as the first entry. return_values_xml.extend(xml) return ''.join(return_values_xml) def get_variable_details(val, evaluate_full_value=True, to_string=None): try: # This should be faster than isinstance (but we have to protect against not having a '__class__' attribute). is_exception_on_eval = val.__class__ == ExceptionOnEvaluate except: is_exception_on_eval = False if is_exception_on_eval: v = val.result else: v = val _type, type_name, resolver = get_type(v) type_qualifier = getattr(_type, "__module__", "") if not evaluate_full_value: value = DEFAULT_VALUE else: try: str_from_provider = _str_from_providers(v, _type, type_name) if str_from_provider is not None: value = str_from_provider elif to_string is not None: value = to_string(v) elif hasattr_checked(v, '__class__'): if v.__class__ == frame_type: value = pydevd_resolver.frameResolver.get_frame_name(v) elif v.__class__ in (list, tuple): if len(v) > 300: value = '%s: %s' % (str(v.__class__), '<Too big to print. Len: %s>' % (len(v),)) else: value = '%s: %s' % (str(v.__class__), v) else: try: cName = str(v.__class__) if cName.find('.') != -1: cName = cName.split('.')[-1] elif cName.find("'") != -1: # does not have '.' (could be something like <type 'int'>) cName = cName[cName.index("'") + 1:] if cName.endswith("'>"): cName = cName[:-2] except: cName = str(v.__class__) value = '%s: %s' % (cName, v) else: value = str(v) except: try: value = repr(v) except: value = 'Unable to get repr for %s' % v.__class__ # fix to work with unicode values try: if value.__class__ == bytes: value = value.decode('utf-8', 'replace') except TypeError: pass return type_name, type_qualifier, is_exception_on_eval, resolver, value def var_to_xml(val, name, trim_if_too_big=True, additional_in_xml='', evaluate_full_value=True): """ single variable or dictionary to xml representation """ type_name, type_qualifier, is_exception_on_eval, resolver, value = get_variable_details( val, evaluate_full_value) scope = get_var_scope(name, val, '', True) try: name = quote(name, '/>_= ') # TODO: Fix PY-5834 without using quote except: pass xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name), make_valid_xml_value(type_name)) if type_qualifier: xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier) else: xml_qualifier = '' if value: # cannot be too big... communication may not handle it. if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and trim_if_too_big: value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE] value += '...' xml_value = ' value="%s"' % (make_valid_xml_value(quote(value, '/>_= '))) else: xml_value = '' if is_exception_on_eval: xml_container = ' isErrorOnEval="True"' else: if resolver is not None: xml_container = ' isContainer="True"' else: xml_container = '' if scope: return ''.join((xml, xml_qualifier, xml_value, xml_container, additional_in_xml, ' scope="', scope, '"', ' />\n')) else: return ''.join((xml, xml_qualifier, xml_value, xml_container, additional_in_xml, ' />\n'))
14,443
Python
35.11
122
0.589767
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py
""" Vendored copy of runpy from the standard library. It's vendored so that we can properly ignore it when used to start user code while still making it possible for the user to debug runpy itself. runpy.py - locating and running Python code using the module namespace Provides support for locating and running Python scripts using the Python module namespace instead of the native filesystem. This allows Python code to play nicely with non-filesystem based PEP 302 importers when locating support scripts as well as when importing modules. """ # Written by Nick Coghlan <ncoghlan at gmail.com> # to implement PEP 338 (Executing Modules as Scripts) import sys import importlib.machinery # importlib first so we can test #15386 via -m import importlib.util import io import types import os __all__ = [ "run_module", "run_path", ] # Note: fabioz: Don't use pkgutil (when handling caught exceptions we could end up # showing exceptions in pkgutil.get_imported (specifically the KeyError), so, # create a copy of the function we need to properly ignore this exception when # running the program. def pkgutil_get_importer(path_item): """Retrieve a finder for the given path item The returned finder is cached in sys.path_importer_cache if it was newly created by a path hook. The cache (or part of it) can be cleared manually if a rescan of sys.path_hooks is necessary. """ try: importer = sys.path_importer_cache[path_item] except KeyError: for path_hook in sys.path_hooks: try: importer = path_hook(path_item) sys.path_importer_cache.setdefault(path_item, importer) break except ImportError: pass else: importer = None return importer class _TempModule(object): """Temporarily replace a module in sys.modules with an empty namespace""" def __init__(self, mod_name): self.mod_name = mod_name self.module = types.ModuleType(mod_name) self._saved_module = [] def __enter__(self): mod_name = self.mod_name try: self._saved_module.append(sys.modules[mod_name]) except KeyError: pass sys.modules[mod_name] = self.module return self def __exit__(self, *args): if self._saved_module: sys.modules[self.mod_name] = self._saved_module[0] else: del sys.modules[self.mod_name] self._saved_module = [] class _ModifiedArgv0(object): def __init__(self, value): self.value = value self._saved_value = self._sentinel = object() def __enter__(self): if self._saved_value is not self._sentinel: raise RuntimeError("Already preserving saved value") self._saved_value = sys.argv[0] sys.argv[0] = self.value def __exit__(self, *args): self.value = self._sentinel sys.argv[0] = self._saved_value # TODO: Replace these helpers with importlib._bootstrap_external functions. def _run_code(code, run_globals, init_globals=None, mod_name=None, mod_spec=None, pkg_name=None, script_name=None): """Helper to run code in nominated namespace""" if init_globals is not None: run_globals.update(init_globals) if mod_spec is None: loader = None fname = script_name cached = None else: loader = mod_spec.loader fname = mod_spec.origin cached = mod_spec.cached if pkg_name is None: pkg_name = mod_spec.parent run_globals.update(__name__=mod_name, __file__=fname, __cached__=cached, __doc__=None, __loader__=loader, __package__=pkg_name, __spec__=mod_spec) exec(code, run_globals) return run_globals def _run_module_code(code, init_globals=None, mod_name=None, mod_spec=None, pkg_name=None, script_name=None): """Helper to run code in new namespace with sys modified""" fname = script_name if mod_spec is None else mod_spec.origin with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname): mod_globals = temp_module.module.__dict__ _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name) # Copy the globals of the temporary module, as they # may be cleared when the temporary module goes away return mod_globals.copy() # Helper to get the full name, spec and code for a module def _get_module_details(mod_name, error=ImportError): if mod_name.startswith("."): raise error("Relative module names not supported") pkg_name, _, _ = mod_name.rpartition(".") if pkg_name: # Try importing the parent to avoid catching initialization errors try: __import__(pkg_name) except ImportError as e: # If the parent or higher ancestor package is missing, let the # error be raised by find_spec() below and then be caught. But do # not allow other errors to be caught. if e.name is None or (e.name != pkg_name and not pkg_name.startswith(e.name + ".")): raise # Warn if the module has already been imported under its normal name existing = sys.modules.get(mod_name) if existing is not None and not hasattr(existing, "__path__"): from warnings import warn msg = "{mod_name!r} found in sys.modules after import of " \ "package {pkg_name!r}, but prior to execution of " \ "{mod_name!r}; this may result in unpredictable " \ "behaviour".format(mod_name=mod_name, pkg_name=pkg_name) warn(RuntimeWarning(msg)) try: spec = importlib.util.find_spec(mod_name) except (ImportError, AttributeError, TypeError, ValueError) as ex: # This hack fixes an impedance mismatch between pkgutil and # importlib, where the latter raises other errors for cases where # pkgutil previously raised ImportError msg = "Error while finding module specification for {!r} ({}: {})" if mod_name.endswith(".py"): msg += (f". Try using '{mod_name[:-3]}' instead of " f"'{mod_name}' as the module name.") raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex if spec is None: raise error("No module named %s" % mod_name) if spec.submodule_search_locations is not None: if mod_name == "__main__" or mod_name.endswith(".__main__"): raise error("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name, error) except error as e: if mod_name not in sys.modules: raise # No module loaded; being a package is irrelevant raise error(("%s; %r is a package and cannot " + "be directly executed") % (e, mod_name)) loader = spec.loader if loader is None: raise error("%r is a namespace package and cannot be executed" % mod_name) try: code = loader.get_code(mod_name) except ImportError as e: raise error(format(e)) from e if code is None: raise error("No code object available for %s" % mod_name) return mod_name, spec, code class _Error(Exception): """Error that _run_module_as_main() should report without a traceback""" # XXX ncoghlan: Should this be documented and made public? # (Current thoughts: don't repeat the mistake that lead to its # creation when run_module() no longer met the needs of # mainmodule.c, but couldn't be changed because it was public) def _run_module_as_main(mod_name, alter_argv=True): """Runs the designated module in the __main__ namespace Note that the executed module will have full access to the __main__ namespace. If this is not desirable, the run_module() function should be used to run the module code in a fresh namespace. At the very least, these variables in __main__ will be overwritten: __name__ __file__ __cached__ __loader__ __package__ """ try: if alter_argv or mod_name != "__main__": # i.e. -m switch mod_name, mod_spec, code = _get_module_details(mod_name, _Error) else: # i.e. directory or zipfile execution mod_name, mod_spec, code = _get_main_module_details(_Error) except _Error as exc: msg = "%s: %s" % (sys.executable, exc) sys.exit(msg) main_globals = sys.modules["__main__"].__dict__ if alter_argv: sys.argv[0] = mod_spec.origin return _run_code(code, main_globals, None, "__main__", mod_spec) def run_module(mod_name, init_globals=None, run_name=None, alter_sys=False): """Execute a module's code without importing it Returns the resulting top level namespace dictionary """ mod_name, mod_spec, code = _get_module_details(mod_name) if run_name is None: run_name = mod_name if alter_sys: return _run_module_code(code, init_globals, run_name, mod_spec) else: # Leave the sys module alone return _run_code(code, {}, init_globals, run_name, mod_spec) def _get_main_module_details(error=ImportError): # Helper that gives a nicer error message when attempting to # execute a zipfile or directory by invoking __main__.py # Also moves the standard __main__ out of the way so that the # preexisting __loader__ entry doesn't cause issues main_name = "__main__" saved_main = sys.modules[main_name] del sys.modules[main_name] try: return _get_module_details(main_name) except ImportError as exc: if main_name in str(exc): raise error("can't find %r module in %r" % (main_name, sys.path[0])) from exc raise finally: sys.modules[main_name] = saved_main try: io_open_code = io.open_code except AttributeError: # Compatibility with Python 3.6/3.7 import tokenize io_open_code = tokenize.open def _get_code_from_file(run_name, fname): # Check for a compiled file first from pkgutil import read_code decoded_path = os.path.abspath(os.fsdecode(fname)) with io_open_code(decoded_path) as f: code = read_code(f) if code is None: # That didn't work, so try it as normal source code with io_open_code(decoded_path) as f: code = compile(f.read(), fname, 'exec') return code, fname def run_path(path_name, init_globals=None, run_name=None): """Execute code located at the specified filesystem location Returns the resulting top level namespace dictionary The file path may refer directly to a Python script (i.e. one that could be directly executed with execfile) or else it may refer to a zipfile or directory containing a top level __main__.py script. """ if run_name is None: run_name = "<run_path>" pkg_name = run_name.rpartition(".")[0] importer = pkgutil_get_importer(path_name) # Trying to avoid importing imp so as to not consume the deprecation warning. is_NullImporter = False if type(importer).__module__ == 'imp': if type(importer).__name__ == 'NullImporter': is_NullImporter = True if isinstance(importer, type(None)) or is_NullImporter: # Not a valid sys.path entry, so run the code directly # execfile() doesn't help as we want to allow compiled files code, fname = _get_code_from_file(run_name, path_name) return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname) else: # Finder is defined for path, so add it to # the start of sys.path sys.path.insert(0, path_name) try: # Here's where things are a little different from the run_module # case. There, we only had to replace the module in sys while the # code was running and doing so was somewhat optional. Here, we # have no choice and we have to remove it even while we read the # code. If we don't do this, a __loader__ attribute in the # existing __main__ module may prevent location of the new module. mod_name, mod_spec, code = _get_main_module_details() with _TempModule(run_name) as temp_module, \ _ModifiedArgv0(path_name): mod_globals = temp_module.module.__dict__ return _run_code(code, mod_globals, init_globals, run_name, mod_spec, pkg_name).copy() finally: try: sys.path.remove(path_name) except ValueError: pass if __name__ == "__main__": # Run the module specified as the next command line argument if len(sys.argv) < 2: print("No module specified for execution", file=sys.stderr) else: del sys.argv[0] # Make the requested module sys.argv[0] _run_module_as_main(sys.argv[0])
13,521
Python
37.19774
82
0.607425
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_dont_trace_files.py
# Important: Autogenerated file. # DO NOT edit manually! # DO NOT edit manually! LIB_FILE = 1 PYDEV_FILE = 2 DONT_TRACE_DIRS = { '_pydev_bundle': PYDEV_FILE, '_pydev_runfiles': PYDEV_FILE, '_pydevd_bundle': PYDEV_FILE, '_pydevd_frame_eval': PYDEV_FILE, 'pydev_ipython': PYDEV_FILE, 'pydev_sitecustomize': PYDEV_FILE, 'pydevd_attach_to_process': PYDEV_FILE, 'pydevd_concurrency_analyser': PYDEV_FILE, 'pydevd_plugins': PYDEV_FILE, 'test_pydevd_reload': PYDEV_FILE, } DONT_TRACE = { # commonly used things from the stdlib that we don't want to trace 'Queue.py':LIB_FILE, 'queue.py':LIB_FILE, 'socket.py':LIB_FILE, 'weakref.py':LIB_FILE, '_weakrefset.py':LIB_FILE, 'linecache.py':LIB_FILE, 'threading.py':LIB_FILE, 'dis.py':LIB_FILE, # things from pydev that we don't want to trace '__main__pydevd_gen_debug_adapter_protocol.py': PYDEV_FILE, '_pydev_calltip_util.py': PYDEV_FILE, '_pydev_completer.py': PYDEV_FILE, '_pydev_execfile.py': PYDEV_FILE, '_pydev_filesystem_encoding.py': PYDEV_FILE, '_pydev_getopt.py': PYDEV_FILE, '_pydev_imports_tipper.py': PYDEV_FILE, '_pydev_jy_imports_tipper.py': PYDEV_FILE, '_pydev_log.py': PYDEV_FILE, '_pydev_saved_modules.py': PYDEV_FILE, '_pydev_sys_patch.py': PYDEV_FILE, '_pydev_tipper_common.py': PYDEV_FILE, 'django_debug.py': PYDEV_FILE, 'jinja2_debug.py': PYDEV_FILE, 'pycompletionserver.py': PYDEV_FILE, 'pydev_app_engine_debug_startup.py': PYDEV_FILE, 'pydev_console_utils.py': PYDEV_FILE, 'pydev_import_hook.py': PYDEV_FILE, 'pydev_imports.py': PYDEV_FILE, 'pydev_ipython_console.py': PYDEV_FILE, 'pydev_ipython_console_011.py': PYDEV_FILE, 'pydev_is_thread_alive.py': PYDEV_FILE, 'pydev_localhost.py': PYDEV_FILE, 'pydev_log.py': PYDEV_FILE, 'pydev_monkey.py': PYDEV_FILE, 'pydev_monkey_qt.py': PYDEV_FILE, 'pydev_override.py': PYDEV_FILE, 'pydev_run_in_console.py': PYDEV_FILE, 'pydev_runfiles.py': PYDEV_FILE, 'pydev_runfiles_coverage.py': PYDEV_FILE, 'pydev_runfiles_nose.py': PYDEV_FILE, 'pydev_runfiles_parallel.py': PYDEV_FILE, 'pydev_runfiles_parallel_client.py': PYDEV_FILE, 'pydev_runfiles_pytest2.py': PYDEV_FILE, 'pydev_runfiles_unittest.py': PYDEV_FILE, 'pydev_runfiles_xml_rpc.py': PYDEV_FILE, 'pydev_umd.py': PYDEV_FILE, 'pydev_versioncheck.py': PYDEV_FILE, 'pydevconsole.py': PYDEV_FILE, 'pydevconsole_code.py': PYDEV_FILE, 'pydevd.py': PYDEV_FILE, 'pydevd_additional_thread_info.py': PYDEV_FILE, 'pydevd_additional_thread_info_regular.py': PYDEV_FILE, 'pydevd_api.py': PYDEV_FILE, 'pydevd_base_schema.py': PYDEV_FILE, 'pydevd_breakpoints.py': PYDEV_FILE, 'pydevd_bytecode_utils.py': PYDEV_FILE, 'pydevd_code_to_source.py': PYDEV_FILE, 'pydevd_collect_bytecode_info.py': PYDEV_FILE, 'pydevd_comm.py': PYDEV_FILE, 'pydevd_comm_constants.py': PYDEV_FILE, 'pydevd_command_line_handling.py': PYDEV_FILE, 'pydevd_concurrency_logger.py': PYDEV_FILE, 'pydevd_console.py': PYDEV_FILE, 'pydevd_constants.py': PYDEV_FILE, 'pydevd_custom_frames.py': PYDEV_FILE, 'pydevd_cython_wrapper.py': PYDEV_FILE, 'pydevd_daemon_thread.py': PYDEV_FILE, 'pydevd_defaults.py': PYDEV_FILE, 'pydevd_dont_trace.py': PYDEV_FILE, 'pydevd_dont_trace_files.py': PYDEV_FILE, 'pydevd_exec2.py': PYDEV_FILE, 'pydevd_extension_api.py': PYDEV_FILE, 'pydevd_extension_utils.py': PYDEV_FILE, 'pydevd_file_utils.py': PYDEV_FILE, 'pydevd_filtering.py': PYDEV_FILE, 'pydevd_frame.py': PYDEV_FILE, 'pydevd_frame_eval_cython_wrapper.py': PYDEV_FILE, 'pydevd_frame_eval_main.py': PYDEV_FILE, 'pydevd_frame_tracing.py': PYDEV_FILE, 'pydevd_frame_utils.py': PYDEV_FILE, 'pydevd_gevent_integration.py': PYDEV_FILE, 'pydevd_helpers.py': PYDEV_FILE, 'pydevd_import_class.py': PYDEV_FILE, 'pydevd_io.py': PYDEV_FILE, 'pydevd_json_debug_options.py': PYDEV_FILE, 'pydevd_line_validation.py': PYDEV_FILE, 'pydevd_modify_bytecode.py': PYDEV_FILE, 'pydevd_net_command.py': PYDEV_FILE, 'pydevd_net_command_factory_json.py': PYDEV_FILE, 'pydevd_net_command_factory_xml.py': PYDEV_FILE, 'pydevd_plugin_numpy_types.py': PYDEV_FILE, 'pydevd_plugin_pandas_types.py': PYDEV_FILE, 'pydevd_plugin_utils.py': PYDEV_FILE, 'pydevd_plugins_django_form_str.py': PYDEV_FILE, 'pydevd_process_net_command.py': PYDEV_FILE, 'pydevd_process_net_command_json.py': PYDEV_FILE, 'pydevd_referrers.py': PYDEV_FILE, 'pydevd_reload.py': PYDEV_FILE, 'pydevd_resolver.py': PYDEV_FILE, 'pydevd_runpy.py': PYDEV_FILE, 'pydevd_safe_repr.py': PYDEV_FILE, 'pydevd_save_locals.py': PYDEV_FILE, 'pydevd_schema.py': PYDEV_FILE, 'pydevd_schema_log.py': PYDEV_FILE, 'pydevd_signature.py': PYDEV_FILE, 'pydevd_source_mapping.py': PYDEV_FILE, 'pydevd_stackless.py': PYDEV_FILE, 'pydevd_suspended_frames.py': PYDEV_FILE, 'pydevd_thread_lifecycle.py': PYDEV_FILE, 'pydevd_thread_wrappers.py': PYDEV_FILE, 'pydevd_timeout.py': PYDEV_FILE, 'pydevd_trace_api.py': PYDEV_FILE, 'pydevd_trace_dispatch.py': PYDEV_FILE, 'pydevd_trace_dispatch_regular.py': PYDEV_FILE, 'pydevd_traceproperty.py': PYDEV_FILE, 'pydevd_tracing.py': PYDEV_FILE, 'pydevd_utils.py': PYDEV_FILE, 'pydevd_vars.py': PYDEV_FILE, 'pydevd_vm_type.py': PYDEV_FILE, 'pydevd_xml.py': PYDEV_FILE, } # if we try to trace io.py it seems it can get halted (see http://bugs.python.org/issue4716) DONT_TRACE['io.py'] = LIB_FILE # Don't trace common encodings too DONT_TRACE['cp1252.py'] = LIB_FILE DONT_TRACE['utf_8.py'] = LIB_FILE DONT_TRACE['codecs.py'] = LIB_FILE
5,814
Python
36.75974
92
0.665807
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_referrers.py
import sys from _pydevd_bundle import pydevd_xml from os.path import basename from _pydev_bundle import pydev_log from urllib.parse import unquote_plus from _pydevd_bundle.pydevd_constants import IS_PY311_OR_GREATER #=================================================================================================== # print_var_node #=================================================================================================== def print_var_node(xml_node, stream): name = xml_node.getAttribute('name') value = xml_node.getAttribute('value') val_type = xml_node.getAttribute('type') found_as = xml_node.getAttribute('found_as') stream.write('Name: ') stream.write(unquote_plus(name)) stream.write(', Value: ') stream.write(unquote_plus(value)) stream.write(', Type: ') stream.write(unquote_plus(val_type)) if found_as: stream.write(', Found as: %s' % (unquote_plus(found_as),)) stream.write('\n') #=================================================================================================== # print_referrers #=================================================================================================== def print_referrers(obj, stream=None): if stream is None: stream = sys.stdout result = get_referrer_info(obj) from xml.dom.minidom import parseString dom = parseString(result) xml = dom.getElementsByTagName('xml')[0] for node in xml.childNodes: if node.nodeType == node.TEXT_NODE: continue if node.localName == 'for': stream.write('Searching references for: ') for child in node.childNodes: if child.nodeType == node.TEXT_NODE: continue print_var_node(child, stream) elif node.localName == 'var': stream.write('Referrer found: ') print_var_node(node, stream) else: sys.stderr.write('Unhandled node: %s\n' % (node,)) return result #=================================================================================================== # get_referrer_info #=================================================================================================== def get_referrer_info(searched_obj): DEBUG = 0 if DEBUG: sys.stderr.write('Getting referrers info.\n') try: try: if searched_obj is None: ret = ['<xml>\n'] ret.append('<for>\n') ret.append(pydevd_xml.var_to_xml( searched_obj, 'Skipping getting referrers for None', additional_in_xml=' id="%s"' % (id(searched_obj),))) ret.append('</for>\n') ret.append('</xml>') ret = ''.join(ret) return ret obj_id = id(searched_obj) try: if DEBUG: sys.stderr.write('Getting referrers...\n') import gc referrers = gc.get_referrers(searched_obj) except: pydev_log.exception() ret = ['<xml>\n'] ret.append('<for>\n') ret.append(pydevd_xml.var_to_xml( searched_obj, 'Exception raised while trying to get_referrers.', additional_in_xml=' id="%s"' % (id(searched_obj),))) ret.append('</for>\n') ret.append('</xml>') ret = ''.join(ret) return ret if DEBUG: sys.stderr.write('Found %s referrers.\n' % (len(referrers),)) curr_frame = sys._getframe() frame_type = type(curr_frame) # Ignore this frame and any caller frame of this frame ignore_frames = {} # Should be a set, but it's not available on all python versions. while curr_frame is not None: if basename(curr_frame.f_code.co_filename).startswith('pydev'): ignore_frames[curr_frame] = 1 curr_frame = curr_frame.f_back ret = ['<xml>\n'] ret.append('<for>\n') if DEBUG: sys.stderr.write('Searching Referrers of obj with id="%s"\n' % (obj_id,)) ret.append(pydevd_xml.var_to_xml( searched_obj, 'Referrers of obj with id="%s"' % (obj_id,))) ret.append('</for>\n') curr_frame = sys._getframe() all_objects = None for r in referrers: try: if r in ignore_frames: continue # Skip the references we may add ourselves except: pass # Ok: unhashable type checked... if r is referrers: continue if r is curr_frame.f_locals: continue r_type = type(r) r_id = str(id(r)) representation = str(r_type) found_as = '' if r_type == frame_type: if DEBUG: sys.stderr.write('Found frame referrer: %r\n' % (r,)) for key, val in r.f_locals.items(): if val is searched_obj: found_as = key break elif r_type == dict: if DEBUG: sys.stderr.write('Found dict referrer: %r\n' % (r,)) # Try to check if it's a value in the dict (and under which key it was found) for key, val in r.items(): if val is searched_obj: found_as = key if DEBUG: sys.stderr.write(' Found as %r in dict\n' % (found_as,)) break # Ok, there's one annoying thing: many times we find it in a dict from an instance, # but with this we don't directly have the class, only the dict, so, to workaround that # we iterate over all reachable objects ad check if one of those has the given dict. if all_objects is None: all_objects = gc.get_objects() for x in all_objects: try: if getattr(x, '__dict__', None) is r: r = x r_type = type(x) r_id = str(id(r)) representation = str(r_type) break except: pass # Just ignore any error here (i.e.: ReferenceError, etc.) elif r_type in (tuple, list): if DEBUG: sys.stderr.write('Found tuple referrer: %r\n' % (r,)) for i, x in enumerate(r): if x is searched_obj: found_as = '%s[%s]' % (r_type.__name__, i) if DEBUG: sys.stderr.write(' Found as %s in tuple: \n' % (found_as,)) break elif IS_PY311_OR_GREATER: # Up to Python 3.10, gc.get_referrers for an instance actually returned the # object.__dict__, but on Python 3.11 it returns the actual object, so, # handling is a bit easier (we don't need the workaround from the dict # case to find the actual instance, we just need to find the attribute name). if DEBUG: sys.stderr.write('Found dict referrer: %r\n' % (r,)) dct = getattr(r, '__dict__', None) if dct: # Try to check if it's a value in the dict (and under which key it was found) for key, val in dct.items(): if val is searched_obj: found_as = key if DEBUG: sys.stderr.write(' Found as %r in object instance\n' % (found_as,)) break if found_as: if not isinstance(found_as, str): found_as = str(found_as) found_as = ' found_as="%s"' % (pydevd_xml.make_valid_xml_value(found_as),) ret.append(pydevd_xml.var_to_xml( r, representation, additional_in_xml=' id="%s"%s' % (r_id, found_as))) finally: if DEBUG: sys.stderr.write('Done searching for references.\n') # If we have any exceptions, don't keep dangling references from this frame to any of our objects. all_objects = None referrers = None searched_obj = None r = None x = None key = None val = None curr_frame = None ignore_frames = None except: pydev_log.exception() ret = ['<xml>\n'] ret.append('<for>\n') ret.append(pydevd_xml.var_to_xml( searched_obj, 'Error getting referrers for:', additional_in_xml=' id="%s"' % (id(searched_obj),))) ret.append('</for>\n') ret.append('</xml>') ret = ''.join(ret) return ret ret.append('</xml>') ret = ''.join(ret) return ret
9,756
Python
36.817829
110
0.432554
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py
from functools import partial import itertools import os import sys import socket as socket_module from _pydev_bundle._pydev_imports_tipper import TYPE_IMPORT, TYPE_CLASS, TYPE_FUNCTION, TYPE_ATTR, \ TYPE_BUILTIN, TYPE_PARAM from _pydev_bundle.pydev_is_thread_alive import is_thread_alive from _pydev_bundle.pydev_override import overrides from _pydevd_bundle._debug_adapter import pydevd_schema from _pydevd_bundle._debug_adapter.pydevd_schema import ModuleEvent, ModuleEventBody, Module, \ OutputEventBody, OutputEvent, ContinuedEventBody, ExitedEventBody, \ ExitedEvent from _pydevd_bundle.pydevd_comm_constants import CMD_THREAD_CREATE, CMD_RETURN, CMD_MODULE_EVENT, \ CMD_WRITE_TO_CONSOLE, CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE, \ CMD_STEP_RETURN, CMD_STEP_CAUGHT_EXCEPTION, CMD_ADD_EXCEPTION_BREAK, CMD_SET_BREAK, \ CMD_SET_NEXT_STATEMENT, CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION, \ CMD_THREAD_RESUME_SINGLE_NOTIFICATION, CMD_THREAD_KILL, CMD_STOP_ON_START, CMD_INPUT_REQUESTED, \ CMD_EXIT, CMD_STEP_INTO_COROUTINE, CMD_STEP_RETURN_MY_CODE, CMD_SMART_STEP_INTO, \ CMD_SET_FUNCTION_BREAK from _pydevd_bundle.pydevd_constants import get_thread_id, ForkSafeLock from _pydevd_bundle.pydevd_net_command import NetCommand, NULL_NET_COMMAND from _pydevd_bundle.pydevd_net_command_factory_xml import NetCommandFactory from _pydevd_bundle.pydevd_utils import get_non_pydevd_threads import pydevd_file_utils from _pydevd_bundle.pydevd_comm import build_exception_info_response from _pydevd_bundle.pydevd_additional_thread_info import set_additional_thread_info from _pydevd_bundle import pydevd_frame_utils, pydevd_constants, pydevd_utils import linecache from _pydevd_bundle.pydevd_thread_lifecycle import pydevd_find_thread_by_id from io import StringIO class ModulesManager(object): def __init__(self): self._lock = ForkSafeLock() self._modules = {} self._next_id = partial(next, itertools.count(0)) def track_module(self, filename_in_utf8, module_name, frame): ''' :return list(NetCommand): Returns a list with the module events to be sent. ''' if filename_in_utf8 in self._modules: return [] module_events = [] with self._lock: # Must check again after getting the lock. if filename_in_utf8 in self._modules: return try: version = str(frame.f_globals.get('__version__', '')) except: version = '<unknown>' try: package_name = str(frame.f_globals.get('__package__', '')) except: package_name = '<unknown>' module_id = self._next_id() module = Module(module_id, module_name, filename_in_utf8) if version: module.version = version if package_name: # Note: package doesn't appear in the docs but seems to be expected? module.kwargs['package'] = package_name module_event = ModuleEvent(ModuleEventBody('new', module)) module_events.append(NetCommand(CMD_MODULE_EVENT, 0, module_event, is_json=True)) self._modules[filename_in_utf8] = module.to_dict() return module_events def get_modules_info(self): ''' :return list(Module) ''' with self._lock: return list(self._modules.values()) class NetCommandFactoryJson(NetCommandFactory): ''' Factory for commands which will provide messages as json (they should be similar to the debug adapter where possible, although some differences are currently Ok). Note that it currently overrides the xml version so that messages can be done one at a time (any message not overridden will currently use the xml version) -- after having all messages handled, it should no longer use NetCommandFactory as the base class. ''' def __init__(self): NetCommandFactory.__init__(self) self.modules_manager = ModulesManager() @overrides(NetCommandFactory.make_version_message) def make_version_message(self, seq): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_protocol_set_message) def make_protocol_set_message(self, seq): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_thread_created_message) def make_thread_created_message(self, thread): # Note: the thread id for the debug adapter must be an int # (make the actual id from get_thread_id respect that later on). msg = pydevd_schema.ThreadEvent( pydevd_schema.ThreadEventBody('started', get_thread_id(thread)), ) return NetCommand(CMD_THREAD_CREATE, 0, msg, is_json=True) @overrides(NetCommandFactory.make_custom_frame_created_message) def make_custom_frame_created_message(self, frame_id, frame_description): self._additional_thread_id_to_thread_name[frame_id] = frame_description msg = pydevd_schema.ThreadEvent( pydevd_schema.ThreadEventBody('started', frame_id), ) return NetCommand(CMD_THREAD_CREATE, 0, msg, is_json=True) @overrides(NetCommandFactory.make_thread_killed_message) def make_thread_killed_message(self, tid): self._additional_thread_id_to_thread_name.pop(tid, None) msg = pydevd_schema.ThreadEvent( pydevd_schema.ThreadEventBody('exited', tid), ) return NetCommand(CMD_THREAD_KILL, 0, msg, is_json=True) @overrides(NetCommandFactory.make_list_threads_message) def make_list_threads_message(self, py_db, seq): threads = [] for thread in get_non_pydevd_threads(): if is_thread_alive(thread): thread_id = get_thread_id(thread) # Notify that it's created (no-op if we already notified before). py_db.notify_thread_created(thread_id, thread) thread_schema = pydevd_schema.Thread(id=thread_id, name=thread.name) threads.append(thread_schema.to_dict()) for thread_id, thread_name in list(self._additional_thread_id_to_thread_name.items()): thread_schema = pydevd_schema.Thread(id=thread_id, name=thread_name) threads.append(thread_schema.to_dict()) body = pydevd_schema.ThreadsResponseBody(threads) response = pydevd_schema.ThreadsResponse( request_seq=seq, success=True, command='threads', body=body) return NetCommand(CMD_RETURN, 0, response, is_json=True) @overrides(NetCommandFactory.make_get_completions_message) def make_get_completions_message(self, seq, completions, qualifier, start): COMPLETION_TYPE_LOOK_UP = { TYPE_IMPORT: pydevd_schema.CompletionItemType.MODULE, TYPE_CLASS: pydevd_schema.CompletionItemType.CLASS, TYPE_FUNCTION: pydevd_schema.CompletionItemType.FUNCTION, TYPE_ATTR: pydevd_schema.CompletionItemType.FIELD, TYPE_BUILTIN: pydevd_schema.CompletionItemType.KEYWORD, TYPE_PARAM: pydevd_schema.CompletionItemType.VARIABLE, } qualifier = qualifier.lower() qualifier_len = len(qualifier) targets = [] for completion in completions: label = completion[0] if label.lower().startswith(qualifier): completion = pydevd_schema.CompletionItem( label=label, type=COMPLETION_TYPE_LOOK_UP[completion[3]], start=start, length=qualifier_len) targets.append(completion.to_dict()) body = pydevd_schema.CompletionsResponseBody(targets) response = pydevd_schema.CompletionsResponse( request_seq=seq, success=True, command='completions', body=body) return NetCommand(CMD_RETURN, 0, response, is_json=True) def _format_frame_name(self, fmt, initial_name, module_name, line, path): if fmt is None: return initial_name frame_name = initial_name if fmt.get('module', False): if module_name: if initial_name == '<module>': frame_name = module_name else: frame_name = '%s.%s' % (module_name, initial_name) else: basename = os.path.basename(path) basename = basename[0:-3] if basename.lower().endswith('.py') else basename if initial_name == '<module>': frame_name = '%s in %s' % (initial_name, basename) else: frame_name = '%s.%s' % (basename, initial_name) if fmt.get('line', False): frame_name = '%s : %d' % (frame_name, line) return frame_name @overrides(NetCommandFactory.make_get_thread_stack_message) def make_get_thread_stack_message(self, py_db, seq, thread_id, topmost_frame, fmt, must_be_suspended=False, start_frame=0, levels=0): frames = [] module_events = [] try: # : :type suspended_frames_manager: SuspendedFramesManager suspended_frames_manager = py_db.suspended_frames_manager frames_list = suspended_frames_manager.get_frames_list(thread_id) if frames_list is None: # Could not find stack of suspended frame... if must_be_suspended: return None else: frames_list = pydevd_frame_utils.create_frames_list_from_frame(topmost_frame) for frame_id, frame, method_name, original_filename, filename_in_utf8, lineno, applied_mapping, show_as_current_frame in self._iter_visible_frames_info( py_db, frames_list ): try: module_name = str(frame.f_globals.get('__name__', '')) except: module_name = '<unknown>' module_events.extend(self.modules_manager.track_module(filename_in_utf8, module_name, frame)) presentation_hint = None if not getattr(frame, 'IS_PLUGIN_FRAME', False): # Never filter out plugin frames! if py_db.is_files_filter_enabled and py_db.apply_files_filter(frame, original_filename, False): continue if not py_db.in_project_scope(frame): presentation_hint = 'subtle' formatted_name = self._format_frame_name(fmt, method_name, module_name, lineno, filename_in_utf8) if show_as_current_frame: formatted_name += ' (Current frame)' source_reference = pydevd_file_utils.get_client_filename_source_reference(filename_in_utf8) if not source_reference and not applied_mapping and not os.path.exists(original_filename): if getattr(frame.f_code, 'co_lnotab', None): # Create a source-reference to be used where we provide the source by decompiling the code. # Note: When the time comes to retrieve the source reference in this case, we'll # check the linecache first (see: get_decompiled_source_from_frame_id). source_reference = pydevd_file_utils.create_source_reference_for_frame_id(frame_id, original_filename) else: # Check if someone added a source reference to the linecache (Python attrs does this). if linecache.getline(original_filename, 1): source_reference = pydevd_file_utils.create_source_reference_for_linecache( original_filename) frames.append(pydevd_schema.StackFrame( frame_id, formatted_name, lineno, column=1, source={ 'path': filename_in_utf8, 'sourceReference': source_reference, }, presentationHint=presentation_hint).to_dict()) finally: topmost_frame = None for module_event in module_events: py_db.writer.add_command(module_event) total_frames = len(frames) stack_frames = frames if bool(levels): start = start_frame end = min(start + levels, total_frames) stack_frames = frames[start:end] response = pydevd_schema.StackTraceResponse( request_seq=seq, success=True, command='stackTrace', body=pydevd_schema.StackTraceResponseBody(stackFrames=stack_frames, totalFrames=total_frames)) return NetCommand(CMD_RETURN, 0, response, is_json=True) @overrides(NetCommandFactory.make_warning_message) def make_warning_message(self, msg): category = 'important' body = OutputEventBody(msg, category) event = OutputEvent(body) return NetCommand(CMD_WRITE_TO_CONSOLE, 0, event, is_json=True) @overrides(NetCommandFactory.make_io_message) def make_io_message(self, msg, ctx): category = 'stdout' if int(ctx) == 1 else 'stderr' body = OutputEventBody(msg, category) event = OutputEvent(body) return NetCommand(CMD_WRITE_TO_CONSOLE, 0, event, is_json=True) _STEP_REASONS = set([ CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE, CMD_STEP_RETURN, CMD_STEP_RETURN_MY_CODE, CMD_STEP_INTO_MY_CODE, CMD_STOP_ON_START, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO, ]) _EXCEPTION_REASONS = set([ CMD_STEP_CAUGHT_EXCEPTION, CMD_ADD_EXCEPTION_BREAK, ]) @overrides(NetCommandFactory.make_thread_suspend_single_notification) def make_thread_suspend_single_notification(self, py_db, thread_id, stop_reason): exc_desc = None exc_name = None thread = pydevd_find_thread_by_id(thread_id) info = set_additional_thread_info(thread) preserve_focus_hint = False if stop_reason in self._STEP_REASONS: if info.pydev_original_step_cmd == CMD_STOP_ON_START: # Just to make sure that's not set as the original reason anymore. info.pydev_original_step_cmd = -1 stop_reason = 'entry' else: stop_reason = 'step' elif stop_reason in self._EXCEPTION_REASONS: stop_reason = 'exception' elif stop_reason == CMD_SET_BREAK: stop_reason = 'breakpoint' elif stop_reason == CMD_SET_FUNCTION_BREAK: stop_reason = 'function breakpoint' elif stop_reason == CMD_SET_NEXT_STATEMENT: stop_reason = 'goto' else: stop_reason = 'pause' preserve_focus_hint = True if stop_reason == 'exception': exception_info_response = build_exception_info_response( py_db, thread_id, -1, set_additional_thread_info, self._iter_visible_frames_info, max_frames=-1) exception_info_response exc_name = exception_info_response.body.exceptionId exc_desc = exception_info_response.body.description body = pydevd_schema.StoppedEventBody( reason=stop_reason, description=exc_desc, threadId=thread_id, text=exc_name, allThreadsStopped=True, preserveFocusHint=preserve_focus_hint, ) event = pydevd_schema.StoppedEvent(body) return NetCommand(CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION, 0, event, is_json=True) @overrides(NetCommandFactory.make_thread_resume_single_notification) def make_thread_resume_single_notification(self, thread_id): body = ContinuedEventBody(threadId=thread_id, allThreadsContinued=True) event = pydevd_schema.ContinuedEvent(body) return NetCommand(CMD_THREAD_RESUME_SINGLE_NOTIFICATION, 0, event, is_json=True) @overrides(NetCommandFactory.make_set_next_stmnt_status_message) def make_set_next_stmnt_status_message(self, seq, is_success, exception_msg): response = pydevd_schema.GotoResponse( request_seq=int(seq), success=is_success, command='goto', body={}, message=(None if is_success else exception_msg)) return NetCommand(CMD_RETURN, 0, response, is_json=True) @overrides(NetCommandFactory.make_send_curr_exception_trace_message) def make_send_curr_exception_trace_message(self, *args, **kwargs): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_send_curr_exception_trace_proceeded_message) def make_send_curr_exception_trace_proceeded_message(self, *args, **kwargs): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_send_breakpoint_exception_message) def make_send_breakpoint_exception_message(self, *args, **kwargs): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_process_created_message) def make_process_created_message(self, *args, **kwargs): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_process_about_to_be_replaced_message) def make_process_about_to_be_replaced_message(self): event = ExitedEvent(ExitedEventBody(-1, pydevdReason="processReplaced")) cmd = NetCommand(CMD_RETURN, 0, event, is_json=True) def after_send(socket): socket.setsockopt(socket_module.IPPROTO_TCP, socket_module.TCP_NODELAY, 1) cmd.call_after_send(after_send) return cmd @overrides(NetCommandFactory.make_thread_suspend_message) def make_thread_suspend_message(self, *args, **kwargs): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_thread_run_message) def make_thread_run_message(self, *args, **kwargs): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_reloaded_code_message) def make_reloaded_code_message(self, *args, **kwargs): return NULL_NET_COMMAND # Not a part of the debug adapter protocol @overrides(NetCommandFactory.make_input_requested_message) def make_input_requested_message(self, started): event = pydevd_schema.PydevdInputRequestedEvent(body={}) return NetCommand(CMD_INPUT_REQUESTED, 0, event, is_json=True) @overrides(NetCommandFactory.make_skipped_step_in_because_of_filters) def make_skipped_step_in_because_of_filters(self, py_db, frame): msg = 'Frame skipped from debugging during step-in.' if py_db.get_use_libraries_filter(): msg += ('\nNote: may have been skipped because of "justMyCode" option (default == true). ' 'Try setting \"justMyCode\": false in the debug configuration (e.g., launch.json).\n') return self.make_warning_message(msg) @overrides(NetCommandFactory.make_evaluation_timeout_msg) def make_evaluation_timeout_msg(self, py_db, expression, curr_thread): msg = '''Evaluating: %s did not finish after %.2f seconds. This may mean a number of things: - This evaluation is really slow and this is expected. In this case it's possible to silence this error by raising the timeout, setting the PYDEVD_WARN_EVALUATION_TIMEOUT environment variable to a bigger value. - The evaluation may need other threads running while it's running: In this case, it's possible to set the PYDEVD_UNBLOCK_THREADS_TIMEOUT environment variable so that if after a given timeout an evaluation doesn't finish, other threads are unblocked or you can manually resume all threads. Alternatively, it's also possible to skip breaking on a particular thread by setting a `pydev_do_not_trace = True` attribute in the related threading.Thread instance (if some thread should always be running and no breakpoints are expected to be hit in it). - The evaluation is deadlocked: In this case you may set the PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT environment variable to true so that a thread dump is shown along with this message and optionally, set the PYDEVD_INTERRUPT_THREAD_TIMEOUT to some value so that the debugger tries to interrupt the evaluation (if possible) when this happens. ''' % (expression, pydevd_constants.PYDEVD_WARN_EVALUATION_TIMEOUT) if pydevd_constants.PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT: stream = StringIO() pydevd_utils.dump_threads(stream, show_pydevd_threads=False) msg += '\n\n%s\n' % stream.getvalue() return self.make_warning_message(msg) @overrides(NetCommandFactory.make_exit_command) def make_exit_command(self, py_db): event = pydevd_schema.TerminatedEvent(pydevd_schema.TerminatedEventBody()) return NetCommand(CMD_EXIT, 0, event, is_json=True)
21,328
Python
43.903158
164
0.644599
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_api.py
import sys import bisect import types from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle import pydevd_utils, pydevd_source_mapping from _pydevd_bundle.pydevd_additional_thread_info import set_additional_thread_info from _pydevd_bundle.pydevd_comm import (InternalGetThreadStack, internal_get_completions, InternalSetNextStatementThread, internal_reload_code, InternalGetVariable, InternalGetArray, InternalLoadFullValue, internal_get_description, internal_get_frame, internal_evaluate_expression, InternalConsoleExec, internal_get_variable_json, internal_change_variable, internal_change_variable_json, internal_evaluate_expression_json, internal_set_expression_json, internal_get_exception_details_json, internal_step_in_thread, internal_smart_step_into) from _pydevd_bundle.pydevd_comm_constants import (CMD_THREAD_SUSPEND, file_system_encoding, CMD_STEP_INTO_MY_CODE, CMD_STOP_ON_START, CMD_SMART_STEP_INTO) from _pydevd_bundle.pydevd_constants import (get_current_thread_id, set_protocol, get_protocol, HTTP_JSON_PROTOCOL, JSON_PROTOCOL, DebugInfoHolder, IS_WINDOWS) from _pydevd_bundle.pydevd_net_command_factory_json import NetCommandFactoryJson from _pydevd_bundle.pydevd_net_command_factory_xml import NetCommandFactory import pydevd_file_utils from _pydev_bundle import pydev_log from _pydevd_bundle.pydevd_breakpoints import LineBreakpoint from pydevd_tracing import get_exception_traceback_str import os import subprocess import ctypes from _pydevd_bundle.pydevd_collect_bytecode_info import code_to_bytecode_representation import itertools import linecache from _pydevd_bundle.pydevd_utils import DAPGrouper from _pydevd_bundle.pydevd_daemon_thread import run_as_pydevd_daemon_thread from _pydevd_bundle.pydevd_thread_lifecycle import pydevd_find_thread_by_id, resume_threads import tokenize try: import dis except ImportError: def _get_code_lines(code): raise NotImplementedError else: def _get_code_lines(code): if not isinstance(code, types.CodeType): path = code with tokenize.open(path) as f: src = f.read() code = compile(src, path, 'exec', 0, dont_inherit=True) return _get_code_lines(code) def iterate(): # First, get all line starts for this code object. This does not include # bodies of nested class and function definitions, as they have their # own objects. for _, lineno in dis.findlinestarts(code): yield lineno # For nested class and function definitions, their respective code objects # are constants referenced by this object. for const in code.co_consts: if isinstance(const, types.CodeType) and const.co_filename == code.co_filename: for lineno in _get_code_lines(const): yield lineno return iterate() class PyDevdAPI(object): class VariablePresentation(object): def __init__(self, special='group', function='group', class_='group', protected='inline'): self._presentation = { DAPGrouper.SCOPE_SPECIAL_VARS: special, DAPGrouper.SCOPE_FUNCTION_VARS: function, DAPGrouper.SCOPE_CLASS_VARS: class_, DAPGrouper.SCOPE_PROTECTED_VARS: protected, } def get_presentation(self, scope): return self._presentation[scope] def run(self, py_db): py_db.ready_to_run = True def notify_initialize(self, py_db): py_db.on_initialize() def notify_configuration_done(self, py_db): py_db.on_configuration_done() def notify_disconnect(self, py_db): py_db.on_disconnect() def set_protocol(self, py_db, seq, protocol): set_protocol(protocol.strip()) if get_protocol() in (HTTP_JSON_PROTOCOL, JSON_PROTOCOL): cmd_factory_class = NetCommandFactoryJson else: cmd_factory_class = NetCommandFactory if not isinstance(py_db.cmd_factory, cmd_factory_class): py_db.cmd_factory = cmd_factory_class() return py_db.cmd_factory.make_protocol_set_message(seq) def set_ide_os_and_breakpoints_by(self, py_db, seq, ide_os, breakpoints_by): ''' :param ide_os: 'WINDOWS' or 'UNIX' :param breakpoints_by: 'ID' or 'LINE' ''' if breakpoints_by == 'ID': py_db._set_breakpoints_with_id = True else: py_db._set_breakpoints_with_id = False self.set_ide_os(ide_os) return py_db.cmd_factory.make_version_message(seq) def set_ide_os(self, ide_os): ''' :param ide_os: 'WINDOWS' or 'UNIX' ''' pydevd_file_utils.set_ide_os(ide_os) def set_gui_event_loop(self, py_db, gui_event_loop): py_db._gui_event_loop = gui_event_loop def send_error_message(self, py_db, msg): cmd = py_db.cmd_factory.make_warning_message('pydevd: %s\n' % (msg,)) py_db.writer.add_command(cmd) def set_show_return_values(self, py_db, show_return_values): if show_return_values: py_db.show_return_values = True else: if py_db.show_return_values: # We should remove saved return values py_db.remove_return_values_flag = True py_db.show_return_values = False pydev_log.debug("Show return values: %s", py_db.show_return_values) def list_threads(self, py_db, seq): # Response is the command with the list of threads to be added to the writer thread. return py_db.cmd_factory.make_list_threads_message(py_db, seq) def request_suspend_thread(self, py_db, thread_id='*'): # Yes, thread suspend is done at this point, not through an internal command. threads = [] suspend_all = thread_id.strip() == '*' if suspend_all: threads = pydevd_utils.get_non_pydevd_threads() elif thread_id.startswith('__frame__:'): sys.stderr.write("Can't suspend tasklet: %s\n" % (thread_id,)) else: threads = [pydevd_find_thread_by_id(thread_id)] for t in threads: if t is None: continue py_db.set_suspend( t, CMD_THREAD_SUSPEND, suspend_other_threads=suspend_all, is_pause=True, ) # Break here (even if it's suspend all) as py_db.set_suspend will # take care of suspending other threads. break def set_enable_thread_notifications(self, py_db, enable): ''' When disabled, no thread notifications (for creation/removal) will be issued until it's re-enabled. Note that when it's re-enabled, a creation notification will be sent for all existing threads even if it was previously sent (this is meant to be used on disconnect/reconnect). ''' py_db.set_enable_thread_notifications(enable) def request_disconnect(self, py_db, resume_threads): self.set_enable_thread_notifications(py_db, False) self.remove_all_breakpoints(py_db, '*') self.remove_all_exception_breakpoints(py_db) self.notify_disconnect(py_db) if resume_threads: self.request_resume_thread(thread_id='*') def request_resume_thread(self, thread_id): resume_threads(thread_id) def request_completions(self, py_db, seq, thread_id, frame_id, act_tok, line=-1, column=-1): py_db.post_method_as_internal_command( thread_id, internal_get_completions, seq, thread_id, frame_id, act_tok, line=line, column=column) def request_stack(self, py_db, seq, thread_id, fmt=None, timeout=.5, start_frame=0, levels=0): # If it's already suspended, get it right away. internal_get_thread_stack = InternalGetThreadStack( seq, thread_id, py_db, set_additional_thread_info, fmt=fmt, timeout=timeout, start_frame=start_frame, levels=levels) if internal_get_thread_stack.can_be_executed_by(get_current_thread_id(threading.current_thread())): internal_get_thread_stack.do_it(py_db) else: py_db.post_internal_command(internal_get_thread_stack, '*') def request_exception_info_json(self, py_db, request, thread_id, max_frames): py_db.post_method_as_internal_command( thread_id, internal_get_exception_details_json, request, thread_id, max_frames, set_additional_thread_info=set_additional_thread_info, iter_visible_frames_info=py_db.cmd_factory._iter_visible_frames_info, ) def request_step(self, py_db, thread_id, step_cmd_id): t = pydevd_find_thread_by_id(thread_id) if t: py_db.post_method_as_internal_command( thread_id, internal_step_in_thread, thread_id, step_cmd_id, set_additional_thread_info=set_additional_thread_info, ) elif thread_id.startswith('__frame__:'): sys.stderr.write("Can't make tasklet step command: %s\n" % (thread_id,)) def request_smart_step_into(self, py_db, seq, thread_id, offset, child_offset): t = pydevd_find_thread_by_id(thread_id) if t: py_db.post_method_as_internal_command( thread_id, internal_smart_step_into, thread_id, offset, child_offset, set_additional_thread_info=set_additional_thread_info) elif thread_id.startswith('__frame__:'): sys.stderr.write("Can't set next statement in tasklet: %s\n" % (thread_id,)) def request_smart_step_into_by_func_name(self, py_db, seq, thread_id, line, func_name): # Same thing as set next, just with a different cmd id. self.request_set_next(py_db, seq, thread_id, CMD_SMART_STEP_INTO, None, line, func_name) def request_set_next(self, py_db, seq, thread_id, set_next_cmd_id, original_filename, line, func_name): ''' set_next_cmd_id may actually be one of: CMD_RUN_TO_LINE CMD_SET_NEXT_STATEMENT CMD_SMART_STEP_INTO -- note: request_smart_step_into is preferred if it's possible to work with bytecode offset. :param Optional[str] original_filename: If available, the filename may be source translated, otherwise no translation will take place (the set next just needs the line afterwards as it executes locally, but for the Jupyter integration, the source mapping may change the actual lines and not only the filename). ''' t = pydevd_find_thread_by_id(thread_id) if t: if original_filename is not None: translated_filename = self.filename_to_server(original_filename) # Apply user path mapping. pydev_log.debug('Set next (after path translation) in: %s line: %s', translated_filename, line) func_name = self.to_str(func_name) assert translated_filename.__class__ == str # i.e.: bytes on py2 and str on py3 assert func_name.__class__ == str # i.e.: bytes on py2 and str on py3 # Apply source mapping (i.e.: ipython). _source_mapped_filename, new_line, multi_mapping_applied = py_db.source_mapping.map_to_server( translated_filename, line) if multi_mapping_applied: pydev_log.debug('Set next (after source mapping) in: %s line: %s', translated_filename, line) line = new_line int_cmd = InternalSetNextStatementThread(thread_id, set_next_cmd_id, line, func_name, seq=seq) py_db.post_internal_command(int_cmd, thread_id) elif thread_id.startswith('__frame__:'): sys.stderr.write("Can't set next statement in tasklet: %s\n" % (thread_id,)) def request_reload_code(self, py_db, seq, module_name, filename): ''' :param seq: if -1 no message will be sent back when the reload is done. Note: either module_name or filename may be None (but not both at the same time). ''' thread_id = '*' # Any thread # Note: not going for the main thread because in this case it'd only do the load # when we stopped on a breakpoint. py_db.post_method_as_internal_command( thread_id, internal_reload_code, seq, module_name, filename) def request_change_variable(self, py_db, seq, thread_id, frame_id, scope, attr, value): ''' :param scope: 'FRAME' or 'GLOBAL' ''' py_db.post_method_as_internal_command( thread_id, internal_change_variable, seq, thread_id, frame_id, scope, attr, value) def request_get_variable(self, py_db, seq, thread_id, frame_id, scope, attrs): ''' :param scope: 'FRAME' or 'GLOBAL' ''' int_cmd = InternalGetVariable(seq, thread_id, frame_id, scope, attrs) py_db.post_internal_command(int_cmd, thread_id) def request_get_array(self, py_db, seq, roffset, coffset, rows, cols, fmt, thread_id, frame_id, scope, attrs): int_cmd = InternalGetArray(seq, roffset, coffset, rows, cols, fmt, thread_id, frame_id, scope, attrs) py_db.post_internal_command(int_cmd, thread_id) def request_load_full_value(self, py_db, seq, thread_id, frame_id, vars): int_cmd = InternalLoadFullValue(seq, thread_id, frame_id, vars) py_db.post_internal_command(int_cmd, thread_id) def request_get_description(self, py_db, seq, thread_id, frame_id, expression): py_db.post_method_as_internal_command( thread_id, internal_get_description, seq, thread_id, frame_id, expression) def request_get_frame(self, py_db, seq, thread_id, frame_id): py_db.post_method_as_internal_command( thread_id, internal_get_frame, seq, thread_id, frame_id) def to_str(self, s): ''' -- in py3 raises an error if it's not str already. ''' if s.__class__ != str: raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (s, s.__class__)) return s def filename_to_str(self, filename): ''' -- in py3 raises an error if it's not str already. ''' if filename.__class__ != str: raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (filename, filename.__class__)) return filename def filename_to_server(self, filename): filename = self.filename_to_str(filename) filename = pydevd_file_utils.map_file_to_server(filename) return filename class _DummyFrame(object): ''' Dummy frame to be used with PyDB.apply_files_filter (as we don't really have the related frame as breakpoints are added before execution). ''' class _DummyCode(object): def __init__(self, filename): self.co_firstlineno = 1 self.co_filename = filename self.co_name = 'invalid func name ' def __init__(self, filename): self.f_code = self._DummyCode(filename) self.f_globals = {} ADD_BREAKPOINT_NO_ERROR = 0 ADD_BREAKPOINT_FILE_NOT_FOUND = 1 ADD_BREAKPOINT_FILE_EXCLUDED_BY_FILTERS = 2 # This means that the breakpoint couldn't be fully validated (more runtime # information may be needed). ADD_BREAKPOINT_LAZY_VALIDATION = 3 ADD_BREAKPOINT_INVALID_LINE = 4 class _AddBreakpointResult(object): # :see: ADD_BREAKPOINT_NO_ERROR = 0 # :see: ADD_BREAKPOINT_FILE_NOT_FOUND = 1 # :see: ADD_BREAKPOINT_FILE_EXCLUDED_BY_FILTERS = 2 # :see: ADD_BREAKPOINT_LAZY_VALIDATION = 3 # :see: ADD_BREAKPOINT_INVALID_LINE = 4 __slots__ = ['error_code', 'breakpoint_id', 'translated_filename', 'translated_line', 'original_line'] def __init__(self, breakpoint_id, translated_filename, translated_line, original_line): self.error_code = PyDevdAPI.ADD_BREAKPOINT_NO_ERROR self.breakpoint_id = breakpoint_id self.translated_filename = translated_filename self.translated_line = translated_line self.original_line = original_line def add_breakpoint( self, py_db, original_filename, breakpoint_type, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint, adjust_line=False, on_changed_breakpoint_state=None): ''' :param str original_filename: Note: must be sent as it was received in the protocol. It may be translated in this function and its final value will be available in the returned _AddBreakpointResult. :param str breakpoint_type: One of: 'python-line', 'django-line', 'jinja2-line'. :param int breakpoint_id: :param int line: Note: it's possible that a new line was actually used. If that's the case its final value will be available in the returned _AddBreakpointResult. :param condition: Either None or the condition to activate the breakpoint. :param str func_name: If "None" (str), may hit in any context. Empty string will hit only top level. Any other value must match the scope of the method to be matched. :param str expression: None or the expression to be evaluated. :param suspend_policy: Either "NONE" (to suspend only the current thread when the breakpoint is hit) or "ALL" (to suspend all threads when a breakpoint is hit). :param str hit_condition: An expression where `@HIT@` will be replaced by the number of hits. i.e.: `@HIT@ == x` or `@HIT@ >= x` :param bool is_logpoint: If True and an expression is passed, pydevd will create an io message command with the result of the evaluation. :param bool adjust_line: If True, the breakpoint line should be adjusted if the current line doesn't really match an executable line (if possible). :param callable on_changed_breakpoint_state: This is called when something changed internally on the breakpoint after it was initially added (for instance, template file_to_line_to_breakpoints could be signaled as invalid initially and later when the related template is loaded, if the line is valid it could be marked as valid). The signature for the callback should be: on_changed_breakpoint_state(breakpoint_id: int, add_breakpoint_result: _AddBreakpointResult) Note that the add_breakpoint_result should not be modified by the callback (the implementation may internally reuse the same instance multiple times). :return _AddBreakpointResult: ''' assert original_filename.__class__ == str, 'Expected str, found: %s' % (original_filename.__class__,) # i.e.: bytes on py2 and str on py3 original_filename_normalized = pydevd_file_utils.normcase_from_client(original_filename) pydev_log.debug('Request for breakpoint in: %s line: %s', original_filename, line) original_line = line # Parameters to reapply breakpoint. api_add_breakpoint_params = (original_filename, breakpoint_type, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint) translated_filename = self.filename_to_server(original_filename) # Apply user path mapping. pydev_log.debug('Breakpoint (after path translation) in: %s line: %s', translated_filename, line) func_name = self.to_str(func_name) assert translated_filename.__class__ == str # i.e.: bytes on py2 and str on py3 assert func_name.__class__ == str # i.e.: bytes on py2 and str on py3 # Apply source mapping (i.e.: ipython). source_mapped_filename, new_line, multi_mapping_applied = py_db.source_mapping.map_to_server( translated_filename, line) if multi_mapping_applied: pydev_log.debug('Breakpoint (after source mapping) in: %s line: %s', source_mapped_filename, new_line) # Note that source mapping is internal and does not change the resulting filename nor line # (we want the outside world to see the line in the original file and not in the ipython # cell, otherwise the editor wouldn't be correct as the returned line is the line to # which the breakpoint will be moved in the editor). result = self._AddBreakpointResult(breakpoint_id, original_filename, line, original_line) # If a multi-mapping was applied, consider it the canonical / source mapped version (translated to ipython cell). translated_absolute_filename = source_mapped_filename canonical_normalized_filename = pydevd_file_utils.normcase(source_mapped_filename) line = new_line else: translated_absolute_filename = pydevd_file_utils.absolute_path(translated_filename) canonical_normalized_filename = pydevd_file_utils.canonical_normalized_path(translated_filename) if adjust_line and not translated_absolute_filename.startswith('<'): # Validate file_to_line_to_breakpoints and adjust their positions. try: lines = sorted(_get_code_lines(translated_absolute_filename)) except Exception: pass else: if line not in lines: # Adjust to the first preceding valid line. idx = bisect.bisect_left(lines, line) if idx > 0: line = lines[idx - 1] result = self._AddBreakpointResult(breakpoint_id, original_filename, line, original_line) py_db.api_received_breakpoints[(original_filename_normalized, breakpoint_id)] = (canonical_normalized_filename, api_add_breakpoint_params) if not translated_absolute_filename.startswith('<'): # Note: if a mapping pointed to a file starting with '<', don't validate. if not pydevd_file_utils.exists(translated_absolute_filename): result.error_code = self.ADD_BREAKPOINT_FILE_NOT_FOUND return result if ( py_db.is_files_filter_enabled and not py_db.get_require_module_for_filters() and py_db.apply_files_filter(self._DummyFrame(translated_absolute_filename), translated_absolute_filename, False) ): # Note that if `get_require_module_for_filters()` returns False, we don't do this check. # This is because we don't have the module name given a file at this point (in # runtime it's gotten from the frame.f_globals). # An option could be calculate it based on the filename and current sys.path, # but on some occasions that may be wrong (for instance with `__main__` or if # the user dynamically changes the PYTHONPATH). # Note: depending on the use-case, filters may be changed, so, keep on going and add the # breakpoint even with the error code. result.error_code = self.ADD_BREAKPOINT_FILE_EXCLUDED_BY_FILTERS if breakpoint_type == 'python-line': added_breakpoint = LineBreakpoint( breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition=hit_condition, is_logpoint=is_logpoint) file_to_line_to_breakpoints = py_db.breakpoints file_to_id_to_breakpoint = py_db.file_to_id_to_line_breakpoint supported_type = True else: add_plugin_breakpoint_result = None plugin = py_db.get_plugin_lazy_init() if plugin is not None: add_plugin_breakpoint_result = plugin.add_breakpoint( 'add_line_breakpoint', py_db, breakpoint_type, canonical_normalized_filename, breakpoint_id, line, condition, expression, func_name, hit_condition=hit_condition, is_logpoint=is_logpoint, add_breakpoint_result=result, on_changed_breakpoint_state=on_changed_breakpoint_state) if add_plugin_breakpoint_result is not None: supported_type = True added_breakpoint, file_to_line_to_breakpoints = add_plugin_breakpoint_result file_to_id_to_breakpoint = py_db.file_to_id_to_plugin_breakpoint else: supported_type = False if not supported_type: raise NameError(breakpoint_type) if DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS > 0: pydev_log.debug('Added breakpoint:%s - line:%s - func_name:%s\n', canonical_normalized_filename, line, func_name) if canonical_normalized_filename in file_to_id_to_breakpoint: id_to_pybreakpoint = file_to_id_to_breakpoint[canonical_normalized_filename] else: id_to_pybreakpoint = file_to_id_to_breakpoint[canonical_normalized_filename] = {} id_to_pybreakpoint[breakpoint_id] = added_breakpoint py_db.consolidate_breakpoints(canonical_normalized_filename, id_to_pybreakpoint, file_to_line_to_breakpoints) if py_db.plugin is not None: py_db.has_plugin_line_breaks = py_db.plugin.has_line_breaks() py_db.plugin.after_breakpoints_consolidated(py_db, canonical_normalized_filename, id_to_pybreakpoint, file_to_line_to_breakpoints) py_db.on_breakpoints_changed() return result def reapply_breakpoints(self, py_db): ''' Reapplies all the received breakpoints as they were received by the API (so, new translations are applied). ''' pydev_log.debug('Reapplying breakpoints.') values = list(py_db.api_received_breakpoints.values()) # Create a copy with items to reapply. self.remove_all_breakpoints(py_db, '*') for val in values: _new_filename, api_add_breakpoint_params = val self.add_breakpoint(py_db, *api_add_breakpoint_params) def remove_all_breakpoints(self, py_db, received_filename): ''' Removes all the breakpoints from a given file or from all files if received_filename == '*'. :param str received_filename: Note: must be sent as it was received in the protocol. It may be translated in this function. ''' assert received_filename.__class__ == str # i.e.: bytes on py2 and str on py3 changed = False lst = [ py_db.file_to_id_to_line_breakpoint, py_db.file_to_id_to_plugin_breakpoint, py_db.breakpoints ] if hasattr(py_db, 'django_breakpoints'): lst.append(py_db.django_breakpoints) if hasattr(py_db, 'jinja2_breakpoints'): lst.append(py_db.jinja2_breakpoints) if received_filename == '*': py_db.api_received_breakpoints.clear() for file_to_id_to_breakpoint in lst: if file_to_id_to_breakpoint: file_to_id_to_breakpoint.clear() changed = True else: received_filename_normalized = pydevd_file_utils.normcase_from_client(received_filename) items = list(py_db.api_received_breakpoints.items()) # Create a copy to remove items. translated_filenames = [] for key, val in items: original_filename_normalized, _breakpoint_id = key if original_filename_normalized == received_filename_normalized: canonical_normalized_filename, _api_add_breakpoint_params = val # Note: there can be actually 1:N mappings due to source mapping (i.e.: ipython). translated_filenames.append(canonical_normalized_filename) del py_db.api_received_breakpoints[key] for canonical_normalized_filename in translated_filenames: for file_to_id_to_breakpoint in lst: if canonical_normalized_filename in file_to_id_to_breakpoint: file_to_id_to_breakpoint.pop(canonical_normalized_filename, None) changed = True if changed: py_db.on_breakpoints_changed(removed=True) def remove_breakpoint(self, py_db, received_filename, breakpoint_type, breakpoint_id): ''' :param str received_filename: Note: must be sent as it was received in the protocol. It may be translated in this function. :param str breakpoint_type: One of: 'python-line', 'django-line', 'jinja2-line'. :param int breakpoint_id: ''' received_filename_normalized = pydevd_file_utils.normcase_from_client(received_filename) for key, val in list(py_db.api_received_breakpoints.items()): original_filename_normalized, existing_breakpoint_id = key _new_filename, _api_add_breakpoint_params = val if received_filename_normalized == original_filename_normalized and existing_breakpoint_id == breakpoint_id: del py_db.api_received_breakpoints[key] break else: pydev_log.info( 'Did not find breakpoint to remove: %s (breakpoint id: %s)', received_filename, breakpoint_id) file_to_id_to_breakpoint = None received_filename = self.filename_to_server(received_filename) canonical_normalized_filename = pydevd_file_utils.canonical_normalized_path(received_filename) if breakpoint_type == 'python-line': file_to_line_to_breakpoints = py_db.breakpoints file_to_id_to_breakpoint = py_db.file_to_id_to_line_breakpoint elif py_db.plugin is not None: result = py_db.plugin.get_breakpoints(py_db, breakpoint_type) if result is not None: file_to_id_to_breakpoint = py_db.file_to_id_to_plugin_breakpoint file_to_line_to_breakpoints = result if file_to_id_to_breakpoint is None: pydev_log.critical('Error removing breakpoint. Cannot handle breakpoint of type %s', breakpoint_type) else: try: id_to_pybreakpoint = file_to_id_to_breakpoint.get(canonical_normalized_filename, {}) if DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS > 0: existing = id_to_pybreakpoint[breakpoint_id] pydev_log.info('Removed breakpoint:%s - line:%s - func_name:%s (id: %s)\n' % ( canonical_normalized_filename, existing.line, existing.func_name.encode('utf-8'), breakpoint_id)) del id_to_pybreakpoint[breakpoint_id] py_db.consolidate_breakpoints(canonical_normalized_filename, id_to_pybreakpoint, file_to_line_to_breakpoints) if py_db.plugin is not None: py_db.has_plugin_line_breaks = py_db.plugin.has_line_breaks() py_db.plugin.after_breakpoints_consolidated(py_db, canonical_normalized_filename, id_to_pybreakpoint, file_to_line_to_breakpoints) except KeyError: pydev_log.info("Error removing breakpoint: Breakpoint id not found: %s id: %s. Available ids: %s\n", canonical_normalized_filename, breakpoint_id, list(id_to_pybreakpoint)) py_db.on_breakpoints_changed(removed=True) def set_function_breakpoints(self, py_db, function_breakpoints): function_breakpoint_name_to_breakpoint = {} for function_breakpoint in function_breakpoints: function_breakpoint_name_to_breakpoint[function_breakpoint.func_name] = function_breakpoint py_db.function_breakpoint_name_to_breakpoint = function_breakpoint_name_to_breakpoint py_db.on_breakpoints_changed() def request_exec_or_evaluate( self, py_db, seq, thread_id, frame_id, expression, is_exec, trim_if_too_big, attr_to_set_result): py_db.post_method_as_internal_command( thread_id, internal_evaluate_expression, seq, thread_id, frame_id, expression, is_exec, trim_if_too_big, attr_to_set_result) def request_exec_or_evaluate_json( self, py_db, request, thread_id): py_db.post_method_as_internal_command( thread_id, internal_evaluate_expression_json, request, thread_id) def request_set_expression_json(self, py_db, request, thread_id): py_db.post_method_as_internal_command( thread_id, internal_set_expression_json, request, thread_id) def request_console_exec(self, py_db, seq, thread_id, frame_id, expression): int_cmd = InternalConsoleExec(seq, thread_id, frame_id, expression) py_db.post_internal_command(int_cmd, thread_id) def request_load_source(self, py_db, seq, filename): ''' :param str filename: Note: must be sent as it was received in the protocol. It may be translated in this function. ''' try: filename = self.filename_to_server(filename) assert filename.__class__ == str # i.e.: bytes on py2 and str on py3 with tokenize.open(filename) as stream: source = stream.read() cmd = py_db.cmd_factory.make_load_source_message(seq, source) except: cmd = py_db.cmd_factory.make_error_message(seq, get_exception_traceback_str()) py_db.writer.add_command(cmd) def get_decompiled_source_from_frame_id(self, py_db, frame_id): ''' :param py_db: :param frame_id: :throws Exception: If unable to get the frame in the currently paused frames or if some error happened when decompiling. ''' variable = py_db.suspended_frames_manager.get_variable(int(frame_id)) frame = variable.value # Check if it's in the linecache first. lines = (linecache.getline(frame.f_code.co_filename, i) for i in itertools.count(1)) lines = itertools.takewhile(bool, lines) # empty lines are '\n', EOF is '' source = ''.join(lines) if not source: source = code_to_bytecode_representation(frame.f_code) return source def request_load_source_from_frame_id(self, py_db, seq, frame_id): try: source = self.get_decompiled_source_from_frame_id(py_db, frame_id) cmd = py_db.cmd_factory.make_load_source_from_frame_id_message(seq, source) except: cmd = py_db.cmd_factory.make_error_message(seq, get_exception_traceback_str()) py_db.writer.add_command(cmd) def add_python_exception_breakpoint( self, py_db, exception, condition, expression, notify_on_handled_exceptions, notify_on_unhandled_exceptions, notify_on_user_unhandled_exceptions, notify_on_first_raise_only, ignore_libraries, ): exception_breakpoint = py_db.add_break_on_exception( exception, condition=condition, expression=expression, notify_on_handled_exceptions=notify_on_handled_exceptions, notify_on_unhandled_exceptions=notify_on_unhandled_exceptions, notify_on_user_unhandled_exceptions=notify_on_user_unhandled_exceptions, notify_on_first_raise_only=notify_on_first_raise_only, ignore_libraries=ignore_libraries, ) if exception_breakpoint is not None: py_db.on_breakpoints_changed() def add_plugins_exception_breakpoint(self, py_db, breakpoint_type, exception): supported_type = False plugin = py_db.get_plugin_lazy_init() if plugin is not None: supported_type = plugin.add_breakpoint('add_exception_breakpoint', py_db, breakpoint_type, exception) if supported_type: py_db.has_plugin_exception_breaks = py_db.plugin.has_exception_breaks() py_db.on_breakpoints_changed() else: raise NameError(breakpoint_type) def remove_python_exception_breakpoint(self, py_db, exception): try: cp = py_db.break_on_uncaught_exceptions.copy() cp.pop(exception, None) py_db.break_on_uncaught_exceptions = cp cp = py_db.break_on_caught_exceptions.copy() cp.pop(exception, None) py_db.break_on_caught_exceptions = cp cp = py_db.break_on_user_uncaught_exceptions.copy() cp.pop(exception, None) py_db.break_on_user_uncaught_exceptions = cp except: pydev_log.exception("Error while removing exception %s", sys.exc_info()[0]) py_db.on_breakpoints_changed(removed=True) def remove_plugins_exception_breakpoint(self, py_db, exception_type, exception): # I.e.: no need to initialize lazy (if we didn't have it in the first place, we can't remove # anything from it anyways). plugin = py_db.plugin if plugin is None: return supported_type = plugin.remove_exception_breakpoint(py_db, exception_type, exception) if supported_type: py_db.has_plugin_exception_breaks = py_db.plugin.has_exception_breaks() else: pydev_log.info('No exception of type: %s was previously registered.', exception_type) py_db.on_breakpoints_changed(removed=True) def remove_all_exception_breakpoints(self, py_db): py_db.break_on_uncaught_exceptions = {} py_db.break_on_caught_exceptions = {} py_db.break_on_user_uncaught_exceptions = {} plugin = py_db.plugin if plugin is not None: plugin.remove_all_exception_breakpoints(py_db) py_db.on_breakpoints_changed(removed=True) def set_project_roots(self, py_db, project_roots): ''' :param str project_roots: ''' py_db.set_project_roots(project_roots) def set_stepping_resumes_all_threads(self, py_db, stepping_resumes_all_threads): py_db.stepping_resumes_all_threads = stepping_resumes_all_threads # Add it to the namespace so that it's available as PyDevdAPI.ExcludeFilter from _pydevd_bundle.pydevd_filtering import ExcludeFilter # noqa def set_exclude_filters(self, py_db, exclude_filters): ''' :param list(PyDevdAPI.ExcludeFilter) exclude_filters: ''' py_db.set_exclude_filters(exclude_filters) def set_use_libraries_filter(self, py_db, use_libraries_filter): py_db.set_use_libraries_filter(use_libraries_filter) def request_get_variable_json(self, py_db, request, thread_id): ''' :param VariablesRequest request: ''' py_db.post_method_as_internal_command( thread_id, internal_get_variable_json, request) def request_change_variable_json(self, py_db, request, thread_id): ''' :param SetVariableRequest request: ''' py_db.post_method_as_internal_command( thread_id, internal_change_variable_json, request) def set_dont_trace_start_end_patterns(self, py_db, start_patterns, end_patterns): # Note: start/end patterns normalized internally. start_patterns = tuple(pydevd_file_utils.normcase(x) for x in start_patterns) end_patterns = tuple(pydevd_file_utils.normcase(x) for x in end_patterns) # After it's set the first time, we can still change it, but we need to reset the # related caches. reset_caches = False dont_trace_start_end_patterns_previously_set = \ py_db.dont_trace_external_files.__name__ == 'custom_dont_trace_external_files' if not dont_trace_start_end_patterns_previously_set and not start_patterns and not end_patterns: # If it wasn't set previously and start and end patterns are empty we don't need to do anything. return if not py_db.is_cache_file_type_empty(): # i.e.: custom function set in set_dont_trace_start_end_patterns. if dont_trace_start_end_patterns_previously_set: reset_caches = py_db.dont_trace_external_files.start_patterns != start_patterns or \ py_db.dont_trace_external_files.end_patterns != end_patterns else: reset_caches = True def custom_dont_trace_external_files(abs_path): normalized_abs_path = pydevd_file_utils.normcase(abs_path) return normalized_abs_path.startswith(start_patterns) or normalized_abs_path.endswith(end_patterns) custom_dont_trace_external_files.start_patterns = start_patterns custom_dont_trace_external_files.end_patterns = end_patterns py_db.dont_trace_external_files = custom_dont_trace_external_files if reset_caches: py_db.clear_dont_trace_start_end_patterns_caches() def stop_on_entry(self): main_thread = pydevd_utils.get_main_thread() if main_thread is None: pydev_log.critical('Could not find main thread while setting Stop on Entry.') else: info = set_additional_thread_info(main_thread) info.pydev_original_step_cmd = CMD_STOP_ON_START info.pydev_step_cmd = CMD_STEP_INTO_MY_CODE def set_ignore_system_exit_codes(self, py_db, ignore_system_exit_codes): py_db.set_ignore_system_exit_codes(ignore_system_exit_codes) SourceMappingEntry = pydevd_source_mapping.SourceMappingEntry def set_source_mapping(self, py_db, source_filename, mapping): ''' :param str source_filename: The filename for the source mapping (bytes on py2 and str on py3). This filename will be made absolute in this function. :param list(SourceMappingEntry) mapping: A list with the source mapping entries to be applied to the given filename. :return str: An error message if it was not possible to set the mapping or an empty string if everything is ok. ''' source_filename = self.filename_to_server(source_filename) absolute_source_filename = pydevd_file_utils.absolute_path(source_filename) for map_entry in mapping: map_entry.source_filename = absolute_source_filename error_msg = py_db.source_mapping.set_source_mapping(absolute_source_filename, mapping) if error_msg: return error_msg self.reapply_breakpoints(py_db) return '' def set_variable_presentation(self, py_db, variable_presentation): assert isinstance(variable_presentation, self.VariablePresentation) py_db.variable_presentation = variable_presentation def get_ppid(self): ''' Provides the parent pid (even for older versions of Python on Windows). ''' ppid = None try: ppid = os.getppid() except AttributeError: pass if ppid is None and IS_WINDOWS: ppid = self._get_windows_ppid() return ppid def _get_windows_ppid(self): this_pid = os.getpid() for ppid, pid in _list_ppid_and_pid(): if pid == this_pid: return ppid return None def _terminate_child_processes_windows(self, dont_terminate_child_pids): this_pid = os.getpid() for _ in range(50): # Try this at most 50 times before giving up. # Note: we can't kill the process itself with taskkill, so, we # list immediate children, kill that tree and then exit this process. children_pids = [] for ppid, pid in _list_ppid_and_pid(): if ppid == this_pid: if pid not in dont_terminate_child_pids: children_pids.append(pid) if not children_pids: break else: for pid in children_pids: self._call( ['taskkill', '/F', '/PID', str(pid), '/T'], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) del children_pids[:] def _terminate_child_processes_linux_and_mac(self, dont_terminate_child_pids): this_pid = os.getpid() def list_children_and_stop_forking(initial_pid, stop=True): children_pids = [] if stop: # Ask to stop forking (shouldn't be called for this process, only subprocesses). self._call( ['kill', '-STOP', str(initial_pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) list_popen = self._popen( ['pgrep', '-P', str(initial_pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) if list_popen is not None: stdout, _ = list_popen.communicate() for line in stdout.splitlines(): line = line.decode('ascii').strip() if line: pid = str(line) if pid in dont_terminate_child_pids: continue children_pids.append(pid) # Recursively get children. children_pids.extend(list_children_and_stop_forking(pid)) return children_pids previously_found = set() for _ in range(50): # Try this at most 50 times before giving up. children_pids = list_children_and_stop_forking(this_pid, stop=False) found_new = False for pid in children_pids: if pid not in previously_found: found_new = True previously_found.add(pid) self._call( ['kill', '-KILL', str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) if not found_new: break def _popen(self, cmdline, **kwargs): try: return subprocess.Popen(cmdline, **kwargs) except: if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1: pydev_log.exception('Error running: %s' % (' '.join(cmdline))) return None def _call(self, cmdline, **kwargs): try: subprocess.check_call(cmdline, **kwargs) except: if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1: pydev_log.exception('Error running: %s' % (' '.join(cmdline))) def set_terminate_child_processes(self, py_db, terminate_child_processes): py_db.terminate_child_processes = terminate_child_processes def terminate_process(self, py_db): ''' Terminates the current process (and child processes if the option to also terminate child processes is enabled). ''' try: if py_db.terminate_child_processes: pydev_log.debug('Terminating child processes.') if IS_WINDOWS: self._terminate_child_processes_windows(py_db.dont_terminate_child_pids) else: self._terminate_child_processes_linux_and_mac(py_db.dont_terminate_child_pids) finally: pydev_log.debug('Exiting process (os._exit(0)).') os._exit(0) def _terminate_if_commands_processed(self, py_db): py_db.dispose_and_kill_all_pydevd_threads() self.terminate_process(py_db) def request_terminate_process(self, py_db): # We mark with a terminate_requested to avoid that paused threads start running # (we should terminate as is without letting any paused thread run). py_db.terminate_requested = True run_as_pydevd_daemon_thread(py_db, self._terminate_if_commands_processed, py_db) def setup_auto_reload_watcher(self, py_db, enable_auto_reload, watch_dirs, poll_target_time, exclude_patterns, include_patterns): py_db.setup_auto_reload_watcher(enable_auto_reload, watch_dirs, poll_target_time, exclude_patterns, include_patterns) def _list_ppid_and_pid(): _TH32CS_SNAPPROCESS = 0x00000002 class PROCESSENTRY32(ctypes.Structure): _fields_ = [("dwSize", ctypes.c_uint32), ("cntUsage", ctypes.c_uint32), ("th32ProcessID", ctypes.c_uint32), ("th32DefaultHeapID", ctypes.c_size_t), ("th32ModuleID", ctypes.c_uint32), ("cntThreads", ctypes.c_uint32), ("th32ParentProcessID", ctypes.c_uint32), ("pcPriClassBase", ctypes.c_long), ("dwFlags", ctypes.c_uint32), ("szExeFile", ctypes.c_char * 260)] kernel32 = ctypes.windll.kernel32 snapshot = kernel32.CreateToolhelp32Snapshot(_TH32CS_SNAPPROCESS, 0) ppid_and_pids = [] try: process_entry = PROCESSENTRY32() process_entry.dwSize = ctypes.sizeof(PROCESSENTRY32) if not kernel32.Process32First(ctypes.c_void_p(snapshot), ctypes.byref(process_entry)): pydev_log.critical('Process32First failed (getting process from CreateToolhelp32Snapshot).') else: while True: ppid_and_pids.append((process_entry.th32ParentProcessID, process_entry.th32ProcessID)) if not kernel32.Process32Next(ctypes.c_void_p(snapshot), ctypes.byref(process_entry)): break finally: kernel32.CloseHandle(snapshot) return ppid_and_pids
50,385
Python
43.120841
150
0.617684
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_collect_bytecode_info.py
import dis import inspect import sys from collections import namedtuple from _pydev_bundle import pydev_log from opcode import (EXTENDED_ARG, HAVE_ARGUMENT, cmp_op, hascompare, hasconst, hasfree, hasjrel, haslocal, hasname, opname) from io import StringIO class TryExceptInfo(object): def __init__(self, try_line, ignore=False): ''' :param try_line: :param ignore: Usually we should ignore any block that's not a try..except (this can happen for finally blocks, with statements, etc, for which we create temporary entries). ''' self.try_line = try_line self.ignore = ignore self.except_line = -1 self.except_end_line = -1 self.raise_lines_in_except = [] # Note: these may not be available if generated from source instead of bytecode. self.except_bytecode_offset = -1 self.except_end_bytecode_offset = -1 def is_line_in_try_block(self, line): return self.try_line <= line < self.except_line def is_line_in_except_block(self, line): return self.except_line <= line <= self.except_end_line def __str__(self): lst = [ '{try:', str(self.try_line), ' except ', str(self.except_line), ' end block ', str(self.except_end_line), ] if self.raise_lines_in_except: lst.append(' raises: %s' % (', '.join(str(x) for x in self.raise_lines_in_except),)) lst.append('}') return ''.join(lst) __repr__ = __str__ class ReturnInfo(object): def __init__(self, return_line): self.return_line = return_line def __str__(self): return '{return: %s}' % (self.return_line,) __repr__ = __str__ def _get_line(op_offset_to_line, op_offset, firstlineno, search=False): op_offset_original = op_offset while op_offset >= 0: ret = op_offset_to_line.get(op_offset) if ret is not None: return ret - firstlineno if not search: return ret else: op_offset -= 1 raise AssertionError('Unable to find line for offset: %s.Info: %s' % ( op_offset_original, op_offset_to_line)) def debug(s): pass _Instruction = namedtuple('_Instruction', 'opname, opcode, starts_line, argval, is_jump_target, offset, argrepr') def _iter_as_bytecode_as_instructions_py2(co): code = co.co_code op_offset_to_line = dict(dis.findlinestarts(co)) labels = set(dis.findlabels(code)) bytecode_len = len(code) i = 0 extended_arg = 0 free = None op_to_name = opname while i < bytecode_len: c = code[i] op = ord(c) is_jump_target = i in labels curr_op_name = op_to_name[op] initial_bytecode_offset = i i = i + 1 if op < HAVE_ARGUMENT: yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), None, is_jump_target, initial_bytecode_offset, '') else: oparg = ord(code[i]) + ord(code[i + 1]) * 256 + extended_arg extended_arg = 0 i = i + 2 if op == EXTENDED_ARG: extended_arg = oparg * 65536 if op in hasconst: yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), co.co_consts[oparg], is_jump_target, initial_bytecode_offset, repr(co.co_consts[oparg])) elif op in hasname: yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), co.co_names[oparg], is_jump_target, initial_bytecode_offset, str(co.co_names[oparg])) elif op in hasjrel: argval = i + oparg yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), argval, is_jump_target, initial_bytecode_offset, "to " + repr(argval)) elif op in haslocal: yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), co.co_varnames[oparg], is_jump_target, initial_bytecode_offset, str(co.co_varnames[oparg])) elif op in hascompare: yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), cmp_op[oparg], is_jump_target, initial_bytecode_offset, cmp_op[oparg]) elif op in hasfree: if free is None: free = co.co_cellvars + co.co_freevars yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), free[oparg], is_jump_target, initial_bytecode_offset, str(free[oparg])) else: yield _Instruction(curr_op_name, op, _get_line(op_offset_to_line, initial_bytecode_offset, 0), oparg, is_jump_target, initial_bytecode_offset, str(oparg)) def iter_instructions(co): if sys.version_info[0] < 3: iter_in = _iter_as_bytecode_as_instructions_py2(co) else: iter_in = dis.Bytecode(co) iter_in = list(iter_in) bytecode_to_instruction = {} for instruction in iter_in: bytecode_to_instruction[instruction.offset] = instruction if iter_in: for instruction in iter_in: yield instruction def collect_return_info(co, use_func_first_line=False): if not hasattr(co, 'co_lnotab'): return [] if use_func_first_line: firstlineno = co.co_firstlineno else: firstlineno = 0 lst = [] op_offset_to_line = dict(dis.findlinestarts(co)) for instruction in iter_instructions(co): curr_op_name = instruction.opname if curr_op_name == 'RETURN_VALUE': lst.append(ReturnInfo(_get_line(op_offset_to_line, instruction.offset, firstlineno, search=True))) return lst if sys.version_info[:2] <= (3, 9): class _TargetInfo(object): def __init__(self, except_end_instruction, jump_if_not_exc_instruction=None): self.except_end_instruction = except_end_instruction self.jump_if_not_exc_instruction = jump_if_not_exc_instruction def __str__(self): msg = ['_TargetInfo('] msg.append(self.except_end_instruction.opname) if self.jump_if_not_exc_instruction: msg.append(' - ') msg.append(self.jump_if_not_exc_instruction.opname) msg.append('(') msg.append(str(self.jump_if_not_exc_instruction.argval)) msg.append(')') msg.append(')') return ''.join(msg) def _get_except_target_info(instructions, exception_end_instruction_index, offset_to_instruction_idx): next_3 = [j_instruction.opname for j_instruction in instructions[exception_end_instruction_index:exception_end_instruction_index + 3]] # print('next_3:', [(j_instruction.opname, j_instruction.argval) for j_instruction in instructions[exception_end_instruction_index:exception_end_instruction_index + 3]]) if next_3 == ['POP_TOP', 'POP_TOP', 'POP_TOP']: # try..except without checking exception. try: jump_instruction = instructions[exception_end_instruction_index - 1] if jump_instruction.opname not in ('JUMP_FORWARD', 'JUMP_ABSOLUTE'): return None except IndexError: pass if jump_instruction.opname == 'JUMP_ABSOLUTE': # On latest versions of Python 3 the interpreter has a go-backwards step, # used to show the initial line of a for/while, etc (which is this # JUMP_ABSOLUTE)... we're not really interested in it, but rather on where # it points to. except_end_instruction = instructions[offset_to_instruction_idx[jump_instruction.argval]] idx = offset_to_instruction_idx[except_end_instruction.argval] # Search for the POP_EXCEPT which should be at the end of the block. for pop_except_instruction in reversed(instructions[:idx]): if pop_except_instruction.opname == 'POP_EXCEPT': except_end_instruction = pop_except_instruction return _TargetInfo(except_end_instruction) else: return None # i.e.: Continue outer loop else: # JUMP_FORWARD i = offset_to_instruction_idx[jump_instruction.argval] try: # i.e.: the jump is to the instruction after the block finishes (so, we need to # get the previous instruction as that should be the place where the exception # block finishes). except_end_instruction = instructions[i - 1] except: pydev_log.critical('Error when computing try..except block end.') return None return _TargetInfo(except_end_instruction) elif next_3 and next_3[0] == 'DUP_TOP': # try..except AssertionError. iter_in = instructions[exception_end_instruction_index + 1:] for j, jump_if_not_exc_instruction in enumerate(iter_in): if jump_if_not_exc_instruction.opname == 'JUMP_IF_NOT_EXC_MATCH': # Python 3.9 except_end_instruction = instructions[offset_to_instruction_idx[jump_if_not_exc_instruction.argval]] return _TargetInfo(except_end_instruction, jump_if_not_exc_instruction) elif jump_if_not_exc_instruction.opname == 'COMPARE_OP' and jump_if_not_exc_instruction.argval == 'exception match': # Python 3.8 and before try: next_instruction = iter_in[j + 1] except: continue if next_instruction.opname == 'POP_JUMP_IF_FALSE': except_end_instruction = instructions[offset_to_instruction_idx[next_instruction.argval]] return _TargetInfo(except_end_instruction, next_instruction) else: return None # i.e.: Continue outer loop else: # i.e.: we're not interested in try..finally statements, only try..except. return None def collect_try_except_info(co, use_func_first_line=False): # We no longer have 'END_FINALLY', so, we need to do things differently in Python 3.9 if not hasattr(co, 'co_lnotab'): return [] if use_func_first_line: firstlineno = co.co_firstlineno else: firstlineno = 0 try_except_info_lst = [] op_offset_to_line = dict(dis.findlinestarts(co)) offset_to_instruction_idx = {} instructions = list(iter_instructions(co)) for i, instruction in enumerate(instructions): offset_to_instruction_idx[instruction.offset] = i for i, instruction in enumerate(instructions): curr_op_name = instruction.opname if curr_op_name in ('SETUP_FINALLY', 'SETUP_EXCEPT'): # SETUP_EXCEPT before Python 3.8, SETUP_FINALLY Python 3.8 onwards. exception_end_instruction_index = offset_to_instruction_idx[instruction.argval] jump_instruction = instructions[exception_end_instruction_index - 1] if jump_instruction.opname not in ('JUMP_FORWARD', 'JUMP_ABSOLUTE'): continue except_end_instruction = None indexes_checked = set() indexes_checked.add(exception_end_instruction_index) target_info = _get_except_target_info(instructions, exception_end_instruction_index, offset_to_instruction_idx) while target_info is not None: # Handle a try..except..except..except. jump_instruction = target_info.jump_if_not_exc_instruction except_end_instruction = target_info.except_end_instruction if jump_instruction is not None: check_index = offset_to_instruction_idx[jump_instruction.argval] if check_index in indexes_checked: break indexes_checked.add(check_index) target_info = _get_except_target_info(instructions, check_index, offset_to_instruction_idx) else: break if except_end_instruction is not None: try_except_info = TryExceptInfo( _get_line(op_offset_to_line, instruction.offset, firstlineno, search=True), ignore=False ) try_except_info.except_bytecode_offset = instruction.argval try_except_info.except_line = _get_line( op_offset_to_line, try_except_info.except_bytecode_offset, firstlineno, search=True ) try_except_info.except_end_bytecode_offset = except_end_instruction.offset try_except_info.except_end_line = _get_line(op_offset_to_line, except_end_instruction.offset, firstlineno, search=True) try_except_info_lst.append(try_except_info) for raise_instruction in instructions[i:offset_to_instruction_idx[try_except_info.except_end_bytecode_offset]]: if raise_instruction.opname == 'RAISE_VARARGS': if raise_instruction.argval == 0: try_except_info.raise_lines_in_except.append( _get_line(op_offset_to_line, raise_instruction.offset, firstlineno, search=True)) return try_except_info_lst elif sys.version_info[:2] == (3, 10): class _TargetInfo(object): def __init__(self, except_end_instruction, jump_if_not_exc_instruction=None): self.except_end_instruction = except_end_instruction self.jump_if_not_exc_instruction = jump_if_not_exc_instruction def __str__(self): msg = ['_TargetInfo('] msg.append(self.except_end_instruction.opname) if self.jump_if_not_exc_instruction: msg.append(' - ') msg.append(self.jump_if_not_exc_instruction.opname) msg.append('(') msg.append(str(self.jump_if_not_exc_instruction.argval)) msg.append(')') msg.append(')') return ''.join(msg) def _get_except_target_info(instructions, exception_end_instruction_index, offset_to_instruction_idx): next_3 = [j_instruction.opname for j_instruction in instructions[exception_end_instruction_index:exception_end_instruction_index + 3]] # print('next_3:', [(j_instruction.opname, j_instruction.argval) for j_instruction in instructions[exception_end_instruction_index:exception_end_instruction_index + 3]]) if next_3 == ['POP_TOP', 'POP_TOP', 'POP_TOP']: # try..except without checking exception. # Previously there was a jump which was able to point where the exception would end. This # is no longer true, now a bare except doesn't really have any indication in the bytecode # where the end would be expected if the exception wasn't raised, so, we just blindly # search for a POP_EXCEPT from the current position. for pop_except_instruction in instructions[exception_end_instruction_index + 3:]: if pop_except_instruction.opname == 'POP_EXCEPT': except_end_instruction = pop_except_instruction return _TargetInfo(except_end_instruction) elif next_3 and next_3[0] == 'DUP_TOP': # try..except AssertionError. iter_in = instructions[exception_end_instruction_index + 1:] for jump_if_not_exc_instruction in iter_in: if jump_if_not_exc_instruction.opname == 'JUMP_IF_NOT_EXC_MATCH': # Python 3.9 except_end_instruction = instructions[offset_to_instruction_idx[jump_if_not_exc_instruction.argval]] return _TargetInfo(except_end_instruction, jump_if_not_exc_instruction) else: return None # i.e.: Continue outer loop else: # i.e.: we're not interested in try..finally statements, only try..except. return None def collect_try_except_info(co, use_func_first_line=False): # We no longer have 'END_FINALLY', so, we need to do things differently in Python 3.9 if not hasattr(co, 'co_lnotab'): return [] if use_func_first_line: firstlineno = co.co_firstlineno else: firstlineno = 0 try_except_info_lst = [] op_offset_to_line = dict(dis.findlinestarts(co)) offset_to_instruction_idx = {} instructions = list(iter_instructions(co)) for i, instruction in enumerate(instructions): offset_to_instruction_idx[instruction.offset] = i for i, instruction in enumerate(instructions): curr_op_name = instruction.opname if curr_op_name == 'SETUP_FINALLY': exception_end_instruction_index = offset_to_instruction_idx[instruction.argval] jump_instruction = instructions[exception_end_instruction_index] if jump_instruction.opname != 'DUP_TOP': continue except_end_instruction = None indexes_checked = set() indexes_checked.add(exception_end_instruction_index) target_info = _get_except_target_info(instructions, exception_end_instruction_index, offset_to_instruction_idx) while target_info is not None: # Handle a try..except..except..except. jump_instruction = target_info.jump_if_not_exc_instruction except_end_instruction = target_info.except_end_instruction if jump_instruction is not None: check_index = offset_to_instruction_idx[jump_instruction.argval] if check_index in indexes_checked: break indexes_checked.add(check_index) target_info = _get_except_target_info(instructions, check_index, offset_to_instruction_idx) else: break if except_end_instruction is not None: try_except_info = TryExceptInfo( _get_line(op_offset_to_line, instruction.offset, firstlineno, search=True), ignore=False ) try_except_info.except_bytecode_offset = instruction.argval try_except_info.except_line = _get_line( op_offset_to_line, try_except_info.except_bytecode_offset, firstlineno, search=True ) try_except_info.except_end_bytecode_offset = except_end_instruction.offset # On Python 3.10 the final line of the except end isn't really correct, rather, # it's engineered to be the same line of the except and not the end line of the # block, so, the approach taken is to search for the biggest line between the # except and the end instruction except_end_line = -1 start_i = offset_to_instruction_idx[try_except_info.except_bytecode_offset] end_i = offset_to_instruction_idx[except_end_instruction.offset] for instruction in instructions[start_i: end_i + 1]: found_at_line = op_offset_to_line.get(instruction.offset) if found_at_line is not None and found_at_line > except_end_line: except_end_line = found_at_line try_except_info.except_end_line = except_end_line - firstlineno try_except_info_lst.append(try_except_info) for raise_instruction in instructions[i:offset_to_instruction_idx[try_except_info.except_end_bytecode_offset]]: if raise_instruction.opname == 'RAISE_VARARGS': if raise_instruction.argval == 0: try_except_info.raise_lines_in_except.append( _get_line(op_offset_to_line, raise_instruction.offset, firstlineno, search=True)) return try_except_info_lst elif sys.version_info[:2] >= (3, 11): def collect_try_except_info(co, use_func_first_line=False): ''' Note: if the filename is available and we can get the source, `collect_try_except_info_from_source` is preferred (this is kept as a fallback for cases where sources aren't available). ''' return [] import ast as ast_module class _Visitor(ast_module.NodeVisitor): def __init__(self): self.try_except_infos = [] self._stack = [] self._in_except_stack = [] self.max_line = -1 def generic_visit(self, node): if hasattr(node, 'lineno'): if node.lineno > self.max_line: self.max_line = node.lineno return ast_module.NodeVisitor.generic_visit(self, node) def visit_Try(self, node): info = TryExceptInfo(node.lineno, ignore=True) self._stack.append(info) self.generic_visit(node) assert info is self._stack.pop() if not info.ignore: self.try_except_infos.insert(0, info) if sys.version_info[0] < 3: visit_TryExcept = visit_Try def visit_ExceptHandler(self, node): info = self._stack[-1] info.ignore = False if info.except_line == -1: info.except_line = node.lineno self._in_except_stack.append(info) self.generic_visit(node) if hasattr(node, 'end_lineno'): info.except_end_line = node.end_lineno else: info.except_end_line = self.max_line self._in_except_stack.pop() if sys.version_info[0] >= 3: def visit_Raise(self, node): for info in self._in_except_stack: if node.exc is None: info.raise_lines_in_except.append(node.lineno) self.generic_visit(node) else: def visit_Raise(self, node): for info in self._in_except_stack: if node.type is None and node.tback is None: info.raise_lines_in_except.append(node.lineno) self.generic_visit(node) def collect_try_except_info_from_source(filename): with open(filename, 'rb') as stream: contents = stream.read() return collect_try_except_info_from_contents(contents, filename) def collect_try_except_info_from_contents(contents, filename='<unknown>'): ast = ast_module.parse(contents, filename) visitor = _Visitor() visitor.visit(ast) return visitor.try_except_infos RESTART_FROM_LOOKAHEAD = object() SEPARATOR = object() class _MsgPart(object): def __init__(self, line, tok): assert line >= 0 self.line = line self.tok = tok @classmethod def add_to_line_to_contents(cls, obj, line_to_contents, line=None): if isinstance(obj, (list, tuple)): for o in obj: cls.add_to_line_to_contents(o, line_to_contents, line=line) return if isinstance(obj, str): assert line is not None line = int(line) lst = line_to_contents.setdefault(line, []) lst.append(obj) return if isinstance(obj, _MsgPart): if isinstance(obj.tok, (list, tuple)): cls.add_to_line_to_contents(obj.tok, line_to_contents, line=obj.line) return if isinstance(obj.tok, str): lst = line_to_contents.setdefault(obj.line, []) lst.append(obj.tok) return raise AssertionError("Unhandled: %" % (obj,)) class _Disassembler(object): def __init__(self, co, firstlineno, level=0): self.co = co self.firstlineno = firstlineno self.level = level self.instructions = list(iter_instructions(co)) op_offset_to_line = self.op_offset_to_line = dict(dis.findlinestarts(co)) # Update offsets so that all offsets have the line index (and update it based on # the passed firstlineno). line_index = co.co_firstlineno - firstlineno for instruction in self.instructions: new_line_index = op_offset_to_line.get(instruction.offset) if new_line_index is not None: line_index = new_line_index - firstlineno op_offset_to_line[instruction.offset] = line_index else: op_offset_to_line[instruction.offset] = line_index BIG_LINE_INT = 9999999 SMALL_LINE_INT = -1 def min_line(self, *args): m = self.BIG_LINE_INT for arg in args: if isinstance(arg, (list, tuple)): m = min(m, self.min_line(*arg)) elif isinstance(arg, _MsgPart): m = min(m, arg.line) elif hasattr(arg, 'offset'): m = min(m, self.op_offset_to_line[arg.offset]) return m def max_line(self, *args): m = self.SMALL_LINE_INT for arg in args: if isinstance(arg, (list, tuple)): m = max(m, self.max_line(*arg)) elif isinstance(arg, _MsgPart): m = max(m, arg.line) elif hasattr(arg, 'offset'): m = max(m, self.op_offset_to_line[arg.offset]) return m def _lookahead(self): ''' This handles and converts some common constructs from bytecode to actual source code. It may change the list of instructions. ''' msg = self._create_msg_part found = [] fullrepr = None # Collect all the load instructions for next_instruction in self.instructions: if next_instruction.opname in ('LOAD_GLOBAL', 'LOAD_FAST', 'LOAD_CONST', 'LOAD_NAME'): found.append(next_instruction) else: break if not found: return None if next_instruction.opname == 'LOAD_ATTR': prev_instruction = found[-1] # Remove the current LOAD_ATTR assert self.instructions.pop(len(found)) is next_instruction # Add the LOAD_ATTR to the previous LOAD self.instructions[len(found) - 1] = _Instruction( prev_instruction.opname, prev_instruction.opcode, prev_instruction.starts_line, prev_instruction.argval, False, # prev_instruction.is_jump_target, prev_instruction.offset, ( msg(prev_instruction), msg(prev_instruction, '.'), msg(next_instruction) ), ) return RESTART_FROM_LOOKAHEAD if next_instruction.opname in ('CALL_FUNCTION', 'PRECALL'): if len(found) == next_instruction.argval + 1: force_restart = False delta = 0 else: force_restart = True if len(found) > next_instruction.argval + 1: delta = len(found) - (next_instruction.argval + 1) else: return None # This is odd del_upto = delta + next_instruction.argval + 2 # +2 = NAME / CALL_FUNCTION if next_instruction.opname == 'PRECALL': del_upto += 1 # Also remove the CALL right after the PRECALL. del self.instructions[delta:del_upto] found = iter(found[delta:]) call_func = next(found) args = list(found) fullrepr = [ msg(call_func), msg(call_func, '('), ] prev = call_func for i, arg in enumerate(args): if i > 0: fullrepr.append(msg(prev, ', ')) prev = arg fullrepr.append(msg(arg)) fullrepr.append(msg(prev, ')')) if force_restart: self.instructions.insert(delta, _Instruction( call_func.opname, call_func.opcode, call_func.starts_line, call_func.argval, False, # call_func.is_jump_target, call_func.offset, tuple(fullrepr), )) return RESTART_FROM_LOOKAHEAD elif next_instruction.opname == 'BUILD_TUPLE': if len(found) == next_instruction.argval: force_restart = False delta = 0 else: force_restart = True if len(found) > next_instruction.argval: delta = len(found) - (next_instruction.argval) else: return None # This is odd del self.instructions[delta:delta + next_instruction.argval + 1] # +1 = BUILD_TUPLE found = iter(found[delta:]) args = [instruction for instruction in found] if args: first_instruction = args[0] else: first_instruction = next_instruction prev = first_instruction fullrepr = [] fullrepr.append(msg(prev, '(')) for i, arg in enumerate(args): if i > 0: fullrepr.append(msg(prev, ', ')) prev = arg fullrepr.append(msg(arg)) fullrepr.append(msg(prev, ')')) if force_restart: self.instructions.insert(delta, _Instruction( first_instruction.opname, first_instruction.opcode, first_instruction.starts_line, first_instruction.argval, False, # first_instruction.is_jump_target, first_instruction.offset, tuple(fullrepr), )) return RESTART_FROM_LOOKAHEAD if fullrepr is not None and self.instructions: if self.instructions[0].opname == 'POP_TOP': self.instructions.pop(0) if self.instructions[0].opname in ('STORE_FAST', 'STORE_NAME'): next_instruction = self.instructions.pop(0) return msg(next_instruction), msg(next_instruction, ' = '), fullrepr if self.instructions[0].opname == 'RETURN_VALUE': next_instruction = self.instructions.pop(0) return msg(next_instruction, 'return ', line=self.min_line(next_instruction, fullrepr)), fullrepr return fullrepr def _decorate_jump_target(self, instruction, instruction_repr): if instruction.is_jump_target: return ('|', str(instruction.offset), '|', instruction_repr) return instruction_repr def _create_msg_part(self, instruction, tok=None, line=None): dec = self._decorate_jump_target if line is None or line in (self.BIG_LINE_INT, self.SMALL_LINE_INT): line = self.op_offset_to_line[instruction.offset] argrepr = instruction.argrepr if isinstance(argrepr, str) and argrepr.startswith('NULL + '): argrepr = argrepr[7:] return _MsgPart( line, tok if tok is not None else dec(instruction, argrepr)) def _next_instruction_to_str(self, line_to_contents): # indent = '' # if self.level > 0: # indent += ' ' * self.level # print(indent, 'handle', self.instructions[0]) if self.instructions: ret = self._lookahead() if ret: return ret msg = self._create_msg_part instruction = self.instructions.pop(0) if instruction.opname in 'RESUME': return None if instruction.opname in ('LOAD_GLOBAL', 'LOAD_FAST', 'LOAD_CONST', 'LOAD_NAME'): next_instruction = self.instructions[0] if next_instruction.opname in ('STORE_FAST', 'STORE_NAME'): self.instructions.pop(0) return ( msg(next_instruction), msg(next_instruction, ' = '), msg(instruction)) if next_instruction.opname == 'RETURN_VALUE': self.instructions.pop(0) return (msg(instruction, 'return ', line=self.min_line(instruction)), msg(instruction)) if next_instruction.opname == 'RAISE_VARARGS' and next_instruction.argval == 1: self.instructions.pop(0) return (msg(instruction, 'raise ', line=self.min_line(instruction)), msg(instruction)) if instruction.opname == 'LOAD_CONST': if inspect.iscode(instruction.argval): code_line_to_contents = _Disassembler( instruction.argval, self.firstlineno, self.level + 1 ).build_line_to_contents() for contents in code_line_to_contents.values(): contents.insert(0, ' ') for line, contents in code_line_to_contents.items(): line_to_contents.setdefault(line, []).extend(contents) return msg(instruction, 'LOAD_CONST(code)') if instruction.opname == 'RAISE_VARARGS': if instruction.argval == 0: return msg(instruction, 'raise') if instruction.opname == 'SETUP_FINALLY': return msg(instruction, ('try(', instruction.argrepr, '):')) if instruction.argrepr: return msg(instruction, (instruction.opname, '(', instruction.argrepr, ')')) if instruction.argval: return msg(instruction, '%s{%s}' % (instruction.opname, instruction.argval,)) return msg(instruction, instruction.opname) def build_line_to_contents(self): # print('----') # for instruction in self.instructions: # print(instruction) # print('----\n\n') line_to_contents = {} instructions = self.instructions while instructions: s = self._next_instruction_to_str(line_to_contents) if s is RESTART_FROM_LOOKAHEAD: continue if s is None: continue _MsgPart.add_to_line_to_contents(s, line_to_contents) m = self.max_line(s) if m != self.SMALL_LINE_INT: line_to_contents.setdefault(m, []).append(SEPARATOR) return line_to_contents def disassemble(self): line_to_contents = self.build_line_to_contents() stream = StringIO() last_line = 0 show_lines = False for line, contents in sorted(line_to_contents.items()): while last_line < line - 1: if show_lines: stream.write('%s.\n' % (last_line + 1,)) else: stream.write('\n') last_line += 1 if show_lines: stream.write('%s. ' % (line,)) for i, content in enumerate(contents): if content == SEPARATOR: if i != len(contents) - 1: stream.write(', ') else: stream.write(content) stream.write('\n') last_line = line return stream.getvalue() def code_to_bytecode_representation(co, use_func_first_line=False): ''' A simple disassemble of bytecode. It does not attempt to provide the full Python source code, rather, it provides a low-level representation of the bytecode, respecting the lines (so, its target is making the bytecode easier to grasp and not providing the original source code). Note that it does show jump locations/targets and converts some common bytecode constructs to Python code to make it a bit easier to understand. ''' # Reference for bytecodes: # https://docs.python.org/3/library/dis.html if use_func_first_line: firstlineno = co.co_firstlineno else: firstlineno = 0 return _Disassembler(co, firstlineno).disassemble()
37,141
Python
39.110151
202
0.562532
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame_utils.py
from _pydevd_bundle.pydevd_constants import EXCEPTION_TYPE_USER_UNHANDLED, EXCEPTION_TYPE_UNHANDLED from _pydev_bundle import pydev_log class Frame(object): def __init__( self, f_back, f_fileno, f_code, f_locals, f_globals=None, f_trace=None): self.f_back = f_back self.f_lineno = f_fileno self.f_code = f_code self.f_locals = f_locals self.f_globals = f_globals self.f_trace = f_trace if self.f_globals is None: self.f_globals = {} class FCode(object): def __init__(self, name, filename): self.co_name = name self.co_filename = filename self.co_firstlineno = 1 self.co_flags = 0 def add_exception_to_frame(frame, exception_info): frame.f_locals['__exception__'] = exception_info def remove_exception_from_frame(frame): frame.f_locals.pop('__exception__', None) FILES_WITH_IMPORT_HOOKS = ['pydev_monkey_qt.py', 'pydev_import_hook.py'] def just_raised(trace): if trace is None: return False return trace.tb_next is None def ignore_exception_trace(trace): while trace is not None: filename = trace.tb_frame.f_code.co_filename if filename in ( '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap_external>'): # Do not stop on inner exceptions in py3 while importing return True # ImportError should appear in a user's code, not inside debugger for file in FILES_WITH_IMPORT_HOOKS: if filename.endswith(file): return True trace = trace.tb_next return False def cached_call(obj, func, *args): cached_name = '_cached_' + func.__name__ if not hasattr(obj, cached_name): setattr(obj, cached_name, func(*args)) return getattr(obj, cached_name) class FramesList(object): def __init__(self): self._frames = [] # If available, the line number for the frame will be gotten from this dict, # otherwise frame.f_lineno will be used (needed for unhandled exceptions as # the place where we report may be different from the place where it's raised). self.frame_id_to_lineno = {} self.exc_type = None self.exc_desc = None self.trace_obj = None # This may be set to set the current frame (for the case where we have # an unhandled exception where we want to show the root bu we have a different # executing frame). self.current_frame = None # This is to know whether an exception was extracted from a __cause__ or __context__. self.exc_context_msg = '' def append(self, frame): self._frames.append(frame) def last_frame(self): return self._frames[-1] def __len__(self): return len(self._frames) def __iter__(self): return iter(self._frames) def __repr__(self): lst = ['FramesList('] lst.append('\n exc_type: ') lst.append(str(self.exc_type)) lst.append('\n exc_desc: ') lst.append(str(self.exc_desc)) lst.append('\n trace_obj: ') lst.append(str(self.trace_obj)) lst.append('\n current_frame: ') lst.append(str(self.current_frame)) for frame in self._frames: lst.append('\n ') lst.append(repr(frame)) lst.append(',') lst.append('\n)') return ''.join(lst) __str__ = __repr__ class _DummyFrameWrapper(object): def __init__(self, frame, f_lineno, f_back): self._base_frame = frame self.f_lineno = f_lineno self.f_back = f_back self.f_trace = None original_code = frame.f_code self.f_code = FCode(original_code.co_name , original_code.co_filename) @property def f_locals(self): return self._base_frame.f_locals @property def f_globals(self): return self._base_frame.f_globals _cause_message = ( "\nThe above exception was the direct cause " "of the following exception:\n\n") _context_message = ( "\nDuring handling of the above exception, " "another exception occurred:\n\n") def create_frames_list_from_exception_cause(trace_obj, frame, exc_type, exc_desc, memo): lst = [] msg = '<Unknown context>' try: exc_cause = getattr(exc_desc, '__cause__', None) msg = _cause_message except Exception: exc_cause = None if exc_cause is None: try: exc_cause = getattr(exc_desc, '__context__', None) msg = _context_message except Exception: exc_cause = None if exc_cause is None or id(exc_cause) in memo: return None # The traceback module does this, so, let's play safe here too... memo.add(id(exc_cause)) tb = exc_cause.__traceback__ frames_list = FramesList() frames_list.exc_type = type(exc_cause) frames_list.exc_desc = exc_cause frames_list.trace_obj = tb frames_list.exc_context_msg = msg while tb is not None: # Note: we don't use the actual tb.tb_frame because if the cause of the exception # uses the same frame object, the id(frame) would be the same and the frame_id_to_lineno # would be wrong as the same frame needs to appear with 2 different lines. lst.append((_DummyFrameWrapper(tb.tb_frame, tb.tb_lineno, None), tb.tb_lineno)) tb = tb.tb_next for tb_frame, tb_lineno in lst: frames_list.append(tb_frame) frames_list.frame_id_to_lineno[id(tb_frame)] = tb_lineno return frames_list def create_frames_list_from_traceback(trace_obj, frame, exc_type, exc_desc, exception_type=None): ''' :param trace_obj: This is the traceback from which the list should be created. :param frame: This is the first frame to be considered (i.e.: topmost frame). If None is passed, all the frames from the traceback are shown (so, None should be passed for unhandled exceptions). :param exception_type: If this is an unhandled exception or user unhandled exception, we'll not trim the stack to create from the passed frame, rather, we'll just mark the frame in the frames list. ''' lst = [] tb = trace_obj if tb is not None and tb.tb_frame is not None: f = tb.tb_frame.f_back while f is not None: lst.insert(0, (f, f.f_lineno)) f = f.f_back while tb is not None: lst.append((tb.tb_frame, tb.tb_lineno)) tb = tb.tb_next curr = exc_desc memo = set() while True: initial = curr try: curr = getattr(initial, '__cause__', None) except Exception: curr = None if curr is None: try: curr = getattr(initial, '__context__', None) except Exception: curr = None if curr is None or id(curr) in memo: break # The traceback module does this, so, let's play safe here too... memo.add(id(curr)) tb = getattr(curr, '__traceback__', None) while tb is not None: # Note: we don't use the actual tb.tb_frame because if the cause of the exception # uses the same frame object, the id(frame) would be the same and the frame_id_to_lineno # would be wrong as the same frame needs to appear with 2 different lines. lst.append((_DummyFrameWrapper(tb.tb_frame, tb.tb_lineno, None), tb.tb_lineno)) tb = tb.tb_next frames_list = None for tb_frame, tb_lineno in reversed(lst): if frames_list is None and ( (frame is tb_frame) or (frame is None) or (exception_type == EXCEPTION_TYPE_USER_UNHANDLED) ): frames_list = FramesList() if frames_list is not None: frames_list.append(tb_frame) frames_list.frame_id_to_lineno[id(tb_frame)] = tb_lineno if frames_list is None and frame is not None: # Fallback (shouldn't happen in practice). pydev_log.info('create_frames_list_from_traceback did not find topmost frame in list.') frames_list = create_frames_list_from_frame(frame) frames_list.exc_type = exc_type frames_list.exc_desc = exc_desc frames_list.trace_obj = trace_obj if exception_type == EXCEPTION_TYPE_USER_UNHANDLED: frames_list.current_frame = frame elif exception_type == EXCEPTION_TYPE_UNHANDLED: if len(frames_list) > 0: frames_list.current_frame = frames_list.last_frame() return frames_list def create_frames_list_from_frame(frame): lst = FramesList() while frame is not None: lst.append(frame) frame = frame.f_back return lst
8,923
Python
28.452145
121
0.596212
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_code_to_source.py
""" Decompiler that can be used with the debugger (where statements correctly represent the line numbers). Note: this is a work in progress / proof of concept / not ready to be used. """ import dis from _pydevd_bundle.pydevd_collect_bytecode_info import iter_instructions from _pydev_bundle import pydev_log import sys import inspect from io import StringIO class _Stack(object): def __init__(self): self._contents = [] def push(self, obj): # print('push', obj) self._contents.append(obj) def pop(self): return self._contents.pop(-1) INDENT_MARKER = object() DEDENT_MARKER = object() _SENTINEL = object() DEBUG = False class _Token(object): def __init__(self, i_line, instruction=None, tok=_SENTINEL, priority=0, after=None, end_of_line=False): ''' :param i_line: :param instruction: :param tok: :param priority: :param after: :param end_of_line: Marker to signal only after all the other tokens have been written. ''' self.i_line = i_line if tok is not _SENTINEL: self.tok = tok else: if instruction is not None: if inspect.iscode(instruction.argval): self.tok = '' else: self.tok = str(instruction.argval) else: raise AssertionError('Either the tok or the instruction is needed.') self.instruction = instruction self.priority = priority self.end_of_line = end_of_line self._after_tokens = set() self._after_handler_tokens = set() if after: self.mark_after(after) def mark_after(self, v): if isinstance(v, _Token): self._after_tokens.add(v) elif isinstance(v, _BaseHandler): self._after_handler_tokens.add(v) else: raise AssertionError('Unhandled: %s' % (v,)) def get_after_tokens(self): ret = self._after_tokens.copy() for handler in self._after_handler_tokens: ret.update(handler.tokens) return ret def __repr__(self): return 'Token(%s, after: %s)' % (self.tok, self.get_after_tokens()) __str__ = __repr__ class _Writer(object): def __init__(self): self.line_to_contents = {} self.all_tokens = set() def get_line(self, line): lst = self.line_to_contents.get(line) if lst is None: lst = self.line_to_contents[line] = [] return lst def indent(self, line): self.get_line(line).append(INDENT_MARKER) def dedent(self, line): self.get_line(line).append(DEDENT_MARKER) def write(self, line, token): if token in self.all_tokens: return self.all_tokens.add(token) assert isinstance(token, _Token) lst = self.get_line(line) lst.append(token) class _BaseHandler(object): def __init__(self, i_line, instruction, stack, writer, disassembler): self.i_line = i_line self.instruction = instruction self.stack = stack self.writer = writer self.disassembler = disassembler self.tokens = [] self._handle() def _write_tokens(self): for token in self.tokens: self.writer.write(token.i_line, token) def _handle(self): raise NotImplementedError(self) def __repr__(self, *args, **kwargs): try: return "%s line:%s" % (self.instruction, self.i_line) except: return object.__repr__(self) __str__ = __repr__ _op_name_to_handler = {} def _register(cls): _op_name_to_handler[cls.opname] = cls return cls class _BasePushHandler(_BaseHandler): def _handle(self): self.stack.push(self) class _BaseLoadHandler(_BasePushHandler): def _handle(self): _BasePushHandler._handle(self) self.tokens = [_Token(self.i_line, self.instruction)] @_register class _LoadBuildClass(_BasePushHandler): opname = "LOAD_BUILD_CLASS" @_register class _LoadConst(_BaseLoadHandler): opname = "LOAD_CONST" @_register class _LoadName(_BaseLoadHandler): opname = "LOAD_NAME" @_register class _LoadGlobal(_BaseLoadHandler): opname = "LOAD_GLOBAL" @_register class _LoadFast(_BaseLoadHandler): opname = "LOAD_FAST" @_register class _GetIter(_BaseHandler): ''' Implements TOS = iter(TOS). ''' opname = "GET_ITER" iter_target = None def _handle(self): self.iter_target = self.stack.pop() self.tokens.extend(self.iter_target.tokens) self.stack.push(self) @_register class _ForIter(_BaseHandler): ''' TOS is an iterator. Call its __next__() method. If this yields a new value, push it on the stack (leaving the iterator below it). If the iterator indicates it is exhausted TOS is popped, and the byte code counter is incremented by delta. ''' opname = "FOR_ITER" iter_in = None def _handle(self): self.iter_in = self.stack.pop() self.stack.push(self) def store_in_name(self, store_name): for_token = _Token(self.i_line, None, 'for ') self.tokens.append(for_token) prev = for_token t_name = _Token(store_name.i_line, store_name.instruction, after=prev) self.tokens.append(t_name) prev = t_name in_token = _Token(store_name.i_line, None, ' in ', after=prev) self.tokens.append(in_token) prev = in_token max_line = store_name.i_line if self.iter_in: for t in self.iter_in.tokens: t.mark_after(prev) max_line = max(max_line, t.i_line) prev = t self.tokens.extend(self.iter_in.tokens) colon_token = _Token(self.i_line, None, ':', after=prev) self.tokens.append(colon_token) prev = for_token self._write_tokens() @_register class _StoreName(_BaseHandler): ''' Implements name = TOS. namei is the index of name in the attribute co_names of the code object. The compiler tries to use STORE_FAST or STORE_GLOBAL if possible. ''' opname = "STORE_NAME" def _handle(self): v = self.stack.pop() if isinstance(v, _ForIter): v.store_in_name(self) else: if not isinstance(v, _MakeFunction) or v.is_lambda: line = self.i_line for t in v.tokens: line = min(line, t.i_line) t_name = _Token(line, self.instruction) t_equal = _Token(line, None, '=', after=t_name) self.tokens.append(t_name) self.tokens.append(t_equal) for t in v.tokens: t.mark_after(t_equal) self.tokens.extend(v.tokens) self._write_tokens() @_register class _ReturnValue(_BaseHandler): """ Returns with TOS to the caller of the function. """ opname = "RETURN_VALUE" def _handle(self): v = self.stack.pop() return_token = _Token(self.i_line, None, 'return ', end_of_line=True) self.tokens.append(return_token) for token in v.tokens: token.mark_after(return_token) self.tokens.extend(v.tokens) self._write_tokens() @_register class _CallFunction(_BaseHandler): """ CALL_FUNCTION(argc) Calls a callable object with positional arguments. argc indicates the number of positional arguments. The top of the stack contains positional arguments, with the right-most argument on top. Below the arguments is a callable object to call. CALL_FUNCTION pops all arguments and the callable object off the stack, calls the callable object with those arguments, and pushes the return value returned by the callable object. Changed in version 3.6: This opcode is used only for calls with positional arguments. """ opname = "CALL_FUNCTION" def _handle(self): args = [] for _i in range(self.instruction.argval + 1): arg = self.stack.pop() args.append(arg) it = reversed(args) name = next(it) max_line = name.i_line for t in name.tokens: self.tokens.append(t) tok_open_parens = _Token(name.i_line, None, '(', after=name) self.tokens.append(tok_open_parens) prev = tok_open_parens for i, arg in enumerate(it): for t in arg.tokens: t.mark_after(name) t.mark_after(prev) max_line = max(max_line, t.i_line) self.tokens.append(t) prev = arg if i > 0: comma_token = _Token(prev.i_line, None, ',', after=prev) self.tokens.append(comma_token) prev = comma_token tok_close_parens = _Token(max_line, None, ')', after=prev) self.tokens.append(tok_close_parens) self._write_tokens() self.stack.push(self) @_register class _MakeFunctionPy3(_BaseHandler): """ Pushes a new function object on the stack. From bottom to top, the consumed stack must consist of values if the argument carries a specified flag value 0x01 a tuple of default values for positional-only and positional-or-keyword parameters in positional order 0x02 a dictionary of keyword-only parameters' default values 0x04 an annotation dictionary 0x08 a tuple containing cells for free variables, making a closure the code associated with the function (at TOS1) the qualified name of the function (at TOS) """ opname = "MAKE_FUNCTION" is_lambda = False def _handle(self): stack = self.stack self.qualified_name = stack.pop() self.code = stack.pop() default_node = None if self.instruction.argval & 0x01: default_node = stack.pop() is_lambda = self.is_lambda = '<lambda>' in [x.tok for x in self.qualified_name.tokens] if not is_lambda: def_token = _Token(self.i_line, None, 'def ') self.tokens.append(def_token) for token in self.qualified_name.tokens: self.tokens.append(token) if not is_lambda: token.mark_after(def_token) prev = token open_parens_token = _Token(self.i_line, None, '(', after=prev) self.tokens.append(open_parens_token) prev = open_parens_token code = self.code.instruction.argval if default_node: defaults = ([_SENTINEL] * (len(code.co_varnames) - len(default_node.instruction.argval))) + list(default_node.instruction.argval) else: defaults = [_SENTINEL] * len(code.co_varnames) for i, arg in enumerate(code.co_varnames): if i > 0: comma_token = _Token(prev.i_line, None, ', ', after=prev) self.tokens.append(comma_token) prev = comma_token arg_token = _Token(self.i_line, None, arg, after=prev) self.tokens.append(arg_token) default = defaults[i] if default is not _SENTINEL: eq_token = _Token(default_node.i_line, None, '=', after=prev) self.tokens.append(eq_token) prev = eq_token default_token = _Token(default_node.i_line, None, str(default), after=prev) self.tokens.append(default_token) prev = default_token tok_close_parens = _Token(prev.i_line, None, '):', after=prev) self.tokens.append(tok_close_parens) self._write_tokens() stack.push(self) self.writer.indent(prev.i_line + 1) self.writer.dedent(max(self.disassembler.merge_code(code))) _MakeFunction = _MakeFunctionPy3 def _print_after_info(line_contents, stream=None): if stream is None: stream = sys.stdout for token in line_contents: after_tokens = token.get_after_tokens() if after_tokens: s = '%s after: %s\n' % ( repr(token.tok), ('"' + '", "'.join(t.tok for t in token.get_after_tokens()) + '"')) stream.write(s) else: stream.write('%s (NO REQUISITES)' % repr(token.tok)) def _compose_line_contents(line_contents, previous_line_tokens): lst = [] handled = set() add_to_end_of_line = [] delete_indexes = [] for i, token in enumerate(line_contents): if token.end_of_line: add_to_end_of_line.append(token) delete_indexes.append(i) for i in reversed(delete_indexes): del line_contents[i] del delete_indexes while line_contents: added = False delete_indexes = [] for i, token in enumerate(line_contents): after_tokens = token.get_after_tokens() for after in after_tokens: if after not in handled and after not in previous_line_tokens: break else: added = True previous_line_tokens.add(token) handled.add(token) lst.append(token.tok) delete_indexes.append(i) for i in reversed(delete_indexes): del line_contents[i] if not added: if add_to_end_of_line: line_contents.extend(add_to_end_of_line) del add_to_end_of_line[:] continue # Something is off, let's just add as is. for token in line_contents: if token not in handled: lst.append(token.tok) stream = StringIO() _print_after_info(line_contents, stream) pydev_log.critical('Error. After markers are not correct:\n%s', stream.getvalue()) break return ''.join(lst) class _PyCodeToSource(object): def __init__(self, co, memo=None): if memo is None: memo = {} self.memo = memo self.co = co self.instructions = list(iter_instructions(co)) self.stack = _Stack() self.writer = _Writer() def _process_next(self, i_line): instruction = self.instructions.pop(0) handler_class = _op_name_to_handler.get(instruction.opname) if handler_class is not None: s = handler_class(i_line, instruction, self.stack, self.writer, self) if DEBUG: print(s) else: if DEBUG: print("UNHANDLED", instruction) def build_line_to_contents(self): co = self.co op_offset_to_line = dict(dis.findlinestarts(co)) curr_line_index = 0 instructions = self.instructions while instructions: instruction = instructions[0] new_line_index = op_offset_to_line.get(instruction.offset) if new_line_index is not None: if new_line_index is not None: curr_line_index = new_line_index self._process_next(curr_line_index) return self.writer.line_to_contents def merge_code(self, code): if DEBUG: print('merge code ----') # for d in dir(code): # if not d.startswith('_'): # print(d, getattr(code, d)) line_to_contents = _PyCodeToSource(code, self.memo).build_line_to_contents() lines = [] for line, contents in sorted(line_to_contents.items()): lines.append(line) self.writer.get_line(line).extend(contents) if DEBUG: print('end merge code ----') return lines def disassemble(self): show_lines = False line_to_contents = self.build_line_to_contents() stream = StringIO() last_line = 0 indent = '' previous_line_tokens = set() for i_line, contents in sorted(line_to_contents.items()): while last_line < i_line - 1: if show_lines: stream.write(u"%s.\n" % (last_line + 1,)) else: stream.write(u"\n") last_line += 1 line_contents = [] dedents_found = 0 for part in contents: if part is INDENT_MARKER: if DEBUG: print('found indent', i_line) indent += ' ' continue if part is DEDENT_MARKER: if DEBUG: print('found dedent', i_line) dedents_found += 1 continue line_contents.append(part) s = indent + _compose_line_contents(line_contents, previous_line_tokens) if show_lines: stream.write(u"%s. %s\n" % (i_line, s)) else: stream.write(u"%s\n" % s) if dedents_found: indent = indent[:-(4 * dedents_found)] last_line = i_line return stream.getvalue() def code_obj_to_source(co): """ Converts a code object to source code to provide a suitable representation for the compiler when the actual source code is not found. This is a work in progress / proof of concept / not ready to be used. """ ret = _PyCodeToSource(co).disassemble() if DEBUG: print(ret) return ret
17,622
Python
27.795752
141
0.563046
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_save_locals.py
""" Utility for saving locals. """ import sys try: import types frame_type = types.FrameType except: frame_type = type(sys._getframe()) def is_save_locals_available(): return save_locals_impl is not None def save_locals(frame): """ Copy values from locals_dict into the fast stack slots in the given frame. Note: the 'save_locals' branch had a different approach wrapping the frame (much more code, but it gives ideas on how to save things partially, not the 'whole' locals). """ if not isinstance(frame, frame_type): # Fix exception when changing Django variable (receiving DjangoTemplateFrame) return if save_locals_impl is not None: try: save_locals_impl(frame) except: pass def make_save_locals_impl(): """ Factory for the 'save_locals_impl' method. This may seem like a complicated pattern but it is essential that the method is created at module load time. Inner imports after module load time would cause an occasional debugger deadlock due to the importer lock and debugger lock being taken in different order in different threads. """ try: if '__pypy__' in sys.builtin_module_names: import __pypy__ # @UnresolvedImport save_locals = __pypy__.locals_to_fast except: pass else: if '__pypy__' in sys.builtin_module_names: def save_locals_pypy_impl(frame): save_locals(frame) return save_locals_pypy_impl try: import ctypes locals_to_fast = ctypes.pythonapi.PyFrame_LocalsToFast except: pass else: def save_locals_ctypes_impl(frame): locals_to_fast(ctypes.py_object(frame), ctypes.c_int(0)) return save_locals_ctypes_impl return None save_locals_impl = make_save_locals_impl() def update_globals_and_locals(updated_globals, initial_globals, frame): # We don't have the locals and passed all in globals, so, we have to # manually choose how to update the variables. # # Note that the current implementation is a bit tricky: it does work in general # but if we do something as 'some_var = 10' and 'some_var' is already defined to have # the value '10' in the globals, we won't actually put that value in the locals # (which means that the frame locals won't be updated). # Still, the approach to have a single namespace was chosen because it was the only # one that enabled creating and using variables during the same evaluation. assert updated_globals is not None f_locals = None for key, val in updated_globals.items(): if initial_globals.get(key) is not val: if f_locals is None: # Note: we call f_locals only once because each time # we call it the values may be reset. f_locals = frame.f_locals f_locals[key] = val if f_locals is not None: save_locals(frame)
3,020
Python
30.14433
140
0.647682
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_custom_frames.py
from _pydevd_bundle.pydevd_constants import get_current_thread_id, Null, ForkSafeLock from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame from _pydev_bundle._pydev_saved_modules import thread, threading import sys from _pydev_bundle import pydev_log DEBUG = False class CustomFramesContainer: # Actual Values initialized later on. custom_frames_lock = None # : :type custom_frames_lock: threading.Lock custom_frames = None _next_frame_id = None _py_db_command_thread_event = None def custom_frames_container_init(): # Note: no staticmethod on jython 2.1 (so, use free-function) CustomFramesContainer.custom_frames_lock = ForkSafeLock() # custom_frames can only be accessed if properly locked with custom_frames_lock! # Key is a string identifying the frame (as well as the thread it belongs to). # Value is a CustomFrame. # CustomFramesContainer.custom_frames = {} # Only to be used in this module CustomFramesContainer._next_frame_id = 0 # This is the event we must set to release an internal process events. It's later set by the actual debugger # when we do create the debugger. CustomFramesContainer._py_db_command_thread_event = Null() # Initialize it the first time (it may be reinitialized later on when dealing with a fork). custom_frames_container_init() class CustomFrame: def __init__(self, name, frame, thread_id): # 0 = string with the representation of that frame self.name = name # 1 = the frame to show self.frame = frame # 2 = an integer identifying the last time the frame was changed. self.mod_time = 0 # 3 = the thread id of the given frame self.thread_id = thread_id def add_custom_frame(frame, name, thread_id): ''' It's possible to show paused frames by adding a custom frame through this API (it's intended to be used for coroutines, but could potentially be used for generators too). :param frame: The topmost frame to be shown paused when a thread with thread.ident == thread_id is paused. :param name: The name to be shown for the custom thread in the UI. :param thread_id: The thread id to which this frame is related (must match thread.ident). :return: str Returns the custom thread id which will be used to show the given frame paused. ''' with CustomFramesContainer.custom_frames_lock: curr_thread_id = get_current_thread_id(threading.current_thread()) next_id = CustomFramesContainer._next_frame_id = CustomFramesContainer._next_frame_id + 1 # Note: the frame id kept contains an id and thread information on the thread where the frame was added # so that later on we can check if the frame is from the current thread by doing frame_id.endswith('|'+thread_id). frame_custom_thread_id = '__frame__:%s|%s' % (next_id, curr_thread_id) if DEBUG: sys.stderr.write('add_custom_frame: %s (%s) %s %s\n' % ( frame_custom_thread_id, get_abs_path_real_path_and_base_from_frame(frame)[-1], frame.f_lineno, frame.f_code.co_name)) CustomFramesContainer.custom_frames[frame_custom_thread_id] = CustomFrame(name, frame, thread_id) CustomFramesContainer._py_db_command_thread_event.set() return frame_custom_thread_id def update_custom_frame(frame_custom_thread_id, frame, thread_id, name=None): with CustomFramesContainer.custom_frames_lock: if DEBUG: sys.stderr.write('update_custom_frame: %s\n' % frame_custom_thread_id) try: old = CustomFramesContainer.custom_frames[frame_custom_thread_id] if name is not None: old.name = name old.mod_time += 1 old.thread_id = thread_id except: sys.stderr.write('Unable to get frame to replace: %s\n' % (frame_custom_thread_id,)) pydev_log.exception() CustomFramesContainer._py_db_command_thread_event.set() def remove_custom_frame(frame_custom_thread_id): with CustomFramesContainer.custom_frames_lock: if DEBUG: sys.stderr.write('remove_custom_frame: %s\n' % frame_custom_thread_id) CustomFramesContainer.custom_frames.pop(frame_custom_thread_id, None) CustomFramesContainer._py_db_command_thread_event.set()
4,399
Python
36.606837
133
0.677881
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_safe_repr.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See LICENSE in the project root # for license information. # Gotten from ptvsd for supporting the format expected there. import sys from _pydevd_bundle.pydevd_constants import IS_PY36_OR_GREATER import locale from _pydev_bundle import pydev_log class SafeRepr(object): # Can be used to override the encoding from locale.getpreferredencoding() locale_preferred_encoding = None # Can be used to override the encoding used for sys.stdout.encoding sys_stdout_encoding = None # String types are truncated to maxstring_outer when at the outer- # most level, and truncated to maxstring_inner characters inside # collections. maxstring_outer = 2 ** 16 maxstring_inner = 30 string_types = (str, bytes) bytes = bytes set_info = (set, '{', '}', False) frozenset_info = (frozenset, 'frozenset({', '})', False) int_types = (int,) long_iter_types = (list, tuple, bytearray, range, dict, set, frozenset) # Collection types are recursively iterated for each limit in # maxcollection. maxcollection = (15, 10) # Specifies type, prefix string, suffix string, and whether to include a # comma if there is only one element. (Using a sequence rather than a # mapping because we use isinstance() to determine the matching type.) collection_types = [ (tuple, '(', ')', True), (list, '[', ']', False), frozenset_info, set_info, ] try: from collections import deque collection_types.append((deque, 'deque([', '])', False)) except Exception: pass # type, prefix string, suffix string, item prefix string, # item key/value separator, item suffix string dict_types = [(dict, '{', '}', '', ': ', '')] try: from collections import OrderedDict dict_types.append((OrderedDict, 'OrderedDict([', '])', '(', ', ', ')')) except Exception: pass # All other types are treated identically to strings, but using # different limits. maxother_outer = 2 ** 16 maxother_inner = 30 convert_to_hex = False raw_value = False def __call__(self, obj): ''' :param object obj: The object for which we want a representation. :return str: Returns bytes encoded as utf-8 on py2 and str on py3. ''' try: return ''.join(self._repr(obj, 0)) except Exception: try: return 'An exception was raised: %r' % sys.exc_info()[1] except Exception: return 'An exception was raised' def _repr(self, obj, level): '''Returns an iterable of the parts in the final repr string.''' try: obj_repr = type(obj).__repr__ except Exception: obj_repr = None def has_obj_repr(t): r = t.__repr__ try: return obj_repr == r except Exception: return obj_repr is r for t, prefix, suffix, comma in self.collection_types: if isinstance(obj, t) and has_obj_repr(t): return self._repr_iter(obj, level, prefix, suffix, comma) for t, prefix, suffix, item_prefix, item_sep, item_suffix in self.dict_types: # noqa if isinstance(obj, t) and has_obj_repr(t): return self._repr_dict(obj, level, prefix, suffix, item_prefix, item_sep, item_suffix) for t in self.string_types: if isinstance(obj, t) and has_obj_repr(t): return self._repr_str(obj, level) if self._is_long_iter(obj): return self._repr_long_iter(obj) return self._repr_other(obj, level) # Determines whether an iterable exceeds the limits set in # maxlimits, and is therefore unsafe to repr(). def _is_long_iter(self, obj, level=0): try: # Strings have their own limits (and do not nest). Because # they don't have __iter__ in 2.x, this check goes before # the next one. if isinstance(obj, self.string_types): return len(obj) > self.maxstring_inner # If it's not an iterable (and not a string), it's fine. if not hasattr(obj, '__iter__'): return False # If it's not an instance of these collection types then it # is fine. Note: this is a fix for # https://github.com/Microsoft/ptvsd/issues/406 if not isinstance(obj, self.long_iter_types): return False # Iterable is its own iterator - this is a one-off iterable # like generator or enumerate(). We can't really count that, # but repr() for these should not include any elements anyway, # so we can treat it the same as non-iterables. if obj is iter(obj): return False # range reprs fine regardless of length. if isinstance(obj, range): return False # numpy and scipy collections (ndarray etc) have # self-truncating repr, so they're always safe. try: module = type(obj).__module__.partition('.')[0] if module in ('numpy', 'scipy'): return False except Exception: pass # Iterables that nest too deep are considered long. if level >= len(self.maxcollection): return True # It is too long if the length exceeds the limit, or any # of its elements are long iterables. if hasattr(obj, '__len__'): try: size = len(obj) except Exception: size = None if size is not None and size > self.maxcollection[level]: return True return any((self._is_long_iter(item, level + 1) for item in obj)) # noqa return any(i > self.maxcollection[level] or self._is_long_iter(item, level + 1) for i, item in enumerate(obj)) # noqa except Exception: # If anything breaks, assume the worst case. return True def _repr_iter(self, obj, level, prefix, suffix, comma_after_single_element=False): yield prefix if level >= len(self.maxcollection): yield '...' else: count = self.maxcollection[level] yield_comma = False for item in obj: if yield_comma: yield ', ' yield_comma = True count -= 1 if count <= 0: yield '...' break for p in self._repr(item, 100 if item is obj else level + 1): yield p else: if comma_after_single_element: if count == self.maxcollection[level] - 1: yield ',' yield suffix def _repr_long_iter(self, obj): try: length = hex(len(obj)) if self.convert_to_hex else len(obj) obj_repr = '<%s, len() = %s>' % (type(obj).__name__, length) except Exception: try: obj_repr = '<' + type(obj).__name__ + '>' except Exception: obj_repr = '<no repr available for object>' yield obj_repr def _repr_dict(self, obj, level, prefix, suffix, item_prefix, item_sep, item_suffix): if not obj: yield prefix + suffix return if level >= len(self.maxcollection): yield prefix + '...' + suffix return yield prefix count = self.maxcollection[level] yield_comma = False if IS_PY36_OR_GREATER: # On Python 3.6 (onwards) dictionaries now keep # insertion order. sorted_keys = list(obj) else: try: sorted_keys = sorted(obj) except Exception: sorted_keys = list(obj) for key in sorted_keys: if yield_comma: yield ', ' yield_comma = True count -= 1 if count <= 0: yield '...' break yield item_prefix for p in self._repr(key, level + 1): yield p yield item_sep try: item = obj[key] except Exception: yield '<?>' else: for p in self._repr(item, 100 if item is obj else level + 1): yield p yield item_suffix yield suffix def _repr_str(self, obj, level): try: if self.raw_value: # For raw value retrieval, ignore all limits. if isinstance(obj, bytes): yield obj.decode('latin-1') else: yield obj return limit_inner = self.maxother_inner limit_outer = self.maxother_outer limit = limit_inner if level > 0 else limit_outer if len(obj) <= limit: # Note that we check the limit before doing the repr (so, the final string # may actually be considerably bigger on some cases, as besides # the additional u, b, ' chars, some chars may be escaped in repr, so # even a single char such as \U0010ffff may end up adding more # chars than expected). yield self._convert_to_unicode_or_bytes_repr(repr(obj)) return # Slightly imprecise calculations - we may end up with a string that is # up to 6 characters longer than limit. If you need precise formatting, # you are using the wrong class. left_count, right_count = max(1, int(2 * limit / 3)), max(1, int(limit / 3)) # noqa # Important: only do repr after slicing to avoid duplicating a byte array that could be # huge. # Note: we don't deal with high surrogates here because we're not dealing with the # repr() of a random object. # i.e.: A high surrogate unicode char may be splitted on Py2, but as we do a `repr` # afterwards, that's ok. # Also, we just show the unicode/string/bytes repr() directly to make clear what the # input type was (so, on py2 a unicode would start with u' and on py3 a bytes would # start with b'). part1 = obj[:left_count] part1 = repr(part1) part1 = part1[:part1.rindex("'")] # Remove the last ' part2 = obj[-right_count:] part2 = repr(part2) part2 = part2[part2.index("'") + 1:] # Remove the first ' (and possibly u or b). yield part1 yield '...' yield part2 except: # This shouldn't really happen, but let's play it safe. pydev_log.exception('Error getting string representation to show.') for part in self._repr_obj(obj, level, self.maxother_inner, self.maxother_outer): yield part def _repr_other(self, obj, level): return self._repr_obj(obj, level, self.maxother_inner, self.maxother_outer) def _repr_obj(self, obj, level, limit_inner, limit_outer): try: if self.raw_value: # For raw value retrieval, ignore all limits. if isinstance(obj, bytes): yield obj.decode('latin-1') return try: mv = memoryview(obj) except Exception: yield self._convert_to_unicode_or_bytes_repr(repr(obj)) return else: # Map bytes to Unicode codepoints with same values. yield mv.tobytes().decode('latin-1') return elif self.convert_to_hex and isinstance(obj, self.int_types): obj_repr = hex(obj) else: obj_repr = repr(obj) except Exception: try: obj_repr = object.__repr__(obj) except Exception: try: obj_repr = '<no repr available for ' + type(obj).__name__ + '>' # noqa except Exception: obj_repr = '<no repr available for object>' limit = limit_inner if level > 0 else limit_outer if limit >= len(obj_repr): yield self._convert_to_unicode_or_bytes_repr(obj_repr) return # Slightly imprecise calculations - we may end up with a string that is # up to 3 characters longer than limit. If you need precise formatting, # you are using the wrong class. left_count, right_count = max(1, int(2 * limit / 3)), max(1, int(limit / 3)) # noqa yield obj_repr[:left_count] yield '...' yield obj_repr[-right_count:] def _convert_to_unicode_or_bytes_repr(self, obj_repr): return obj_repr def _bytes_as_unicode_if_possible(self, obj_repr): # We try to decode with 3 possible encoding (sys.stdout.encoding, # locale.getpreferredencoding() and 'utf-8). If no encoding can decode # the input, we return the original bytes. try_encodings = [] encoding = self.sys_stdout_encoding or getattr(sys.stdout, 'encoding', '') if encoding: try_encodings.append(encoding.lower()) preferred_encoding = self.locale_preferred_encoding or locale.getpreferredencoding() if preferred_encoding: preferred_encoding = preferred_encoding.lower() if preferred_encoding not in try_encodings: try_encodings.append(preferred_encoding) if 'utf-8' not in try_encodings: try_encodings.append('utf-8') for encoding in try_encodings: try: return obj_repr.decode(encoding) except UnicodeDecodeError: pass return obj_repr # Return the original version (in bytes)
14,554
Python
35.3875
130
0.535592
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_dont_trace.py
''' Support for a tag that allows skipping over functions while debugging. ''' import linecache import re # To suppress tracing a method, add the tag @DontTrace # to a comment either preceding or on the same line as # the method definition # # E.g.: # #@DontTrace # def test1(): # pass # # ... or ... # # def test2(): #@DontTrace # pass DONT_TRACE_TAG = '@DontTrace' # Regular expression to match a decorator (at the beginning # of a line). RE_DECORATOR = re.compile(r'^\s*@') # Mapping from code object to bool. # If the key exists, the value is the cached result of should_trace_hook _filename_to_ignored_lines = {} def default_should_trace_hook(frame, absolute_filename): ''' Return True if this frame should be traced, False if tracing should be blocked. ''' # First, check whether this code object has a cached value ignored_lines = _filename_to_ignored_lines.get(absolute_filename) if ignored_lines is None: # Now, look up that line of code and check for a @DontTrace # preceding or on the same line as the method. # E.g.: # #@DontTrace # def test(): # pass # ... or ... # def test(): #@DontTrace # pass ignored_lines = {} lines = linecache.getlines(absolute_filename) for i_line, line in enumerate(lines): j = line.find('#') if j >= 0: comment = line[j:] if DONT_TRACE_TAG in comment: ignored_lines[i_line] = 1 # Note: when it's found in the comment, mark it up and down for the decorator lines found. k = i_line - 1 while k >= 0: if RE_DECORATOR.match(lines[k]): ignored_lines[k] = 1 k -= 1 else: break k = i_line + 1 while k <= len(lines): if RE_DECORATOR.match(lines[k]): ignored_lines[k] = 1 k += 1 else: break _filename_to_ignored_lines[absolute_filename] = ignored_lines func_line = frame.f_code.co_firstlineno - 1 # co_firstlineno is 1-based, so -1 is needed return not ( func_line - 1 in ignored_lines or # -1 to get line before method func_line in ignored_lines) # method line should_trace_hook = None def clear_trace_filter_cache(): ''' Clear the trace filter cache. Call this after reloading. ''' global should_trace_hook try: # Need to temporarily disable a hook because otherwise # _filename_to_ignored_lines.clear() will never complete. old_hook = should_trace_hook should_trace_hook = None # Clear the linecache linecache.clearcache() _filename_to_ignored_lines.clear() finally: should_trace_hook = old_hook def trace_filter(mode): ''' Set the trace filter mode. mode: Whether to enable the trace hook. True: Trace filtering on (skipping methods tagged @DontTrace) False: Trace filtering off (trace methods tagged @DontTrace) None/default: Toggle trace filtering. ''' global should_trace_hook if mode is None: mode = should_trace_hook is None if mode: should_trace_hook = default_should_trace_hook else: should_trace_hook = None return mode
3,567
Python
27.774193
110
0.561256
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_reload.py
""" Based on the python xreload. Changes ====================== 1. we don't recreate the old namespace from new classes. Rather, we keep the existing namespace, load a new version of it and update only some of the things we can inplace. That way, we don't break things such as singletons or end up with a second representation of the same class in memory. 2. If we find it to be a __metaclass__, we try to update it as a regular class. 3. We don't remove old attributes (and leave them lying around even if they're no longer used). 4. Reload hooks were changed These changes make it more stable, especially in the common case (where in a debug session only the contents of a function are changed), besides providing flexibility for users that want to extend on it. Hooks ====================== Classes/modules can be specially crafted to work with the reload (so that it can, for instance, update some constant which was changed). 1. To participate in the change of some attribute: In a module: __xreload_old_new__(namespace, name, old, new) in a class: @classmethod __xreload_old_new__(cls, name, old, new) A class or module may include a method called '__xreload_old_new__' which is called when we're unable to reload a given attribute. 2. To do something after the whole reload is finished: In a module: __xreload_after_reload_update__(namespace): In a class: @classmethod __xreload_after_reload_update__(cls): A class or module may include a method called '__xreload_after_reload_update__' which is called after the reload finishes. Important: when providing a hook, always use the namespace or cls provided and not anything in the global namespace, as the global namespace are only temporarily created during the reload and may not reflect the actual application state (while the cls and namespace passed are). Current limitations ====================== - Attributes/constants are added, but not changed (so singletons and the application state is not broken -- use provided hooks to workaround it). - Code using metaclasses may not always work. - Functions and methods using decorators (other than classmethod and staticmethod) are not handled correctly. - Renamings are not handled correctly. - Dependent modules are not reloaded. - New __slots__ can't be added to existing classes. Info ====================== Original: http://svn.python.org/projects/sandbox/trunk/xreload/xreload.py Note: it seems https://github.com/plone/plone.reload/blob/master/plone/reload/xreload.py enhances it (to check later) Interesting alternative: https://code.google.com/p/reimport/ Alternative to reload(). This works by executing the module in a scratch namespace, and then patching classes, methods and functions in place. This avoids the need to patch instances. New objects are copied into the target namespace. """ from _pydev_bundle.pydev_imports import execfile from _pydevd_bundle import pydevd_dont_trace import types from _pydev_bundle import pydev_log from _pydevd_bundle.pydevd_constants import get_global_debugger NO_DEBUG = 0 LEVEL1 = 1 LEVEL2 = 2 DEBUG = NO_DEBUG def write_err(*args): py_db = get_global_debugger() if py_db is not None: new_lst = [] for a in args: new_lst.append(str(a)) msg = ' '.join(new_lst) s = 'code reload: %s\n' % (msg,) cmd = py_db.cmd_factory.make_io_message(s, 2) if py_db.writer is not None: py_db.writer.add_command(cmd) def notify_info0(*args): write_err(*args) def notify_info(*args): if DEBUG >= LEVEL1: write_err(*args) def notify_info2(*args): if DEBUG >= LEVEL2: write_err(*args) def notify_error(*args): write_err(*args) #======================================================================================================================= # code_objects_equal #======================================================================================================================= def code_objects_equal(code0, code1): for d in dir(code0): if d.startswith('_') or 'line' in d or d in ('replace', 'co_positions', 'co_qualname'): continue if getattr(code0, d) != getattr(code1, d): return False return True #======================================================================================================================= # xreload #======================================================================================================================= def xreload(mod): """Reload a module in place, updating classes, methods and functions. mod: a module object Returns a boolean indicating whether a change was done. """ r = Reload(mod) r.apply() found_change = r.found_change r = None pydevd_dont_trace.clear_trace_filter_cache() return found_change # This isn't actually used... Initially I planned to reload variables which are immutable on the # namespace, but this can destroy places where we're saving state, which may not be what we want, # so, we're being conservative and giving the user hooks if he wants to do a reload. # # immutable_types = [int, str, float, tuple] #That should be common to all Python versions # # for name in 'long basestr unicode frozenset'.split(): # try: # immutable_types.append(__builtins__[name]) # except: # pass #Just ignore: not all python versions are created equal. # immutable_types = tuple(immutable_types) #======================================================================================================================= # Reload #======================================================================================================================= class Reload: def __init__(self, mod, mod_name=None, mod_filename=None): self.mod = mod if mod_name: self.mod_name = mod_name else: self.mod_name = mod.__name__ if mod is not None else None if mod_filename: self.mod_filename = mod_filename else: self.mod_filename = mod.__file__ if mod is not None else None self.found_change = False def apply(self): mod = self.mod self._on_finish_callbacks = [] try: # Get the module namespace (dict) early; this is part of the type check modns = mod.__dict__ # Execute the code. We copy the module dict to a temporary; then # clear the module dict; then execute the new code in the module # dict; then swap things back and around. This trick (due to # Glyph Lefkowitz) ensures that the (readonly) __globals__ # attribute of methods and functions is set to the correct dict # object. new_namespace = modns.copy() new_namespace.clear() if self.mod_filename: new_namespace["__file__"] = self.mod_filename try: new_namespace["__builtins__"] = __builtins__ except NameError: raise # Ok if not there. if self.mod_name: new_namespace["__name__"] = self.mod_name if new_namespace["__name__"] == '__main__': # We do this because usually the __main__ starts-up the program, guarded by # the if __name__ == '__main__', but we don't want to start the program again # on a reload. new_namespace["__name__"] = '__main_reloaded__' execfile(self.mod_filename, new_namespace, new_namespace) # Now we get to the hard part oldnames = set(modns) newnames = set(new_namespace) # Create new tokens (note: not deleting existing) for name in newnames - oldnames: notify_info0('Added:', name, 'to namespace') self.found_change = True modns[name] = new_namespace[name] # Update in-place what we can for name in oldnames & newnames: self._update(modns, name, modns[name], new_namespace[name]) self._handle_namespace(modns) for c in self._on_finish_callbacks: c() del self._on_finish_callbacks[:] except: pydev_log.exception() def _handle_namespace(self, namespace, is_class_namespace=False): on_finish = None if is_class_namespace: xreload_after_update = getattr(namespace, '__xreload_after_reload_update__', None) if xreload_after_update is not None: self.found_change = True on_finish = lambda: xreload_after_update() elif '__xreload_after_reload_update__' in namespace: xreload_after_update = namespace['__xreload_after_reload_update__'] self.found_change = True on_finish = lambda: xreload_after_update(namespace) if on_finish is not None: # If a client wants to know about it, give him a chance. self._on_finish_callbacks.append(on_finish) def _update(self, namespace, name, oldobj, newobj, is_class_namespace=False): """Update oldobj, if possible in place, with newobj. If oldobj is immutable, this simply returns newobj. Args: oldobj: the object to be updated newobj: the object used as the source for the update """ try: notify_info2('Updating: ', oldobj) if oldobj is newobj: # Probably something imported return if type(oldobj) is not type(newobj): # Cop-out: if the type changed, give up if name not in ('__builtins__',): notify_error('Type of: %s (old: %s != new: %s) changed... Skipping.' % (name, type(oldobj), type(newobj))) return if isinstance(newobj, types.FunctionType): self._update_function(oldobj, newobj) return if isinstance(newobj, types.MethodType): self._update_method(oldobj, newobj) return if isinstance(newobj, classmethod): self._update_classmethod(oldobj, newobj) return if isinstance(newobj, staticmethod): self._update_staticmethod(oldobj, newobj) return if hasattr(types, 'ClassType'): classtype = (types.ClassType, type) # object is not instance of types.ClassType. else: classtype = type if isinstance(newobj, classtype): self._update_class(oldobj, newobj) return # New: dealing with metaclasses. if hasattr(newobj, '__metaclass__') and hasattr(newobj, '__class__') and newobj.__metaclass__ == newobj.__class__: self._update_class(oldobj, newobj) return if namespace is not None: # Check for the `__xreload_old_new__` protocol (don't even compare things # as even doing a comparison may break things -- see: https://github.com/microsoft/debugpy/issues/615). xreload_old_new = None if is_class_namespace: xreload_old_new = getattr(namespace, '__xreload_old_new__', None) if xreload_old_new is not None: self.found_change = True xreload_old_new(name, oldobj, newobj) elif '__xreload_old_new__' in namespace: xreload_old_new = namespace['__xreload_old_new__'] xreload_old_new(namespace, name, oldobj, newobj) self.found_change = True # Too much information to the user... # else: # notify_info0('%s NOT updated. Create __xreload_old_new__(name, old, new) for custom reload' % (name,)) except: notify_error('Exception found when updating %s. Proceeding for other items.' % (name,)) pydev_log.exception() # All of the following functions have the same signature as _update() def _update_function(self, oldfunc, newfunc): """Update a function object.""" oldfunc.__doc__ = newfunc.__doc__ oldfunc.__dict__.update(newfunc.__dict__) try: newfunc.__code__ attr_name = '__code__' except AttributeError: newfunc.func_code attr_name = 'func_code' old_code = getattr(oldfunc, attr_name) new_code = getattr(newfunc, attr_name) if not code_objects_equal(old_code, new_code): notify_info0('Updated function code:', oldfunc) setattr(oldfunc, attr_name, new_code) self.found_change = True try: oldfunc.__defaults__ = newfunc.__defaults__ except AttributeError: oldfunc.func_defaults = newfunc.func_defaults return oldfunc def _update_method(self, oldmeth, newmeth): """Update a method object.""" # XXX What if im_func is not a function? if hasattr(oldmeth, 'im_func') and hasattr(newmeth, 'im_func'): self._update(None, None, oldmeth.im_func, newmeth.im_func) elif hasattr(oldmeth, '__func__') and hasattr(newmeth, '__func__'): self._update(None, None, oldmeth.__func__, newmeth.__func__) return oldmeth def _update_class(self, oldclass, newclass): """Update a class object.""" olddict = oldclass.__dict__ newdict = newclass.__dict__ oldnames = set(olddict) newnames = set(newdict) for name in newnames - oldnames: setattr(oldclass, name, newdict[name]) notify_info0('Added:', name, 'to', oldclass) self.found_change = True # Note: not removing old things... # for name in oldnames - newnames: # notify_info('Removed:', name, 'from', oldclass) # delattr(oldclass, name) for name in (oldnames & newnames) - set(['__dict__', '__doc__']): self._update(oldclass, name, olddict[name], newdict[name], is_class_namespace=True) old_bases = getattr(oldclass, '__bases__', None) new_bases = getattr(newclass, '__bases__', None) if str(old_bases) != str(new_bases): notify_error('Changing the hierarchy of a class is not supported. %s may be inconsistent.' % (oldclass,)) self._handle_namespace(oldclass, is_class_namespace=True) def _update_classmethod(self, oldcm, newcm): """Update a classmethod update.""" # While we can't modify the classmethod object itself (it has no # mutable attributes), we *can* extract the underlying function # (by calling __get__(), which returns a method object) and update # it in-place. We don't have the class available to pass to # __get__() but any object except None will do. self._update(None, None, oldcm.__get__(0), newcm.__get__(0)) def _update_staticmethod(self, oldsm, newsm): """Update a staticmethod update.""" # While we can't modify the staticmethod object itself (it has no # mutable attributes), we *can* extract the underlying function # (by calling __get__(), which returns it) and update it in-place. # We don't have the class available to pass to __get__() but any # object except None will do. self._update(None, None, oldsm.__get__(0), newsm.__get__(0))
15,773
Python
35.345622
126
0.572561
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py
from _pydev_bundle._pydev_saved_modules import threading from _pydev_bundle import _pydev_saved_modules from _pydevd_bundle.pydevd_utils import notify_about_gevent_if_needed import weakref from _pydevd_bundle.pydevd_constants import IS_JYTHON, IS_IRONPYTHON, \ PYDEVD_APPLY_PATCHING_TO_HIDE_PYDEVD_THREADS from _pydev_bundle.pydev_log import exception as pydev_log_exception import sys from _pydev_bundle import pydev_log import pydevd_tracing from _pydevd_bundle.pydevd_collect_bytecode_info import iter_instructions if IS_JYTHON: import org.python.core as JyCore # @UnresolvedImport class PyDBDaemonThread(threading.Thread): def __init__(self, py_db, target_and_args=None): ''' :param target_and_args: tuple(func, args, kwargs) if this should be a function and args to run. -- Note: use through run_as_pydevd_daemon_thread(). ''' threading.Thread.__init__(self) notify_about_gevent_if_needed() self._py_db = weakref.ref(py_db) self._kill_received = False mark_as_pydevd_daemon_thread(self) self._target_and_args = target_and_args @property def py_db(self): return self._py_db() def run(self): created_pydb_daemon = self.py_db.created_pydb_daemon_threads created_pydb_daemon[self] = 1 try: try: if IS_JYTHON and not isinstance(threading.current_thread(), threading._MainThread): # we shouldn't update sys.modules for the main thread, cause it leads to the second importing 'threading' # module, and the new instance of main thread is created ss = JyCore.PySystemState() # Note: Py.setSystemState() affects only the current thread. JyCore.Py.setSystemState(ss) self._stop_trace() self._on_run() except: if sys is not None and pydev_log_exception is not None: pydev_log_exception() finally: del created_pydb_daemon[self] def _on_run(self): if self._target_and_args is not None: target, args, kwargs = self._target_and_args target(*args, **kwargs) else: raise NotImplementedError('Should be reimplemented by: %s' % self.__class__) def do_kill_pydev_thread(self): if not self._kill_received: pydev_log.debug('%s received kill signal', self.name) self._kill_received = True def _stop_trace(self): if self.pydev_do_not_trace: pydevd_tracing.SetTrace(None) # no debugging on this thread def _collect_load_names(func): found_load_names = set() for instruction in iter_instructions(func.__code__): if instruction.opname in ('LOAD_GLOBAL', 'LOAD_ATTR', 'LOAD_METHOD'): found_load_names.add(instruction.argrepr) return found_load_names def _patch_threading_to_hide_pydevd_threads(): ''' Patches the needed functions on the `threading` module so that the pydevd threads are hidden. Note that we patch the functions __code__ to avoid issues if some code had already imported those variables prior to the patching. ''' found_load_names = _collect_load_names(threading.enumerate) # i.e.: we'll only apply the patching if the function seems to be what we expect. new_threading_enumerate = None if found_load_names in ( {'_active_limbo_lock', '_limbo', '_active', 'values', 'list'}, {'_active_limbo_lock', '_limbo', '_active', 'values', 'NULL + list'} ): pydev_log.debug('Applying patching to hide pydevd threads (Py3 version).') def new_threading_enumerate(): with _active_limbo_lock: ret = list(_active.values()) + list(_limbo.values()) return [t for t in ret if not getattr(t, 'is_pydev_daemon_thread', False)] elif found_load_names == set(('_active_limbo_lock', '_limbo', '_active', 'values')): pydev_log.debug('Applying patching to hide pydevd threads (Py2 version).') def new_threading_enumerate(): with _active_limbo_lock: ret = _active.values() + _limbo.values() return [t for t in ret if not getattr(t, 'is_pydev_daemon_thread', False)] else: pydev_log.info('Unable to hide pydevd threads. Found names in threading.enumerate: %s', found_load_names) if new_threading_enumerate is not None: def pydevd_saved_threading_enumerate(): with threading._active_limbo_lock: return list(threading._active.values()) + list(threading._limbo.values()) _pydev_saved_modules.pydevd_saved_threading_enumerate = pydevd_saved_threading_enumerate threading.enumerate.__code__ = new_threading_enumerate.__code__ # We also need to patch the active count (to match what we have in the enumerate). def new_active_count(): # Note: as this will be executed in the `threading` module, `enumerate` will # actually be threading.enumerate. return len(enumerate()) threading.active_count.__code__ = new_active_count.__code__ # When shutting down, Python (on some versions) may do something as: # # def _pickSomeNonDaemonThread(): # for t in enumerate(): # if not t.daemon and t.is_alive(): # return t # return None # # But in this particular case, we do want threads with `is_pydev_daemon_thread` to appear # explicitly due to the pydevd `CheckAliveThread` (because we want the shutdown to wait on it). # So, it can't rely on the `enumerate` for that anymore as it's patched to not return pydevd threads. if hasattr(threading, '_pickSomeNonDaemonThread'): def new_pick_some_non_daemon_thread(): with _active_limbo_lock: # Ok for py2 and py3. threads = list(_active.values()) + list(_limbo.values()) for t in threads: if not t.daemon and t.is_alive(): return t return None threading._pickSomeNonDaemonThread.__code__ = new_pick_some_non_daemon_thread.__code__ _patched_threading_to_hide_pydevd_threads = False def mark_as_pydevd_daemon_thread(thread): if not IS_JYTHON and not IS_IRONPYTHON and PYDEVD_APPLY_PATCHING_TO_HIDE_PYDEVD_THREADS: global _patched_threading_to_hide_pydevd_threads if not _patched_threading_to_hide_pydevd_threads: # When we mark the first thread as a pydevd daemon thread, we also change the threading # functions to hide pydevd threads. # Note: we don't just "hide" the pydevd threads from the threading module by not using it # (i.e.: just using the `thread.start_new_thread` instead of `threading.Thread`) # because there's 1 thread (the `CheckAliveThread`) which is a pydevd thread but # isn't really a daemon thread (so, we need CPython to wait on it for shutdown, # in which case it needs to be in `threading` and the patching would be needed anyways). _patched_threading_to_hide_pydevd_threads = True try: _patch_threading_to_hide_pydevd_threads() except: pydev_log.exception('Error applying patching to hide pydevd threads.') thread.pydev_do_not_trace = True thread.is_pydev_daemon_thread = True thread.daemon = True def run_as_pydevd_daemon_thread(py_db, func, *args, **kwargs): ''' Runs a function as a pydevd daemon thread (without any tracing in place). ''' t = PyDBDaemonThread(py_db, target_and_args=(func, args, kwargs)) t.name = '%s (pydevd daemon thread)' % (func.__name__,) t.start() return t
7,964
Python
40.056701
125
0.621673
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_filtering.py
import fnmatch import glob import os.path import sys from _pydev_bundle import pydev_log import pydevd_file_utils import json from collections import namedtuple from _pydev_bundle._pydev_saved_modules import threading from pydevd_file_utils import normcase from _pydevd_bundle.pydevd_constants import USER_CODE_BASENAMES_STARTING_WITH, \ LIBRARY_CODE_BASENAMES_STARTING_WITH, IS_PYPY, IS_WINDOWS from _pydevd_bundle import pydevd_constants ExcludeFilter = namedtuple('ExcludeFilter', 'name, exclude, is_path') def _convert_to_str_and_clear_empty(roots): new_roots = [] for root in roots: assert isinstance(root, str), '%s not str (found: %s)' % (root, type(root)) if root: new_roots.append(root) return new_roots def _check_matches(patterns, paths): if not patterns and not paths: # Matched to the end. return True if (not patterns and paths) or (patterns and not paths): return False pattern = normcase(patterns[0]) path = normcase(paths[0]) if not glob.has_magic(pattern): if pattern != path: return False elif pattern == '**': if len(patterns) == 1: return True # if ** is the last one it matches anything to the right. for i in range(len(paths)): # Recursively check the remaining patterns as the # current pattern could match any number of paths. if _check_matches(patterns[1:], paths[i:]): return True elif not fnmatch.fnmatch(path, pattern): # Current part doesn't match. return False return _check_matches(patterns[1:], paths[1:]) def glob_matches_path(path, pattern, sep=os.sep, altsep=os.altsep): if altsep: pattern = pattern.replace(altsep, sep) path = path.replace(altsep, sep) drive = '' if len(path) > 1 and path[1] == ':': drive, path = path[0], path[2:] if drive and len(pattern) > 1: if pattern[1] == ':': if drive.lower() != pattern[0].lower(): return False pattern = pattern[2:] patterns = pattern.split(sep) paths = path.split(sep) if paths: if paths[0] == '': paths = paths[1:] if patterns: if patterns[0] == '': patterns = patterns[1:] return _check_matches(patterns, paths) class FilesFiltering(object): ''' Note: calls at FilesFiltering are uncached. The actual API used should be through PyDB. ''' def __init__(self): self._exclude_filters = [] self._project_roots = [] self._library_roots = [] # Filter out libraries? self._use_libraries_filter = False self.require_module = False # True if some exclude filter filters by the module. self.set_use_libraries_filter(os.getenv('PYDEVD_FILTER_LIBRARIES') is not None) project_roots = os.getenv('IDE_PROJECT_ROOTS', None) if project_roots is not None: project_roots = project_roots.split(os.pathsep) else: project_roots = [] self.set_project_roots(project_roots) library_roots = os.getenv('LIBRARY_ROOTS', None) if library_roots is not None: library_roots = library_roots.split(os.pathsep) else: library_roots = self._get_default_library_roots() self.set_library_roots(library_roots) # Stepping filters. pydevd_filters = os.getenv('PYDEVD_FILTERS', '') # To filter out it's something as: {'**/not_my_code/**': True} if pydevd_filters: pydev_log.debug("PYDEVD_FILTERS %s", (pydevd_filters,)) if pydevd_filters.startswith('{'): # dict(glob_pattern (str) -> exclude(True or False)) exclude_filters = [] for key, val in json.loads(pydevd_filters).items(): exclude_filters.append(ExcludeFilter(key, val, True)) self._exclude_filters = exclude_filters else: # A ';' separated list of strings with globs for the # list of excludes. filters = pydevd_filters.split(';') new_filters = [] for new_filter in filters: if new_filter.strip(): new_filters.append(ExcludeFilter(new_filter.strip(), True, True)) self._exclude_filters = new_filters @classmethod def _get_default_library_roots(cls): pydev_log.debug("Collecting default library roots.") # Provide sensible defaults if not in env vars. import site roots = [] try: import sysconfig # Python 2.7 onwards only. except ImportError: pass else: for path_name in set(('stdlib', 'platstdlib', 'purelib', 'platlib')) & set(sysconfig.get_path_names()): roots.append(sysconfig.get_path(path_name)) # Make sure we always get at least the standard library location (based on the `os` and # `threading` modules -- it's a bit weird that it may be different on the ci, but it happens). roots.append(os.path.dirname(os.__file__)) roots.append(os.path.dirname(threading.__file__)) if IS_PYPY: # On PyPy 3.6 (7.3.1) it wrongly says that sysconfig.get_path('stdlib') is # <install>/lib-pypy when the installed version is <install>/lib_pypy. try: import _pypy_wait except ImportError: pydev_log.debug("Unable to import _pypy_wait on PyPy when collecting default library roots.") else: pypy_lib_dir = os.path.dirname(_pypy_wait.__file__) pydev_log.debug("Adding %s to default library roots.", pypy_lib_dir) roots.append(pypy_lib_dir) if hasattr(site, 'getusersitepackages'): site_paths = site.getusersitepackages() if isinstance(site_paths, (list, tuple)): for site_path in site_paths: roots.append(site_path) else: roots.append(site_paths) if hasattr(site, 'getsitepackages'): site_paths = site.getsitepackages() if isinstance(site_paths, (list, tuple)): for site_path in site_paths: roots.append(site_path) else: roots.append(site_paths) for path in sys.path: if os.path.exists(path) and os.path.basename(path) in ('site-packages', 'pip-global'): roots.append(path) roots.extend([os.path.realpath(path) for path in roots]) return sorted(set(roots)) def _fix_roots(self, roots): roots = _convert_to_str_and_clear_empty(roots) new_roots = [] for root in roots: path = self._absolute_normalized_path(root) if pydevd_constants.IS_WINDOWS: new_roots.append(path + '\\') else: new_roots.append(path + '/') return new_roots def _absolute_normalized_path(self, filename): ''' Provides a version of the filename that's absolute and normalized. ''' return normcase(pydevd_file_utils.absolute_path(filename)) def set_project_roots(self, project_roots): self._project_roots = self._fix_roots(project_roots) pydev_log.debug("IDE_PROJECT_ROOTS %s\n" % project_roots) def _get_project_roots(self): return self._project_roots def set_library_roots(self, roots): self._library_roots = self._fix_roots(roots) pydev_log.debug("LIBRARY_ROOTS %s\n" % roots) def _get_library_roots(self): return self._library_roots def in_project_roots(self, received_filename): ''' Note: don't call directly. Use PyDb.in_project_scope (there's no caching here and it doesn't handle all possibilities for knowing whether a project is actually in the scope, it just handles the heuristics based on the absolute_normalized_filename without the actual frame). ''' DEBUG = False if received_filename.startswith(USER_CODE_BASENAMES_STARTING_WITH): if DEBUG: pydev_log.debug('In in_project_roots - user basenames - starts with %s (%s)', received_filename, USER_CODE_BASENAMES_STARTING_WITH) return True if received_filename.startswith(LIBRARY_CODE_BASENAMES_STARTING_WITH): if DEBUG: pydev_log.debug('Not in in_project_roots - library basenames - starts with %s (%s)', received_filename, LIBRARY_CODE_BASENAMES_STARTING_WITH) return False project_roots = self._get_project_roots() # roots are absolute/normalized. absolute_normalized_filename = self._absolute_normalized_path(received_filename) absolute_normalized_filename_as_dir = absolute_normalized_filename + ('\\' if IS_WINDOWS else '/') found_in_project = [] for root in project_roots: if root and (absolute_normalized_filename.startswith(root) or root == absolute_normalized_filename_as_dir): if DEBUG: pydev_log.debug('In project: %s (%s)', absolute_normalized_filename, root) found_in_project.append(root) found_in_library = [] library_roots = self._get_library_roots() for root in library_roots: if root and (absolute_normalized_filename.startswith(root) or root == absolute_normalized_filename_as_dir): found_in_library.append(root) if DEBUG: pydev_log.debug('In library: %s (%s)', absolute_normalized_filename, root) else: if DEBUG: pydev_log.debug('Not in library: %s (%s)', absolute_normalized_filename, root) if not project_roots: # If we have no project roots configured, consider it being in the project # roots if it's not found in site-packages (because we have defaults for those # and not the other way around). in_project = not found_in_library if DEBUG: pydev_log.debug('Final in project (no project roots): %s (%s)', absolute_normalized_filename, in_project) else: in_project = False if found_in_project: if not found_in_library: if DEBUG: pydev_log.debug('Final in project (in_project and not found_in_library): %s (True)', absolute_normalized_filename) in_project = True else: # Found in both, let's see which one has the bigger path matched. if max(len(x) for x in found_in_project) > max(len(x) for x in found_in_library): in_project = True if DEBUG: pydev_log.debug('Final in project (found in both): %s (%s)', absolute_normalized_filename, in_project) return in_project def use_libraries_filter(self): ''' Should we debug only what's inside project folders? ''' return self._use_libraries_filter def set_use_libraries_filter(self, use): pydev_log.debug("pydevd: Use libraries filter: %s\n" % use) self._use_libraries_filter = use def use_exclude_filters(self): # Enabled if we have any filters registered. return len(self._exclude_filters) > 0 def exclude_by_filter(self, absolute_filename, module_name): ''' :return: True if it should be excluded, False if it should be included and None if no rule matched the given file. ''' for exclude_filter in self._exclude_filters: # : :type exclude_filter: ExcludeFilter if exclude_filter.is_path: if glob_matches_path(absolute_filename, exclude_filter.name): return exclude_filter.exclude else: # Module filter. if exclude_filter.name == module_name or module_name.startswith(exclude_filter.name + '.'): return exclude_filter.exclude return None def set_exclude_filters(self, exclude_filters): ''' :param list(ExcludeFilter) exclude_filters: ''' self._exclude_filters = exclude_filters self.require_module = False for exclude_filter in exclude_filters: if not exclude_filter.is_path: self.require_module = True break
12,701
Python
37.259036
157
0.587985
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py
import json import os import sys import traceback from _pydev_bundle import pydev_log from _pydev_bundle.pydev_log import exception as pydev_log_exception from _pydevd_bundle import pydevd_traceproperty, pydevd_dont_trace, pydevd_utils from _pydevd_bundle.pydevd_additional_thread_info import set_additional_thread_info from _pydevd_bundle.pydevd_breakpoints import get_exception_class from _pydevd_bundle.pydevd_comm import ( InternalEvaluateConsoleExpression, InternalConsoleGetCompletions, InternalRunCustomOperation, internal_get_next_statement_targets, internal_get_smart_step_into_variants) from _pydevd_bundle.pydevd_constants import NEXT_VALUE_SEPARATOR, IS_WINDOWS, NULL from _pydevd_bundle.pydevd_comm_constants import ID_TO_MEANING, CMD_EXEC_EXPRESSION, CMD_AUTHENTICATE from _pydevd_bundle.pydevd_api import PyDevdAPI from io import StringIO from _pydevd_bundle.pydevd_net_command import NetCommand from _pydevd_bundle.pydevd_thread_lifecycle import pydevd_find_thread_by_id import pydevd_file_utils class _PyDevCommandProcessor(object): def __init__(self): self.api = PyDevdAPI() def process_net_command(self, py_db, cmd_id, seq, text): '''Processes a command received from the Java side @param cmd_id: the id of the command @param seq: the sequence of the command @param text: the text received in the command ''' # We can only proceed if the client is already authenticated or if it's the # command to authenticate. if cmd_id != CMD_AUTHENTICATE and not py_db.authentication.is_authenticated(): cmd = py_db.cmd_factory.make_error_message(seq, 'Client not authenticated.') py_db.writer.add_command(cmd) return meaning = ID_TO_MEANING[str(cmd_id)] # print('Handling %s (%s)' % (meaning, text)) method_name = meaning.lower() on_command = getattr(self, method_name.lower(), None) if on_command is None: # I have no idea what this is all about cmd = py_db.cmd_factory.make_error_message(seq, "unexpected command " + str(cmd_id)) py_db.writer.add_command(cmd) return lock = py_db._main_lock if method_name == 'cmd_thread_dump_to_stderr': # We can skip the main debugger locks for cases where we know it's not needed. lock = NULL with lock: try: cmd = on_command(py_db, cmd_id, seq, text) if cmd is not None: py_db.writer.add_command(cmd) except: if traceback is not None and sys is not None and pydev_log_exception is not None: pydev_log_exception() stream = StringIO() traceback.print_exc(file=stream) cmd = py_db.cmd_factory.make_error_message( seq, "Unexpected exception in process_net_command.\nInitial params: %s. Exception: %s" % ( ((cmd_id, seq, text), stream.getvalue()) ) ) if cmd is not None: py_db.writer.add_command(cmd) def cmd_authenticate(self, py_db, cmd_id, seq, text): access_token = text py_db.authentication.login(access_token) if py_db.authentication.is_authenticated(): return NetCommand(cmd_id, seq, py_db.authentication.client_access_token) return py_db.cmd_factory.make_error_message(seq, 'Client not authenticated.') def cmd_run(self, py_db, cmd_id, seq, text): return self.api.run(py_db) def cmd_list_threads(self, py_db, cmd_id, seq, text): return self.api.list_threads(py_db, seq) def cmd_get_completions(self, py_db, cmd_id, seq, text): # we received some command to get a variable # the text is: thread_id\tframe_id\tactivation token thread_id, frame_id, _scope, act_tok = text.split('\t', 3) return self.api.request_completions(py_db, seq, thread_id, frame_id, act_tok) def cmd_get_thread_stack(self, py_db, cmd_id, seq, text): # Receives a thread_id and a given timeout, which is the time we should # wait to the provide the stack if a given thread is still not suspended. if '\t' in text: thread_id, timeout = text.split('\t') timeout = float(timeout) else: thread_id = text timeout = .5 # Default timeout is .5 seconds return self.api.request_stack(py_db, seq, thread_id, fmt={}, timeout=timeout) def cmd_set_protocol(self, py_db, cmd_id, seq, text): return self.api.set_protocol(py_db, seq, text.strip()) def cmd_thread_suspend(self, py_db, cmd_id, seq, text): return self.api.request_suspend_thread(py_db, text.strip()) def cmd_version(self, py_db, cmd_id, seq, text): # Default based on server process (although ideally the IDE should # provide it). if IS_WINDOWS: ide_os = 'WINDOWS' else: ide_os = 'UNIX' # Breakpoints can be grouped by 'LINE' or by 'ID'. breakpoints_by = 'LINE' splitted = text.split('\t') if len(splitted) == 1: _local_version = splitted elif len(splitted) == 2: _local_version, ide_os = splitted elif len(splitted) == 3: _local_version, ide_os, breakpoints_by = splitted version_msg = self.api.set_ide_os_and_breakpoints_by(py_db, seq, ide_os, breakpoints_by) # Enable thread notifications after the version command is completed. self.api.set_enable_thread_notifications(py_db, True) return version_msg def cmd_thread_run(self, py_db, cmd_id, seq, text): return self.api.request_resume_thread(text.strip()) def _cmd_step(self, py_db, cmd_id, seq, text): return self.api.request_step(py_db, text.strip(), cmd_id) cmd_step_into = _cmd_step cmd_step_into_my_code = _cmd_step cmd_step_over = _cmd_step cmd_step_over_my_code = _cmd_step cmd_step_return = _cmd_step cmd_step_return_my_code = _cmd_step def _cmd_set_next(self, py_db, cmd_id, seq, text): thread_id, line, func_name = text.split('\t', 2) return self.api.request_set_next(py_db, seq, thread_id, cmd_id, None, line, func_name) cmd_run_to_line = _cmd_set_next cmd_set_next_statement = _cmd_set_next def cmd_smart_step_into(self, py_db, cmd_id, seq, text): thread_id, line_or_bytecode_offset, func_name = text.split('\t', 2) if line_or_bytecode_offset.startswith('offset='): # In this case we request the smart step into to stop given the parent frame # and the location of the parent frame bytecode offset and not just the func_name # (this implies that `CMD_GET_SMART_STEP_INTO_VARIANTS` was previously used # to know what are the valid stop points). temp = line_or_bytecode_offset[len('offset='):] if ';' in temp: offset, child_offset = temp.split(';') offset = int(offset) child_offset = int(child_offset) else: child_offset = -1 offset = int(temp) return self.api.request_smart_step_into(py_db, seq, thread_id, offset, child_offset) else: # If the offset wasn't passed, just use the line/func_name to do the stop. return self.api.request_smart_step_into_by_func_name(py_db, seq, thread_id, line_or_bytecode_offset, func_name) def cmd_reload_code(self, py_db, cmd_id, seq, text): text = text.strip() if '\t' not in text: module_name = text.strip() filename = None else: module_name, filename = text.split('\t', 1) self.api.request_reload_code(py_db, seq, module_name, filename) def cmd_change_variable(self, py_db, cmd_id, seq, text): # the text is: thread\tstackframe\tFRAME|GLOBAL\tattribute_to_change\tvalue_to_change thread_id, frame_id, scope, attr_and_value = text.split('\t', 3) tab_index = attr_and_value.rindex('\t') attr = attr_and_value[0:tab_index].replace('\t', '.') value = attr_and_value[tab_index + 1:] self.api.request_change_variable(py_db, seq, thread_id, frame_id, scope, attr, value) def cmd_get_variable(self, py_db, cmd_id, seq, text): # we received some command to get a variable # the text is: thread_id\tframe_id\tFRAME|GLOBAL\tattributes* thread_id, frame_id, scopeattrs = text.split('\t', 2) if scopeattrs.find('\t') != -1: # there are attributes beyond scope scope, attrs = scopeattrs.split('\t', 1) else: scope, attrs = (scopeattrs, None) self.api.request_get_variable(py_db, seq, thread_id, frame_id, scope, attrs) def cmd_get_array(self, py_db, cmd_id, seq, text): # Note: untested and unused in pydev # we received some command to get an array variable # the text is: thread_id\tframe_id\tFRAME|GLOBAL\tname\ttemp\troffs\tcoffs\trows\tcols\tformat roffset, coffset, rows, cols, format, thread_id, frame_id, scopeattrs = text.split('\t', 7) if scopeattrs.find('\t') != -1: # there are attributes beyond scope scope, attrs = scopeattrs.split('\t', 1) else: scope, attrs = (scopeattrs, None) self.api.request_get_array(py_db, seq, roffset, coffset, rows, cols, format, thread_id, frame_id, scope, attrs) def cmd_show_return_values(self, py_db, cmd_id, seq, text): show_return_values = text.split('\t')[1] self.api.set_show_return_values(py_db, int(show_return_values) == 1) def cmd_load_full_value(self, py_db, cmd_id, seq, text): # Note: untested and unused in pydev thread_id, frame_id, scopeattrs = text.split('\t', 2) vars = scopeattrs.split(NEXT_VALUE_SEPARATOR) self.api.request_load_full_value(py_db, seq, thread_id, frame_id, vars) def cmd_get_description(self, py_db, cmd_id, seq, text): # Note: untested and unused in pydev thread_id, frame_id, expression = text.split('\t', 2) self.api.request_get_description(py_db, seq, thread_id, frame_id, expression) def cmd_get_frame(self, py_db, cmd_id, seq, text): thread_id, frame_id, scope = text.split('\t', 2) self.api.request_get_frame(py_db, seq, thread_id, frame_id) def cmd_set_break(self, py_db, cmd_id, seq, text): # func name: 'None': match anything. Empty: match global, specified: only method context. # command to add some breakpoint. # text is filename\tline. Add to breakpoints dictionary suspend_policy = u"NONE" # Can be 'NONE' or 'ALL' is_logpoint = False hit_condition = None if py_db._set_breakpoints_with_id: try: try: breakpoint_id, btype, filename, line, func_name, condition, expression, hit_condition, is_logpoint, suspend_policy = text.split(u'\t', 9) except ValueError: # not enough values to unpack # No suspend_policy passed (use default). breakpoint_id, btype, filename, line, func_name, condition, expression, hit_condition, is_logpoint = text.split(u'\t', 8) is_logpoint = is_logpoint == u'True' except ValueError: # not enough values to unpack breakpoint_id, btype, filename, line, func_name, condition, expression = text.split(u'\t', 6) breakpoint_id = int(breakpoint_id) line = int(line) # We must restore new lines and tabs as done in # AbstractDebugTarget.breakpointAdded condition = condition.replace(u"@_@NEW_LINE_CHAR@_@", u'\n').\ replace(u"@_@TAB_CHAR@_@", u'\t').strip() expression = expression.replace(u"@_@NEW_LINE_CHAR@_@", u'\n').\ replace(u"@_@TAB_CHAR@_@", u'\t').strip() else: # Note: this else should be removed after PyCharm migrates to setting # breakpoints by id (and ideally also provides func_name). btype, filename, line, func_name, suspend_policy, condition, expression = text.split(u'\t', 6) # If we don't have an id given for each breakpoint, consider # the id to be the line. breakpoint_id = line = int(line) condition = condition.replace(u"@_@NEW_LINE_CHAR@_@", u'\n'). \ replace(u"@_@TAB_CHAR@_@", u'\t').strip() expression = expression.replace(u"@_@NEW_LINE_CHAR@_@", u'\n'). \ replace(u"@_@TAB_CHAR@_@", u'\t').strip() if condition is not None and (len(condition) <= 0 or condition == u"None"): condition = None if expression is not None and (len(expression) <= 0 or expression == u"None"): expression = None if hit_condition is not None and (len(hit_condition) <= 0 or hit_condition == u"None"): hit_condition = None def on_changed_breakpoint_state(breakpoint_id, add_breakpoint_result): error_code = add_breakpoint_result.error_code translated_line = add_breakpoint_result.translated_line translated_filename = add_breakpoint_result.translated_filename msg = '' if error_code: if error_code == self.api.ADD_BREAKPOINT_FILE_NOT_FOUND: msg = 'pydev debugger: Trying to add breakpoint to file that does not exist: %s (will have no effect).\n' % (translated_filename,) elif error_code == self.api.ADD_BREAKPOINT_FILE_EXCLUDED_BY_FILTERS: msg = 'pydev debugger: Trying to add breakpoint to file that is excluded by filters: %s (will have no effect).\n' % (translated_filename,) elif error_code == self.api.ADD_BREAKPOINT_LAZY_VALIDATION: msg = '' # Ignore this here (if/when loaded, it'll call on_changed_breakpoint_state again accordingly). elif error_code == self.api.ADD_BREAKPOINT_INVALID_LINE: msg = 'pydev debugger: Trying to add breakpoint to line (%s) that is not valid in: %s.\n' % (translated_line, translated_filename,) else: # Shouldn't get here. msg = 'pydev debugger: Breakpoint not validated (reason unknown -- please report as error): %s (%s).\n' % (translated_filename, translated_line) else: if add_breakpoint_result.original_line != translated_line: msg = 'pydev debugger (info): Breakpoint in line: %s moved to line: %s (in %s).\n' % (add_breakpoint_result.original_line, translated_line, translated_filename) if msg: py_db.writer.add_command(py_db.cmd_factory.make_warning_message(msg)) result = self.api.add_breakpoint( py_db, self.api.filename_to_str(filename), btype, breakpoint_id, line, condition, func_name, expression, suspend_policy, hit_condition, is_logpoint, on_changed_breakpoint_state=on_changed_breakpoint_state) on_changed_breakpoint_state(breakpoint_id, result) def cmd_remove_break(self, py_db, cmd_id, seq, text): # command to remove some breakpoint # text is type\file\tid. Remove from breakpoints dictionary breakpoint_type, filename, breakpoint_id = text.split('\t', 2) filename = self.api.filename_to_str(filename) try: breakpoint_id = int(breakpoint_id) except ValueError: pydev_log.critical('Error removing breakpoint. Expected breakpoint_id to be an int. Found: %s', breakpoint_id) else: self.api.remove_breakpoint(py_db, filename, breakpoint_type, breakpoint_id) def _cmd_exec_or_evaluate_expression(self, py_db, cmd_id, seq, text): # command to evaluate the given expression # text is: thread\tstackframe\tLOCAL\texpression attr_to_set_result = "" try: thread_id, frame_id, scope, expression, trim, attr_to_set_result = text.split('\t', 5) except ValueError: thread_id, frame_id, scope, expression, trim = text.split('\t', 4) is_exec = cmd_id == CMD_EXEC_EXPRESSION trim_if_too_big = int(trim) == 1 self.api.request_exec_or_evaluate( py_db, seq, thread_id, frame_id, expression, is_exec, trim_if_too_big, attr_to_set_result) cmd_evaluate_expression = _cmd_exec_or_evaluate_expression cmd_exec_expression = _cmd_exec_or_evaluate_expression def cmd_console_exec(self, py_db, cmd_id, seq, text): # command to exec expression in console, in case expression is only partially valid 'False' is returned # text is: thread\tstackframe\tLOCAL\texpression thread_id, frame_id, scope, expression = text.split('\t', 3) self.api.request_console_exec(py_db, seq, thread_id, frame_id, expression) def cmd_set_path_mapping_json(self, py_db, cmd_id, seq, text): ''' :param text: Json text. Something as: { "pathMappings": [ { "localRoot": "c:/temp", "remoteRoot": "/usr/temp" } ], "debug": true, "force": false } ''' as_json = json.loads(text) force = as_json.get('force', False) path_mappings = [] for pathMapping in as_json.get('pathMappings', []): localRoot = pathMapping.get('localRoot', '') remoteRoot = pathMapping.get('remoteRoot', '') if (localRoot != '') and (remoteRoot != ''): path_mappings.append((localRoot, remoteRoot)) if bool(path_mappings) or force: pydevd_file_utils.setup_client_server_paths(path_mappings) debug = as_json.get('debug', False) if debug or force: pydevd_file_utils.DEBUG_CLIENT_SERVER_TRANSLATION = debug def cmd_set_py_exception_json(self, py_db, cmd_id, seq, text): # This API is optional and works 'in bulk' -- it's possible # to get finer-grained control with CMD_ADD_EXCEPTION_BREAK/CMD_REMOVE_EXCEPTION_BREAK # which allows setting caught/uncaught per exception, although global settings such as: # - skip_on_exceptions_thrown_in_same_context # - ignore_exceptions_thrown_in_lines_with_ignore_exception # must still be set through this API (before anything else as this clears all existing # exception breakpoints). try: py_db.break_on_uncaught_exceptions = {} py_db.break_on_caught_exceptions = {} py_db.break_on_user_uncaught_exceptions = {} as_json = json.loads(text) break_on_uncaught = as_json.get('break_on_uncaught', False) break_on_caught = as_json.get('break_on_caught', False) break_on_user_caught = as_json.get('break_on_user_caught', False) py_db.skip_on_exceptions_thrown_in_same_context = as_json.get('skip_on_exceptions_thrown_in_same_context', False) py_db.ignore_exceptions_thrown_in_lines_with_ignore_exception = as_json.get('ignore_exceptions_thrown_in_lines_with_ignore_exception', False) ignore_libraries = as_json.get('ignore_libraries', False) exception_types = as_json.get('exception_types', []) for exception_type in exception_types: if not exception_type: continue py_db.add_break_on_exception( exception_type, condition=None, expression=None, notify_on_handled_exceptions=break_on_caught, notify_on_unhandled_exceptions=break_on_uncaught, notify_on_user_unhandled_exceptions=break_on_user_caught, notify_on_first_raise_only=True, ignore_libraries=ignore_libraries, ) py_db.on_breakpoints_changed() except: pydev_log.exception("Error when setting exception list. Received: %s", text) def cmd_set_py_exception(self, py_db, cmd_id, seq, text): # DEPRECATED. Use cmd_set_py_exception_json instead. try: splitted = text.split(';') py_db.break_on_uncaught_exceptions = {} py_db.break_on_caught_exceptions = {} py_db.break_on_user_uncaught_exceptions = {} if len(splitted) >= 5: if splitted[0] == 'true': break_on_uncaught = True else: break_on_uncaught = False if splitted[1] == 'true': break_on_caught = True else: break_on_caught = False if splitted[2] == 'true': py_db.skip_on_exceptions_thrown_in_same_context = True else: py_db.skip_on_exceptions_thrown_in_same_context = False if splitted[3] == 'true': py_db.ignore_exceptions_thrown_in_lines_with_ignore_exception = True else: py_db.ignore_exceptions_thrown_in_lines_with_ignore_exception = False if splitted[4] == 'true': ignore_libraries = True else: ignore_libraries = False for exception_type in splitted[5:]: exception_type = exception_type.strip() if not exception_type: continue py_db.add_break_on_exception( exception_type, condition=None, expression=None, notify_on_handled_exceptions=break_on_caught, notify_on_unhandled_exceptions=break_on_uncaught, notify_on_user_unhandled_exceptions=False, # TODO (not currently supported in this API). notify_on_first_raise_only=True, ignore_libraries=ignore_libraries, ) else: pydev_log.exception("Expected to have at least 5 ';' separated items. Received: %s", text) except: pydev_log.exception("Error when setting exception list. Received: %s", text) def _load_source(self, py_db, cmd_id, seq, text): filename = text filename = self.api.filename_to_str(filename) self.api.request_load_source(py_db, seq, filename) cmd_load_source = _load_source cmd_get_file_contents = _load_source def cmd_load_source_from_frame_id(self, py_db, cmd_id, seq, text): frame_id = text self.api.request_load_source_from_frame_id(py_db, seq, frame_id) def cmd_set_property_trace(self, py_db, cmd_id, seq, text): # Command which receives whether to trace property getter/setter/deleter # text is feature_state(true/false);disable_getter/disable_setter/disable_deleter if text: splitted = text.split(';') if len(splitted) >= 3: if not py_db.disable_property_trace and splitted[0] == 'true': # Replacing property by custom property only when the debugger starts pydevd_traceproperty.replace_builtin_property() py_db.disable_property_trace = True # Enable/Disable tracing of the property getter if splitted[1] == 'true': py_db.disable_property_getter_trace = True else: py_db.disable_property_getter_trace = False # Enable/Disable tracing of the property setter if splitted[2] == 'true': py_db.disable_property_setter_trace = True else: py_db.disable_property_setter_trace = False # Enable/Disable tracing of the property deleter if splitted[3] == 'true': py_db.disable_property_deleter_trace = True else: py_db.disable_property_deleter_trace = False def cmd_add_exception_break(self, py_db, cmd_id, seq, text): # Note that this message has some idiosyncrasies... # # notify_on_handled_exceptions can be 0, 1 or 2 # 0 means we should not stop on handled exceptions. # 1 means we should stop on handled exceptions showing it on all frames where the exception passes. # 2 means we should stop on handled exceptions but we should only notify about it once. # # To ignore_libraries properly, besides setting ignore_libraries to 1, the IDE_PROJECT_ROOTS environment # variable must be set (so, we'll ignore anything not below IDE_PROJECT_ROOTS) -- this is not ideal as # the environment variable may not be properly set if it didn't start from the debugger (we should # create a custom message for that). # # There are 2 global settings which can only be set in CMD_SET_PY_EXCEPTION. Namely: # # py_db.skip_on_exceptions_thrown_in_same_context # - If True, we should only show the exception in a caller, not where it was first raised. # # py_db.ignore_exceptions_thrown_in_lines_with_ignore_exception # - If True exceptions thrown in lines with '@IgnoreException' will not be shown. condition = "" expression = "" if text.find('\t') != -1: try: exception, condition, expression, notify_on_handled_exceptions, notify_on_unhandled_exceptions, ignore_libraries = text.split('\t', 5) except: exception, notify_on_handled_exceptions, notify_on_unhandled_exceptions, ignore_libraries = text.split('\t', 3) else: exception, notify_on_handled_exceptions, notify_on_unhandled_exceptions, ignore_libraries = text, 0, 0, 0 condition = condition.replace("@_@NEW_LINE_CHAR@_@", '\n').replace("@_@TAB_CHAR@_@", '\t').strip() if condition is not None and (len(condition) == 0 or condition == "None"): condition = None expression = expression.replace("@_@NEW_LINE_CHAR@_@", '\n').replace("@_@TAB_CHAR@_@", '\t').strip() if expression is not None and (len(expression) == 0 or expression == "None"): expression = None if exception.find('-') != -1: breakpoint_type, exception = exception.split('-') else: breakpoint_type = 'python' if breakpoint_type == 'python': self.api.add_python_exception_breakpoint( py_db, exception, condition, expression, notify_on_handled_exceptions=int(notify_on_handled_exceptions) > 0, notify_on_unhandled_exceptions=int(notify_on_unhandled_exceptions) == 1, notify_on_user_unhandled_exceptions=0, # TODO (not currently supported in this API). notify_on_first_raise_only=int(notify_on_handled_exceptions) == 2, ignore_libraries=int(ignore_libraries) > 0, ) else: self.api.add_plugins_exception_breakpoint(py_db, breakpoint_type, exception) def cmd_remove_exception_break(self, py_db, cmd_id, seq, text): exception = text if exception.find('-') != -1: exception_type, exception = exception.split('-') else: exception_type = 'python' if exception_type == 'python': self.api.remove_python_exception_breakpoint(py_db, exception) else: self.api.remove_plugins_exception_breakpoint(py_db, exception_type, exception) def cmd_add_django_exception_break(self, py_db, cmd_id, seq, text): self.api.add_plugins_exception_breakpoint(py_db, breakpoint_type='django', exception=text) def cmd_remove_django_exception_break(self, py_db, cmd_id, seq, text): self.api.remove_plugins_exception_breakpoint(py_db, exception_type='django', exception=text) def cmd_evaluate_console_expression(self, py_db, cmd_id, seq, text): # Command which takes care for the debug console communication if text != "": thread_id, frame_id, console_command = text.split('\t', 2) console_command, line = console_command.split('\t') if console_command == 'EVALUATE': int_cmd = InternalEvaluateConsoleExpression( seq, thread_id, frame_id, line, buffer_output=True) elif console_command == 'EVALUATE_UNBUFFERED': int_cmd = InternalEvaluateConsoleExpression( seq, thread_id, frame_id, line, buffer_output=False) elif console_command == 'GET_COMPLETIONS': int_cmd = InternalConsoleGetCompletions(seq, thread_id, frame_id, line) else: raise ValueError('Unrecognized command: %s' % (console_command,)) py_db.post_internal_command(int_cmd, thread_id) def cmd_run_custom_operation(self, py_db, cmd_id, seq, text): # Command which runs a custom operation if text != "": try: location, custom = text.split('||', 1) except: sys.stderr.write('Custom operation now needs a || separator. Found: %s\n' % (text,)) raise thread_id, frame_id, scopeattrs = location.split('\t', 2) if scopeattrs.find('\t') != -1: # there are attributes beyond scope scope, attrs = scopeattrs.split('\t', 1) else: scope, attrs = (scopeattrs, None) # : style: EXECFILE or EXEC # : encoded_code_or_file: file to execute or code # : fname: name of function to be executed in the resulting namespace style, encoded_code_or_file, fnname = custom.split('\t', 3) int_cmd = InternalRunCustomOperation(seq, thread_id, frame_id, scope, attrs, style, encoded_code_or_file, fnname) py_db.post_internal_command(int_cmd, thread_id) def cmd_ignore_thrown_exception_at(self, py_db, cmd_id, seq, text): if text: replace = 'REPLACE:' # Not all 3.x versions support u'REPLACE:', so, doing workaround. if text.startswith(replace): text = text[8:] py_db.filename_to_lines_where_exceptions_are_ignored.clear() if text: for line in text.split('||'): # Can be bulk-created (one in each line) original_filename, line_number = line.split('|') original_filename = self.api.filename_to_server(original_filename) canonical_normalized_filename = pydevd_file_utils.canonical_normalized_path(original_filename) absolute_filename = pydevd_file_utils.absolute_path(original_filename) if os.path.exists(absolute_filename): lines_ignored = py_db.filename_to_lines_where_exceptions_are_ignored.get(canonical_normalized_filename) if lines_ignored is None: lines_ignored = py_db.filename_to_lines_where_exceptions_are_ignored[canonical_normalized_filename] = {} lines_ignored[int(line_number)] = 1 else: sys.stderr.write('pydev debugger: warning: trying to ignore exception thrown'\ ' on file that does not exist: %s (will have no effect)\n' % (absolute_filename,)) def cmd_enable_dont_trace(self, py_db, cmd_id, seq, text): if text: true_str = 'true' # Not all 3.x versions support u'str', so, doing workaround. mode = text.strip() == true_str pydevd_dont_trace.trace_filter(mode) def cmd_redirect_output(self, py_db, cmd_id, seq, text): if text: py_db.enable_output_redirection('STDOUT' in text, 'STDERR' in text) def cmd_get_next_statement_targets(self, py_db, cmd_id, seq, text): thread_id, frame_id = text.split('\t', 1) py_db.post_method_as_internal_command( thread_id, internal_get_next_statement_targets, seq, thread_id, frame_id) def cmd_get_smart_step_into_variants(self, py_db, cmd_id, seq, text): thread_id, frame_id, start_line, end_line = text.split('\t', 3) py_db.post_method_as_internal_command( thread_id, internal_get_smart_step_into_variants, seq, thread_id, frame_id, start_line, end_line, set_additional_thread_info=set_additional_thread_info) def cmd_set_project_roots(self, py_db, cmd_id, seq, text): self.api.set_project_roots(py_db, text.split(u'\t')) def cmd_thread_dump_to_stderr(self, py_db, cmd_id, seq, text): pydevd_utils.dump_threads() def cmd_stop_on_start(self, py_db, cmd_id, seq, text): if text.strip() in ('True', 'true', '1'): self.api.stop_on_entry() def cmd_pydevd_json_config(self, py_db, cmd_id, seq, text): # Expected to receive a json string as: # { # 'skip_suspend_on_breakpoint_exception': [<exception names where we should suspend>], # 'skip_print_breakpoint_exception': [<exception names where we should print>], # 'multi_threads_single_notification': bool, # } msg = json.loads(text.strip()) if 'skip_suspend_on_breakpoint_exception' in msg: py_db.skip_suspend_on_breakpoint_exception = tuple( get_exception_class(x) for x in msg['skip_suspend_on_breakpoint_exception']) if 'skip_print_breakpoint_exception' in msg: py_db.skip_print_breakpoint_exception = tuple( get_exception_class(x) for x in msg['skip_print_breakpoint_exception']) if 'multi_threads_single_notification' in msg: py_db.multi_threads_single_notification = msg['multi_threads_single_notification'] def cmd_get_exception_details(self, py_db, cmd_id, seq, text): thread_id = text t = pydevd_find_thread_by_id(thread_id) frame = None if t and not getattr(t, 'pydev_do_not_trace', None): additional_info = set_additional_thread_info(t) frame = additional_info.get_topmost_frame(t) try: return py_db.cmd_factory.make_get_exception_details_message(py_db, seq, thread_id, frame) finally: frame = None t = None process_net_command = _PyDevCommandProcessor().process_net_command
35,106
Python
45.315303
180
0.59326
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_xml.py
import json from _pydev_bundle.pydev_is_thread_alive import is_thread_alive from _pydev_bundle._pydev_saved_modules import thread from _pydevd_bundle import pydevd_xml, pydevd_frame_utils, pydevd_constants, pydevd_utils from _pydevd_bundle.pydevd_comm_constants import ( CMD_THREAD_CREATE, CMD_THREAD_KILL, CMD_THREAD_SUSPEND, CMD_THREAD_RUN, CMD_GET_VARIABLE, CMD_EVALUATE_EXPRESSION, CMD_GET_FRAME, CMD_WRITE_TO_CONSOLE, CMD_GET_COMPLETIONS, CMD_LOAD_SOURCE, CMD_SET_NEXT_STATEMENT, CMD_EXIT, CMD_GET_FILE_CONTENTS, CMD_EVALUATE_CONSOLE_EXPRESSION, CMD_RUN_CUSTOM_OPERATION, CMD_GET_BREAKPOINT_EXCEPTION, CMD_SEND_CURR_EXCEPTION_TRACE, CMD_SEND_CURR_EXCEPTION_TRACE_PROCEEDED, CMD_SHOW_CONSOLE, CMD_GET_ARRAY, CMD_INPUT_REQUESTED, CMD_GET_DESCRIPTION, CMD_PROCESS_CREATED, CMD_SHOW_CYTHON_WARNING, CMD_LOAD_FULL_VALUE, CMD_GET_THREAD_STACK, CMD_GET_EXCEPTION_DETAILS, CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION, CMD_THREAD_RESUME_SINGLE_NOTIFICATION, CMD_GET_NEXT_STATEMENT_TARGETS, CMD_VERSION, CMD_RETURN, CMD_SET_PROTOCOL, CMD_ERROR, MAX_IO_MSG_SIZE, VERSION_STRING, CMD_RELOAD_CODE, CMD_LOAD_SOURCE_FROM_FRAME_ID) from _pydevd_bundle.pydevd_constants import (DebugInfoHolder, get_thread_id, get_global_debugger, GetGlobalDebugger, set_global_debugger) # Keep for backward compatibility @UnusedImport from _pydevd_bundle.pydevd_net_command import NetCommand, NULL_NET_COMMAND, NULL_EXIT_COMMAND from _pydevd_bundle.pydevd_utils import quote_smart as quote, get_non_pydevd_threads from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame import pydevd_file_utils from pydevd_tracing import get_exception_traceback_str from _pydev_bundle._pydev_completer import completions_to_xml from _pydev_bundle import pydev_log from _pydevd_bundle.pydevd_frame_utils import FramesList from io import StringIO #======================================================================================================================= # NetCommandFactory #======================================================================================================================= class NetCommandFactory(object): def __init__(self): self._additional_thread_id_to_thread_name = {} def _thread_to_xml(self, thread): """ thread information as XML """ name = pydevd_xml.make_valid_xml_value(thread.name) cmd_text = '<thread name="%s" id="%s" />' % (quote(name), get_thread_id(thread)) return cmd_text def make_error_message(self, seq, text): cmd = NetCommand(CMD_ERROR, seq, text) if DebugInfoHolder.DEBUG_TRACE_LEVEL > 2: pydev_log.error("Error: %s" % (text,)) return cmd def make_protocol_set_message(self, seq): return NetCommand(CMD_SET_PROTOCOL, seq, '') def make_thread_created_message(self, thread): cmdText = "<xml>" + self._thread_to_xml(thread) + "</xml>" return NetCommand(CMD_THREAD_CREATE, 0, cmdText) def make_process_created_message(self): cmdText = '<process/>' return NetCommand(CMD_PROCESS_CREATED, 0, cmdText) def make_process_about_to_be_replaced_message(self): return NULL_NET_COMMAND def make_show_cython_warning_message(self): try: return NetCommand(CMD_SHOW_CYTHON_WARNING, 0, '') except: return self.make_error_message(0, get_exception_traceback_str()) def make_custom_frame_created_message(self, frame_id, frame_description): self._additional_thread_id_to_thread_name[frame_id] = frame_description frame_description = pydevd_xml.make_valid_xml_value(frame_description) return NetCommand(CMD_THREAD_CREATE, 0, '<xml><thread name="%s" id="%s"/></xml>' % (frame_description, frame_id)) def make_list_threads_message(self, py_db, seq): """ returns thread listing as XML """ try: threads = get_non_pydevd_threads() cmd_text = ["<xml>"] append = cmd_text.append for thread in threads: if is_thread_alive(thread): append(self._thread_to_xml(thread)) for thread_id, thread_name in list(self._additional_thread_id_to_thread_name.items()): name = pydevd_xml.make_valid_xml_value(thread_name) append('<thread name="%s" id="%s" />' % (quote(name), thread_id)) append("</xml>") return NetCommand(CMD_RETURN, seq, ''.join(cmd_text)) except: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_thread_stack_message(self, py_db, seq, thread_id, topmost_frame, fmt, must_be_suspended=False, start_frame=0, levels=0): """ Returns thread stack as XML. :param must_be_suspended: If True and the thread is not suspended, returns None. """ try: # If frame is None, the return is an empty frame list. cmd_text = ['<xml><thread id="%s">' % (thread_id,)] if topmost_frame is not None: try: # : :type suspended_frames_manager: SuspendedFramesManager suspended_frames_manager = py_db.suspended_frames_manager frames_list = suspended_frames_manager.get_frames_list(thread_id) if frames_list is None: # Could not find stack of suspended frame... if must_be_suspended: return None else: frames_list = pydevd_frame_utils.create_frames_list_from_frame(topmost_frame) cmd_text.append(self.make_thread_stack_str(py_db, frames_list)) finally: topmost_frame = None cmd_text.append('</thread></xml>') return NetCommand(CMD_GET_THREAD_STACK, seq, ''.join(cmd_text)) except: return self.make_error_message(seq, get_exception_traceback_str()) def make_variable_changed_message(self, seq, payload): # notify debugger that value was changed successfully return NetCommand(CMD_RETURN, seq, payload) def make_warning_message(self, msg): return self.make_io_message(msg, 2) def make_io_message(self, msg, ctx): ''' @param msg: the message to pass to the debug server @param ctx: 1 for stdio 2 for stderr ''' try: msg = pydevd_constants.as_str(msg) if len(msg) > MAX_IO_MSG_SIZE: msg = msg[0:MAX_IO_MSG_SIZE] msg += '...' msg = pydevd_xml.make_valid_xml_value(quote(msg, '/>_= ')) return NetCommand(str(CMD_WRITE_TO_CONSOLE), 0, '<xml><io s="%s" ctx="%s"/></xml>' % (msg, ctx)) except: return self.make_error_message(0, get_exception_traceback_str()) def make_version_message(self, seq): try: return NetCommand(CMD_VERSION, seq, VERSION_STRING) except: return self.make_error_message(seq, get_exception_traceback_str()) def make_thread_killed_message(self, tid): self._additional_thread_id_to_thread_name.pop(tid, None) try: return NetCommand(CMD_THREAD_KILL, 0, str(tid)) except: return self.make_error_message(0, get_exception_traceback_str()) def _iter_visible_frames_info(self, py_db, frames_list): assert frames_list.__class__ == FramesList for frame in frames_list: show_as_current_frame = frame is frames_list.current_frame if frame.f_code is None: pydev_log.info('Frame without f_code: %s', frame) continue # IronPython sometimes does not have it! method_name = frame.f_code.co_name # method name (if in method) or ? if global if method_name is None: pydev_log.info('Frame without co_name: %s', frame) continue # IronPython sometimes does not have it! abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) if py_db.get_file_type(frame, abs_path_real_path_and_base) == py_db.PYDEV_FILE: # Skip pydevd files. frame = frame.f_back continue frame_id = id(frame) lineno = frames_list.frame_id_to_lineno.get(frame_id, frame.f_lineno) filename_in_utf8, lineno, changed = py_db.source_mapping.map_to_client(abs_path_real_path_and_base[0], lineno) new_filename_in_utf8, applied_mapping = pydevd_file_utils.map_file_to_client(filename_in_utf8) applied_mapping = applied_mapping or changed yield frame_id, frame, method_name, abs_path_real_path_and_base[0], new_filename_in_utf8, lineno, applied_mapping, show_as_current_frame def make_thread_stack_str(self, py_db, frames_list): assert frames_list.__class__ == FramesList make_valid_xml_value = pydevd_xml.make_valid_xml_value cmd_text_list = [] append = cmd_text_list.append try: for frame_id, frame, method_name, _original_filename, filename_in_utf8, lineno, _applied_mapping, _show_as_current_frame in self._iter_visible_frames_info( py_db, frames_list ): # print("file is ", filename_in_utf8) # print("line is ", lineno) # Note: variables are all gotten 'on-demand'. append('<frame id="%s" name="%s" ' % (frame_id , make_valid_xml_value(method_name))) append('file="%s" line="%s">' % (quote(make_valid_xml_value(filename_in_utf8), '/>_= \t'), lineno)) append("</frame>") except: pydev_log.exception() return ''.join(cmd_text_list) def make_thread_suspend_str( self, py_db, thread_id, frames_list, stop_reason=None, message=None, suspend_type="trace", ): """ :return tuple(str,str): Returns tuple(thread_suspended_str, thread_stack_str). i.e.: ( ''' <xml> <thread id="id" stop_reason="reason"> <frame id="id" name="functionName " file="file" line="line"> </frame> </thread> </xml> ''' , ''' <frame id="id" name="functionName " file="file" line="line"> </frame> ''' ) """ assert frames_list.__class__ == FramesList make_valid_xml_value = pydevd_xml.make_valid_xml_value cmd_text_list = [] append = cmd_text_list.append cmd_text_list.append('<xml>') if message: message = make_valid_xml_value(message) append('<thread id="%s"' % (thread_id,)) if stop_reason is not None: append(' stop_reason="%s"' % (stop_reason,)) if message is not None: append(' message="%s"' % (message,)) if suspend_type is not None: append(' suspend_type="%s"' % (suspend_type,)) append('>') thread_stack_str = self.make_thread_stack_str(py_db, frames_list) append(thread_stack_str) append("</thread></xml>") return ''.join(cmd_text_list), thread_stack_str def make_thread_suspend_message(self, py_db, thread_id, frames_list, stop_reason, message, suspend_type): try: thread_suspend_str, thread_stack_str = self.make_thread_suspend_str( py_db, thread_id, frames_list, stop_reason, message, suspend_type) cmd = NetCommand(CMD_THREAD_SUSPEND, 0, thread_suspend_str) cmd.thread_stack_str = thread_stack_str cmd.thread_suspend_str = thread_suspend_str return cmd except: return self.make_error_message(0, get_exception_traceback_str()) def make_thread_suspend_single_notification(self, py_db, thread_id, stop_reason): try: return NetCommand(CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION, 0, json.dumps( {'thread_id': thread_id, 'stop_reason':stop_reason})) except: return self.make_error_message(0, get_exception_traceback_str()) def make_thread_resume_single_notification(self, thread_id): try: return NetCommand(CMD_THREAD_RESUME_SINGLE_NOTIFICATION, 0, json.dumps( {'thread_id': thread_id})) except: return self.make_error_message(0, get_exception_traceback_str()) def make_thread_run_message(self, thread_id, reason): try: return NetCommand(CMD_THREAD_RUN, 0, "%s\t%s" % (thread_id, reason)) except: return self.make_error_message(0, get_exception_traceback_str()) def make_get_variable_message(self, seq, payload): try: return NetCommand(CMD_GET_VARIABLE, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_array_message(self, seq, payload): try: return NetCommand(CMD_GET_ARRAY, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_description_message(self, seq, payload): try: return NetCommand(CMD_GET_DESCRIPTION, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_frame_message(self, seq, payload): try: return NetCommand(CMD_GET_FRAME, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_evaluate_expression_message(self, seq, payload): try: return NetCommand(CMD_EVALUATE_EXPRESSION, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_completions_message(self, seq, completions, qualifier, start): try: payload = completions_to_xml(completions) return NetCommand(CMD_GET_COMPLETIONS, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_file_contents(self, seq, payload): try: return NetCommand(CMD_GET_FILE_CONTENTS, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_reloaded_code_message(self, seq, reloaded_ok): try: return NetCommand(CMD_RELOAD_CODE, seq, '<xml><reloaded ok="%s"></reloaded></xml>' % reloaded_ok) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_send_breakpoint_exception_message(self, seq, payload): try: return NetCommand(CMD_GET_BREAKPOINT_EXCEPTION, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def _make_send_curr_exception_trace_str(self, py_db, thread_id, exc_type, exc_desc, trace_obj): frames_list = pydevd_frame_utils.create_frames_list_from_traceback(trace_obj, None, exc_type, exc_desc) exc_type = pydevd_xml.make_valid_xml_value(str(exc_type)).replace('\t', ' ') or 'exception: type unknown' exc_desc = pydevd_xml.make_valid_xml_value(str(exc_desc)).replace('\t', ' ') or 'exception: no description' thread_suspend_str, thread_stack_str = self.make_thread_suspend_str( py_db, thread_id, frames_list, CMD_SEND_CURR_EXCEPTION_TRACE, '') return exc_type, exc_desc, thread_suspend_str, thread_stack_str def make_send_curr_exception_trace_message(self, py_db, seq, thread_id, curr_frame_id, exc_type, exc_desc, trace_obj): try: exc_type, exc_desc, thread_suspend_str, _thread_stack_str = self._make_send_curr_exception_trace_str( py_db, thread_id, exc_type, exc_desc, trace_obj) payload = str(curr_frame_id) + '\t' + exc_type + "\t" + exc_desc + "\t" + thread_suspend_str return NetCommand(CMD_SEND_CURR_EXCEPTION_TRACE, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_exception_details_message(self, py_db, seq, thread_id, topmost_frame): """Returns exception details as XML """ try: # If the debugger is not suspended, just return the thread and its id. cmd_text = ['<xml><thread id="%s" ' % (thread_id,)] if topmost_frame is not None: try: frame = topmost_frame topmost_frame = None while frame is not None: if frame.f_code.co_name == 'do_wait_suspend' and frame.f_code.co_filename.endswith('pydevd.py'): arg = frame.f_locals.get('arg', None) if arg is not None: exc_type, exc_desc, _thread_suspend_str, thread_stack_str = self._make_send_curr_exception_trace_str( py_db, thread_id, *arg) cmd_text.append('exc_type="%s" ' % (exc_type,)) cmd_text.append('exc_desc="%s" ' % (exc_desc,)) cmd_text.append('>') cmd_text.append(thread_stack_str) break frame = frame.f_back else: cmd_text.append('>') finally: frame = None cmd_text.append('</thread></xml>') return NetCommand(CMD_GET_EXCEPTION_DETAILS, seq, ''.join(cmd_text)) except: return self.make_error_message(seq, get_exception_traceback_str()) def make_send_curr_exception_trace_proceeded_message(self, seq, thread_id): try: return NetCommand(CMD_SEND_CURR_EXCEPTION_TRACE_PROCEEDED, 0, str(thread_id)) except: return self.make_error_message(0, get_exception_traceback_str()) def make_send_console_message(self, seq, payload): try: return NetCommand(CMD_EVALUATE_CONSOLE_EXPRESSION, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_custom_operation_message(self, seq, payload): try: return NetCommand(CMD_RUN_CUSTOM_OPERATION, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_load_source_message(self, seq, source): return NetCommand(CMD_LOAD_SOURCE, seq, source) def make_load_source_from_frame_id_message(self, seq, source): return NetCommand(CMD_LOAD_SOURCE_FROM_FRAME_ID, seq, source) def make_show_console_message(self, py_db, thread_id, frame): try: frames_list = pydevd_frame_utils.create_frames_list_from_frame(frame) thread_suspended_str, _thread_stack_str = self.make_thread_suspend_str( py_db, thread_id, frames_list, CMD_SHOW_CONSOLE, '') return NetCommand(CMD_SHOW_CONSOLE, 0, thread_suspended_str) except: return self.make_error_message(0, get_exception_traceback_str()) def make_input_requested_message(self, started): try: return NetCommand(CMD_INPUT_REQUESTED, 0, str(started)) except: return self.make_error_message(0, get_exception_traceback_str()) def make_set_next_stmnt_status_message(self, seq, is_success, exception_msg): try: message = str(is_success) + '\t' + exception_msg return NetCommand(CMD_SET_NEXT_STATEMENT, int(seq), message) except: return self.make_error_message(0, get_exception_traceback_str()) def make_load_full_value_message(self, seq, payload): try: return NetCommand(CMD_LOAD_FULL_VALUE, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_get_next_statement_targets_message(self, seq, payload): try: return NetCommand(CMD_GET_NEXT_STATEMENT_TARGETS, seq, payload) except Exception: return self.make_error_message(seq, get_exception_traceback_str()) def make_skipped_step_in_because_of_filters(self, py_db, frame): return NULL_NET_COMMAND # Not a part of the xml protocol def make_evaluation_timeout_msg(self, py_db, expression, thread): msg = '''pydevd: Evaluating: %s did not finish after %.2f seconds. This may mean a number of things: - This evaluation is really slow and this is expected. In this case it's possible to silence this error by raising the timeout, setting the PYDEVD_WARN_EVALUATION_TIMEOUT environment variable to a bigger value. - The evaluation may need other threads running while it's running: In this case, you may need to manually let other paused threads continue. Alternatively, it's also possible to skip breaking on a particular thread by setting a `pydev_do_not_trace = True` attribute in the related threading.Thread instance (if some thread should always be running and no breakpoints are expected to be hit in it). - The evaluation is deadlocked: In this case you may set the PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT environment variable to true so that a thread dump is shown along with this message and optionally, set the PYDEVD_INTERRUPT_THREAD_TIMEOUT to some value so that the debugger tries to interrupt the evaluation (if possible) when this happens. ''' % (expression, pydevd_constants.PYDEVD_WARN_EVALUATION_TIMEOUT) if pydevd_constants.PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT: stream = StringIO() pydevd_utils.dump_threads(stream, show_pydevd_threads=False) msg += '\n\n%s\n' % stream.getvalue() return self.make_warning_message(msg) def make_exit_command(self, py_db): return NULL_EXIT_COMMAND
22,531
Python
44.611336
167
0.602503
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm_constants.py
CMD_RUN = 101 CMD_LIST_THREADS = 102 CMD_THREAD_CREATE = 103 CMD_THREAD_KILL = 104 CMD_THREAD_SUSPEND = 105 CMD_THREAD_RUN = 106 CMD_STEP_INTO = 107 CMD_STEP_OVER = 108 CMD_STEP_RETURN = 109 CMD_GET_VARIABLE = 110 CMD_SET_BREAK = 111 CMD_REMOVE_BREAK = 112 CMD_EVALUATE_EXPRESSION = 113 CMD_GET_FRAME = 114 CMD_EXEC_EXPRESSION = 115 CMD_WRITE_TO_CONSOLE = 116 CMD_CHANGE_VARIABLE = 117 CMD_RUN_TO_LINE = 118 CMD_RELOAD_CODE = 119 CMD_GET_COMPLETIONS = 120 # Note: renumbered (conflicted on merge) CMD_CONSOLE_EXEC = 121 CMD_ADD_EXCEPTION_BREAK = 122 CMD_REMOVE_EXCEPTION_BREAK = 123 CMD_LOAD_SOURCE = 124 CMD_ADD_DJANGO_EXCEPTION_BREAK = 125 CMD_REMOVE_DJANGO_EXCEPTION_BREAK = 126 CMD_SET_NEXT_STATEMENT = 127 CMD_SMART_STEP_INTO = 128 CMD_EXIT = 129 CMD_SIGNATURE_CALL_TRACE = 130 CMD_SET_PY_EXCEPTION = 131 CMD_GET_FILE_CONTENTS = 132 CMD_SET_PROPERTY_TRACE = 133 # Pydev debug console commands CMD_EVALUATE_CONSOLE_EXPRESSION = 134 CMD_RUN_CUSTOM_OPERATION = 135 CMD_GET_BREAKPOINT_EXCEPTION = 136 CMD_STEP_CAUGHT_EXCEPTION = 137 CMD_SEND_CURR_EXCEPTION_TRACE = 138 CMD_SEND_CURR_EXCEPTION_TRACE_PROCEEDED = 139 CMD_IGNORE_THROWN_EXCEPTION_AT = 140 CMD_ENABLE_DONT_TRACE = 141 CMD_SHOW_CONSOLE = 142 CMD_GET_ARRAY = 143 CMD_STEP_INTO_MY_CODE = 144 CMD_GET_CONCURRENCY_EVENT = 145 CMD_SHOW_RETURN_VALUES = 146 CMD_INPUT_REQUESTED = 147 CMD_GET_DESCRIPTION = 148 CMD_PROCESS_CREATED = 149 CMD_SHOW_CYTHON_WARNING = 150 CMD_LOAD_FULL_VALUE = 151 CMD_GET_THREAD_STACK = 152 # This is mostly for unit-tests to diagnose errors on ci. CMD_THREAD_DUMP_TO_STDERR = 153 # Sent from the client to signal that we should stop when we start executing user code. CMD_STOP_ON_START = 154 # When the debugger is stopped in an exception, this command will provide the details of the current exception (in the current thread). CMD_GET_EXCEPTION_DETAILS = 155 # Allows configuring pydevd settings (can be called multiple times and only keys # available in the json will be configured -- keys not passed will not change the # previous configuration). CMD_PYDEVD_JSON_CONFIG = 156 CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION = 157 CMD_THREAD_RESUME_SINGLE_NOTIFICATION = 158 CMD_STEP_OVER_MY_CODE = 159 CMD_STEP_RETURN_MY_CODE = 160 CMD_SET_PY_EXCEPTION_JSON = 161 CMD_SET_PATH_MAPPING_JSON = 162 CMD_GET_SMART_STEP_INTO_VARIANTS = 163 # XXX: PyCharm has 160 for this (we're currently incompatible anyways). CMD_REDIRECT_OUTPUT = 200 CMD_GET_NEXT_STATEMENT_TARGETS = 201 CMD_SET_PROJECT_ROOTS = 202 CMD_MODULE_EVENT = 203 CMD_PROCESS_EVENT = 204 CMD_AUTHENTICATE = 205 CMD_STEP_INTO_COROUTINE = 206 CMD_LOAD_SOURCE_FROM_FRAME_ID = 207 CMD_SET_FUNCTION_BREAK = 208 CMD_VERSION = 501 CMD_RETURN = 502 CMD_SET_PROTOCOL = 503 CMD_ERROR = 901 # this number can be changed if there's need to do so # if the io is too big, we'll not send all (could make the debugger too non-responsive) MAX_IO_MSG_SIZE = 10000 VERSION_STRING = "@@BUILD_NUMBER@@" from _pydev_bundle._pydev_filesystem_encoding import getfilesystemencoding file_system_encoding = getfilesystemencoding() filesystem_encoding_is_utf8 = file_system_encoding.lower() in ('utf-8', 'utf_8', 'utf8') ID_TO_MEANING = { '101': 'CMD_RUN', '102': 'CMD_LIST_THREADS', '103': 'CMD_THREAD_CREATE', '104': 'CMD_THREAD_KILL', '105': 'CMD_THREAD_SUSPEND', '106': 'CMD_THREAD_RUN', '107': 'CMD_STEP_INTO', '108': 'CMD_STEP_OVER', '109': 'CMD_STEP_RETURN', '110': 'CMD_GET_VARIABLE', '111': 'CMD_SET_BREAK', '112': 'CMD_REMOVE_BREAK', '113': 'CMD_EVALUATE_EXPRESSION', '114': 'CMD_GET_FRAME', '115': 'CMD_EXEC_EXPRESSION', '116': 'CMD_WRITE_TO_CONSOLE', '117': 'CMD_CHANGE_VARIABLE', '118': 'CMD_RUN_TO_LINE', '119': 'CMD_RELOAD_CODE', '120': 'CMD_GET_COMPLETIONS', '121': 'CMD_CONSOLE_EXEC', '122': 'CMD_ADD_EXCEPTION_BREAK', '123': 'CMD_REMOVE_EXCEPTION_BREAK', '124': 'CMD_LOAD_SOURCE', '125': 'CMD_ADD_DJANGO_EXCEPTION_BREAK', '126': 'CMD_REMOVE_DJANGO_EXCEPTION_BREAK', '127': 'CMD_SET_NEXT_STATEMENT', '128': 'CMD_SMART_STEP_INTO', '129': 'CMD_EXIT', '130': 'CMD_SIGNATURE_CALL_TRACE', '131': 'CMD_SET_PY_EXCEPTION', '132': 'CMD_GET_FILE_CONTENTS', '133': 'CMD_SET_PROPERTY_TRACE', '134': 'CMD_EVALUATE_CONSOLE_EXPRESSION', '135': 'CMD_RUN_CUSTOM_OPERATION', '136': 'CMD_GET_BREAKPOINT_EXCEPTION', '137': 'CMD_STEP_CAUGHT_EXCEPTION', '138': 'CMD_SEND_CURR_EXCEPTION_TRACE', '139': 'CMD_SEND_CURR_EXCEPTION_TRACE_PROCEEDED', '140': 'CMD_IGNORE_THROWN_EXCEPTION_AT', '141': 'CMD_ENABLE_DONT_TRACE', '142': 'CMD_SHOW_CONSOLE', '143': 'CMD_GET_ARRAY', '144': 'CMD_STEP_INTO_MY_CODE', '145': 'CMD_GET_CONCURRENCY_EVENT', '146': 'CMD_SHOW_RETURN_VALUES', '147': 'CMD_INPUT_REQUESTED', '148': 'CMD_GET_DESCRIPTION', '149': 'CMD_PROCESS_CREATED', # Note: this is actually a notification of a sub-process created. '150': 'CMD_SHOW_CYTHON_WARNING', '151': 'CMD_LOAD_FULL_VALUE', '152': 'CMD_GET_THREAD_STACK', '153': 'CMD_THREAD_DUMP_TO_STDERR', '154': 'CMD_STOP_ON_START', '155': 'CMD_GET_EXCEPTION_DETAILS', '156': 'CMD_PYDEVD_JSON_CONFIG', '157': 'CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION', '158': 'CMD_THREAD_RESUME_SINGLE_NOTIFICATION', '159': 'CMD_STEP_OVER_MY_CODE', '160': 'CMD_STEP_RETURN_MY_CODE', '161': 'CMD_SET_PY_EXCEPTION_JSON', '162': 'CMD_SET_PATH_MAPPING_JSON', '163': 'CMD_GET_SMART_STEP_INTO_VARIANTS', '200': 'CMD_REDIRECT_OUTPUT', '201': 'CMD_GET_NEXT_STATEMENT_TARGETS', '202': 'CMD_SET_PROJECT_ROOTS', '203': 'CMD_MODULE_EVENT', '204': 'CMD_PROCESS_EVENT', # DAP process event. '205': 'CMD_AUTHENTICATE', '206': 'CMD_STEP_INTO_COROUTINE', '207': 'CMD_LOAD_SOURCE_FROM_FRAME_ID', '501': 'CMD_VERSION', '502': 'CMD_RETURN', '503': 'CMD_SET_PROTOCOL', '901': 'CMD_ERROR', } def constant_to_str(constant): s = ID_TO_MEANING.get(str(constant)) if not s: s = '<Unknown: %s>' % (constant,) return s
6,084
Python
28.114832
135
0.674556
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_bytecode_utils.py
""" Bytecode analysing utils. Originally added for using in smart step into. Note: not importable from Python 2. """ from _pydev_bundle import pydev_log from types import CodeType from _pydevd_frame_eval.vendored.bytecode.instr import _Variable from _pydevd_frame_eval.vendored import bytecode from _pydevd_frame_eval.vendored.bytecode import cfg as bytecode_cfg import dis import opcode as _opcode from _pydevd_bundle.pydevd_constants import KeyifyList, DebugInfoHolder, IS_PY311_OR_GREATER from bisect import bisect from collections import deque # When True, throws errors on unknown bytecodes, when False, ignore those as if they didn't change the stack. STRICT_MODE = False DEBUG = False _BINARY_OPS = set([opname for opname in dis.opname if opname.startswith('BINARY_')]) _BINARY_OP_MAP = { 'BINARY_POWER': '__pow__', 'BINARY_MULTIPLY': '__mul__', 'BINARY_MATRIX_MULTIPLY': '__matmul__', 'BINARY_FLOOR_DIVIDE': '__floordiv__', 'BINARY_TRUE_DIVIDE': '__div__', 'BINARY_MODULO': '__mod__', 'BINARY_ADD': '__add__', 'BINARY_SUBTRACT': '__sub__', 'BINARY_LSHIFT': '__lshift__', 'BINARY_RSHIFT': '__rshift__', 'BINARY_AND': '__and__', 'BINARY_OR': '__or__', 'BINARY_XOR': '__xor__', 'BINARY_SUBSCR': '__getitem__', 'BINARY_DIVIDE': '__div__' } _COMP_OP_MAP = { '<': '__lt__', '<=': '__le__', '==': '__eq__', '!=': '__ne__', '>': '__gt__', '>=': '__ge__', 'in': '__contains__', 'not in': '__contains__', } class Target(object): __slots__ = ['arg', 'lineno', 'offset', 'children_targets'] def __init__(self, arg, lineno, offset, children_targets=()): self.arg = arg self.lineno = lineno self.offset = offset self.children_targets = children_targets def __repr__(self): ret = [] for s in self.__slots__: ret.append('%s: %s' % (s, getattr(self, s))) return 'Target(%s)' % ', '.join(ret) __str__ = __repr__ class _TargetIdHashable(object): def __init__(self, target): self.target = target def __eq__(self, other): if not hasattr(other, 'target'): return return other.target is self.target def __ne__(self, other): return not self == other def __hash__(self): return id(self.target) class _StackInterpreter(object): ''' Good reference: https://github.com/python/cpython/blob/fcb55c0037baab6f98f91ee38ce84b6f874f034a/Python/ceval.c ''' def __init__(self, bytecode): self.bytecode = bytecode self._stack = deque() self.function_calls = [] self.load_attrs = {} self.func = set() self.func_name_id_to_code_object = {} def __str__(self): return 'Stack:\nFunction calls:\n%s\nLoad attrs:\n%s\n' % (self.function_calls, list(self.load_attrs.values())) def _getname(self, instr): if instr.opcode in _opcode.hascompare: cmp_op = dis.cmp_op[instr.arg] if cmp_op not in ('exception match', 'BAD'): return _COMP_OP_MAP.get(cmp_op, cmp_op) return instr.arg def _getcallname(self, instr): if instr.name == 'BINARY_SUBSCR': return '__getitem__().__call__' if instr.name == 'CALL_FUNCTION': # Note: previously a '__call__().__call__' was returned, but this was a bit weird # and on Python 3.9 this construct could appear for some internal things where # it wouldn't be expected. # Note: it'd be what we had in func()(). return None if instr.name == 'MAKE_FUNCTION': return '__func__().__call__' if instr.name == 'LOAD_ASSERTION_ERROR': return 'AssertionError' name = self._getname(instr) if isinstance(name, CodeType): name = name.co_qualname # Note: only available for Python 3.11 if isinstance(name, _Variable): name = name.name if not isinstance(name, str): return None if name.endswith('>'): # xxx.<listcomp>, xxx.<lambda>, ... return name.split('.')[-1] return name def _no_stack_change(self, instr): pass # Can be aliased when the instruction does nothing. def on_LOAD_GLOBAL(self, instr): self._stack.append(instr) def on_POP_TOP(self, instr): try: self._stack.pop() except IndexError: pass # Ok (in the end of blocks) def on_LOAD_ATTR(self, instr): self.on_POP_TOP(instr) # replaces the current top self._stack.append(instr) self.load_attrs[_TargetIdHashable(instr)] = Target(self._getname(instr), instr.lineno, instr.offset) on_LOOKUP_METHOD = on_LOAD_ATTR # Improvement in PyPy def on_LOAD_CONST(self, instr): self._stack.append(instr) on_LOAD_DEREF = on_LOAD_CONST on_LOAD_NAME = on_LOAD_CONST on_LOAD_CLOSURE = on_LOAD_CONST on_LOAD_CLASSDEREF = on_LOAD_CONST # Although it actually changes the stack, it's inconsequential for us as a function call can't # really be found there. on_IMPORT_NAME = _no_stack_change on_IMPORT_FROM = _no_stack_change on_IMPORT_STAR = _no_stack_change on_SETUP_ANNOTATIONS = _no_stack_change def on_STORE_FAST(self, instr): try: self._stack.pop() except IndexError: pass # Ok, we may have a block just with the store # Note: it stores in the locals and doesn't put anything in the stack. on_STORE_GLOBAL = on_STORE_FAST on_STORE_DEREF = on_STORE_FAST on_STORE_ATTR = on_STORE_FAST on_STORE_NAME = on_STORE_FAST on_DELETE_NAME = on_POP_TOP on_DELETE_ATTR = on_POP_TOP on_DELETE_GLOBAL = on_POP_TOP on_DELETE_FAST = on_POP_TOP on_DELETE_DEREF = on_POP_TOP on_DICT_UPDATE = on_POP_TOP on_SET_UPDATE = on_POP_TOP on_GEN_START = on_POP_TOP def on_NOP(self, instr): pass def _handle_call_from_instr(self, func_name_instr, func_call_instr): self.load_attrs.pop(_TargetIdHashable(func_name_instr), None) call_name = self._getcallname(func_name_instr) target = None if not call_name: pass # Ignore if we can't identify a name elif call_name in ('<listcomp>', '<genexpr>', '<setcomp>', '<dictcomp>'): code_obj = self.func_name_id_to_code_object[_TargetIdHashable(func_name_instr)] if code_obj is not None: children_targets = _get_smart_step_into_targets(code_obj) if children_targets: # i.e.: we have targets inside of a <listcomp> or <genexpr>. # Note that to actually match this in the debugger we need to do matches on 2 frames, # the one with the <listcomp> and then the actual target inside the <listcomp>. target = Target(call_name, func_name_instr.lineno, func_call_instr.offset, children_targets) self.function_calls.append( target) else: # Ok, regular call target = Target(call_name, func_name_instr.lineno, func_call_instr.offset) self.function_calls.append(target) if DEBUG and target is not None: print('Created target', target) self._stack.append(func_call_instr) # Keep the func call as the result def on_COMPARE_OP(self, instr): try: _right = self._stack.pop() except IndexError: return try: _left = self._stack.pop() except IndexError: return cmp_op = dis.cmp_op[instr.arg] if cmp_op not in ('exception match', 'BAD'): self.function_calls.append(Target(self._getname(instr), instr.lineno, instr.offset)) self._stack.append(instr) def on_IS_OP(self, instr): try: self._stack.pop() except IndexError: return try: self._stack.pop() except IndexError: return def on_BINARY_SUBSCR(self, instr): try: _sub = self._stack.pop() except IndexError: return try: _container = self._stack.pop() except IndexError: return self.function_calls.append(Target(_BINARY_OP_MAP[instr.name], instr.lineno, instr.offset)) self._stack.append(instr) on_BINARY_MATRIX_MULTIPLY = on_BINARY_SUBSCR on_BINARY_POWER = on_BINARY_SUBSCR on_BINARY_MULTIPLY = on_BINARY_SUBSCR on_BINARY_FLOOR_DIVIDE = on_BINARY_SUBSCR on_BINARY_TRUE_DIVIDE = on_BINARY_SUBSCR on_BINARY_MODULO = on_BINARY_SUBSCR on_BINARY_ADD = on_BINARY_SUBSCR on_BINARY_SUBTRACT = on_BINARY_SUBSCR on_BINARY_LSHIFT = on_BINARY_SUBSCR on_BINARY_RSHIFT = on_BINARY_SUBSCR on_BINARY_AND = on_BINARY_SUBSCR on_BINARY_OR = on_BINARY_SUBSCR on_BINARY_XOR = on_BINARY_SUBSCR def on_LOAD_METHOD(self, instr): self.on_POP_TOP(instr) # Remove the previous as we're loading something from it. self._stack.append(instr) def on_MAKE_FUNCTION(self, instr): if not IS_PY311_OR_GREATER: # The qualifier name is no longer put in the stack. qualname = self._stack.pop() code_obj_instr = self._stack.pop() else: # In 3.11 the code object has a co_qualname which we can use. qualname = code_obj_instr = self._stack.pop() arg = instr.arg if arg & 0x08: _func_closure = self._stack.pop() if arg & 0x04: _func_annotations = self._stack.pop() if arg & 0x02: _func_kwdefaults = self._stack.pop() if arg & 0x01: _func_defaults = self._stack.pop() call_name = self._getcallname(qualname) if call_name in ('<genexpr>', '<listcomp>', '<setcomp>', '<dictcomp>'): if isinstance(code_obj_instr.arg, CodeType): self.func_name_id_to_code_object[_TargetIdHashable(qualname)] = code_obj_instr.arg self._stack.append(qualname) def on_LOAD_FAST(self, instr): self._stack.append(instr) def on_LOAD_ASSERTION_ERROR(self, instr): self._stack.append(instr) on_LOAD_BUILD_CLASS = on_LOAD_FAST def on_CALL_METHOD(self, instr): # pop the actual args for _ in range(instr.arg): self._stack.pop() func_name_instr = self._stack.pop() self._handle_call_from_instr(func_name_instr, instr) def on_PUSH_NULL(self, instr): self._stack.append(instr) def on_CALL_FUNCTION(self, instr): arg = instr.arg argc = arg & 0xff # positional args argc += ((arg >> 8) * 2) # keyword args # pop the actual args for _ in range(argc): try: self._stack.pop() except IndexError: return try: func_name_instr = self._stack.pop() except IndexError: return self._handle_call_from_instr(func_name_instr, instr) def on_CALL_FUNCTION_KW(self, instr): # names of kw args _names_of_kw_args = self._stack.pop() # pop the actual args arg = instr.arg argc = arg & 0xff # positional args argc += ((arg >> 8) * 2) # keyword args for _ in range(argc): self._stack.pop() func_name_instr = self._stack.pop() self._handle_call_from_instr(func_name_instr, instr) def on_CALL_FUNCTION_VAR(self, instr): # var name _var_arg = self._stack.pop() # pop the actual args arg = instr.arg argc = arg & 0xff # positional args argc += ((arg >> 8) * 2) # keyword args for _ in range(argc): self._stack.pop() func_name_instr = self._stack.pop() self._handle_call_from_instr(func_name_instr, instr) def on_CALL_FUNCTION_VAR_KW(self, instr): # names of kw args _names_of_kw_args = self._stack.pop() arg = instr.arg argc = arg & 0xff # positional args argc += ((arg >> 8) * 2) # keyword args # also pop **kwargs self._stack.pop() # pop the actual args for _ in range(argc): self._stack.pop() func_name_instr = self._stack.pop() self._handle_call_from_instr(func_name_instr, instr) def on_CALL_FUNCTION_EX(self, instr): if instr.arg & 0x01: _kwargs = self._stack.pop() _callargs = self._stack.pop() func_name_instr = self._stack.pop() self._handle_call_from_instr(func_name_instr, instr) on_YIELD_VALUE = _no_stack_change on_GET_AITER = _no_stack_change on_GET_ANEXT = _no_stack_change on_END_ASYNC_FOR = _no_stack_change on_BEFORE_ASYNC_WITH = _no_stack_change on_SETUP_ASYNC_WITH = _no_stack_change on_YIELD_FROM = _no_stack_change on_SETUP_LOOP = _no_stack_change on_FOR_ITER = _no_stack_change on_BREAK_LOOP = _no_stack_change on_JUMP_ABSOLUTE = _no_stack_change on_RERAISE = _no_stack_change on_LIST_TO_TUPLE = _no_stack_change on_CALL_FINALLY = _no_stack_change on_POP_FINALLY = _no_stack_change def on_JUMP_IF_FALSE_OR_POP(self, instr): try: self._stack.pop() except IndexError: return on_JUMP_IF_TRUE_OR_POP = on_JUMP_IF_FALSE_OR_POP def on_JUMP_IF_NOT_EXC_MATCH(self, instr): try: self._stack.pop() except IndexError: return try: self._stack.pop() except IndexError: return def on_ROT_TWO(self, instr): try: p0 = self._stack.pop() except IndexError: return try: p1 = self._stack.pop() except: self._stack.append(p0) return self._stack.append(p0) self._stack.append(p1) def on_ROT_THREE(self, instr): try: p0 = self._stack.pop() except IndexError: return try: p1 = self._stack.pop() except: self._stack.append(p0) return try: p2 = self._stack.pop() except: self._stack.append(p0) self._stack.append(p1) return self._stack.append(p0) self._stack.append(p1) self._stack.append(p2) def on_ROT_FOUR(self, instr): try: p0 = self._stack.pop() except IndexError: return try: p1 = self._stack.pop() except: self._stack.append(p0) return try: p2 = self._stack.pop() except: self._stack.append(p0) self._stack.append(p1) return try: p3 = self._stack.pop() except: self._stack.append(p0) self._stack.append(p1) self._stack.append(p2) return self._stack.append(p0) self._stack.append(p1) self._stack.append(p2) self._stack.append(p3) def on_BUILD_LIST_FROM_ARG(self, instr): self._stack.append(instr) def on_BUILD_MAP(self, instr): for _i in range(instr.arg): self._stack.pop() self._stack.pop() self._stack.append(instr) def on_BUILD_CONST_KEY_MAP(self, instr): self.on_POP_TOP(instr) # keys for _i in range(instr.arg): self.on_POP_TOP(instr) # value self._stack.append(instr) on_RETURN_VALUE = on_POP_TOP on_POP_JUMP_IF_FALSE = on_POP_TOP on_POP_JUMP_IF_TRUE = on_POP_TOP on_DICT_MERGE = on_POP_TOP on_LIST_APPEND = on_POP_TOP on_SET_ADD = on_POP_TOP on_LIST_EXTEND = on_POP_TOP on_UNPACK_EX = on_POP_TOP # ok: doesn't change the stack (converts top to getiter(top)) on_GET_ITER = _no_stack_change on_GET_AWAITABLE = _no_stack_change on_GET_YIELD_FROM_ITER = _no_stack_change def on_RETURN_GENERATOR(self, instr): self._stack.append(instr) on_RETURN_GENERATOR = _no_stack_change on_RESUME = _no_stack_change def on_MAP_ADD(self, instr): self.on_POP_TOP(instr) self.on_POP_TOP(instr) def on_UNPACK_SEQUENCE(self, instr): self._stack.pop() for _i in range(instr.arg): self._stack.append(instr) def on_BUILD_LIST(self, instr): for _i in range(instr.arg): self.on_POP_TOP(instr) self._stack.append(instr) on_BUILD_TUPLE = on_BUILD_LIST on_BUILD_STRING = on_BUILD_LIST on_BUILD_TUPLE_UNPACK_WITH_CALL = on_BUILD_LIST on_BUILD_TUPLE_UNPACK = on_BUILD_LIST on_BUILD_LIST_UNPACK = on_BUILD_LIST on_BUILD_MAP_UNPACK_WITH_CALL = on_BUILD_LIST on_BUILD_MAP_UNPACK = on_BUILD_LIST on_BUILD_SET = on_BUILD_LIST on_BUILD_SET_UNPACK = on_BUILD_LIST on_SETUP_FINALLY = _no_stack_change on_POP_FINALLY = _no_stack_change on_BEGIN_FINALLY = _no_stack_change on_END_FINALLY = _no_stack_change def on_RAISE_VARARGS(self, instr): for _i in range(instr.arg): self.on_POP_TOP(instr) on_POP_BLOCK = _no_stack_change on_JUMP_FORWARD = _no_stack_change on_POP_EXCEPT = _no_stack_change on_SETUP_EXCEPT = _no_stack_change on_WITH_EXCEPT_START = _no_stack_change on_END_FINALLY = _no_stack_change on_BEGIN_FINALLY = _no_stack_change on_SETUP_WITH = _no_stack_change on_WITH_CLEANUP_START = _no_stack_change on_WITH_CLEANUP_FINISH = _no_stack_change on_FORMAT_VALUE = _no_stack_change on_EXTENDED_ARG = _no_stack_change def on_INPLACE_ADD(self, instr): # This would actually pop 2 and leave the value in the stack. # In a += 1 it pop `a` and `1` and leave the resulting value # for a load. In our case, let's just pop the `1` and leave the `a` # instead of leaving the INPLACE_ADD bytecode. try: self._stack.pop() except IndexError: pass on_INPLACE_POWER = on_INPLACE_ADD on_INPLACE_MULTIPLY = on_INPLACE_ADD on_INPLACE_MATRIX_MULTIPLY = on_INPLACE_ADD on_INPLACE_TRUE_DIVIDE = on_INPLACE_ADD on_INPLACE_FLOOR_DIVIDE = on_INPLACE_ADD on_INPLACE_MODULO = on_INPLACE_ADD on_INPLACE_SUBTRACT = on_INPLACE_ADD on_INPLACE_RSHIFT = on_INPLACE_ADD on_INPLACE_LSHIFT = on_INPLACE_ADD on_INPLACE_AND = on_INPLACE_ADD on_INPLACE_OR = on_INPLACE_ADD on_INPLACE_XOR = on_INPLACE_ADD def on_DUP_TOP(self, instr): try: i = self._stack[-1] except IndexError: # ok (in the start of block) self._stack.append(instr) else: self._stack.append(i) def on_DUP_TOP_TWO(self, instr): if len(self._stack) == 0: self._stack.append(instr) return if len(self._stack) == 1: i = self._stack[-1] self._stack.append(i) self._stack.append(instr) return i = self._stack[-1] j = self._stack[-2] self._stack.append(j) self._stack.append(i) def on_BUILD_SLICE(self, instr): for _ in range(instr.arg): try: self._stack.pop() except IndexError: pass self._stack.append(instr) def on_STORE_SUBSCR(self, instr): try: self._stack.pop() self._stack.pop() self._stack.pop() except IndexError: pass def on_DELETE_SUBSCR(self, instr): try: self._stack.pop() self._stack.pop() except IndexError: pass # Note: on Python 3 this is only found on interactive mode to print the results of # some evaluation. on_PRINT_EXPR = on_POP_TOP on_UNARY_POSITIVE = _no_stack_change on_UNARY_NEGATIVE = _no_stack_change on_UNARY_NOT = _no_stack_change on_UNARY_INVERT = _no_stack_change on_CACHE = _no_stack_change on_PRECALL = _no_stack_change def _get_smart_step_into_targets(code): ''' :return list(Target) ''' b = bytecode.Bytecode.from_code(code) cfg = bytecode_cfg.ControlFlowGraph.from_bytecode(b) ret = [] for block in cfg: if DEBUG: print('\nStart block----') stack = _StackInterpreter(block) for instr in block: try: func_name = 'on_%s' % (instr.name,) func = getattr(stack, func_name, None) if DEBUG: if instr.name != 'CACHE': # Filter the ones we don't want to see. print('\nWill handle: ', instr, '>>', stack._getname(instr), '<<') print('Current stack:') for entry in stack._stack: print(' arg:', stack._getname(entry), '(', entry, ')') if func is None: if STRICT_MODE: raise AssertionError('%s not found.' % (func_name,)) else: continue func(instr) except: if STRICT_MODE: raise # Error in strict mode. else: # In non-strict mode, log it (if in verbose mode) and keep on going. if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 2: pydev_log.exception('Exception computing step into targets (handled).') ret.extend(stack.function_calls) # No longer considering attr loads as calls (while in theory sometimes it's possible # that something as `some.attr` can turn out to be a property which could be stepped # in, it's not that common in practice and can be surprising for users, so, disabling # step into from stepping into properties). # ret.extend(stack.load_attrs.values()) return ret # Note that the offset is unique within the frame (so, we can use it as the target id). # Also, as the offset is the instruction offset within the frame, it's possible to # to inspect the parent frame for frame.f_lasti to know where we actually are (as the # caller name may not always match the new frame name). class Variant(object): __slots__ = ['name', 'is_visited', 'line', 'offset', 'call_order', 'children_variants', 'parent'] def __init__(self, name, is_visited, line, offset, call_order, children_variants=None): self.name = name self.is_visited = is_visited self.line = line self.offset = offset self.call_order = call_order self.children_variants = children_variants self.parent = None if children_variants: for variant in children_variants: variant.parent = self def __repr__(self): ret = [] for s in self.__slots__: if s == 'parent': try: parent = self.parent except AttributeError: ret.append('%s: <not set>' % (s,)) else: if parent is None: ret.append('parent: None') else: ret.append('parent: %s (%s)' % (parent.name, parent.offset)) continue if s == 'children_variants': ret.append('children_variants: %s' % (len(self.children_variants) if self.children_variants else 0)) continue try: ret.append('%s: %s' % (s, getattr(self, s))) except AttributeError: ret.append('%s: <not set>' % (s,)) return 'Variant(%s)' % ', '.join(ret) __str__ = __repr__ def _convert_target_to_variant(target, start_line, end_line, call_order_cache, lasti, base): name = target.arg if not isinstance(name, str): return if target.lineno > end_line: return if target.lineno < start_line: return call_order = call_order_cache.get(name, 0) + 1 call_order_cache[name] = call_order is_visited = target.offset <= lasti children_targets = target.children_targets children_variants = None if children_targets: children_variants = [ _convert_target_to_variant(child, start_line, end_line, call_order_cache, lasti, base) for child in target.children_targets] return Variant(name, is_visited, target.lineno - base, target.offset, call_order, children_variants) def calculate_smart_step_into_variants(frame, start_line, end_line, base=0): """ Calculate smart step into variants for the given line range. :param frame: :type frame: :py:class:`types.FrameType` :param start_line: :param end_line: :return: A list of call names from the first to the last. :note: it's guaranteed that the offsets appear in order. :raise: :py:class:`RuntimeError` if failed to parse the bytecode or if dis cannot be used. """ variants = [] code = frame.f_code lasti = frame.f_lasti call_order_cache = {} if DEBUG: print('dis.dis:') if IS_PY311_OR_GREATER: dis.dis(code, show_caches=False) else: dis.dis(code) for target in _get_smart_step_into_targets(code): variant = _convert_target_to_variant(target, start_line, end_line, call_order_cache, lasti, base) if variant is None: continue variants.append(variant) return variants def get_smart_step_into_variant_from_frame_offset(frame_f_lasti, variants): """ Given the frame.f_lasti, return the related `Variant`. :note: if the offset is found before any variant available or no variants are available, None is returned. :rtype: Variant|NoneType """ if not variants: return None i = bisect(KeyifyList(variants, lambda entry:entry.offset), frame_f_lasti) if i == 0: return None else: return variants[i - 1]
26,277
Python
30.135071
119
0.568101
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_io.py
from _pydevd_bundle.pydevd_constants import ForkSafeLock, get_global_debugger import os import sys from contextlib import contextmanager class IORedirector: ''' This class works to wrap a stream (stdout/stderr) with an additional redirect. ''' def __init__(self, original, new_redirect, wrap_buffer=False): ''' :param stream original: The stream to be wrapped (usually stdout/stderr, but could be None). :param stream new_redirect: Usually IOBuf (below). :param bool wrap_buffer: Whether to create a buffer attribute (needed to mimick python 3 s tdout/stderr which has a buffer to write binary data). ''' self._lock = ForkSafeLock(rlock=True) self._writing = False self._redirect_to = (original, new_redirect) if wrap_buffer and hasattr(original, 'buffer'): self.buffer = IORedirector(original.buffer, new_redirect.buffer, False) def write(self, s): # Note that writing to the original stream may fail for some reasons # (such as trying to write something that's not a string or having it closed). with self._lock: if self._writing: return self._writing = True try: for r in self._redirect_to: if hasattr(r, 'write'): r.write(s) finally: self._writing = False def isatty(self): for r in self._redirect_to: if hasattr(r, 'isatty'): return r.isatty() return False def flush(self): for r in self._redirect_to: if hasattr(r, 'flush'): r.flush() def __getattr__(self, name): for r in self._redirect_to: if hasattr(r, name): return getattr(r, name) raise AttributeError(name) class RedirectToPyDBIoMessages(object): def __init__(self, out_ctx, wrap_stream, wrap_buffer, on_write=None): ''' :param out_ctx: 1=stdout and 2=stderr :param wrap_stream: Either sys.stdout or sys.stderr. :param bool wrap_buffer: If True the buffer attribute (which wraps writing bytes) should be wrapped. :param callable(str) on_write: May be a custom callable to be called when to write something. If not passed the default implementation will create an io message and send it through the debugger. ''' encoding = getattr(wrap_stream, 'encoding', None) if not encoding: encoding = os.environ.get('PYTHONIOENCODING', 'utf-8') self.encoding = encoding self._out_ctx = out_ctx if wrap_buffer: self.buffer = RedirectToPyDBIoMessages(out_ctx, wrap_stream, wrap_buffer=False, on_write=on_write) self._on_write = on_write def get_pydb(self): # Note: separate method for mocking on tests. return get_global_debugger() def flush(self): pass # no-op here def write(self, s): if self._on_write is not None: self._on_write(s) return if s: # Need s in str if isinstance(s, bytes): s = s.decode(self.encoding, errors='replace') py_db = self.get_pydb() if py_db is not None: # Note that the actual message contents will be a xml with utf-8, although # the entry is str on py3 and bytes on py2. cmd = py_db.cmd_factory.make_io_message(s, self._out_ctx) if py_db.writer is not None: py_db.writer.add_command(cmd) class IOBuf: '''This class works as a replacement for stdio and stderr. It is a buffer and when its contents are requested, it will erase what it has so far so that the next return will not return the same contents again. ''' def __init__(self): self.buflist = [] import os self.encoding = os.environ.get('PYTHONIOENCODING', 'utf-8') def getvalue(self): b = self.buflist self.buflist = [] # clear it return ''.join(b) # bytes on py2, str on py3. def write(self, s): if isinstance(s, bytes): s = s.decode(self.encoding, errors='replace') self.buflist.append(s) def isatty(self): return False def flush(self): pass def empty(self): return len(self.buflist) == 0 class _RedirectInfo(object): def __init__(self, original, redirect_to): self.original = original self.redirect_to = redirect_to class _RedirectionsHolder: _lock = ForkSafeLock(rlock=True) _stack_stdout = [] _stack_stderr = [] _pydevd_stdout_redirect_ = None _pydevd_stderr_redirect_ = None def start_redirect(keep_original_redirection=False, std='stdout', redirect_to=None): ''' @param std: 'stdout', 'stderr', or 'both' ''' with _RedirectionsHolder._lock: if redirect_to is None: redirect_to = IOBuf() if std == 'both': config_stds = ['stdout', 'stderr'] else: config_stds = [std] for std in config_stds: original = getattr(sys, std) stack = getattr(_RedirectionsHolder, '_stack_%s' % std) if keep_original_redirection: wrap_buffer = True if hasattr(redirect_to, 'buffer') else False new_std_instance = IORedirector(getattr(sys, std), redirect_to, wrap_buffer=wrap_buffer) setattr(sys, std, new_std_instance) else: new_std_instance = redirect_to setattr(sys, std, redirect_to) stack.append(_RedirectInfo(original, new_std_instance)) return redirect_to def end_redirect(std='stdout'): with _RedirectionsHolder._lock: if std == 'both': config_stds = ['stdout', 'stderr'] else: config_stds = [std] for std in config_stds: stack = getattr(_RedirectionsHolder, '_stack_%s' % std) redirect_info = stack.pop() setattr(sys, std, redirect_info.original) def redirect_stream_to_pydb_io_messages(std): ''' :param std: 'stdout' or 'stderr' ''' with _RedirectionsHolder._lock: redirect_to_name = '_pydevd_%s_redirect_' % (std,) if getattr(_RedirectionsHolder, redirect_to_name) is None: wrap_buffer = True original = getattr(sys, std) redirect_to = RedirectToPyDBIoMessages(1 if std == 'stdout' else 2, original, wrap_buffer) start_redirect(keep_original_redirection=True, std=std, redirect_to=redirect_to) stack = getattr(_RedirectionsHolder, '_stack_%s' % std) setattr(_RedirectionsHolder, redirect_to_name, stack[-1]) return True return False def stop_redirect_stream_to_pydb_io_messages(std): ''' :param std: 'stdout' or 'stderr' ''' with _RedirectionsHolder._lock: redirect_to_name = '_pydevd_%s_redirect_' % (std,) redirect_info = getattr(_RedirectionsHolder, redirect_to_name) if redirect_info is not None: # :type redirect_info: _RedirectInfo setattr(_RedirectionsHolder, redirect_to_name, None) stack = getattr(_RedirectionsHolder, '_stack_%s' % std) prev_info = stack.pop() curr = getattr(sys, std) if curr is redirect_info.redirect_to: setattr(sys, std, redirect_info.original) @contextmanager def redirect_stream_to_pydb_io_messages_context(): with _RedirectionsHolder._lock: redirecting = [] for std in ('stdout', 'stderr'): if redirect_stream_to_pydb_io_messages(std): redirecting.append(std) try: yield finally: for std in redirecting: stop_redirect_stream_to_pydb_io_messages(std)
8,117
Python
30.343629
110
0.575459
omniverse-code/kit/exts/omni.kit.debug.python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_gevent_integration.py
import pydevd_tracing import greenlet import gevent from _pydev_bundle._pydev_saved_modules import threading from _pydevd_bundle.pydevd_custom_frames import add_custom_frame, update_custom_frame, remove_custom_frame from _pydevd_bundle.pydevd_constants import GEVENT_SHOW_PAUSED_GREENLETS, get_global_debugger, \ thread_get_ident from _pydev_bundle import pydev_log from pydevd_file_utils import basename _saved_greenlets_to_custom_frame_thread_id = {} if GEVENT_SHOW_PAUSED_GREENLETS: def _get_paused_name(py_db, g): frame = g.gr_frame use_frame = frame # i.e.: Show in the description of the greenlet the last user-code found. while use_frame is not None: if py_db.apply_files_filter(use_frame, use_frame.f_code.co_filename, True): frame = use_frame use_frame = use_frame.f_back else: break if use_frame is None: use_frame = frame return '%s: %s - %s' % (type(g).__name__, use_frame.f_code.co_name, basename(use_frame.f_code.co_filename)) def greenlet_events(event, args): if event in ('switch', 'throw'): py_db = get_global_debugger() origin, target = args if not origin.dead and origin.gr_frame is not None: frame_custom_thread_id = _saved_greenlets_to_custom_frame_thread_id.get(origin) if frame_custom_thread_id is None: _saved_greenlets_to_custom_frame_thread_id[origin] = add_custom_frame( origin.gr_frame, _get_paused_name(py_db, origin), thread_get_ident()) else: update_custom_frame( frame_custom_thread_id, origin.gr_frame, _get_paused_name(py_db, origin), thread_get_ident()) else: frame_custom_thread_id = _saved_greenlets_to_custom_frame_thread_id.pop(origin, None) if frame_custom_thread_id is not None: remove_custom_frame(frame_custom_thread_id) # This one will be resumed, so, remove custom frame from it. frame_custom_thread_id = _saved_greenlets_to_custom_frame_thread_id.pop(target, None) if frame_custom_thread_id is not None: remove_custom_frame(frame_custom_thread_id) # The tracing needs to be reapplied for each greenlet as gevent # clears the tracing set through sys.settrace for each greenlet. pydevd_tracing.reapply_settrace() else: # i.e.: no logic related to showing paused greenlets is needed. def greenlet_events(event, args): pydevd_tracing.reapply_settrace() def enable_gevent_integration(): # References: # https://greenlet.readthedocs.io/en/latest/api.html#greenlet.settrace # https://greenlet.readthedocs.io/en/latest/tracing.html # Note: gevent.version_info is WRONG (gevent.__version__ must be used). try: if tuple(int(x) for x in gevent.__version__.split('.')[:2]) <= (20, 0): if not GEVENT_SHOW_PAUSED_GREENLETS: return if not hasattr(greenlet, 'settrace'): # In older versions it was optional. # We still try to use if available though (because without it pydev_log.debug('greenlet.settrace not available. GEVENT_SHOW_PAUSED_GREENLETS will have no effect.') return try: greenlet.settrace(greenlet_events) except: pydev_log.exception('Error with greenlet.settrace.') except: pydev_log.exception('Error setting up gevent %s.', gevent.__version__) def log_gevent_debug_info(): pydev_log.debug('Greenlet version: %s', greenlet.__version__) pydev_log.debug('Gevent version: %s', gevent.__version__) pydev_log.debug('Gevent install location: %s', gevent.__file__)
3,896
Python
40.457446
117
0.622433