├── lib ├── _pydev_imps │ ├── __init__.py │ ├── _pydev_select.py │ ├── _pydev_socket.py │ ├── _pydev_time.py │ ├── _pydev_thread.py │ ├── _pydev_execfile.py │ └── _pydev_sys_patch.py ├── pydev_ipython │ ├── __init__.py │ ├── README │ ├── qt.py │ ├── inputhooktk.py │ ├── inputhookgtk.py │ ├── inputhookgtk3.py │ ├── version.py │ └── qt_for_kernel.py ├── pydevd_plugins │ └── __init__.py ├── third_party │ ├── __init__.py │ ├── pep8 │ │ └── lib2to3 │ │ │ └── lib2to3 │ │ │ ├── __init__.py │ │ │ ├── fixes │ │ │ ├── __init__.py │ │ │ ├── fix_imports2.py │ │ │ ├── fix_basestring.py │ │ │ ├── fix_raw_input.py │ │ │ ├── fix_getcwdu.py │ │ │ ├── fix_standarderror.py │ │ │ ├── fix_long.py │ │ │ ├── fix_future.py │ │ │ ├── fix_ne.py │ │ │ ├── fix_buffer.py │ │ │ ├── fix_nonzero.py │ │ │ ├── fix_repr.py │ │ │ ├── fix_methodattrs.py │ │ │ ├── fix_funcattrs.py │ │ │ ├── fix_xreadlines.py │ │ │ ├── fix_input.py │ │ │ ├── fix_numliterals.py │ │ │ ├── fix_reduce.py │ │ │ ├── fix_zip.py │ │ │ ├── fix_sys_exc.py │ │ │ ├── fix_exec.py │ │ │ ├── fix_ws_comma.py │ │ │ ├── fix_callable.py │ │ │ ├── fix_paren.py │ │ │ ├── fix_unicode.py │ │ │ ├── fix_intern.py │ │ │ ├── fix_itertools.py │ │ │ ├── fix_throw.py │ │ │ ├── fix_isinstance.py │ │ │ ├── fix_set_literal.py │ │ │ ├── fix_types.py │ │ │ ├── fix_apply.py │ │ │ ├── fix_execfile.py │ │ │ ├── fix_itertools_imports.py │ │ │ ├── fix_filter.py │ │ │ ├── fix_renames.py │ │ │ ├── fix_exitfunc.py │ │ │ ├── fix_xrange.py │ │ │ ├── fix_print.py │ │ │ ├── fix_raise.py │ │ │ └── fix_map.py │ │ │ ├── __main__.py │ │ │ ├── pgen2 │ │ │ ├── __init__.py │ │ │ ├── token.py │ │ │ └── literals.py │ │ │ ├── PatternGrammar.txt │ │ │ └── pygram.py │ └── wrapped_for_pydev │ │ ├── not_in_default_pythonpath.txt │ │ ├── ctypes │ │ ├── _ctypes.dll │ │ ├── macholib │ │ │ ├── __init__.py │ │ │ ├── dylib.py │ │ │ └── framework.py │ │ ├── _endian.py │ │ └── wintypes.py │ │ └── removed_ctypes.txt ├── tests_runfiles │ ├── samples │ │ ├── __init__.py │ │ ├── nested_dir │ │ │ ├── __init__.py │ │ │ ├── nested2 │ │ │ │ ├── __init__.py │ │ │ │ ├── non_test_file.py │ │ │ │ └── deep_nest_test.py │ │ │ ├── nested3 │ │ │ │ ├── __init__.py │ │ │ │ ├── junk.txt │ │ │ │ └── non_test_file.py │ │ │ ├── non_test_file.py │ │ │ └── simple4_test.py │ │ ├── not_in_default_pythonpath.txt │ │ ├── non_test_file.py │ │ ├── simple2_test.py │ │ ├── simple3_test.py │ │ ├── simpleClass_test.py │ │ ├── simpleModule_test.py │ │ └── simple_test.py │ ├── not_in_default_pythonpath.txt │ └── test_pydevdio.py ├── tests │ ├── __not_in_default_pythonpath.txt │ └── test_pydev_ipython_010.py ├── tests_mainloop │ ├── __not_in_default_pythonpath.txt │ ├── README │ ├── gui-tk.py │ ├── gui-pyglet.py │ ├── gui-gtk3.py │ ├── gui-gtk.py │ ├── gui-qt.py │ └── gui-glut.py ├── tests_python │ ├── __not_in_default_pythonpath.txt │ ├── _debugger_case15_execfile.py │ ├── _debugger_case3.py │ ├── _debugger_case4.py │ ├── _debugger_case56.py │ ├── _debugger_case7.py │ ├── _debugger_case19.py │ ├── _debugger_case17a.py │ ├── _debugger_case89.py │ ├── _debugger_case10.py │ ├── _debugger_case16.py │ ├── _debugger_case18.py │ ├── _debugger_case2.py │ ├── _debugger_case17.py │ ├── _debugger_case_qthread1.py │ ├── _debugger_case14.py │ ├── _debugger_case15.py │ ├── _debugger_case_qthread3.py │ ├── _debugger_case_qthread2.py │ ├── _debugger_case13.py │ ├── _debugger_case1.py │ └── test_save_locals.py ├── pydev_sitecustomize │ └── __not_in_default_pythonpath.txt ├── requirements.txt ├── pydevd_attach_to_process │ ├── winappdbg │ │ ├── plugins │ │ │ ├── README │ │ │ ├── __init__.py │ │ │ ├── do_symfix.py │ │ │ ├── do_example.py │ │ │ ├── do_exploitable.py │ │ │ └── do_exchain.py │ │ └── win32 │ │ │ └── __init__.py │ ├── attach_x86.dll │ ├── attach_amd64.dll │ ├── attach_x86.dylib │ ├── attach_x86_64.dylib │ ├── _check.py │ ├── _test_attach_to_process.py │ ├── linux │ │ ├── compile_mac.sh │ │ ├── compile_so.sh │ │ ├── gdb_threads_settrace.py │ │ ├── lldb_prepare.py │ │ ├── Makefile │ │ └── lldb_threads_settrace.py │ ├── README.txt │ ├── dll │ │ ├── compile_dll.bat │ │ ├── stdafx.cpp │ │ ├── targetver.h │ │ ├── stdafx.h │ │ └── attach.h │ ├── attach_script.py │ ├── _always_live_program.py │ ├── attach_pydevd.py │ └── _test_attach_to_process_linux.py ├── _pydev_inspect.py ├── pydev_pysrc.py ├── pydevd_exec.py ├── pydevd_exec2.py ├── _pydev_jython_execfile.py ├── .settings │ └── org.eclipse.core.resources.prefs ├── _pydevd_re.py ├── README.md ├── fix_getpass.py ├── _pydev_threading.py ├── pydev_versioncheck.py ├── pydevd_psyco_stub.py ├── _pydev_log.py ├── pydev_app_engine_debug_startup.py ├── pydev_log.py ├── pydevd_trace_api.py ├── _pydev_filesystem_encoding.py ├── pydev_import_hook.py ├── pydev_localhost.py ├── _pydev_execfile.py ├── pycompletion.py ├── pydev_override.py ├── pydevd_vm_type.py ├── pydevd_save_locals.py ├── pydevd_frame_utils.py ├── _pydev_tipper_common.py ├── pydevd_import_class.py ├── pydev_coverage.py ├── pydev_run_in_console.py ├── pydev_ipython_console.py ├── pydevd_plugin_utils.py ├── pydevd_io.py ├── pydev_imports.py └── _pydev_xmlrpc_hook.py ├── icon.png ├── LICENSE.txt ├── changelog.txt ├── .gitignore ├── addon.xml └── README.md /lib/_pydev_imps/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/pydev_ipython/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/pydevd_plugins/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/third_party/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/tests/__not_in_default_pythonpath.txt: -------------------------------------------------------------------------------- 1 | (no __init__.py file) -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/nested2/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/nested3/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/__init__.py: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /lib/tests_mainloop/__not_in_default_pythonpath.txt: -------------------------------------------------------------------------------- 1 | (no __init__.py file) -------------------------------------------------------------------------------- /lib/tests_python/__not_in_default_pythonpath.txt: -------------------------------------------------------------------------------- 1 | (no __init__.py file) -------------------------------------------------------------------------------- /lib/tests_runfiles/not_in_default_pythonpath.txt: -------------------------------------------------------------------------------- 1 | (no __init__.py file) -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/nested3/junk.txt: -------------------------------------------------------------------------------- 1 | im a junk file 2 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/icon.png -------------------------------------------------------------------------------- /lib/pydev_sitecustomize/__not_in_default_pythonpath.txt: -------------------------------------------------------------------------------- 1 | (no __init__.py file) -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case15_execfile.py: -------------------------------------------------------------------------------- 1 | f=lambda x: 'val=%s' % x 2 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/not_in_default_pythonpath.txt: -------------------------------------------------------------------------------- 1 | (no __init__.py file) -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/LICENSE.txt -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | v4.4.0 2 | - Update Pydev version 3 | v3.4.1 4 | - Packed for XBMC 5 | -------------------------------------------------------------------------------- /lib/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==1.6.5 2 | nose==1.3.3 3 | ipython==2.1.0 4 | numpy==1.8.2 -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/winappdbg/plugins/README: -------------------------------------------------------------------------------- 1 | Here go the plugins for the interactive debugger. -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/non_test_file.py: -------------------------------------------------------------------------------- 1 | 2 | """ i am a python file with no tests """ 3 | pass 4 | -------------------------------------------------------------------------------- /lib/_pydev_inspect.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/lib/_pydev_inspect.py -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/__init__.py: -------------------------------------------------------------------------------- 1 | # Dummy file to make this directory a package. 2 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/non_test_file.py: -------------------------------------------------------------------------------- 1 | 2 | """ i am a python file with no tests """ 3 | pass 4 | -------------------------------------------------------------------------------- /lib/pydev_pysrc.py: -------------------------------------------------------------------------------- 1 | '''An empty file in pysrc that can be imported (from sitecustomize) to find the location of pysrc''' -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/nested2/non_test_file.py: -------------------------------------------------------------------------------- 1 | 2 | """ i am a python file with no tests """ 3 | pass 4 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/nested3/non_test_file.py: -------------------------------------------------------------------------------- 1 | 2 | """ i am a python file with no tests """ 3 | pass 4 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/__main__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from .main import main 3 | 4 | sys.exit(main("lib2to3.fixes")) 5 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/attach_x86.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/lib/pydevd_attach_to_process/attach_x86.dll -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/attach_amd64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/lib/pydevd_attach_to_process/attach_amd64.dll -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/attach_x86.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/lib/pydevd_attach_to_process/attach_x86.dylib -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/not_in_default_pythonpath.txt: -------------------------------------------------------------------------------- 1 | The wrapped_for_pydev folder is not in the default pythonpath... (no __init__.py file) -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/attach_x86_64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/lib/pydevd_attach_to_process/attach_x86_64.dylib -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/ctypes/_ctypes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/powlo/script.module.pydevd/HEAD/lib/third_party/wrapped_for_pydev/ctypes/_ctypes.dll -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/_check.py: -------------------------------------------------------------------------------- 1 | import add_code_to_python_process 2 | print add_code_to_python_process.run_python_code(3736, "print(20)", connect_debugger_tracing=False) -------------------------------------------------------------------------------- /lib/pydevd_exec.py: -------------------------------------------------------------------------------- 1 | def Exec(exp, global_vars, local_vars=None): 2 | if local_vars is not None: 3 | exec exp in global_vars, local_vars 4 | else: 5 | exec exp in global_vars -------------------------------------------------------------------------------- /lib/pydevd_exec2.py: -------------------------------------------------------------------------------- 1 | def Exec(exp, global_vars, local_vars=None): 2 | if local_vars is not None: 3 | exec(exp, global_vars, local_vars) 4 | else: 5 | exec(exp, global_vars) -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/pgen2/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """The pgen2 package.""" 5 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case3.py: -------------------------------------------------------------------------------- 1 | import time 2 | if __name__ == '__main__': 3 | for i in range(15): 4 | print('here') 5 | time.sleep(.2) 6 | 7 | print('TEST SUCEEDED') 8 | 9 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case4.py: -------------------------------------------------------------------------------- 1 | import time 2 | if __name__ == '__main__': 3 | for i in range(10): 4 | print('here %s' % i) 5 | time.sleep(1) 6 | 7 | print('TEST SUCEEDED') 8 | 9 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case56.py: -------------------------------------------------------------------------------- 1 | def Call2(): 2 | print('Call2') 3 | 4 | def Call1(a): 5 | print('Call1') 6 | 7 | if __name__ == '__main__': 8 | Call1(Call2()) 9 | print('TEST SUCEEDED!') 10 | -------------------------------------------------------------------------------- /lib/_pydev_imps/_pydev_select.py: -------------------------------------------------------------------------------- 1 | from select import * 2 | 3 | try: 4 | from gevent import monkey 5 | saved = monkey.saved['select'] 6 | for key, val in saved.items(): 7 | globals()[key] = val 8 | except: 9 | pass -------------------------------------------------------------------------------- /lib/_pydev_imps/_pydev_socket.py: -------------------------------------------------------------------------------- 1 | from socket import * 2 | 3 | try: 4 | from gevent import monkey 5 | saved = monkey.saved['socket'] 6 | for key, val in saved.items(): 7 | globals()[key] = val 8 | except: 9 | pass -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case7.py: -------------------------------------------------------------------------------- 1 | def Call(): 2 | variable_for_test_1 = 10 3 | variable_for_test_2 = 20 4 | variable_for_test_3 = 30 5 | 6 | if __name__ == '__main__': 7 | Call() 8 | print('TEST SUCEEDED!') 9 | -------------------------------------------------------------------------------- /lib/_pydev_imps/_pydev_time.py: -------------------------------------------------------------------------------- 1 | from time import * 2 | 3 | try: 4 | from gevent import monkey 5 | saved = monkey.saved['time'] 6 | for key, val in saved.items(): 7 | globals()[key] = val 8 | except: 9 | pass 10 | -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/ctypes/macholib/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Enough Mach-O to make your head spin. 3 | 4 | See the relevant header files in /usr/include/mach-o 5 | 6 | And also Apple's documentation. 7 | """ 8 | 9 | __version__ = '1.0' 10 | -------------------------------------------------------------------------------- /lib/_pydev_jython_execfile.py: -------------------------------------------------------------------------------- 1 | def jython_execfile(argv): 2 | import org.python.util.PythonInterpreter as PythonInterpreter 3 | interpreter = PythonInterpreter() 4 | state = interpreter.getSystemState() 5 | state.argv = argv 6 | interpreter.execfile(argv[0]) -------------------------------------------------------------------------------- /lib/tests_mainloop/README: -------------------------------------------------------------------------------- 1 | # Parts of IPython, files from: https://github.com/ipython/ipython/tree/rel-1.0.0/examples/lib 2 | # The files in this folder are manual tests for main loop integration 3 | 4 | # These tests have been modified to work in the PyDev Console context 5 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case19.py: -------------------------------------------------------------------------------- 1 | class A: 2 | 3 | def __init__(self): 4 | self.__var = 10 5 | 6 | if __name__ == '__main__': 7 | a = A() 8 | print(a._A__var) 9 | # Evaluate 'a.__var' should give a._A__var_ 10 | print('TEST SUCEEDED') 11 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case17a.py: -------------------------------------------------------------------------------- 1 | def m1(): 2 | print('m1') 3 | 4 | def m2(): # @DontTrace 5 | m1() 6 | print('m2') 7 | 8 | def m3(): 9 | m2() 10 | print('m3') 11 | 12 | if __name__ == '__main__': 13 | m3() 14 | 15 | print('TEST SUCEEDED') 16 | -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/removed_ctypes.txt: -------------------------------------------------------------------------------- 1 | Because this folder contained a precompiled distribution of ctypes (containing a DLL) it has been removed. 2 | 3 | If you need ctypes for PyDev remote debug then you'll need to drop the files back here. 4 | 5 | http://ctypes.sourceforge.net/‎ -------------------------------------------------------------------------------- /lib/_pydev_imps/_pydev_thread.py: -------------------------------------------------------------------------------- 1 | try: 2 | from thread import * 3 | except: 4 | from _thread import * #Py3k 5 | 6 | try: 7 | from gevent import monkey 8 | saved = monkey.saved['thread'] 9 | for key, val in saved.items(): 10 | globals()[key] = val 11 | except: 12 | pass 13 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/simple2_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | class YetAnotherSampleTest(unittest.TestCase): 4 | 5 | def setUp(self): 6 | return 7 | 8 | def tearDown(self): 9 | return 10 | 11 | def test_abc(self): 12 | pass 13 | 14 | 15 | if __name__ == '__main__': 16 | unittest.main() 17 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case89.py: -------------------------------------------------------------------------------- 1 | def Method1(): 2 | print('m1') 3 | 4 | def Method2(): 5 | print('m2 before') 6 | Method1() 7 | print('m2 after') 8 | 9 | def Method3(): 10 | print('m3 before') 11 | Method2() 12 | print('m3 after') 13 | 14 | if __name__ == '__main__': 15 | Method3() 16 | print('TEST SUCEEDED!') 17 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/simple3_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | class StillYetAnotherSampleTest(unittest.TestCase): 4 | 5 | def setUp(self): 6 | return 7 | 8 | def tearDown(self): 9 | return 10 | 11 | def test_non_unique_name(self): 12 | pass 13 | 14 | 15 | if __name__ == '__main__': 16 | unittest.main() 17 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/_test_attach_to_process.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import sys 3 | print(sys.executable) 4 | 5 | if __name__ == '__main__': 6 | p = subprocess.Popen([sys.executable, '-u', '_always_live_program.py']) 7 | import attach_pydevd 8 | attach_pydevd.main(attach_pydevd.process_command_line(['--pid', str(p.pid)])) 9 | p.wait() 10 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/simple4_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | class NestedSampleTest(unittest.TestCase): 4 | 5 | def setUp(self): 6 | return 7 | 8 | def tearDown(self): 9 | return 10 | 11 | def test_non_unique_name(self): 12 | pass 13 | 14 | 15 | if __name__ == '__main__': 16 | unittest.main() 17 | -------------------------------------------------------------------------------- /lib/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//pydev_ipython/inputhook.py=utf-8 3 | encoding//pydev_ipython/inputhookglut.py=utf-8 4 | encoding//pydev_ipython/inputhookpyglet.py=utf-8 5 | encoding//pydev_ipython/inputhookqt4.py=utf-8 6 | encoding//pydev_ipython/inputhooktk.py=utf-8 7 | encoding//pydev_ipython/inputhookwx.py=utf-8 8 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/simpleClass_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | class SetUpClassTest(unittest.TestCase): 4 | 5 | @classmethod 6 | def setUpClass(cls): 7 | raise ValueError("This is an INTENTIONAL value error in setUpClass.") 8 | 9 | def test_blank(self): 10 | pass 11 | 12 | 13 | if __name__ == '__main__': 14 | unittest.main() 15 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/linux/compile_mac.sh: -------------------------------------------------------------------------------- 1 | g++ -fPIC -D_REENTRANT -arch x86_64 I. -c -o attach_linux_x86_64.o attach_linux.c 2 | g++ -dynamiclib -arch x86_64 -o attach_x86_64.dylib attach_linux_x86_64.o -lc 3 | 4 | 5 | g++ -fPIC -D_REENTRANT -arch i386 -I. -c -o attach_linux_x86.o attach_linux.c 6 | g++ -dynamiclib -arch i386 -o attach_x86.dylib attach_linux_x86.o -lc 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case10.py: -------------------------------------------------------------------------------- 1 | def Method1(): 2 | print('m1') 3 | print('m1') 4 | 5 | def Method1a(): 6 | print('m1a') 7 | print('m1a') 8 | 9 | def Method2(): 10 | print('m2 before') 11 | Method1() 12 | Method1a() 13 | print('m2 after') 14 | 15 | 16 | if __name__ == '__main__': 17 | Method2() 18 | print('TEST SUCEEDED!') 19 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/simpleModule_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | def setUpModule(): 4 | raise ValueError("This is an INTENTIONAL value error in setUpModule.") 5 | 6 | class SetUpModuleTest(unittest.TestCase): 7 | 8 | def setUp(cls): 9 | pass 10 | 11 | def test_blank(self): 12 | pass 13 | 14 | 15 | if __name__ == '__main__': 16 | unittest.main() 17 | -------------------------------------------------------------------------------- /lib/_pydevd_re.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = [ "match", "search", "sub", "subn", "split", "findall", 3 | "compile", "purge", "template", "escape", "I", "L", "M", "S", "X", 4 | "U", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE", 5 | "UNICODE", "error" ] 6 | 7 | import sre, sys 8 | module = sys.modules['re'] 9 | for name in __all__: 10 | setattr(module, name, getattr(sre, name)) 11 | 12 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains the utilities to attach a target process to the pydev debugger. 2 | 3 | The main module to be called for the attach is: 4 | 5 | attach_pydevd.py 6 | 7 | it should be called as; 8 | 9 | python attach_pydevd.py --port 5678 --pid 1234 10 | 11 | Note that the client is responsible for having a remote debugger alive in the given port for the attach to work. -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case16.py: -------------------------------------------------------------------------------- 1 | # this test requires numpy to be installed 2 | import numpy 3 | 4 | def main(): 5 | smallarray = numpy.arange(100) * 1 + 1j 6 | bigarray = numpy.arange(100000).reshape((10,10000)) # 100 thousand 7 | hugearray = numpy.arange(10000000) # 10 million 8 | 9 | pass # location of breakpoint after all arrays defined 10 | 11 | main() 12 | print('TEST SUCEEDED') 13 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_imports2.py: -------------------------------------------------------------------------------- 1 | """Fix incompatible imports and module references that must be fixed after 2 | fix_imports.""" 3 | from . import fix_imports 4 | 5 | 6 | MAPPING = { 7 | 'whichdb': 'dbm', 8 | 'anydbm': 'dbm', 9 | } 10 | 11 | 12 | class FixImports2(fix_imports.FixImports): 13 | 14 | run_order = 7 15 | 16 | mapping = MAPPING 17 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_basestring.py: -------------------------------------------------------------------------------- 1 | """Fixer for basestring -> str.""" 2 | # Author: Christian Heimes 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name 7 | 8 | class FixBasestring(fixer_base.BaseFix): 9 | BM_compatible = True 10 | 11 | PATTERN = "'basestring'" 12 | 13 | def transform(self, node, results): 14 | return Name(u"str", prefix=node.prefix) 15 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/dll/compile_dll.bat: -------------------------------------------------------------------------------- 1 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 2 | cl -DUNICODE -D_UNICODE /EHsc /LD attach.cpp /link /out:attach_x86.dll 3 | copy attach_x86.dll ..\attach_x86.dll /Y 4 | 5 | 6 | 7 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64 8 | cl -DUNICODE -D_UNICODE /EHsc /LD attach.cpp /link /out:attach_amd64.dll 9 | copy attach_amd64.dll ..\attach_amd64.dll /Y -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | bin 14 | var 15 | sdist 16 | develop-eggs 17 | .installed.cfg 18 | lib64 19 | 20 | # Installer logs 21 | pip-log.txt 22 | 23 | # Unit test / coverage reports 24 | .coverage 25 | .tox 26 | nosetests.xml 27 | 28 | # Translations 29 | *.mo 30 | 31 | # Mr Developer 32 | .mr.developer.cfg 33 | .project 34 | .pydevproject 35 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/linux/compile_so.sh: -------------------------------------------------------------------------------- 1 | g++ -m64 -shared -o attach_linux_amd64.so -fPIC -nostartfiles attach_linux.c 2 | mv attach_linux_amd64.so ../attach_linux_amd64.so 3 | 4 | echo Note: may need "sudo apt-get install libx32gcc-4.8-dev" and "sudo apt-get install libc6-dev-i386" and "sudo apt-get install g++-multilib" to compile 32 bits 5 | 6 | g++ -m32 -shared -o attach_linux_x86.so -fPIC -nostartfiles attach_linux.c 7 | mv attach_linux_x86.so ../attach_linux_x86.so -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | PyDev.Debugger 2 | ============== 3 | 4 | [![Build Status](https://travis-ci.org/fabioz/PyDev.Debugger.png)](https://travis-ci.org/fabioz/PyDev.Debugger) 5 | 6 | This repository contains the sources for the Debugger used in PyDev & PyCharm. 7 | 8 | It should be compatible with Python 2.4 onwards (as well as Jython 2.2.1, IronPython and PyPy -- and any 9 | other variant which properly supports the Python structure for debuggers -- i.e.: sys.settrace/threading.settrace). -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/nested_dir/nested2/deep_nest_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | class SampleTest(unittest.TestCase): 4 | 5 | def setUp(self): 6 | return 7 | 8 | def tearDown(self): 9 | return 10 | 11 | def test_non_unique_name(self): 12 | pass 13 | 14 | def test_asdf2(self): 15 | pass 16 | 17 | def test_i_am_a_unique_test_name(self): 18 | pass 19 | 20 | 21 | if __name__ == '__main__': 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /lib/fix_getpass.py: -------------------------------------------------------------------------------- 1 | def fixGetpass(): 2 | try: 3 | import getpass 4 | except ImportError: 5 | return #If we can't import it, we can't fix it 6 | import warnings 7 | fallback = getattr(getpass, 'fallback_getpass', None) # >= 2.6 8 | if not fallback: 9 | fallback = getpass.default_getpass # <= 2.5 10 | getpass.getpass = fallback 11 | if hasattr(getpass, 'GetPassWarning'): 12 | warnings.simplefilter("ignore", category=getpass.GetPassWarning) 13 | 14 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case18.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def m2(a): 4 | a = 10 5 | b = 20 #Break here and set a = 40 6 | c = 30 7 | 8 | def function2(): 9 | print(a) 10 | 11 | return a 12 | 13 | 14 | def m1(a): 15 | return m2(a) 16 | 17 | 18 | if __name__ == '__main__': 19 | found = m1(10) 20 | if found == 40: 21 | print('TEST SUCEEDED') 22 | else: 23 | raise AssertionError('Expected variable to be changed to 40. Found: %s' % (found,)) 24 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case2.py: -------------------------------------------------------------------------------- 1 | 2 | def Call4(): 3 | print('Start Call4') 4 | print('End Call4') 5 | 6 | def Call3(): 7 | print('Start Call3') 8 | Call4() 9 | print('End Call3') 10 | 11 | def Call2(): 12 | print('Start Call2') 13 | Call3() 14 | print('End Call2 - a') 15 | print('End Call2 - b') 16 | 17 | def Call1(): 18 | print('Start Call1') 19 | Call2() 20 | print('End Call1') 21 | 22 | if __name__ == '__main__': 23 | Call1() 24 | print('TEST SUCEEDED!') 25 | -------------------------------------------------------------------------------- /lib/_pydev_threading.py: -------------------------------------------------------------------------------- 1 | from threading import * # Make up for things we may forget @UnusedWildImport 2 | 3 | # Force what we know we need 4 | from threading import enumerate, currentThread, Condition, Event, Thread, Lock 5 | try: 6 | from threading import settrace 7 | except: 8 | pass 9 | try: 10 | from threading import Timer 11 | except: 12 | pass # Jython 2.1 13 | 14 | 15 | try: 16 | from gevent import monkey 17 | saved = monkey.saved['threading'] 18 | for key, val in saved.items(): 19 | globals()[key] = val 20 | except: 21 | pass 22 | -------------------------------------------------------------------------------- /lib/pydev_ipython/README: -------------------------------------------------------------------------------- 1 | # Parts of IPython, files from: https://github.com/ipython/ipython/tree/rel-1.0.0/IPython 2 | # The files in this package are extracted from IPython to aid the main loop integration 3 | # See tests_mainloop for some manually runable tests 4 | 5 | # What we are doing is reusing the "inputhook" functionality (i.e. what in IPython 6 | # ends up on PyOS_InputHook) and using it in the pydevconsole context. 7 | # Rather that having the callbacks called in PyOS_InputHook, we use a custom XML-RPC 8 | # Server (HookableXMLRPCServer) that calls the inputhook when idle 9 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case17.py: -------------------------------------------------------------------------------- 1 | def get_here(): 2 | a = 10 3 | 4 | def foo(func): 5 | return func 6 | 7 | def m1(): # @DontTrace 8 | get_here() 9 | 10 | # @DontTrace 11 | def m2(): 12 | get_here() 13 | 14 | # @DontTrace 15 | @foo 16 | def m3(): 17 | get_here() 18 | 19 | @foo 20 | @foo 21 | def m4(): # @DontTrace 22 | get_here() 23 | 24 | 25 | def main(): 26 | 27 | m1() 28 | 29 | m2() 30 | 31 | m3() 32 | 33 | m4() 34 | 35 | if __name__ == '__main__': 36 | main() 37 | 38 | print('TEST SUCEEDED') 39 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_raw_input.py: -------------------------------------------------------------------------------- 1 | """Fixer that changes raw_input(...) into input(...).""" 2 | # Author: Andre Roberge 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name 7 | 8 | class FixRawInput(fixer_base.BaseFix): 9 | 10 | BM_compatible = True 11 | PATTERN = """ 12 | power< name='raw_input' trailer< '(' [any] ')' > any* > 13 | """ 14 | 15 | def transform(self, node, results): 16 | name = results["name"] 17 | name.replace(Name(u"input", prefix=name.prefix)) 18 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_getcwdu.py: -------------------------------------------------------------------------------- 1 | """ 2 | Fixer that changes os.getcwdu() to os.getcwd(). 3 | """ 4 | # Author: Victor Stinner 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | class FixGetcwdu(fixer_base.BaseFix): 11 | BM_compatible = True 12 | 13 | PATTERN = """ 14 | power< 'os' trailer< dot='.' name='getcwdu' > any* > 15 | """ 16 | 17 | def transform(self, node, results): 18 | name = results["name"] 19 | name.replace(Name(u"getcwd", prefix=name.prefix)) 20 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_standarderror.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for StandardError -> Exception.""" 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | 11 | class FixStandarderror(fixer_base.BaseFix): 12 | BM_compatible = True 13 | PATTERN = """ 14 | 'StandardError' 15 | """ 16 | 17 | def transform(self, node, results): 18 | return Name(u"Exception", prefix=node.prefix) 19 | -------------------------------------------------------------------------------- /lib/pydev_versioncheck.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def versionok_for_gui(): 4 | ''' Return True if running Python is suitable for GUI Event Integration and deeper IPython integration ''' 5 | # We require Python 2.6+ ... 6 | if sys.hexversion < 0x02060000: 7 | return False 8 | # Or Python 3.2+ 9 | if sys.hexversion >= 0x03000000 and sys.hexversion < 0x03020000: 10 | return False 11 | # Not supported under Jython nor IronPython 12 | if sys.platform.startswith("java") or sys.platform.startswith('cli'): 13 | return False 14 | 15 | return True 16 | 17 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_long.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that turns 'long' into 'int' everywhere. 5 | """ 6 | 7 | # Local imports 8 | from lib2to3 import fixer_base 9 | from lib2to3.fixer_util import is_probably_builtin 10 | 11 | 12 | class FixLong(fixer_base.BaseFix): 13 | BM_compatible = True 14 | PATTERN = "'long'" 15 | 16 | def transform(self, node, results): 17 | if is_probably_builtin(node): 18 | node.value = u"int" 19 | node.changed() 20 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case_qthread1.py: -------------------------------------------------------------------------------- 1 | import time 2 | import sys 3 | 4 | try: 5 | from PySide import QtCore 6 | except: 7 | from PyQt4 import QtCore 8 | 9 | # Subclassing QThread 10 | # http://doc.qt.nokia.com/latest/qthread.html 11 | class AThread(QtCore.QThread): 12 | 13 | def run(self): 14 | count = 0 15 | while count < 5: 16 | time.sleep(.5) 17 | print("Increasing", count);sys.stdout.flush() 18 | count += 1 19 | 20 | app = QtCore.QCoreApplication([]) 21 | thread = AThread() 22 | thread.finished.connect(app.exit) 23 | thread.start() 24 | app.exec_() 25 | print('TEST SUCEEDED!') -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_future.py: -------------------------------------------------------------------------------- 1 | """Remove __future__ imports 2 | 3 | from __future__ import foo is replaced with an empty line. 4 | """ 5 | # Author: Christian Heimes 6 | 7 | # Local imports 8 | from .. import fixer_base 9 | from ..fixer_util import BlankLine 10 | 11 | class FixFuture(fixer_base.BaseFix): 12 | BM_compatible = True 13 | 14 | PATTERN = """import_from< 'from' module_name="__future__" 'import' any >""" 15 | 16 | # This should be run last -- some things check for the import 17 | run_order = 10 18 | 19 | def transform(self, node, results): 20 | new = BlankLine() 21 | new.prefix = node.prefix 22 | return new 23 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/linux/gdb_threads_settrace.py: -------------------------------------------------------------------------------- 1 | # This file is meant to be run inside GDB as a command after 2 | # the attach_linux.so dll has already been loaded to settrace for all threads. 3 | if __name__ == '__main__': 4 | #print('Startup GDB in Python!') 5 | 6 | try: 7 | show_debug_info = 0 8 | is_debug = 0 9 | for t in list(gdb.selected_inferior().threads()): 10 | t.switch() 11 | if t.is_stopped(): 12 | #print('Will settrace in: %s' % (t,)) 13 | gdb.execute("call SetSysTraceFunc(%s, %s)" % ( 14 | show_debug_info, is_debug)) 15 | except: 16 | import traceback;traceback.print_exc() 17 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_ne.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that turns <> into !=.""" 5 | 6 | # Local imports 7 | from .. import pytree 8 | from ..pgen2 import token 9 | from .. import fixer_base 10 | 11 | 12 | class FixNe(fixer_base.BaseFix): 13 | # This is so simple that we don't need the pattern compiler. 14 | 15 | _accept_type = token.NOTEQUAL 16 | 17 | def match(self, node): 18 | # Override 19 | return node.value == u"<>" 20 | 21 | def transform(self, node, results): 22 | new = pytree.Leaf(token.NOTEQUAL, u"!=", prefix=node.prefix) 23 | return new 24 | -------------------------------------------------------------------------------- /lib/_pydev_imps/_pydev_execfile.py: -------------------------------------------------------------------------------- 1 | #We must redefine it in Py3k if it's not already there 2 | def execfile(file, glob=None, loc=None): 3 | if glob is None: 4 | import sys 5 | glob = sys._getframe().f_back.f_globals 6 | if loc is None: 7 | loc = glob 8 | 9 | # It seems that the best way is using tokenize.open(): http://code.activestate.com/lists/python-dev/131251/ 10 | import tokenize 11 | stream = tokenize.open(file) 12 | try: 13 | contents = stream.read() 14 | finally: 15 | stream.close() 16 | 17 | #execute the script (note: it's important to compile first to have the filename set in debug mode) 18 | exec(compile(contents+"\n", file, 'exec'), glob, loc) -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_buffer.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that changes buffer(...) into memoryview(...).""" 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | 11 | class FixBuffer(fixer_base.BaseFix): 12 | BM_compatible = True 13 | 14 | explicit = True # The user must ask for this fixer 15 | 16 | PATTERN = """ 17 | power< name='buffer' trailer< '(' [any] ')' > any* > 18 | """ 19 | 20 | def transform(self, node, results): 21 | name = results["name"] 22 | name.replace(Name(u"memoryview", prefix=name.prefix)) 23 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_nonzero.py: -------------------------------------------------------------------------------- 1 | """Fixer for __nonzero__ -> __bool__ methods.""" 2 | # Author: Collin Winter 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name, syms 7 | 8 | class FixNonzero(fixer_base.BaseFix): 9 | BM_compatible = True 10 | PATTERN = """ 11 | classdef< 'class' any+ ':' 12 | suite< any* 13 | funcdef< 'def' name='__nonzero__' 14 | parameters< '(' NAME ')' > any+ > 15 | any* > > 16 | """ 17 | 18 | def transform(self, node, results): 19 | name = results["name"] 20 | new = Name(u"__bool__", prefix=name.prefix) 21 | name.replace(new) 22 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_repr.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that transforms `xyzzy` into repr(xyzzy).""" 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Call, Name, parenthesize 9 | 10 | 11 | class FixRepr(fixer_base.BaseFix): 12 | 13 | BM_compatible = True 14 | PATTERN = """ 15 | atom < '`' expr=any '`' > 16 | """ 17 | 18 | def transform(self, node, results): 19 | expr = results["expr"].clone() 20 | 21 | if expr.type == self.syms.testlist1: 22 | expr = parenthesize(expr) 23 | return Call(Name(u"repr"), [expr], prefix=node.prefix) 24 | -------------------------------------------------------------------------------- /lib/pydevd_psyco_stub.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Psyco stub: should implement all the external API from psyco. 3 | ''' 4 | 5 | def proxy(func, *args, **kwargs): 6 | return func 7 | 8 | def bind(func, *args, **kwargs): 9 | return func 10 | 11 | def unbind(func, *args, **kwargs): 12 | return func 13 | 14 | def unproxy(func, *args, **kwargs): 15 | return func 16 | 17 | def full(*args, **kwargs): 18 | pass 19 | 20 | def log(*args, **kwargs): 21 | pass 22 | 23 | def runonly(*args, **kwargs): 24 | pass 25 | 26 | def background(*args, **kwargs): 27 | pass 28 | 29 | def cannotcompile(*args, **kwargs): 30 | pass 31 | 32 | def profile(*args, **kwargs): 33 | pass 34 | 35 | def stop(*args, **kwargs): 36 | pass 37 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case14.py: -------------------------------------------------------------------------------- 1 | 2 | class Car(object): 3 | """A car class""" 4 | def __init__(self, model, make, color): 5 | self.model = model 6 | self.make = make 7 | self.color = color 8 | self.price = None 9 | 10 | def get_price(self): 11 | return self.price 12 | 13 | def set_price(self, value): 14 | self.price = value 15 | 16 | availableCars = [] 17 | def main(): 18 | global availableCars 19 | 20 | #Create a new car obj 21 | carObj = Car("Maruti SX4", "2011", "Black") 22 | carObj.set_price(950000) # Set price 23 | # Add this to available cars 24 | availableCars.append(carObj) 25 | 26 | print('TEST SUCEEDED') 27 | 28 | if __name__ == '__main__': 29 | main() 30 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case15.py: -------------------------------------------------------------------------------- 1 | 2 | class Car(object): 3 | """A car class""" 4 | def __init__(self, model, make, color): 5 | self.model = model 6 | self.make = make 7 | self.color = color 8 | self.price = None 9 | 10 | def get_price(self): 11 | return self.price 12 | 13 | def set_price(self, value): 14 | self.price = value 15 | 16 | availableCars = [] 17 | def main(): 18 | global availableCars 19 | 20 | #Create a new car obj 21 | carObj = Car("Maruti SX4", "2011", "Black") 22 | carObj.set_price(950000) # Set price 23 | # Add this to available cars 24 | availableCars.append(carObj) 25 | 26 | print('TEST SUCEEDED') 27 | 28 | if __name__ == '__main__': 29 | main() 30 | -------------------------------------------------------------------------------- /lib/_pydev_log.py: -------------------------------------------------------------------------------- 1 | import traceback 2 | import sys 3 | try: 4 | import StringIO 5 | except: 6 | import io as StringIO #Python 3.0 7 | 8 | 9 | class Log: 10 | 11 | def __init__(self): 12 | self._contents = [] 13 | 14 | def AddContent(self, *content): 15 | self._contents.append(' '.join(content)) 16 | 17 | def AddException(self): 18 | s = StringIO.StringIO() 19 | exc_info = sys.exc_info() 20 | traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file=s) 21 | self._contents.append(s.getvalue()) 22 | 23 | 24 | def GetContents(self): 25 | return '\n'.join(self._contents) 26 | 27 | def Clear(self): 28 | del self._contents[:] -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/attach_script.py: -------------------------------------------------------------------------------- 1 | def attach(port, host): 2 | try: 3 | import pydevd 4 | pydevd.stoptrace() #I.e.: disconnect if already connected 5 | # pydevd.DebugInfoHolder.DEBUG_RECORD_SOCKET_READS = True 6 | # pydevd.DebugInfoHolder.DEBUG_TRACE_BREAKPOINTS = 3 7 | # pydevd.DebugInfoHolder.DEBUG_TRACE_LEVEL = 3 8 | pydevd.settrace( 9 | port=port, 10 | host=host, 11 | stdoutToServer=True, 12 | stderrToServer=True, 13 | overwrite_prev_trace=True, 14 | suspend=False, 15 | trace_only_current_thread=False, 16 | patch_multiprocessing=False, 17 | ) 18 | except: 19 | import traceback;traceback.print_exc() -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py: -------------------------------------------------------------------------------- 1 | """Fix bound method attributes (method.im_? -> method.__?__). 2 | """ 3 | # Author: Christian Heimes 4 | 5 | # Local imports 6 | from .. import fixer_base 7 | from ..fixer_util import Name 8 | 9 | MAP = { 10 | "im_func" : "__func__", 11 | "im_self" : "__self__", 12 | "im_class" : "__self__.__class__" 13 | } 14 | 15 | class FixMethodattrs(fixer_base.BaseFix): 16 | BM_compatible = True 17 | PATTERN = """ 18 | power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* > 19 | """ 20 | 21 | def transform(self, node, results): 22 | attr = results["attr"][0] 23 | new = unicode(MAP[attr.value]) 24 | attr.replace(Name(new, prefix=attr.prefix)) 25 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_funcattrs.py: -------------------------------------------------------------------------------- 1 | """Fix function attribute names (f.func_x -> f.__x__).""" 2 | # Author: Collin Winter 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Name 7 | 8 | 9 | class FixFuncattrs(fixer_base.BaseFix): 10 | BM_compatible = True 11 | 12 | PATTERN = """ 13 | power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals' 14 | | 'func_name' | 'func_defaults' | 'func_code' 15 | | 'func_dict') > any* > 16 | """ 17 | 18 | def transform(self, node, results): 19 | attr = results["attr"][0] 20 | attr.replace(Name((u"__%s__" % attr.value[5:]), 21 | prefix=attr.prefix)) 22 | -------------------------------------------------------------------------------- /lib/pydev_app_engine_debug_startup.py: -------------------------------------------------------------------------------- 1 | if False: 2 | config = None 3 | 4 | 5 | # See: https://docs.google.com/document/d/1CCSaRiIWCLgbD3OwmuKsRoHHDfBffbROWyVWWL0ZXN4/edit 6 | if ':' not in config.version_id: 7 | # The default server version_id does not contain ':' 8 | import json 9 | import os 10 | import sys 11 | 12 | startup = config.python_config.startup_args 13 | if not startup: 14 | raise AssertionError('Expected --python_startup_args to be passed from the pydev debugger.') 15 | 16 | setup = json.loads(startup) 17 | pydevd_path = setup['pydevd'] 18 | sys.path.append(os.path.dirname(pydevd_path)) 19 | 20 | import pydevd 21 | pydevd.settrace(setup['client'], port=setup['port'], suspend=False, trace_only_current_thread=False) 22 | -------------------------------------------------------------------------------- /lib/pydev_ipython/qt.py: -------------------------------------------------------------------------------- 1 | """ A Qt API selector that can be used to switch between PyQt and PySide. 2 | 3 | This uses the ETS 4.0 selection pattern of: 4 | PySide first, PyQt with API v2. second. 5 | 6 | Do not use this if you need PyQt with the old QString/QVariant API. 7 | """ 8 | 9 | import os 10 | 11 | from pydev_ipython.qt_loaders import (load_qt, QT_API_PYSIDE, 12 | QT_API_PYQT) 13 | 14 | QT_API = os.environ.get('QT_API', None) 15 | if QT_API not in [QT_API_PYSIDE, QT_API_PYQT, None]: 16 | raise RuntimeError("Invalid Qt API %r, valid values are: %r, %r" % 17 | (QT_API, QT_API_PYSIDE, QT_API_PYQT)) 18 | if QT_API is None: 19 | api_opts = [QT_API_PYSIDE, QT_API_PYQT] 20 | else: 21 | api_opts = [QT_API] 22 | 23 | QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts) 24 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_xreadlines.py: -------------------------------------------------------------------------------- 1 | """Fix "for x in f.xreadlines()" -> "for x in f". 2 | 3 | This fixer will also convert g(f.xreadlines) into g(f.__iter__).""" 4 | # Author: Collin Winter 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name 9 | 10 | 11 | class FixXreadlines(fixer_base.BaseFix): 12 | BM_compatible = True 13 | PATTERN = """ 14 | power< call=any+ trailer< '.' 'xreadlines' > trailer< '(' ')' > > 15 | | 16 | power< any+ trailer< '.' no_call='xreadlines' > > 17 | """ 18 | 19 | def transform(self, node, results): 20 | no_call = results.get("no_call") 21 | 22 | if no_call: 23 | no_call.replace(Name(u"__iter__", prefix=no_call.prefix)) 24 | else: 25 | node.replace([x.clone() for x in results["call"]]) 26 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/_always_live_program.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import struct 3 | print('Executable: %s' % sys.executable) 4 | import os 5 | def loop_in_thread(): 6 | while True: 7 | import time 8 | time.sleep(.5) 9 | sys.stdout.write('#') 10 | sys.stdout.flush() 11 | 12 | import threading 13 | threading.Thread(target=loop_in_thread).start() 14 | 15 | 16 | def is_python_64bit(): 17 | return (struct.calcsize('P') == 8) 18 | 19 | print('Is 64: %s' % is_python_64bit()) 20 | 21 | if __name__ == '__main__': 22 | print('pid:%s' % (os.getpid())) 23 | i = 0 24 | while True: 25 | i += 1 26 | import time 27 | time.sleep(.5) 28 | sys.stdout.write('.') 29 | sys.stdout.flush() 30 | if i % 40 == 0: 31 | sys.stdout.write('\n') 32 | sys.stdout.flush() 33 | -------------------------------------------------------------------------------- /lib/pydev_ipython/inputhooktk.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # Unlike what IPython does, we need to have an explicit inputhook because tkinter handles 3 | # input hook in the C Source code 4 | 5 | #----------------------------------------------------------------------------- 6 | # Imports 7 | #----------------------------------------------------------------------------- 8 | 9 | from pydev_ipython.inputhook import stdin_ready 10 | 11 | #----------------------------------------------------------------------------- 12 | # Code 13 | #----------------------------------------------------------------------------- 14 | 15 | TCL_DONT_WAIT = 1 << 1 16 | 17 | def create_inputhook_tk(app): 18 | def inputhook_tk(): 19 | while app.dooneevent(TCL_DONT_WAIT) == 1: 20 | if stdin_ready(): 21 | break 22 | return 0 23 | return inputhook_tk 24 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_input.py: -------------------------------------------------------------------------------- 1 | """Fixer that changes input(...) into eval(input(...)).""" 2 | # Author: Andre Roberge 3 | 4 | # Local imports 5 | from .. import fixer_base 6 | from ..fixer_util import Call, Name 7 | from .. import patcomp 8 | 9 | 10 | context = patcomp.compile_pattern("power< 'eval' trailer< '(' any ')' > >") 11 | 12 | 13 | class FixInput(fixer_base.BaseFix): 14 | BM_compatible = True 15 | PATTERN = """ 16 | power< 'input' args=trailer< '(' [any] ')' > > 17 | """ 18 | 19 | def transform(self, node, results): 20 | # If we're already wrapped in a eval() call, we're done. 21 | if context.match(node.parent.parent): 22 | return 23 | 24 | new = node.clone() 25 | new.prefix = u"" 26 | return Call(Name(u"eval"), [new], prefix=node.prefix) 27 | -------------------------------------------------------------------------------- /lib/pydev_log.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from pydevd_constants import DebugInfoHolder 3 | from pydevd_constants import DictContains 4 | 5 | import traceback 6 | 7 | WARN_ONCE_MAP = {} 8 | 9 | def stderr_write(message): 10 | sys.stderr.write(message) 11 | sys.stderr.write("\n") 12 | 13 | 14 | def debug(message): 15 | if DebugInfoHolder.DEBUG_TRACE_LEVEL>2: 16 | stderr_write(message) 17 | 18 | 19 | def warn(message): 20 | if DebugInfoHolder.DEBUG_TRACE_LEVEL>1: 21 | stderr_write(message) 22 | 23 | 24 | def info(message): 25 | stderr_write(message) 26 | 27 | 28 | def error(message, tb=False): 29 | stderr_write(message) 30 | if tb: 31 | traceback.print_exc() 32 | 33 | 34 | def error_once(message): 35 | if not DictContains(WARN_ONCE_MAP, message): 36 | WARN_ONCE_MAP[message] = True 37 | error(message) 38 | 39 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case_qthread3.py: -------------------------------------------------------------------------------- 1 | import time 2 | import sys 3 | 4 | try: 5 | from PySide import QtCore 6 | except: 7 | from PyQt4 import QtCore 8 | 9 | # Using a QRunnable 10 | # http://doc.qt.nokia.com/latest/qthreadpool.html 11 | # Note that a QRunnable isn't a subclass of QObject and therefore does 12 | # not provide signals and slots. 13 | class Runnable(QtCore.QRunnable): 14 | 15 | def run(self): 16 | count = 0 17 | app = QtCore.QCoreApplication.instance() 18 | while count < 5: 19 | print "Increasing" 20 | time.sleep(.5) 21 | count += 1 22 | app.quit() 23 | 24 | 25 | app = QtCore.QCoreApplication([]) 26 | runnable = Runnable() 27 | QtCore.QThreadPool.globalInstance().start(runnable) 28 | app.exec_() 29 | QtCore.QThreadPool.globalInstance().waitForDone() 30 | print('TEST SUCEEDED!') -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case_qthread2.py: -------------------------------------------------------------------------------- 1 | import time 2 | import sys 3 | 4 | try: 5 | from PySide import QtCore 6 | except: 7 | from PyQt4 import QtCore 8 | 9 | # Subclassing QObject and using moveToThread 10 | # http://labs.qt.nokia.com/2007/07/05/qthreads-no-longer-abstract/ 11 | class SomeObject(QtCore.QObject): 12 | 13 | finished = QtCore.Signal() 14 | 15 | def longRunning(self): 16 | count = 0 17 | while count < 5: 18 | time.sleep(.5) 19 | print "Increasing" 20 | count += 1 21 | self.finished.emit() 22 | 23 | app = QtCore.QCoreApplication([]) 24 | objThread = QtCore.QThread() 25 | obj = SomeObject() 26 | obj.moveToThread(objThread) 27 | obj.finished.connect(objThread.quit) 28 | objThread.started.connect(obj.longRunning) 29 | objThread.finished.connect(app.exit) 30 | objThread.start() 31 | app.exec_() 32 | print('TEST SUCEEDED!') -------------------------------------------------------------------------------- /lib/tests_mainloop/gui-tk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Simple Tk example to manually test event loop integration. 3 | 4 | To run this: 5 | 1) Enable the PyDev GUI event loop integration for tk 6 | 2) do an execfile on this script 7 | 3) ensure you have a working GUI simultaneously with an 8 | interactive console 9 | """ 10 | 11 | if __name__ == '__main__': 12 | 13 | try: 14 | from Tkinter import * 15 | except: 16 | # Python 3 17 | from tkinter import * 18 | 19 | class MyApp: 20 | 21 | def __init__(self, root): 22 | frame = Frame(root) 23 | frame.pack() 24 | 25 | self.button = Button(frame, text="Hello", command=self.hello_world) 26 | self.button.pack(side=LEFT) 27 | 28 | def hello_world(self): 29 | print("Hello World!") 30 | 31 | root = Tk() 32 | 33 | app = MyApp(root) 34 | -------------------------------------------------------------------------------- /lib/tests_mainloop/gui-pyglet.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Simple pyglet example to manually test event loop integration. 3 | 4 | To run this: 5 | 1) Enable the PyDev GUI event loop integration for pyglet 6 | 2) do an execfile on this script 7 | 3) ensure you have a working GUI simultaneously with an 8 | interactive console 9 | """ 10 | 11 | if __name__ == '__main__': 12 | import pyglet 13 | 14 | 15 | window = pyglet.window.Window() 16 | label = pyglet.text.Label('Hello, world', 17 | font_name='Times New Roman', 18 | font_size=36, 19 | x=window.width//2, y=window.height//2, 20 | anchor_x='center', anchor_y='center') 21 | @window.event 22 | def on_close(): 23 | window.close() 24 | 25 | @window.event 26 | def on_draw(): 27 | window.clear() 28 | label.draw() 29 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_numliterals.py: -------------------------------------------------------------------------------- 1 | """Fixer that turns 1L into 1, 0755 into 0o755. 2 | """ 3 | # Copyright 2007 Georg Brandl. 4 | # Licensed to PSF under a Contributor Agreement. 5 | 6 | # Local imports 7 | from ..pgen2 import token 8 | from .. import fixer_base 9 | from ..fixer_util import Number 10 | 11 | 12 | class FixNumliterals(fixer_base.BaseFix): 13 | # This is so simple that we don't need the pattern compiler. 14 | 15 | _accept_type = token.NUMBER 16 | 17 | def match(self, node): 18 | # Override 19 | return (node.value.startswith(u"0") or node.value[-1] in u"Ll") 20 | 21 | def transform(self, node, results): 22 | val = node.value 23 | if val[-1] in u'Ll': 24 | val = val[:-1] 25 | elif val.startswith(u'0') and val.isdigit() and len(set(val)) > 1: 26 | val = u"0o" + val[1:] 27 | 28 | return Number(val, prefix=node.prefix) 29 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/PatternGrammar.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | # A grammar to describe tree matching patterns. 5 | # Not shown here: 6 | # - 'TOKEN' stands for any token (leaf node) 7 | # - 'any' stands for any node (leaf or interior) 8 | # With 'any' we can still specify the sub-structure. 9 | 10 | # The start symbol is 'Matcher'. 11 | 12 | Matcher: Alternatives ENDMARKER 13 | 14 | Alternatives: Alternative ('|' Alternative)* 15 | 16 | Alternative: (Unit | NegatedUnit)+ 17 | 18 | Unit: [NAME '='] ( STRING [Repeater] 19 | | NAME [Details] [Repeater] 20 | | '(' Alternatives ')' [Repeater] 21 | | '[' Alternatives ']' 22 | ) 23 | 24 | NegatedUnit: 'not' (STRING | NAME [Details] | '(' Alternatives ')') 25 | 26 | Repeater: '*' | '+' | '{' NUMBER [',' NUMBER] '}' 27 | 28 | Details: '<' Alternatives '>' 29 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case13.py: -------------------------------------------------------------------------------- 1 | 2 | class TestProperty(object): 3 | def __init__(self, name = "Default"): 4 | self._x = None 5 | self.name = name 6 | 7 | def get_name(self): 8 | return self.__name 9 | 10 | 11 | def set_name(self, value): 12 | self.__name = value 13 | 14 | 15 | def del_name(self): 16 | del self.__name 17 | name = property(get_name, set_name, del_name, "name's docstring") 18 | 19 | @property 20 | def x(self): 21 | return self._x 22 | 23 | @x.setter 24 | def x(self, value): 25 | self._x = value 26 | 27 | @x.deleter 28 | def x(self): 29 | del self._x 30 | 31 | def main(): 32 | """ 33 | """ 34 | testObj = TestProperty() 35 | testObj.x = 10 36 | val = testObj.x 37 | 38 | testObj.name = "Pydev" 39 | debugType = testObj.name 40 | print('TEST SUCEEDED!') 41 | 42 | if __name__ == '__main__': 43 | main() -------------------------------------------------------------------------------- /lib/tests_mainloop/gui-gtk3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Simple Gtk example to manually test event loop integration. 3 | 4 | To run this: 5 | 1) Enable the PyDev GUI event loop integration for gtk3 6 | 2) do an execfile on this script 7 | 3) ensure you have a working GUI simultaneously with an 8 | interactive console 9 | """ 10 | 11 | if __name__ == '__main__': 12 | from gi.repository import Gtk 13 | 14 | 15 | def hello_world(wigdet, data=None): 16 | print("Hello World") 17 | 18 | def delete_event(widget, event, data=None): 19 | return False 20 | 21 | def destroy(widget, data=None): 22 | Gtk.main_quit() 23 | 24 | window = Gtk.Window(Gtk.WindowType.TOPLEVEL) 25 | window.connect("delete_event", delete_event) 26 | window.connect("destroy", destroy) 27 | button = Gtk.Button("Hello World") 28 | button.connect("clicked", hello_world, None) 29 | 30 | window.add(button) 31 | button.show() 32 | window.show() 33 | 34 | -------------------------------------------------------------------------------- /lib/tests_mainloop/gui-gtk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Simple GTK example to manually test event loop integration. 3 | 4 | To run this: 5 | 1) Enable the PyDev GUI event loop integration for gtk 6 | 2) do an execfile on this script 7 | 3) ensure you have a working GUI simultaneously with an 8 | interactive console 9 | """ 10 | 11 | if __name__ == '__main__': 12 | import pygtk 13 | pygtk.require('2.0') 14 | import gtk 15 | 16 | 17 | def hello_world(wigdet, data=None): 18 | print("Hello World") 19 | 20 | def delete_event(widget, event, data=None): 21 | return False 22 | 23 | def destroy(widget, data=None): 24 | gtk.main_quit() 25 | 26 | window = gtk.Window(gtk.WINDOW_TOPLEVEL) 27 | window.connect("delete_event", delete_event) 28 | window.connect("destroy", destroy) 29 | button = gtk.Button("Hello World") 30 | button.connect("clicked", hello_world, None) 31 | 32 | window.add(button) 33 | button.show() 34 | window.show() 35 | 36 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_reduce.py: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Armin Ronacher. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for reduce(). 5 | 6 | Makes sure reduce() is imported from the functools module if reduce is 7 | used in that module. 8 | """ 9 | 10 | from lib2to3 import fixer_base 11 | from lib2to3.fixer_util import touch_import 12 | 13 | 14 | 15 | class FixReduce(fixer_base.BaseFix): 16 | 17 | BM_compatible = True 18 | order = "pre" 19 | 20 | PATTERN = """ 21 | power< 'reduce' 22 | trailer< '(' 23 | arglist< ( 24 | (not(argument) any ',' 27 | not(argument 31 | > 32 | """ 33 | 34 | def transform(self, node, results): 35 | touch_import(u'functools', u'reduce', node) 36 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_zip.py: -------------------------------------------------------------------------------- 1 | """ 2 | Fixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...) 3 | unless there exists a 'from future_builtins import zip' statement in the 4 | top-level namespace. 5 | 6 | We avoid the transformation if the zip() call is directly contained in 7 | iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:. 8 | """ 9 | 10 | # Local imports 11 | from .. import fixer_base 12 | from ..fixer_util import Name, Call, in_special_context 13 | 14 | class FixZip(fixer_base.ConditionalFix): 15 | 16 | BM_compatible = True 17 | PATTERN = """ 18 | power< 'zip' args=trailer< '(' [any] ')' > 19 | > 20 | """ 21 | 22 | skip_on = "future_builtins.zip" 23 | 24 | def transform(self, node, results): 25 | if self.should_skip(node): 26 | return 27 | 28 | if in_special_context(node): 29 | return None 30 | 31 | new = node.clone() 32 | new.prefix = u"" 33 | new = Call(Name(u"list"), [new]) 34 | new.prefix = node.prefix 35 | return new 36 | -------------------------------------------------------------------------------- /lib/tests_runfiles/samples/simple_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | class SampleTest(unittest.TestCase): 4 | 5 | def setUp(self): 6 | pass 7 | 8 | def tearDown(self): 9 | pass 10 | 11 | def test_xxxxxx1(self): 12 | self.fail('Fail test 2') 13 | def test_xxxxxx2(self): 14 | pass 15 | def test_xxxxxx3(self): 16 | pass 17 | def test_xxxxxx4(self): 18 | pass 19 | def test_non_unique_name(self): 20 | print('non unique name ran') 21 | 22 | 23 | class AnotherSampleTest(unittest.TestCase): 24 | def setUp(self): 25 | pass 26 | 27 | def tearDown(self): 28 | pass 29 | 30 | def test_1(self): 31 | pass 32 | def test_2(self): 33 | """ im a doc string""" 34 | pass 35 | def todo_not_tested(self): 36 | ''' 37 | Not there by default! 38 | ''' 39 | 40 | 41 | if __name__ == '__main__': 42 | # suite = unittest.makeSuite(SampleTest, 'test') 43 | # runner = unittest.TextTestRunner( verbosity=3 ) 44 | # runner.run(suite) 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/dll/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* **************************************************************************** 2 | * 3 | * Copyright (c) Microsoft Corporation. 4 | * 5 | * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 6 | * copy of the license can be found in the License.html file at the root of this distribution. If 7 | * you cannot locate the Apache License, Version 2.0, please send an email to 8 | * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 9 | * by the terms of the Apache License, Version 2.0. 10 | * 11 | * You must not remove this notice, or any other, from this software. 12 | * 13 | * ***************************************************************************/ 14 | 15 | // stdafx.cpp : source file that includes just the standard includes 16 | // PyDebugAttach.pch will be the pre-compiled header 17 | // stdafx.obj will contain the pre-compiled type information 18 | 19 | #include "stdafx.h" 20 | 21 | // TODO: reference any additional headers you need in STDAFX.H 22 | // and not in this file 23 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/dll/targetver.h: -------------------------------------------------------------------------------- 1 | /* **************************************************************************** 2 | * 3 | * Copyright (c) Microsoft Corporation. 4 | * 5 | * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 6 | * copy of the license can be found in the License.html file at the root of this distribution. If 7 | * you cannot locate the Apache License, Version 2.0, please send an email to 8 | * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 9 | * by the terms of the Apache License, Version 2.0. 10 | * 11 | * You must not remove this notice, or any other, from this software. 12 | * 13 | * ***************************************************************************/ 14 | 15 | #pragma once 16 | 17 | // Including SDKDDKVer.h defines the highest available Windows platform. 18 | 19 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 20 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 21 | 22 | #include 23 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_sys_exc.py: -------------------------------------------------------------------------------- 1 | """Fixer for sys.exc_{type, value, traceback} 2 | 3 | sys.exc_type -> sys.exc_info()[0] 4 | sys.exc_value -> sys.exc_info()[1] 5 | sys.exc_traceback -> sys.exc_info()[2] 6 | """ 7 | 8 | # By Jeff Balogh and Benjamin Peterson 9 | 10 | # Local imports 11 | from .. import fixer_base 12 | from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms 13 | 14 | class FixSysExc(fixer_base.BaseFix): 15 | # This order matches the ordering of sys.exc_info(). 16 | exc_info = [u"exc_type", u"exc_value", u"exc_traceback"] 17 | BM_compatible = True 18 | PATTERN = """ 19 | power< 'sys' trailer< dot='.' attribute=(%s) > > 20 | """ % '|'.join("'%s'" % e for e in exc_info) 21 | 22 | def transform(self, node, results): 23 | sys_attr = results["attribute"][0] 24 | index = Number(self.exc_info.index(sys_attr.value)) 25 | 26 | call = Call(Name(u"exc_info"), prefix=sys_attr.prefix) 27 | attr = Attr(Name(u"sys"), call) 28 | attr[1].children[0].prefix = results["dot"].prefix 29 | attr.append(Subscript(index)) 30 | return Node(syms.power, attr, prefix=node.prefix) 31 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_exec.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for exec. 5 | 6 | This converts usages of the exec statement into calls to a built-in 7 | exec() function. 8 | 9 | exec code in ns1, ns2 -> exec(code, ns1, ns2) 10 | """ 11 | 12 | # Local imports 13 | from .. import pytree 14 | from .. import fixer_base 15 | from ..fixer_util import Comma, Name, Call 16 | 17 | 18 | class FixExec(fixer_base.BaseFix): 19 | BM_compatible = True 20 | 21 | PATTERN = """ 22 | exec_stmt< 'exec' a=any 'in' b=any [',' c=any] > 23 | | 24 | exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any > 25 | """ 26 | 27 | def transform(self, node, results): 28 | assert results 29 | syms = self.syms 30 | a = results["a"] 31 | b = results.get("b") 32 | c = results.get("c") 33 | args = [a.clone()] 34 | args[0].prefix = "" 35 | if b is not None: 36 | args.extend([Comma(), b.clone()]) 37 | if c is not None: 38 | args.extend([Comma(), c.clone()]) 39 | 40 | return Call(Name(u"exec"), args, prefix=node.prefix) 41 | -------------------------------------------------------------------------------- /lib/pydevd_trace_api.py: -------------------------------------------------------------------------------- 1 | def add_line_breakpoint(plugin, pydb, type, file, line, condition, expression, func_name): 2 | return None 3 | 4 | def add_exception_breakpoint(plugin, pydb, type, exception): 5 | return False 6 | 7 | def remove_exception_breakpoint(plugin, pydb, type, exception): 8 | return False 9 | 10 | def get_breakpoints(plugin, pydb): 11 | return None 12 | 13 | def can_not_skip(plugin, pydb, pydb_frame, frame): 14 | return False 15 | 16 | def has_exception_breaks(plugin): 17 | return False 18 | 19 | def has_line_breaks(plugin): 20 | return False 21 | 22 | def cmd_step_into(plugin, pydb, frame, event, args, stop_info, stop): 23 | return False 24 | 25 | def cmd_step_over(plugin, pydb, frame, event, args, stop_info, stop): 26 | return False 27 | 28 | def stop(plugin, pydb, frame, event, args, stop_info, arg, step_cmd): 29 | return False 30 | 31 | def get_breakpoint(plugin, pydb, pydb_frame, frame, event, args): 32 | return None 33 | 34 | def suspend(plugin, pydb, thread, frame): 35 | return None 36 | 37 | def exception_break(plugin, pydb, pydb_frame, frame, args, arg): 38 | return None 39 | 40 | def change_variable(plugin, frame, attr, expression): 41 | return False 42 | -------------------------------------------------------------------------------- /lib/tests_mainloop/gui-qt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Simple Qt4 example to manually test event loop integration. 3 | 4 | To run this: 5 | 1) Enable the PyDev GUI event loop integration for qt 6 | 2) do an execfile on this script 7 | 3) ensure you have a working GUI simultaneously with an 8 | interactive console 9 | 10 | Ref: Modified from http://zetcode.com/tutorials/pyqt4/firstprograms/ 11 | """ 12 | 13 | if __name__ == '__main__': 14 | import sys 15 | from PyQt4 import QtGui, QtCore 16 | 17 | class SimpleWindow(QtGui.QWidget): 18 | def __init__(self, parent=None): 19 | QtGui.QWidget.__init__(self, parent) 20 | 21 | self.setGeometry(300, 300, 200, 80) 22 | self.setWindowTitle('Hello World') 23 | 24 | quit = QtGui.QPushButton('Close', self) 25 | quit.setGeometry(10, 10, 60, 35) 26 | 27 | self.connect(quit, QtCore.SIGNAL('clicked()'), 28 | self, QtCore.SLOT('close()')) 29 | 30 | if __name__ == '__main__': 31 | app = QtCore.QCoreApplication.instance() 32 | if app is None: 33 | app = QtGui.QApplication([]) 34 | 35 | sw = SimpleWindow() 36 | sw.show() 37 | -------------------------------------------------------------------------------- /lib/pydev_ipython/inputhookgtk.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | """ 3 | Enable pygtk to be used interacive by setting PyOS_InputHook. 4 | 5 | Authors: Brian Granger 6 | """ 7 | 8 | #----------------------------------------------------------------------------- 9 | # Copyright (C) 2008-2011 The IPython Development Team 10 | # 11 | # Distributed under the terms of the BSD License. The full license is in 12 | # the file COPYING, distributed as part of this software. 13 | #----------------------------------------------------------------------------- 14 | 15 | #----------------------------------------------------------------------------- 16 | # Imports 17 | #----------------------------------------------------------------------------- 18 | 19 | import gtk, gobject 20 | 21 | #----------------------------------------------------------------------------- 22 | # Code 23 | #----------------------------------------------------------------------------- 24 | 25 | 26 | def _main_quit(*args, **kwargs): 27 | gtk.main_quit() 28 | return False 29 | 30 | def create_inputhook_gtk(stdin_file): 31 | def inputhook_gtk(): 32 | gobject.io_add_watch(stdin_file, gobject.IO_IN, _main_quit) 33 | gtk.main() 34 | return 0 35 | return inputhook_gtk 36 | 37 | -------------------------------------------------------------------------------- /lib/pydev_ipython/inputhookgtk3.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | """ 3 | Enable Gtk3 to be used interacive by IPython. 4 | 5 | Authors: Thomi Richards 6 | """ 7 | #----------------------------------------------------------------------------- 8 | # Copyright (c) 2012, the IPython Development Team. 9 | # 10 | # Distributed under the terms of the Modified BSD License. 11 | # 12 | # The full license is in the file COPYING.txt, distributed with this software. 13 | #----------------------------------------------------------------------------- 14 | 15 | #----------------------------------------------------------------------------- 16 | # Imports 17 | #----------------------------------------------------------------------------- 18 | 19 | from gi.repository import Gtk, GLib # @UnresolvedImport 20 | 21 | #----------------------------------------------------------------------------- 22 | # Code 23 | #----------------------------------------------------------------------------- 24 | 25 | def _main_quit(*args, **kwargs): 26 | Gtk.main_quit() 27 | return False 28 | 29 | 30 | def create_inputhook_gtk3(stdin_file): 31 | def inputhook_gtk3(): 32 | GLib.io_add_watch(stdin_file, GLib.IO_IN, _main_quit) 33 | Gtk.main() 34 | return 0 35 | return inputhook_gtk3 36 | -------------------------------------------------------------------------------- /lib/_pydev_filesystem_encoding.py: -------------------------------------------------------------------------------- 1 | def __getfilesystemencoding(): 2 | ''' 3 | Note: there's a copy of this method in interpreterInfo.py 4 | ''' 5 | import sys 6 | try: 7 | ret = sys.getfilesystemencoding() 8 | if not ret: 9 | raise RuntimeError('Unable to get encoding.') 10 | return ret 11 | except: 12 | try: 13 | #Handle Jython 14 | from java.lang import System 15 | env = System.getProperty("os.name").lower() 16 | if env.find('win') != -1: 17 | return 'ISO-8859-1' #mbcs does not work on Jython, so, use a (hopefully) suitable replacement 18 | return 'utf-8' 19 | except: 20 | pass 21 | 22 | #Only available from 2.3 onwards. 23 | if sys.platform == 'win32': 24 | return 'mbcs' 25 | return 'utf-8' 26 | 27 | def getfilesystemencoding(): 28 | try: 29 | ret = __getfilesystemencoding() 30 | 31 | #Check if the encoding is actually there to be used! 32 | if hasattr('', 'encode'): 33 | ''.encode(ret) 34 | if hasattr('', 'decode'): 35 | ''.decode(ret) 36 | 37 | return ret 38 | except: 39 | return 'utf-8' 40 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_ws_comma.py: -------------------------------------------------------------------------------- 1 | """Fixer that changes 'a ,b' into 'a, b'. 2 | 3 | This also changes '{a :b}' into '{a: b}', but does not touch other 4 | uses of colons. It does not touch other uses of whitespace. 5 | 6 | """ 7 | 8 | from .. import pytree 9 | from ..pgen2 import token 10 | from .. import fixer_base 11 | 12 | class FixWsComma(fixer_base.BaseFix): 13 | 14 | explicit = True # The user must ask for this fixers 15 | 16 | PATTERN = """ 17 | any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]> 18 | """ 19 | 20 | COMMA = pytree.Leaf(token.COMMA, u",") 21 | COLON = pytree.Leaf(token.COLON, u":") 22 | SEPS = (COMMA, COLON) 23 | 24 | def transform(self, node, results): 25 | new = node.clone() 26 | comma = False 27 | for child in new.children: 28 | if child in self.SEPS: 29 | prefix = child.prefix 30 | if prefix.isspace() and u"\n" not in prefix: 31 | child.prefix = u"" 32 | comma = True 33 | else: 34 | if comma: 35 | prefix = child.prefix 36 | if not prefix: 37 | child.prefix = u" " 38 | comma = False 39 | return new 40 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/pygram.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Export the Python grammar and symbols.""" 5 | 6 | # Python imports 7 | import os 8 | 9 | # Local imports 10 | from .pgen2 import token 11 | from .pgen2 import driver 12 | from . import pytree 13 | 14 | # The grammar file 15 | _GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt") 16 | _PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), 17 | "PatternGrammar.txt") 18 | 19 | 20 | class Symbols(object): 21 | 22 | def __init__(self, grammar): 23 | """Initializer. 24 | 25 | Creates an attribute for each grammar symbol (nonterminal), 26 | whose value is the symbol's type (an int >= 256). 27 | """ 28 | for name, symbol in grammar.symbol2number.iteritems(): 29 | setattr(self, name, symbol) 30 | 31 | 32 | python_grammar = driver.load_grammar(_GRAMMAR_FILE) 33 | 34 | python_symbols = Symbols(python_grammar) 35 | 36 | python_grammar_no_print_statement = python_grammar.copy() 37 | del python_grammar_no_print_statement.keywords["print"] 38 | 39 | pattern_grammar = driver.load_grammar(_PATTERN_GRAMMAR_FILE) 40 | pattern_symbols = Symbols(pattern_grammar) 41 | -------------------------------------------------------------------------------- /lib/pydev_import_hook.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from pydevd_constants import DictContains 4 | from types import ModuleType 5 | 6 | 7 | class ImportHookManager(ModuleType): 8 | def __init__(self, name, system_import): 9 | ModuleType.__init__(self, name) 10 | self._system_import = system_import 11 | self._modules_to_patch = {} 12 | 13 | def add_module_name(self, module_name, activate_function): 14 | self._modules_to_patch[module_name] = activate_function 15 | 16 | def do_import(self, name, *args, **kwargs): 17 | activate_func = None 18 | if DictContains(self._modules_to_patch, name): 19 | activate_func = self._modules_to_patch.pop(name) 20 | 21 | module = self._system_import(name, *args, **kwargs) 22 | try: 23 | if activate_func: 24 | activate_func() #call activate function 25 | except: 26 | sys.stderr.write("Matplotlib support failed\n") 27 | return module 28 | 29 | try: 30 | import __builtin__ as builtins 31 | except ImportError: 32 | import builtins 33 | 34 | import_hook_manager = ImportHookManager(__name__ + '.import_hook', builtins.__import__) 35 | builtins.__import__ = import_hook_manager.do_import 36 | sys.modules[import_hook_manager.__name__] = import_hook_manager 37 | del builtins -------------------------------------------------------------------------------- /addon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Kodi support for PyDev remote debugging in Eclipse/Aptana. 8 | See here for details: http://pydev.org/manual_adv_remote_debugger.html 9 | all 10 | 11 | Eclipse Public License 12 | http://forum.kodi.tv/showthread.php?tid=170715 13 | http://pydev.org/ 14 | https://github.com/powlo/script.module.pydevd 15 | 16 | Use at your own risk. The authors accept no liability. May cause permanent and/or catastrophic damage. Side effects include, but are not limited to, loss of memory, seizures, sudden fits of rage, sudden fits of melancholy, inability to recall prominent capital cities, lack of respect for authority, fear of cats, temporary and/or permanent black outs. Avoid inhalation. Use in a well ventilated space. Keep away from small children. 17 | 18 | 19 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/dll/stdafx.h: -------------------------------------------------------------------------------- 1 | /* **************************************************************************** 2 | * 3 | * Copyright (c) Microsoft Corporation. 4 | * 5 | * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 6 | * copy of the license can be found in the License.html file at the root of this distribution. If 7 | * you cannot locate the Apache License, Version 2.0, please send an email to 8 | * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 9 | * by the terms of the Apache License, Version 2.0. 10 | * 11 | * You must not remove this notice, or any other, from this software. 12 | * 13 | * ***************************************************************************/ 14 | 15 | // stdafx.h : include file for standard system include files, 16 | // or project specific include files that are used frequently, but 17 | // are changed infrequently 18 | // 19 | 20 | #pragma once 21 | 22 | #include "targetver.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define WIN32_LEAN_AND_MEAN 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | -------------------------------------------------------------------------------- /lib/pydev_localhost.py: -------------------------------------------------------------------------------- 1 | import pydevd_constants 2 | from _pydev_imps import _pydev_socket as socket 3 | 4 | _cache = None 5 | def get_localhost(): 6 | ''' 7 | Should return 127.0.0.1 in ipv4 and ::1 in ipv6 8 | 9 | localhost is not used because on windows vista/windows 7, there can be issues where the resolving doesn't work 10 | properly and takes a lot of time (had this issue on the pyunit server). 11 | 12 | Using the IP directly solves the problem. 13 | ''' 14 | #TODO: Needs better investigation! 15 | 16 | global _cache 17 | if _cache is None: 18 | try: 19 | for addr_info in socket.getaddrinfo("localhost", 80, 0, 0, socket.SOL_TCP): 20 | config = addr_info[4] 21 | if config[0] == '127.0.0.1': 22 | _cache = '127.0.0.1' 23 | return _cache 24 | except: 25 | #Ok, some versions of Python don't have getaddrinfo or SOL_TCP... Just consider it 127.0.0.1 in this case. 26 | _cache = '127.0.0.1' 27 | else: 28 | _cache = 'localhost' 29 | 30 | return _cache 31 | 32 | 33 | def get_socket_name(): 34 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 35 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 36 | sock.bind(('', 0)) 37 | return sock.getsockname() 38 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_callable.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for callable(). 5 | 6 | This converts callable(obj) into isinstance(obj, collections.Callable), adding a 7 | collections import if needed.""" 8 | 9 | # Local imports 10 | from lib2to3 import fixer_base 11 | from lib2to3.fixer_util import Call, Name, String, Attr, touch_import 12 | 13 | class FixCallable(fixer_base.BaseFix): 14 | BM_compatible = True 15 | 16 | order = "pre" 17 | 18 | # Ignore callable(*args) or use of keywords. 19 | # Either could be a hint that the builtin callable() is not being used. 20 | PATTERN = """ 21 | power< 'callable' 22 | trailer< lpar='(' 23 | ( not(arglist | argument) any ','> ) 25 | rpar=')' > 26 | after=any* 27 | > 28 | """ 29 | 30 | def transform(self, node, results): 31 | func = results['func'] 32 | 33 | touch_import(None, u'collections', node=node) 34 | 35 | args = [func.clone(), String(u', ')] 36 | args.extend(Attr(Name(u'collections'), Name(u'Callable'))) 37 | return Call(Name(u'isinstance'), args, prefix=node.prefix) 38 | -------------------------------------------------------------------------------- /lib/pydev_ipython/version.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | """ 3 | Utilities for version comparison 4 | 5 | It is a bit ridiculous that we need these. 6 | """ 7 | 8 | #----------------------------------------------------------------------------- 9 | # Copyright (C) 2013 The IPython Development Team 10 | # 11 | # Distributed under the terms of the BSD License. The full license is in 12 | # the file COPYING, distributed as part of this software. 13 | #----------------------------------------------------------------------------- 14 | 15 | #----------------------------------------------------------------------------- 16 | # Imports 17 | #----------------------------------------------------------------------------- 18 | 19 | from distutils.version import LooseVersion 20 | 21 | #----------------------------------------------------------------------------- 22 | # Code 23 | #----------------------------------------------------------------------------- 24 | 25 | def check_version(v, check): 26 | """check version string v >= check 27 | 28 | If dev/prerelease tags result in TypeError for string-number comparison, 29 | it is assumed that the dependency is satisfied. 30 | Users on dev branches are responsible for keeping their own packages up to date. 31 | """ 32 | try: 33 | return LooseVersion(v) >= LooseVersion(check) 34 | except TypeError: 35 | return True 36 | 37 | -------------------------------------------------------------------------------- /lib/_pydev_execfile.py: -------------------------------------------------------------------------------- 1 | #We must redefine it in Py3k if it's not already there 2 | def execfile(file, glob=None, loc=None): 3 | if glob is None: 4 | import sys 5 | glob = sys._getframe().f_back.f_globals 6 | if loc is None: 7 | loc = glob 8 | stream = open(file, 'rb') 9 | try: 10 | encoding = None 11 | #Get encoding! 12 | for _i in range(2): 13 | line = stream.readline() #Should not raise an exception even if there are no more contents 14 | #Must be a comment line 15 | if line.strip().startswith(b'#'): 16 | #Don't import re if there's no chance that there's an encoding in the line 17 | if b'coding' in line: 18 | import re 19 | p = re.search(br"coding[:=]\s*([-\w.]+)", line) 20 | if p: 21 | try: 22 | encoding = p.group(1).decode('ascii') 23 | break 24 | except: 25 | encoding = None 26 | finally: 27 | stream.close() 28 | 29 | if encoding: 30 | stream = open(file, encoding=encoding) 31 | else: 32 | stream = open(file) 33 | try: 34 | contents = stream.read() 35 | finally: 36 | stream.close() 37 | 38 | exec(compile(contents+"\n", file, 'exec'), glob, loc) #execute the script -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_paren.py: -------------------------------------------------------------------------------- 1 | """Fixer that addes parentheses where they are required 2 | 3 | This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.""" 4 | 5 | # By Taek Joo Kim and Benjamin Peterson 6 | 7 | # Local imports 8 | from .. import fixer_base 9 | from ..fixer_util import LParen, RParen 10 | 11 | # XXX This doesn't support nested for loops like [x for x in 1, 2 for x in 1, 2] 12 | class FixParen(fixer_base.BaseFix): 13 | BM_compatible = True 14 | 15 | PATTERN = """ 16 | atom< ('[' | '(') 17 | (listmaker< any 18 | comp_for< 19 | 'for' NAME 'in' 20 | target=testlist_safe< any (',' any)+ [','] 21 | > 22 | [any] 23 | > 24 | > 25 | | 26 | testlist_gexp< any 27 | comp_for< 28 | 'for' NAME 'in' 29 | target=testlist_safe< any (',' any)+ [','] 30 | > 31 | [any] 32 | > 33 | >) 34 | (']' | ')') > 35 | """ 36 | 37 | def transform(self, node, results): 38 | target = results["target"] 39 | 40 | lparen = LParen() 41 | lparen.prefix = target.prefix 42 | target.prefix = u"" # Make it hug the parentheses 43 | target.insert_child(0, lparen) 44 | target.append_child(RParen()) 45 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_unicode.py: -------------------------------------------------------------------------------- 1 | r"""Fixer for unicode. 2 | 3 | * Changes unicode to str and unichr to chr. 4 | 5 | * If "...\u..." is not unicode literal change it into "...\\u...". 6 | 7 | * Change u"..." into "...". 8 | 9 | """ 10 | 11 | from ..pgen2 import token 12 | from .. import fixer_base 13 | 14 | _mapping = {u"unichr" : u"chr", u"unicode" : u"str"} 15 | 16 | class FixUnicode(fixer_base.BaseFix): 17 | BM_compatible = True 18 | PATTERN = "STRING | 'unicode' | 'unichr'" 19 | 20 | def start_tree(self, tree, filename): 21 | super(FixUnicode, self).start_tree(tree, filename) 22 | self.unicode_literals = 'unicode_literals' in tree.future_features 23 | 24 | def transform(self, node, results): 25 | if node.type == token.NAME: 26 | new = node.clone() 27 | new.value = _mapping[node.value] 28 | return new 29 | elif node.type == token.STRING: 30 | val = node.value 31 | if not self.unicode_literals and val[0] in u'\'"' and u'\\' in val: 32 | val = ur'\\'.join([ 33 | v.replace(u'\\u', ur'\\u').replace(u'\\U', ur'\\U') 34 | for v in val.split(ur'\\') 35 | ]) 36 | if val[0] in u'uU': 37 | val = val[1:] 38 | if val == node.value: 39 | return node 40 | new = node.clone() 41 | new.value = val 42 | return new 43 | -------------------------------------------------------------------------------- /lib/pycompletion.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | ''' 3 | @author Radim Kubacki 4 | ''' 5 | import _pydev_imports_tipper 6 | import traceback 7 | import StringIO 8 | import sys 9 | import urllib 10 | import pycompletionserver 11 | 12 | 13 | #======================================================================================================================= 14 | # GetImports 15 | #======================================================================================================================= 16 | def GetImports(module_name): 17 | try: 18 | processor = pycompletionserver.Processor() 19 | data = urllib.unquote_plus(module_name) 20 | def_file, completions = _pydev_imports_tipper.GenerateTip(data) 21 | return processor.formatCompletionMessage(def_file, completions) 22 | except: 23 | s = StringIO.StringIO() 24 | exc_info = sys.exc_info() 25 | 26 | traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file=s) 27 | err = s.getvalue() 28 | pycompletionserver.dbg('Received error: ' + str(err), pycompletionserver.ERROR) 29 | raise 30 | 31 | 32 | #======================================================================================================================= 33 | # main 34 | #======================================================================================================================= 35 | if __name__ == '__main__': 36 | mod_name = sys.argv[1] 37 | 38 | print(GetImports(mod_name)) 39 | 40 | -------------------------------------------------------------------------------- /lib/pydev_override.py: -------------------------------------------------------------------------------- 1 | def overrides(method): 2 | ''' 3 | Initially meant to be used as 4 | 5 | class B: 6 | @overrides(A.m1) 7 | def m1(self): 8 | pass 9 | 10 | but as we want to be compatible with Jython 2.1 where decorators have an uglier syntax (needing an assign 11 | after the method), it should now be used without being a decorator as below (in which case we don't even check 12 | for anything, just that the parent name was actually properly loaded). 13 | 14 | i.e.: 15 | 16 | class B: 17 | overrides(A.m1) 18 | def m1(self): 19 | pass 20 | ''' 21 | return 22 | 23 | # def wrapper(func): 24 | # if func.__name__ != method.__name__: 25 | # msg = "Wrong @override: %r expected, but overwriting %r." 26 | # msg = msg % (func.__name__, method.__name__) 27 | # raise AssertionError(msg) 28 | # 29 | # if func.__doc__ is None: 30 | # func.__doc__ = method.__doc__ 31 | # 32 | # return func 33 | # 34 | # return wrapper 35 | 36 | def implements(method): 37 | return 38 | # def wrapper(func): 39 | # if func.__name__ != method.__name__: 40 | # msg = "Wrong @implements: %r expected, but implementing %r." 41 | # msg = msg % (func.__name__, method.__name__) 42 | # raise AssertionError(msg) 43 | # 44 | # if func.__doc__ is None: 45 | # func.__doc__ = method.__doc__ 46 | # 47 | # return func 48 | # 49 | # return wrapper -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | script.module.pydevd 2 | ================== 3 | 4 | Kodi support for PyDev debugging in Eclipse/Aptana. 5 | 6 | How to use: 7 | ----------- 8 | 9 | * Add script.module.pydevd as a requirement to the module under test: 10 | 11 | ```xml 12 | 13 | 14 | 15 | 16 | 17 | 18 | ``` 19 | * Start the debug server in Eclipse. 20 | 21 | If the debug server is not running when you call settrace then you'll encounter: 22 | 23 | ```python 24 | Error Type: 25 | Error Contents: [Errno 111] Connection refused 26 | ``` 27 | 28 | * Then in the code under test: 29 | 30 | ```python 31 | import pydevd 32 | pydevd.settrace(stdoutToServer=True, stderrToServer=True) 33 | ``` 34 | * Use Eclipse debug perspective to move through code. 35 | 36 | See http://pydev.org/ for details. 37 | 38 | Known Issues: 39 | ------------- 40 | 41 | When attempting to exit or shutdown, Kodi will often freeze after a debug session 42 | has been initiated. 43 | 44 | Images in Kodi skins often fail to render during a debug session. If you want to 45 | verify that images are being rendered then do not run under a pydev debug session. 46 | 47 | Trademarks: 48 | ---------- 49 | 50 | "Python" is a registered trademark of the PSF. The Python logos (in several variants) are trademarks of the PSF as well. The logos are not registered, but registration does not equal ownership of trademarks. 51 | 52 | www.python.org/psf/trademarks/ 53 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/dll/attach.h: -------------------------------------------------------------------------------- 1 | /* **************************************************************************** 2 | * 3 | * Copyright (c) Brainwy software Ltda. 4 | * 5 | * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 6 | * copy of the license can be found in the License.html file at the root of this distribution. If 7 | * you cannot locate the Apache License, Version 2.0, please send an email to 8 | * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 9 | * by the terms of the Apache License, Version 2.0. 10 | * 11 | * You must not remove this notice, or any other, from this software. 12 | * 13 | * ***************************************************************************/ 14 | 15 | #ifndef _ATTACH_DLL_H_ 16 | #define _ATTACH_DLL_H_ 17 | 18 | #if defined DLL_EXPORT 19 | #define DECLDIR __declspec(dllexport) 20 | #else 21 | #define DECLDIR __declspec(dllimport) 22 | #endif 23 | 24 | extern "C" 25 | { 26 | DECLDIR int AttachAndRunPythonCode(const char *command, int *result ); 27 | 28 | 29 | /* 30 | Could be used with ctypes (note that the threading should be initialized, so, 31 | doing it in a thread as below is recommended): 32 | 33 | def check(): 34 | 35 | import ctypes 36 | lib = ctypes.cdll.LoadLibrary(r'C:\...\attach_x86.dll') 37 | print 'result', lib.AttachDebuggerTracing(0) 38 | 39 | t = threading.Thread(target=check) 40 | t.start() 41 | t.join() 42 | */ 43 | DECLDIR int AttachDebuggerTracing(bool showDebugInfo); 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_intern.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Georg Brandl. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for intern(). 5 | 6 | intern(s) -> sys.intern(s)""" 7 | 8 | # Local imports 9 | from .. import pytree 10 | from .. import fixer_base 11 | from ..fixer_util import Name, Attr, touch_import 12 | 13 | 14 | class FixIntern(fixer_base.BaseFix): 15 | BM_compatible = True 16 | order = "pre" 17 | 18 | PATTERN = """ 19 | power< 'intern' 20 | trailer< lpar='(' 21 | ( not(arglist | argument) any ','> ) 23 | rpar=')' > 24 | after=any* 25 | > 26 | """ 27 | 28 | def transform(self, node, results): 29 | syms = self.syms 30 | obj = results["obj"].clone() 31 | if obj.type == syms.arglist: 32 | newarglist = obj.clone() 33 | else: 34 | newarglist = pytree.Node(syms.arglist, [obj.clone()]) 35 | after = results["after"] 36 | if after: 37 | after = [n.clone() for n in after] 38 | new = pytree.Node(syms.power, 39 | Attr(Name(u"sys"), Name(u"intern")) + 40 | [pytree.Node(syms.trailer, 41 | [results["lpar"].clone(), 42 | newarglist, 43 | results["rpar"].clone()])] + after) 44 | new.prefix = node.prefix 45 | touch_import(None, u'sys', node) 46 | return new 47 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/pgen2/token.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """Token constants (from "token.h").""" 4 | 5 | # Taken from Python (r53757) and modified to include some tokens 6 | # originally monkeypatched in by pgen2.tokenize 7 | 8 | #--start constants-- 9 | ENDMARKER = 0 10 | NAME = 1 11 | NUMBER = 2 12 | STRING = 3 13 | NEWLINE = 4 14 | INDENT = 5 15 | DEDENT = 6 16 | LPAR = 7 17 | RPAR = 8 18 | LSQB = 9 19 | RSQB = 10 20 | COLON = 11 21 | COMMA = 12 22 | SEMI = 13 23 | PLUS = 14 24 | MINUS = 15 25 | STAR = 16 26 | SLASH = 17 27 | VBAR = 18 28 | AMPER = 19 29 | LESS = 20 30 | GREATER = 21 31 | EQUAL = 22 32 | DOT = 23 33 | PERCENT = 24 34 | BACKQUOTE = 25 35 | LBRACE = 26 36 | RBRACE = 27 37 | EQEQUAL = 28 38 | NOTEQUAL = 29 39 | LESSEQUAL = 30 40 | GREATEREQUAL = 31 41 | TILDE = 32 42 | CIRCUMFLEX = 33 43 | LEFTSHIFT = 34 44 | RIGHTSHIFT = 35 45 | DOUBLESTAR = 36 46 | PLUSEQUAL = 37 47 | MINEQUAL = 38 48 | STAREQUAL = 39 49 | SLASHEQUAL = 40 50 | PERCENTEQUAL = 41 51 | AMPEREQUAL = 42 52 | VBAREQUAL = 43 53 | CIRCUMFLEXEQUAL = 44 54 | LEFTSHIFTEQUAL = 45 55 | RIGHTSHIFTEQUAL = 46 56 | DOUBLESTAREQUAL = 47 57 | DOUBLESLASH = 48 58 | DOUBLESLASHEQUAL = 49 59 | AT = 50 60 | OP = 51 61 | COMMENT = 52 62 | NL = 53 63 | RARROW = 54 64 | ERRORTOKEN = 55 65 | N_TOKENS = 56 66 | NT_OFFSET = 256 67 | #--end constants-- 68 | 69 | tok_name = {} 70 | for _name, _value in globals().items(): 71 | if type(_value) is type(0): 72 | tok_name[_value] = _name 73 | 74 | 75 | def ISTERMINAL(x): 76 | return x < NT_OFFSET 77 | 78 | def ISNONTERMINAL(x): 79 | return x >= NT_OFFSET 80 | 81 | def ISEOF(x): 82 | return x == ENDMARKER 83 | -------------------------------------------------------------------------------- /lib/tests_runfiles/test_pydevdio.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | 5 | import unittest 6 | 7 | class Test(unittest.TestCase): 8 | 9 | def testIt(self): 10 | #make it as if we were executing from the directory above this one (so that we can use jycompletionserver 11 | #without the need for it being in the pythonpath) 12 | #(twice the dirname to get the previous level from this file.) 13 | import test_pydevdio #@UnresolvedImport - importing itself 14 | ADD_TO_PYTHONPATH = os.path.join(os.path.dirname(os.path.dirname(test_pydevdio.__file__))) 15 | sys.path.insert(0, ADD_TO_PYTHONPATH) 16 | 17 | try: 18 | import pydevd_io 19 | original = sys.stdout 20 | 21 | try: 22 | sys.stdout = pydevd_io.IOBuf() 23 | print('foo') 24 | print('bar') 25 | 26 | self.assertEquals('foo\nbar\n', sys.stdout.getvalue()) #@UndefinedVariable 27 | 28 | print('ww') 29 | print('xx') 30 | self.assertEquals('ww\nxx\n', sys.stdout.getvalue()) #@UndefinedVariable 31 | finally: 32 | sys.stdout = original 33 | finally: 34 | #remove it to leave it ok for other tests 35 | sys.path.remove(ADD_TO_PYTHONPATH) 36 | 37 | if __name__ == '__main__': 38 | #this is so that we can run it frem the jython tests -- because we don't actually have an __main__ module 39 | #(so, it won't try importing the __main__ module) 40 | unittest.TextTestRunner().run(unittest.makeSuite(Test)) 41 | -------------------------------------------------------------------------------- /lib/pydevd_vm_type.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | #======================================================================================================================= 4 | # PydevdVmType 5 | #======================================================================================================================= 6 | class PydevdVmType: 7 | 8 | PYTHON = 'python' 9 | JYTHON = 'jython' 10 | vm_type = None 11 | 12 | 13 | #======================================================================================================================= 14 | # SetVmType 15 | #======================================================================================================================= 16 | def SetVmType(vm_type): 17 | PydevdVmType.vm_type = vm_type 18 | 19 | 20 | #======================================================================================================================= 21 | # GetVmType 22 | #======================================================================================================================= 23 | def GetVmType(): 24 | if PydevdVmType.vm_type is None: 25 | SetupType() 26 | return PydevdVmType.vm_type 27 | 28 | 29 | #======================================================================================================================= 30 | # SetupType 31 | #======================================================================================================================= 32 | def SetupType(str=None): 33 | if str is not None: 34 | PydevdVmType.vm_type = str 35 | return 36 | 37 | if sys.platform.startswith("java"): 38 | PydevdVmType.vm_type = PydevdVmType.JYTHON 39 | else: 40 | PydevdVmType.vm_type = PydevdVmType.PYTHON 41 | 42 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_itertools.py: -------------------------------------------------------------------------------- 1 | """ Fixer for itertools.(imap|ifilter|izip) --> (map|filter|zip) and 2 | itertools.ifilterfalse --> itertools.filterfalse (bugs 2360-2363) 3 | 4 | imports from itertools are fixed in fix_itertools_import.py 5 | 6 | If itertools is imported as something else (ie: import itertools as it; 7 | it.izip(spam, eggs)) method calls will not get fixed. 8 | """ 9 | 10 | # Local imports 11 | from .. import fixer_base 12 | from ..fixer_util import Name 13 | 14 | class FixItertools(fixer_base.BaseFix): 15 | BM_compatible = True 16 | it_funcs = "('imap'|'ifilter'|'izip'|'izip_longest'|'ifilterfalse')" 17 | PATTERN = """ 18 | power< it='itertools' 19 | trailer< 20 | dot='.' func=%(it_funcs)s > trailer< '(' [any] ')' > > 21 | | 22 | power< func=%(it_funcs)s trailer< '(' [any] ')' > > 23 | """ %(locals()) 24 | 25 | # Needs to be run after fix_(map|zip|filter) 26 | run_order = 6 27 | 28 | def transform(self, node, results): 29 | prefix = None 30 | func = results['func'][0] 31 | if ('it' in results and 32 | func.value not in (u'ifilterfalse', u'izip_longest')): 33 | dot, it = (results['dot'], results['it']) 34 | # Remove the 'itertools' 35 | prefix = it.prefix 36 | it.remove() 37 | # Replace the node which contains ('.', 'function') with the 38 | # function (to be consistent with the second part of the pattern) 39 | dot.remove() 40 | func.parent.replace(func) 41 | 42 | prefix = prefix or func.prefix 43 | func.replace(Name(func.value[1:], prefix=prefix)) 44 | -------------------------------------------------------------------------------- /lib/tests_mainloop/gui-glut.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Simple GLUT example to manually test event loop integration. 3 | 4 | To run this: 5 | 1) Enable the PyDev GUI event loop integration for glut 6 | 2) do an execfile on this script 7 | 3) ensure you have a working GUI simultaneously with an 8 | interactive console 9 | 4) run: gl.glClearColor(1,1,1,1) 10 | """ 11 | 12 | if __name__ == '__main__': 13 | 14 | #!/usr/bin/env python 15 | import sys 16 | import OpenGL.GL as gl 17 | import OpenGL.GLUT as glut 18 | 19 | def close(): 20 | glut.glutDestroyWindow(glut.glutGetWindow()) 21 | 22 | def display(): 23 | gl.glClear (gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) 24 | glut.glutSwapBuffers() 25 | 26 | def resize(width,height): 27 | gl.glViewport(0, 0, width, height+4) 28 | gl.glMatrixMode(gl.GL_PROJECTION) 29 | gl.glLoadIdentity() 30 | gl.glOrtho(0, width, 0, height+4, -1, 1) 31 | gl.glMatrixMode(gl.GL_MODELVIEW) 32 | 33 | if glut.glutGetWindow() > 0: 34 | interactive = True 35 | glut.glutInit(sys.argv) 36 | glut.glutInitDisplayMode(glut.GLUT_DOUBLE | 37 | glut.GLUT_RGBA | 38 | glut.GLUT_DEPTH) 39 | else: 40 | interactive = False 41 | 42 | glut.glutCreateWindow('gui-glut') 43 | glut.glutDisplayFunc(display) 44 | glut.glutReshapeFunc(resize) 45 | # This is necessary on osx to be able to close the window 46 | # (else the close button is disabled) 47 | if sys.platform == 'darwin' and not bool(glut.HAVE_FREEGLUT): 48 | glut.glutWMCloseFunc(close) 49 | gl.glClearColor(0,0,0,1) 50 | 51 | if not interactive: 52 | glut.glutMainLoop() 53 | -------------------------------------------------------------------------------- /lib/pydevd_save_locals.py: -------------------------------------------------------------------------------- 1 | """ 2 | Utility for saving locals. 3 | """ 4 | import sys 5 | import pydevd_vars 6 | 7 | def is_save_locals_available(): 8 | try: 9 | if '__pypy__' in sys.builtin_module_names: 10 | import __pypy__ 11 | save_locals = __pypy__.locals_to_fast 12 | return True 13 | except: 14 | pass 15 | 16 | 17 | try: 18 | import ctypes 19 | except: 20 | return False #Not all Python versions have it 21 | 22 | try: 23 | func = ctypes.pythonapi.PyFrame_LocalsToFast 24 | except: 25 | return False 26 | 27 | return True 28 | 29 | def save_locals(frame): 30 | """ 31 | Copy values from locals_dict into the fast stack slots in the given frame. 32 | 33 | Note: the 'save_locals' branch had a different approach wrapping the frame (much more code, but it gives ideas 34 | on how to save things partially, not the 'whole' locals). 35 | """ 36 | if not isinstance(frame, pydevd_vars.frame_type): 37 | # Fix exception when changing Django variable (receiving DjangoTemplateFrame) 38 | return 39 | 40 | try: 41 | if '__pypy__' in sys.builtin_module_names: 42 | import __pypy__ 43 | save_locals = __pypy__.locals_to_fast 44 | save_locals(frame) 45 | return 46 | except: 47 | pass 48 | 49 | 50 | try: 51 | import ctypes 52 | except: 53 | return #Not all Python versions have it 54 | 55 | try: 56 | func = ctypes.pythonapi.PyFrame_LocalsToFast 57 | except: 58 | return 59 | 60 | #parameter 0: don't set to null things that are not in the frame.f_locals (which seems good in the debugger context). 61 | func(ctypes.py_object(frame), ctypes.c_int(0)) 62 | 63 | 64 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_throw.py: -------------------------------------------------------------------------------- 1 | """Fixer for generator.throw(E, V, T). 2 | 3 | g.throw(E) -> g.throw(E) 4 | g.throw(E, V) -> g.throw(E(V)) 5 | g.throw(E, V, T) -> g.throw(E(V).with_traceback(T)) 6 | 7 | g.throw("foo"[, V[, T]]) will warn about string exceptions.""" 8 | # Author: Collin Winter 9 | 10 | # Local imports 11 | from .. import pytree 12 | from ..pgen2 import token 13 | from .. import fixer_base 14 | from ..fixer_util import Name, Call, ArgList, Attr, is_tuple 15 | 16 | class FixThrow(fixer_base.BaseFix): 17 | BM_compatible = True 18 | PATTERN = """ 19 | power< any trailer< '.' 'throw' > 20 | trailer< '(' args=arglist< exc=any ',' val=any [',' tb=any] > ')' > 21 | > 22 | | 23 | power< any trailer< '.' 'throw' > trailer< '(' exc=any ')' > > 24 | """ 25 | 26 | def transform(self, node, results): 27 | syms = self.syms 28 | 29 | exc = results["exc"].clone() 30 | if exc.type is token.STRING: 31 | self.cannot_convert(node, "Python 3 does not support string exceptions") 32 | return 33 | 34 | # Leave "g.throw(E)" alone 35 | val = results.get(u"val") 36 | if val is None: 37 | return 38 | 39 | val = val.clone() 40 | if is_tuple(val): 41 | args = [c.clone() for c in val.children[1:-1]] 42 | else: 43 | val.prefix = u"" 44 | args = [val] 45 | 46 | throw_args = results["args"] 47 | 48 | if "tb" in results: 49 | tb = results["tb"].clone() 50 | tb.prefix = u"" 51 | 52 | e = Call(exc, args) 53 | with_tb = Attr(e, Name(u'with_traceback')) + [ArgList([tb])] 54 | throw_args.replace(pytree.Node(syms.power, with_tb)) 55 | else: 56 | throw_args.replace(Call(exc, args)) 57 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_isinstance.py: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Armin Ronacher. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that cleans up a tuple argument to isinstance after the tokens 5 | in it were fixed. This is mainly used to remove double occurrences of 6 | tokens as a leftover of the long -> int / unicode -> str conversion. 7 | 8 | eg. isinstance(x, (int, long)) -> isinstance(x, (int, int)) 9 | -> isinstance(x, int) 10 | """ 11 | 12 | from .. import fixer_base 13 | from ..fixer_util import token 14 | 15 | 16 | class FixIsinstance(fixer_base.BaseFix): 17 | BM_compatible = True 18 | PATTERN = """ 19 | power< 20 | 'isinstance' 21 | trailer< '(' arglist< any ',' atom< '(' 22 | args=testlist_gexp< any+ > 23 | ')' > > ')' > 24 | > 25 | """ 26 | 27 | run_order = 6 28 | 29 | def transform(self, node, results): 30 | names_inserted = set() 31 | testlist = results["args"] 32 | args = testlist.children 33 | new_args = [] 34 | iterator = enumerate(args) 35 | for idx, arg in iterator: 36 | if arg.type == token.NAME and arg.value in names_inserted: 37 | if idx < len(args) - 1 and args[idx + 1].type == token.COMMA: 38 | iterator.next() 39 | continue 40 | else: 41 | new_args.append(arg) 42 | if arg.type == token.NAME: 43 | names_inserted.add(arg.value) 44 | if new_args and new_args[-1].type == token.COMMA: 45 | del new_args[-1] 46 | if len(new_args) == 1: 47 | atom = testlist.parent 48 | new_args[0].prefix = atom.prefix 49 | atom.replace(new_args[0]) 50 | else: 51 | args[:] = new_args 52 | node.changed() 53 | -------------------------------------------------------------------------------- /lib/pydevd_frame_utils.py: -------------------------------------------------------------------------------- 1 | from pydevd_constants import IS_PY3K 2 | 3 | class Frame(object): 4 | def __init__( 5 | self, 6 | f_back, 7 | f_fileno, 8 | f_code, 9 | f_locals, 10 | f_globals=None, 11 | f_trace=None): 12 | self.f_back = f_back 13 | self.f_lineno = f_fileno 14 | self.f_code = f_code 15 | self.f_locals = f_locals 16 | self.f_globals = f_globals 17 | self.f_trace = f_trace 18 | 19 | if self.f_globals is None: 20 | self.f_globals = {} 21 | 22 | 23 | class FCode(object): 24 | def __init__(self, name, filename): 25 | self.co_name = name 26 | self.co_filename = filename 27 | 28 | 29 | def add_exception_to_frame(frame, exception_info): 30 | frame.f_locals['__exception__'] = exception_info 31 | 32 | FILES_WITH_IMPORT_HOOKS = ['pydev_monkey_qt.py', 'pydev_import_hook.py'] 33 | 34 | def just_raised(trace): 35 | if trace is None: 36 | return False 37 | if trace.tb_next is None: 38 | if IS_PY3K: 39 | if trace.tb_frame.f_code.co_filename != '': 40 | # Do not stop on inner exceptions in py3 while importing 41 | return True 42 | else: 43 | return True 44 | if trace.tb_next is not None: 45 | filename = trace.tb_next.tb_frame.f_code.co_filename 46 | # ImportError should appear in a user's code, not inside debugger 47 | for file in FILES_WITH_IMPORT_HOOKS: 48 | if filename.endswith(file): 49 | return True 50 | return False 51 | 52 | def cached_call(obj, func, *args): 53 | cached_name = '_cached_' + func.__name__ 54 | if not hasattr(obj, cached_name): 55 | setattr(obj, cached_name, func(*args)) 56 | 57 | return getattr(obj, cached_name) 58 | 59 | 60 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/pgen2/literals.py: -------------------------------------------------------------------------------- 1 | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Safely evaluate Python string literals without using eval().""" 5 | 6 | import re 7 | 8 | simple_escapes = {"a": "\a", 9 | "b": "\b", 10 | "f": "\f", 11 | "n": "\n", 12 | "r": "\r", 13 | "t": "\t", 14 | "v": "\v", 15 | "'": "'", 16 | '"': '"', 17 | "\\": "\\"} 18 | 19 | def escape(m): 20 | all, tail = m.group(0, 1) 21 | assert all.startswith("\\") 22 | esc = simple_escapes.get(tail) 23 | if esc is not None: 24 | return esc 25 | if tail.startswith("x"): 26 | hexes = tail[1:] 27 | if len(hexes) < 2: 28 | raise ValueError("invalid hex string escape ('\\%s')" % tail) 29 | try: 30 | i = int(hexes, 16) 31 | except ValueError: 32 | raise ValueError("invalid hex string escape ('\\%s')" % tail) 33 | else: 34 | try: 35 | i = int(tail, 8) 36 | except ValueError: 37 | raise ValueError("invalid octal string escape ('\\%s')" % tail) 38 | return chr(i) 39 | 40 | def evalString(s): 41 | assert s.startswith("'") or s.startswith('"'), repr(s[:1]) 42 | q = s[0] 43 | if s[:3] == q*3: 44 | q = q*3 45 | assert s.endswith(q), repr(s[-len(q):]) 46 | assert len(s) >= 2*len(q) 47 | s = s[len(q):-len(q)] 48 | return re.sub(r"\\(\'|\"|\\|[abfnrtv]|x.{0,2}|[0-7]{1,3})", escape, s) 49 | 50 | def test(): 51 | for i in range(256): 52 | c = chr(i) 53 | s = repr(c) 54 | e = evalString(s) 55 | if e != c: 56 | print i, c, s, e 57 | 58 | 59 | if __name__ == "__main__": 60 | test() 61 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/winappdbg/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Copyright (c) 2009-2014, Mario Vilas 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, 11 | # this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice,this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | # POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """ 32 | Plugins folder for the WinAppDbg interactive debugger. 33 | """ 34 | 35 | __revision__ = "$Id: __init__.py 1125 2012-10-22 14:54:39Z qvasimodo $" 36 | -------------------------------------------------------------------------------- /lib/_pydev_tipper_common.py: -------------------------------------------------------------------------------- 1 | try: 2 | import inspect 3 | except: 4 | try: 5 | from _pydev_imps import _pydev_inspect as inspect 6 | except: 7 | import traceback;traceback.print_exc() #Ok, no inspect available (search will not work) 8 | 9 | try: 10 | import re 11 | except: 12 | try: 13 | import sre as re # for older versions 14 | except: 15 | import traceback;traceback.print_exc() #Ok, no inspect available (search will not work) 16 | 17 | 18 | from pydevd_constants import xrange 19 | 20 | def DoFind(f, mod): 21 | import linecache 22 | if inspect.ismodule(mod): 23 | return f, 0, 0 24 | 25 | lines = linecache.getlines(f) 26 | 27 | if inspect.isclass(mod): 28 | name = mod.__name__ 29 | pat = re.compile(r'^\s*class\s*' + name + r'\b') 30 | for i in xrange(len(lines)): 31 | if pat.match(lines[i]): 32 | return f, i, 0 33 | 34 | return f, 0, 0 35 | 36 | if inspect.ismethod(mod): 37 | mod = mod.im_func 38 | 39 | if inspect.isfunction(mod): 40 | try: 41 | mod = mod.func_code 42 | except AttributeError: 43 | mod = mod.__code__ #python 3k 44 | 45 | if inspect.istraceback(mod): 46 | mod = mod.tb_frame 47 | 48 | if inspect.isframe(mod): 49 | mod = mod.f_code 50 | 51 | if inspect.iscode(mod): 52 | if not hasattr(mod, 'co_filename'): 53 | return None, 0, 0 54 | 55 | if not hasattr(mod, 'co_firstlineno'): 56 | return mod.co_filename, 0, 0 57 | 58 | lnum = mod.co_firstlineno 59 | pat = re.compile(r'^(\s*def\s)|(.*(? 0: 61 | if pat.match(lines[lnum]): 62 | break 63 | lnum -= 1 64 | 65 | return f, lnum, 0 66 | 67 | raise RuntimeError('Do not know about: ' + f + ' ' + str(mod)) 68 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/linux/lldb_prepare.py: -------------------------------------------------------------------------------- 1 | # This file is meant to be run inside lldb 2 | # It registers command to load library and invoke attach function 3 | # Also it marks process threads to to distinguish them from debugger 4 | # threads later while settings trace in threads 5 | 6 | def load_lib_and_attach(debugger, command, result, internal_dict): 7 | import shlex 8 | args = shlex.split(command) 9 | 10 | dll = args[0] 11 | is_debug = args[1] 12 | python_code = args[2] 13 | show_debug_info = args[3] 14 | 15 | import lldb 16 | options = lldb.SBExpressionOptions() 17 | options.SetFetchDynamicValue() 18 | options.SetTryAllThreads(run_others=False) 19 | options.SetTimeoutInMicroSeconds(timeout=10000000) 20 | 21 | print(dll) 22 | target = debugger.GetSelectedTarget() 23 | res = target.EvaluateExpression("(void*)dlopen(\"%s\", 2);" % ( 24 | dll), options) 25 | error = res.GetError() 26 | if error: 27 | print(error) 28 | 29 | print(python_code) 30 | res = target.EvaluateExpression("(int)DoAttach(%s, \"%s\", %s);" % ( 31 | is_debug, python_code.replace('"', "'"), show_debug_info), options) 32 | error = res.GetError() 33 | if error: 34 | print(error) 35 | 36 | def __lldb_init_module(debugger, internal_dict): 37 | import lldb 38 | 39 | debugger.HandleCommand('command script add -f lldb_prepare.load_lib_and_attach load_lib_and_attach') 40 | 41 | try: 42 | target = debugger.GetSelectedTarget() 43 | if target: 44 | process = target.GetProcess() 45 | if process: 46 | for thread in process: 47 | # print('Marking process thread %d'%thread.GetThreadID()) 48 | internal_dict['_thread_%d' % thread.GetThreadID()] = True 49 | # thread.Suspend() 50 | except: 51 | import traceback;traceback.print_exc() 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_set_literal.py: -------------------------------------------------------------------------------- 1 | """ 2 | Optional fixer to transform set() calls to set literals. 3 | """ 4 | 5 | # Author: Benjamin Peterson 6 | 7 | from lib2to3 import fixer_base, pytree 8 | from lib2to3.fixer_util import token, syms 9 | 10 | 11 | 12 | class FixSetLiteral(fixer_base.BaseFix): 13 | 14 | BM_compatible = True 15 | explicit = True 16 | 17 | PATTERN = """power< 'set' trailer< '(' 18 | (atom=atom< '[' (items=listmaker< any ((',' any)* [',']) > 19 | | 20 | single=any) ']' > 21 | | 22 | atom< '(' items=testlist_gexp< any ((',' any)* [',']) > ')' > 23 | ) 24 | ')' > > 25 | """ 26 | 27 | def transform(self, node, results): 28 | single = results.get("single") 29 | if single: 30 | # Make a fake listmaker 31 | fake = pytree.Node(syms.listmaker, [single.clone()]) 32 | single.replace(fake) 33 | items = fake 34 | else: 35 | items = results["items"] 36 | 37 | # Build the contents of the literal 38 | literal = [pytree.Leaf(token.LBRACE, u"{")] 39 | literal.extend(n.clone() for n in items.children) 40 | literal.append(pytree.Leaf(token.RBRACE, u"}")) 41 | # Set the prefix of the right brace to that of the ')' or ']' 42 | literal[-1].prefix = items.next_sibling.prefix 43 | maker = pytree.Node(syms.dictsetmaker, literal) 44 | maker.prefix = node.prefix 45 | 46 | # If the original was a one tuple, we need to remove the extra comma. 47 | if len(maker.children) == 4: 48 | n = maker.children[2] 49 | n.remove() 50 | maker.children[-1].prefix = n.prefix 51 | 52 | # Finally, replace the set call with our shiny new literal. 53 | return maker 54 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/winappdbg/plugins/do_symfix.py: -------------------------------------------------------------------------------- 1 | #!~/.wine/drive_c/Python25/python.exe 2 | # -*- coding: utf-8 -*- 3 | 4 | # Command line debugger using WinAppDbg 5 | # Fix the symbol store path 6 | # Copyright (c) 2009-2014, Mario Vilas 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright notice, 13 | # this list of conditions and the following disclaimer. 14 | # * Redistributions in binary form must reproduce the above copyright 15 | # notice,this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | # POSSIBILITY OF SUCH DAMAGE. 32 | 33 | __revision__ = "$Id$" 34 | 35 | def do(self, arg): 36 | ".symfix - Set the default Microsoft Symbol Store settings if missing" 37 | self.debug.system.fix_symbol_store_path(remote = True, force = False) 38 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_types.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for removing uses of the types module. 5 | 6 | These work for only the known names in the types module. The forms above 7 | can include types. or not. ie, It is assumed the module is imported either as: 8 | 9 | import types 10 | from types import ... # either * or specific types 11 | 12 | The import statements are not modified. 13 | 14 | There should be another fixer that handles at least the following constants: 15 | 16 | type([]) -> list 17 | type(()) -> tuple 18 | type('') -> str 19 | 20 | """ 21 | 22 | # Local imports 23 | from ..pgen2 import token 24 | from .. import fixer_base 25 | from ..fixer_util import Name 26 | 27 | _TYPE_MAPPING = { 28 | 'BooleanType' : 'bool', 29 | 'BufferType' : 'memoryview', 30 | 'ClassType' : 'type', 31 | 'ComplexType' : 'complex', 32 | 'DictType': 'dict', 33 | 'DictionaryType' : 'dict', 34 | 'EllipsisType' : 'type(Ellipsis)', 35 | #'FileType' : 'io.IOBase', 36 | 'FloatType': 'float', 37 | 'IntType': 'int', 38 | 'ListType': 'list', 39 | 'LongType': 'int', 40 | 'ObjectType' : 'object', 41 | 'NoneType': 'type(None)', 42 | 'NotImplementedType' : 'type(NotImplemented)', 43 | 'SliceType' : 'slice', 44 | 'StringType': 'bytes', # XXX ? 45 | 'StringTypes' : 'str', # XXX ? 46 | 'TupleType': 'tuple', 47 | 'TypeType' : 'type', 48 | 'UnicodeType': 'str', 49 | 'XRangeType' : 'range', 50 | } 51 | 52 | _pats = ["power< 'types' trailer< '.' name='%s' > >" % t for t in _TYPE_MAPPING] 53 | 54 | class FixTypes(fixer_base.BaseFix): 55 | BM_compatible = True 56 | PATTERN = '|'.join(_pats) 57 | 58 | def transform(self, node, results): 59 | new_value = unicode(_TYPE_MAPPING.get(results["name"].value)) 60 | if new_value: 61 | return Name(new_value, prefix=node.prefix) 62 | return None 63 | -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/ctypes/_endian.py: -------------------------------------------------------------------------------- 1 | #@PydevCodeAnalysisIgnore 2 | import sys 3 | from ctypes import * 4 | 5 | _array_type = type(c_int * 3) 6 | 7 | def _other_endian(typ): 8 | """Return the type with the 'other' byte order. Simple types like 9 | c_int and so on already have __ctype_be__ and __ctype_le__ 10 | attributes which contain the types, for more complicated types 11 | only arrays are supported. 12 | """ 13 | try: 14 | return getattr(typ, _OTHER_ENDIAN) 15 | except AttributeError: 16 | if type(typ) == _array_type: 17 | return _other_endian(typ._type_) * typ._length_ 18 | raise TypeError("This type does not support other endian: %s" % typ) 19 | 20 | class _swapped_meta(type(Structure)): 21 | def __setattr__(self, attrname, value): 22 | if attrname == "_fields_": 23 | fields = [] 24 | for desc in value: 25 | name = desc[0] 26 | typ = desc[1] 27 | rest = desc[2:] 28 | fields.append((name, _other_endian(typ)) + rest) 29 | value = fields 30 | super(_swapped_meta, self).__setattr__(attrname, value) 31 | 32 | ################################################################ 33 | 34 | # Note: The Structure metaclass checks for the *presence* (not the 35 | # value!) of a _swapped_bytes_ attribute to determine the bit order in 36 | # structures containing bit fields. 37 | 38 | if sys.byteorder == "little": 39 | _OTHER_ENDIAN = "__ctype_be__" 40 | 41 | LittleEndianStructure = Structure 42 | 43 | class BigEndianStructure(Structure): 44 | """Structure with big endian byte order""" 45 | __metaclass__ = _swapped_meta 46 | _swappedbytes_ = None 47 | 48 | elif sys.byteorder == "big": 49 | _OTHER_ENDIAN = "__ctype_le__" 50 | 51 | BigEndianStructure = Structure 52 | class LittleEndianStructure(Structure): 53 | """Structure with little endian byte order""" 54 | __metaclass__ = _swapped_meta 55 | _swappedbytes_ = None 56 | 57 | else: 58 | raise RuntimeError("Invalid byteorder") 59 | -------------------------------------------------------------------------------- /lib/pydevd_import_class.py: -------------------------------------------------------------------------------- 1 | #Note: code gotten from _pydev_imports_tipper. 2 | 3 | import sys 4 | 5 | def _imp(name, log=None): 6 | try: 7 | return __import__(name) 8 | except: 9 | if '.' in name: 10 | sub = name[0:name.rfind('.')] 11 | 12 | if log is not None: 13 | log.AddContent('Unable to import', name, 'trying with', sub) 14 | log.AddException() 15 | 16 | return _imp(sub, log) 17 | else: 18 | s = 'Unable to import module: %s - sys.path: %s' % (str(name), sys.path) 19 | if log is not None: 20 | log.AddContent(s) 21 | log.AddException() 22 | 23 | raise ImportError(s) 24 | 25 | 26 | IS_IPY = False 27 | if sys.platform == 'cli': 28 | IS_IPY = True 29 | _old_imp = _imp 30 | def _imp(name, log=None): 31 | #We must add a reference in clr for .Net 32 | import clr #@UnresolvedImport 33 | initial_name = name 34 | while '.' in name: 35 | try: 36 | clr.AddReference(name) 37 | break #If it worked, that's OK. 38 | except: 39 | name = name[0:name.rfind('.')] 40 | else: 41 | try: 42 | clr.AddReference(name) 43 | except: 44 | pass #That's OK (not dot net module). 45 | 46 | return _old_imp(initial_name, log) 47 | 48 | 49 | def ImportName(name, log=None): 50 | mod = _imp(name, log) 51 | 52 | components = name.split('.') 53 | 54 | old_comp = None 55 | for comp in components[1:]: 56 | try: 57 | #this happens in the following case: 58 | #we have mx.DateTime.mxDateTime.mxDateTime.pyd 59 | #but after importing it, mx.DateTime.mxDateTime shadows access to mxDateTime.pyd 60 | mod = getattr(mod, comp) 61 | except AttributeError: 62 | if old_comp != comp: 63 | raise 64 | 65 | old_comp = comp 66 | 67 | return mod 68 | 69 | -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/ctypes/macholib/dylib.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generic dylib path manipulation 3 | """ 4 | 5 | import re 6 | 7 | __all__ = ['dylib_info'] 8 | 9 | DYLIB_RE = re.compile(r"""(?x) 10 | (?P^.*)(?:^|/) 11 | (?P 12 | (?P\w+?) 13 | (?:\.(?P[^._]+))? 14 | (?:_(?P[^._]+))? 15 | \.dylib$ 16 | ) 17 | """) 18 | 19 | def dylib_info(filename): 20 | """ 21 | A dylib name can take one of the following four forms: 22 | Location/Name.SomeVersion_Suffix.dylib 23 | Location/Name.SomeVersion.dylib 24 | Location/Name_Suffix.dylib 25 | Location/Name.dylib 26 | 27 | returns None if not found or a mapping equivalent to: 28 | dict( 29 | location='Location', 30 | name='Name.SomeVersion_Suffix.dylib', 31 | shortname='Name', 32 | version='SomeVersion', 33 | suffix='Suffix', 34 | ) 35 | 36 | Note that SomeVersion and Suffix are optional and may be None 37 | if not present. 38 | """ 39 | is_dylib = DYLIB_RE.match(filename) 40 | if not is_dylib: 41 | return None 42 | return is_dylib.groupdict() 43 | 44 | 45 | def test_dylib_info(): 46 | def d(location=None, name=None, shortname=None, version=None, suffix=None): 47 | return dict( 48 | location=location, 49 | name=name, 50 | shortname=shortname, 51 | version=version, 52 | suffix=suffix 53 | ) 54 | assert dylib_info('completely/invalid') is None 55 | assert dylib_info('completely/invalide_debug') is None 56 | assert dylib_info('P/Foo.dylib') == d('P', 'Foo.dylib', 'Foo') 57 | assert dylib_info('P/Foo_debug.dylib') == d('P', 'Foo_debug.dylib', 'Foo', suffix='debug') 58 | assert dylib_info('P/Foo.A.dylib') == d('P', 'Foo.A.dylib', 'Foo', 'A') 59 | assert dylib_info('P/Foo_debug.A.dylib') == d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A') 60 | assert dylib_info('P/Foo.A_debug.dylib') == d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug') 61 | 62 | if __name__ == '__main__': 63 | test_dylib_info() 64 | -------------------------------------------------------------------------------- /lib/tests_python/_debugger_case1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import weakref 3 | 4 | def SetUp(): 5 | observable = Observable() 6 | observer = Observer() 7 | observable.AddObserver(observer) 8 | return observable 9 | 10 | 11 | class Observable(object): 12 | def __init__(self): 13 | self.observers = [] 14 | 15 | def AddObserver(self, observer): 16 | sys.stdout.write( 'observer %s\n' % (observer,)) 17 | ref = weakref.ref(observer) 18 | self.observers.append(ref) 19 | sys.stdout.write('weakref: %s\n' % (ref(),)) 20 | 21 | def Notify(self): 22 | for o in self.observers: 23 | o = o() 24 | 25 | 26 | try: 27 | import gc 28 | except ImportError: 29 | o = None #some jython does not have gc, so, there's no sense testing this in it 30 | else: 31 | try: 32 | gc.get_referrers(o) 33 | except: 34 | o = None #jython and ironpython do not have get_referrers 35 | 36 | if o is not None: 37 | sys.stdout.write('still observing %s\n' % (o,)) 38 | sys.stdout.write('number of referrers: %s\n' % len(gc.get_referrers(o))) 39 | frame = gc.get_referrers(o)[0] 40 | frame_referrers = gc.get_referrers(frame) 41 | sys.stdout.write('frame referrer %s\n' % (frame_referrers,)) 42 | referrers1 = gc.get_referrers(frame_referrers[1]) 43 | sys.stdout.write('%s\n' % (referrers1,)) 44 | sys.stderr.write('TEST FAILED: The observer should have died, even when running in debug\n') 45 | else: 46 | sys.stdout.write('TEST SUCEEDED: observer died\n') 47 | 48 | sys.stdout.flush() 49 | sys.stderr.flush() 50 | 51 | class Observer(object): 52 | pass 53 | 54 | 55 | def main(): 56 | observable = SetUp() 57 | observable.Notify() 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_apply.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for apply(). 5 | 6 | This converts apply(func, v, k) into (func)(*v, **k).""" 7 | 8 | # Local imports 9 | from .. import pytree 10 | from ..pgen2 import token 11 | from .. import fixer_base 12 | from ..fixer_util import Call, Comma, parenthesize 13 | 14 | class FixApply(fixer_base.BaseFix): 15 | BM_compatible = True 16 | 17 | PATTERN = """ 18 | power< 'apply' 19 | trailer< 20 | '(' 21 | arglist< 22 | (not argument 26 | ')' 27 | > 28 | > 29 | """ 30 | 31 | def transform(self, node, results): 32 | syms = self.syms 33 | assert results 34 | func = results["func"] 35 | args = results["args"] 36 | kwds = results.get("kwds") 37 | prefix = node.prefix 38 | func = func.clone() 39 | if (func.type not in (token.NAME, syms.atom) and 40 | (func.type != syms.power or 41 | func.children[-2].type == token.DOUBLESTAR)): 42 | # Need to parenthesize 43 | func = parenthesize(func) 44 | func.prefix = "" 45 | args = args.clone() 46 | args.prefix = "" 47 | if kwds is not None: 48 | kwds = kwds.clone() 49 | kwds.prefix = "" 50 | l_newargs = [pytree.Leaf(token.STAR, u"*"), args] 51 | if kwds is not None: 52 | l_newargs.extend([Comma(), 53 | pytree.Leaf(token.DOUBLESTAR, u"**"), 54 | kwds]) 55 | l_newargs[-2].prefix = u" " # that's the ** token 56 | # XXX Sometimes we could be cleverer, e.g. apply(f, (x, y) + t) 57 | # can be translated into f(x, y, *t) instead of f(*(x, y) + t) 58 | #new = pytree.Node(syms.power, (func, ArgList(l_newargs))) 59 | return Call(func, l_newargs, prefix=prefix) 60 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/winappdbg/plugins/do_example.py: -------------------------------------------------------------------------------- 1 | #!~/.wine/drive_c/Python25/python.exe 2 | # -*- coding: utf-8 -*- 3 | 4 | # Command line debugger using WinAppDbg 5 | # Example command 6 | # Copyright (c) 2009-2014, Mario Vilas 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright notice, 13 | # this list of conditions and the following disclaimer. 14 | # * Redistributions in binary form must reproduce the above copyright 15 | # notice,this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | # POSSIBILITY OF SUCH DAMAGE. 32 | 33 | __revision__ = "$Id$" 34 | 35 | def do(self, arg): 36 | ".example - This is an example plugin for the command line debugger" 37 | print "This is an example command." 38 | print "%s.do(%r, %r):" % (__name__, self, arg) 39 | print " last event", self.lastEvent 40 | print " prefix", self.cmdprefix 41 | print " arguments", self.split_tokens(arg) 42 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_execfile.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for execfile. 5 | 6 | This converts usages of the execfile function into calls to the built-in 7 | exec() function. 8 | """ 9 | 10 | from .. import fixer_base 11 | from ..fixer_util import (Comma, Name, Call, LParen, RParen, Dot, Node, 12 | ArgList, String, syms) 13 | 14 | 15 | class FixExecfile(fixer_base.BaseFix): 16 | BM_compatible = True 17 | 18 | PATTERN = """ 19 | power< 'execfile' trailer< '(' arglist< filename=any [',' globals=any [',' locals=any ] ] > ')' > > 20 | | 21 | power< 'execfile' trailer< '(' filename=any ')' > > 22 | """ 23 | 24 | def transform(self, node, results): 25 | assert results 26 | filename = results["filename"] 27 | globals = results.get("globals") 28 | locals = results.get("locals") 29 | 30 | # Copy over the prefix from the right parentheses end of the execfile 31 | # call. 32 | execfile_paren = node.children[-1].children[-1].clone() 33 | # Construct open().read(). 34 | open_args = ArgList([filename.clone()], rparen=execfile_paren) 35 | open_call = Node(syms.power, [Name(u"open"), open_args]) 36 | read = [Node(syms.trailer, [Dot(), Name(u'read')]), 37 | Node(syms.trailer, [LParen(), RParen()])] 38 | open_expr = [open_call] + read 39 | # Wrap the open call in a compile call. This is so the filename will be 40 | # preserved in the execed code. 41 | filename_arg = filename.clone() 42 | filename_arg.prefix = u" " 43 | exec_str = String(u"'exec'", u" ") 44 | compile_args = open_expr + [Comma(), filename_arg, Comma(), exec_str] 45 | compile_call = Call(Name(u"compile"), compile_args, u"") 46 | # Finally, replace the execfile call with an exec call. 47 | args = [compile_call] 48 | if globals is not None: 49 | args.extend([Comma(), globals.clone()]) 50 | if locals is not None: 51 | args.extend([Comma(), locals.clone()]) 52 | return Call(Name(u"exec"), args, prefix=node.prefix) 53 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/linux/Makefile: -------------------------------------------------------------------------------- 1 | # Defaults which can be overridden. 2 | OS = macosx 3 | ARCH_X86 = x86 4 | ARCH_X86_64 = x86_64 5 | 6 | CC=g++ 7 | LD=libtool 8 | CPPFLAGS = -I. 9 | CFLAGS +=-fPIC -D_REENTRANT -nostartfiles 10 | 11 | ARCH_FLAG_X86 = -arch i386 12 | ARCH_FLAG_X86_64 = -arch x86_64 13 | 14 | INSTALL_DIR_X86 = ../os/$(OS)/$(ARCH_X86) 15 | INSTALL_DIR_X86_64 = ../os/$(OS)/$(ARCH_X86_64) 16 | INSTALL_DIR_LINUX_X86 = ../os/$(LINUX)/$(ARCH_X86) 17 | INSTALL_DIR_LINUX_X86_64 = ../os/$(LINUX)/$(ARCH_X86_64) 18 | 19 | ATTACH = attach_mac.so 20 | ATTACH_NAME_FULL_X86 = $(INSTALL_DIR_X86)/attach_x86.dylib 21 | ATTACH_NAME_FULL_X86_64 = $(INSTALL_DIR_X86_64)/attach_x86_64.dylib 22 | 23 | OBJS_ATTACH_X86 = attach_linux_$(ARCH_X86).o 24 | OBJS_ATTACH_X86_64 = attach_linux_$(ARCH_X86_64).o 25 | 26 | OBJS_X86 = $(OBJS_ATTACH_X86) 27 | OBJS_X86_64 = $(OBJS_ATTACH_X86_64) 28 | 29 | all: x86 x86_64 30 | 31 | x86: $(ATTACH_NAME_FULL_X86) 32 | 33 | x86_64: $(ATTACH_NAME_FULL_X86_64) 34 | 35 | linux_x86: $(ATTACH_NAME_FULL_LINUX_X86) 36 | linux_x86_64: $(ATTACH_NAME_FULL_LINUX_X86_64) 37 | 38 | rebuild: clean all 39 | 40 | $(ATTACH_NAME_FULL_X86): $(OBJS_ATTACH_X86) 41 | mkdir -p $(INSTALL_DIR_X86) 42 | $(CC) -dynamiclib $(ARCH_FLAG_X86) -o $(ATTACH_NAME_FULL_X86) $(OBJS_ATTACH_X86) -lc 43 | 44 | $(ATTACH_NAME_FULL_X86_64): $(OBJS_ATTACH_X86_64) 45 | mkdir -p $(INSTALL_DIR_X86_64) 46 | $(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(ATTACH_NAME_FULL_X86_64) $(OBJS_ATTACH_X86_64) -lc 47 | 48 | $(ATTACH_NAME_FULL_LINUX_X86): $(OBJS_ATTACH_X86) 49 | mkdir -p $(INSTALL_DIR_LINUX_X86) 50 | $(CC) -m32 -g -shared -Wl,-soname,$(ATTACH) $(LDFLAGS) -o $(ATTACH_NAME_FULL_LINUX_X86) $(OBJS_ATTACH_X86) 51 | 52 | $(ATTACH_NAME_FULL_LINUX_X86_64): $(OBJS_ATTACH_X86_64) 53 | mkdir -p $(INSTALL_DIR_LINUX_X86_64) 54 | $(CC) -g -shared -Wl,-soname,$(ATTACH) $(LDFLAGS) -o $(ATTACH_NAME_FULL_LINUX_X86_64) $(OBJS_ATTACH_X86_64) 55 | 56 | attach_linux_$(ARCH_X86).o: attach_linux.c 57 | $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ attach_linux.c 58 | 59 | attach_linux_$(ARCH_X86_64).o: attach_linux.c 60 | $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ attach_linux.c 61 | 62 | clean : 63 | $(RM) $(OBJS_X86) $(ATTACH_NAME_FULL_X86) 64 | $(RM) $(OBJS_X86_64) $(ATTACH_NAME_FULL_X86_64) 65 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/attach_pydevd.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | def process_command_line(argv): 5 | setup = {} 6 | setup['port'] = 5678 # Default port for PyDev remote debugger 7 | setup['pid'] = 0 8 | setup['host'] = '127.0.0.1' 9 | 10 | i = 0 11 | while i < len(argv): 12 | if argv[i] == '--port': 13 | del argv[i] 14 | setup['port'] = int(argv[i]) 15 | del argv[i] 16 | 17 | elif argv[i] == '--pid': 18 | del argv[i] 19 | setup['pid'] = int(argv[i]) 20 | del argv[i] 21 | 22 | elif argv[i] == '--host': 23 | del argv[i] 24 | setup['host'] = int(argv[i]) 25 | del argv[i] 26 | 27 | 28 | if not setup['pid']: 29 | sys.stderr.write('Expected --pid to be passed.\n') 30 | sys.exit(1) 31 | return setup 32 | 33 | def main(setup): 34 | import add_code_to_python_process 35 | show_debug_info_on_target_process = 0 36 | 37 | pydevd_dirname = os.path.dirname(os.path.dirname(__file__)) 38 | 39 | if sys.platform == 'win32': 40 | setup['pythonpath'] = pydevd_dirname.replace('\\', '/') 41 | setup['pythonpath2'] = os.path.dirname(__file__).replace('\\', '/') 42 | python_code = '''import sys; 43 | sys.path.append("%(pythonpath)s"); 44 | sys.path.append("%(pythonpath2)s"); 45 | import attach_script; 46 | attach_script.attach(port=%(port)s, host="%(host)s"); 47 | '''.replace('\r\n', '').replace('\r', '').replace('\n', '') 48 | else: 49 | setup['pythonpath'] = pydevd_dirname 50 | setup['pythonpath2'] = os.path.dirname(__file__) 51 | # We have to pass it a bit differently for gdb 52 | python_code = '''import sys; 53 | sys.path.append(\\\"%(pythonpath)s\\\"); 54 | sys.path.append(\\\"%(pythonpath2)s\\\"); 55 | import attach_script; 56 | attach_script.attach(port=%(port)s, host=\\\"%(host)s\\\"); 57 | '''.replace('\r\n', '').replace('\r', '').replace('\n', '') 58 | 59 | python_code = python_code % setup 60 | add_code_to_python_process.run_python_code( 61 | setup['pid'], python_code, connect_debugger_tracing=True, show_debug_info=show_debug_info_on_target_process) 62 | 63 | if __name__ == '__main__': 64 | main(process_command_line(sys.argv[1:])) 65 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/linux/lldb_threads_settrace.py: -------------------------------------------------------------------------------- 1 | # This file is meant to be run inside lldb as a command after 2 | # the attach_linux.dylib dll has already been loaded to settrace for all threads. 3 | def __lldb_init_module(debugger, internal_dict): 4 | # Command Initialization code goes here 5 | # print('Startup LLDB in Python!') 6 | import lldb 7 | 8 | try: 9 | show_debug_info = 1 10 | is_debug = 0 11 | 12 | options = lldb.SBExpressionOptions() 13 | options.SetFetchDynamicValue() 14 | options.SetTryAllThreads(run_others=False) 15 | options.SetTimeoutInMicroSeconds(timeout=10000000) 16 | 17 | target = debugger.GetSelectedTarget() 18 | if target: 19 | process = target.GetProcess() 20 | if process: 21 | for thread in process: 22 | # Get the first frame 23 | # print('Thread %s, suspended %s\n'%(thread, thread.IsStopped())) 24 | 25 | if internal_dict.get('_thread_%d' % thread.GetThreadID(), False): 26 | process.SetSelectedThread(thread) 27 | if not thread.IsStopped(): 28 | # thread.Suspend() 29 | error = process.Stop() 30 | 31 | frame = thread.GetSelectedFrame() 32 | 33 | if frame.GetFunctionName() == '__select': 34 | # print('We are in __select') 35 | # Step over select, otherwise evaluating expression there can terminate thread 36 | thread.StepOver() 37 | frame = thread.GetSelectedFrame() 38 | 39 | print('Will settrace in: %s' % (frame,)) 40 | 41 | for f in thread: 42 | print(f) 43 | 44 | res = frame.EvaluateExpression("(int) SetSysTraceFunc(%s, %s)" % ( 45 | show_debug_info, is_debug), options) 46 | error = res.GetError() 47 | if error: 48 | print(error) 49 | 50 | thread.Resume() 51 | except: 52 | import traceback;traceback.print_exc() 53 | -------------------------------------------------------------------------------- /lib/pydev_coverage.py: -------------------------------------------------------------------------------- 1 | def execute(): 2 | import os 3 | import sys 4 | 5 | files = None 6 | if 'combine' not in sys.argv: 7 | 8 | if '--pydev-analyze' in sys.argv: 9 | 10 | #Ok, what we want here is having the files passed through stdin (because 11 | #there may be too many files for passing in the command line -- we could 12 | #just pass a dir and make the find files here, but as that's already 13 | #given in the java side, let's just gather that info here). 14 | sys.argv.remove('--pydev-analyze') 15 | try: 16 | s = raw_input() 17 | except: 18 | s = input() 19 | s = s.replace('\r', '') 20 | s = s.replace('\n', '') 21 | files = s.split('|') 22 | files = [v for v in files if len(v) > 0] 23 | 24 | #Note that in this case we'll already be in the working dir with the coverage files, so, the 25 | #coverage file location is not passed. 26 | 27 | else: 28 | #For all commands, the coverage file is configured in pydev, and passed as the first argument 29 | #in the command line, so, let's make sure this gets to the coverage module. 30 | os.environ['COVERAGE_FILE'] = sys.argv[1] 31 | del sys.argv[1] 32 | 33 | try: 34 | import coverage #@UnresolvedImport 35 | except: 36 | sys.stderr.write('Error: coverage module could not be imported\n') 37 | sys.stderr.write('Please make sure that the coverage module (http://nedbatchelder.com/code/coverage/)\n') 38 | sys.stderr.write('is properly installed in your interpreter: %s\n' % (sys.executable,)) 39 | 40 | import traceback;traceback.print_exc() 41 | return 42 | 43 | #print(coverage.__version__) TODO: Check if the version is a version we support (should be at least 3.4) -- note that maybe the attr is not there. 44 | from coverage.cmdline import main #@UnresolvedImport 45 | 46 | if files is not None: 47 | sys.argv.append('-r') 48 | sys.argv.append('-m') 49 | sys.argv += files 50 | 51 | main() 52 | 53 | if __name__ == '__main__': 54 | execute() -------------------------------------------------------------------------------- /lib/pydev_run_in_console.py: -------------------------------------------------------------------------------- 1 | 2 | from pydevconsole import * 3 | 4 | import pydev_imports 5 | from pydevd_utils import save_main_module 6 | 7 | 8 | def run_file(file, globals=None, locals=None): 9 | if os.path.isdir(file): 10 | new_target = os.path.join(file, '__main__.py') 11 | if os.path.isfile(new_target): 12 | file = new_target 13 | 14 | if globals is None: 15 | m = save_main_module(file, 'pydev_run_in_console') 16 | 17 | globals = m.__dict__ 18 | try: 19 | globals['__builtins__'] = __builtins__ 20 | except NameError: 21 | pass # Not there on Jython... 22 | 23 | if locals is None: 24 | locals = globals 25 | 26 | sys.path.insert(0, os.path.split(file)[0]) 27 | 28 | print('Running %s'%file) 29 | pydev_imports.execfile(file, globals, locals) # execute the script 30 | 31 | return globals 32 | 33 | #======================================================================================================================= 34 | # main 35 | #======================================================================================================================= 36 | if __name__ == '__main__': 37 | sys.stdin = BaseStdIn() 38 | port, client_port = sys.argv[1:3] 39 | 40 | del sys.argv[1] 41 | del sys.argv[1] 42 | 43 | file = sys.argv[1] 44 | 45 | del sys.argv[0] 46 | 47 | import pydev_localhost 48 | 49 | if int(port) == 0 and int(client_port) == 0: 50 | (h, p) = pydev_localhost.get_socket_name() 51 | 52 | client_port = p 53 | 54 | host = pydev_localhost.get_localhost() 55 | 56 | 57 | #replace exit (see comments on method) 58 | #note that this does not work in jython!!! (sys method can't be replaced). 59 | sys.exit = DoExit 60 | 61 | interpreter = InterpreterInterface(host, int(client_port), threading.currentThread()) 62 | 63 | server_thread = threading.Thread(target=start_server, 64 | name='ServerThread', 65 | args=(host, int(port), interpreter)) 66 | server_thread.setDaemon(True) 67 | server_thread.start() 68 | 69 | globals = run_file(file, None, None) 70 | 71 | interpreter.getNamespace().update(globals) 72 | 73 | process_exec_queue(interpreter) -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_itertools_imports.py: -------------------------------------------------------------------------------- 1 | """ Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """ 2 | 3 | # Local imports 4 | from lib2to3 import fixer_base 5 | from lib2to3.fixer_util import BlankLine, syms, token 6 | 7 | 8 | class FixItertoolsImports(fixer_base.BaseFix): 9 | BM_compatible = True 10 | PATTERN = """ 11 | import_from< 'from' 'itertools' 'import' imports=any > 12 | """ %(locals()) 13 | 14 | def transform(self, node, results): 15 | imports = results['imports'] 16 | if imports.type == syms.import_as_name or not imports.children: 17 | children = [imports] 18 | else: 19 | children = imports.children 20 | for child in children[::2]: 21 | if child.type == token.NAME: 22 | member = child.value 23 | name_node = child 24 | elif child.type == token.STAR: 25 | # Just leave the import as is. 26 | return 27 | else: 28 | assert child.type == syms.import_as_name 29 | name_node = child.children[0] 30 | member_name = name_node.value 31 | if member_name in (u'imap', u'izip', u'ifilter'): 32 | child.value = None 33 | child.remove() 34 | elif member_name in (u'ifilterfalse', u'izip_longest'): 35 | node.changed() 36 | name_node.value = (u'filterfalse' if member_name[1] == u'f' 37 | else u'zip_longest') 38 | 39 | # Make sure the import statement is still sane 40 | children = imports.children[:] or [imports] 41 | remove_comma = True 42 | for child in children: 43 | if remove_comma and child.type == token.COMMA: 44 | child.remove() 45 | else: 46 | remove_comma ^= True 47 | 48 | while children and children[-1].type == token.COMMA: 49 | children.pop().remove() 50 | 51 | # If there are no imports left, just get rid of the entire statement 52 | if (not (imports.children or getattr(imports, 'value', None)) or 53 | imports.parent is None): 54 | p = node.prefix 55 | node = BlankLine() 56 | node.prefix = p 57 | return node 58 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/winappdbg/plugins/do_exploitable.py: -------------------------------------------------------------------------------- 1 | #!~/.wine/drive_c/Python25/python.exe 2 | # -*- coding: utf-8 -*- 3 | 4 | # Command line debugger using WinAppDbg 5 | # Determine the approximate exploitability rating 6 | # Copyright (c) 2009-2014, Mario Vilas 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright notice, 13 | # this list of conditions and the following disclaimer. 14 | # * Redistributions in binary form must reproduce the above copyright 15 | # notice,this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | # POSSIBILITY OF SUCH DAMAGE. 32 | 33 | __revision__ = "$Id$" 34 | 35 | def do(self, arg): 36 | ".exploitable - Determine the approximate exploitability rating" 37 | 38 | from winappdbg import Crash 39 | 40 | event = self.debug.lastEvent 41 | crash = Crash(event) 42 | crash.fetch_extra_data(event) 43 | 44 | status, rule, description = crash.isExploitable() 45 | 46 | print "-" * 79 47 | print "Exploitability: %s" % status 48 | print "Matched rule: %s" % rule 49 | print "Description: %s" % description 50 | print "-" * 79 51 | -------------------------------------------------------------------------------- /lib/_pydev_imps/_pydev_sys_patch.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | 4 | 5 | def patch_sys_module(): 6 | def patched_exc_info(fun): 7 | def pydev_debugger_exc_info(): 8 | type, value, traceback = fun() 9 | if type == ImportError: 10 | #we should not show frame added by plugin_import call 11 | if traceback and hasattr(traceback, "tb_next"): 12 | return type, value, traceback.tb_next 13 | return type, value, traceback 14 | return pydev_debugger_exc_info 15 | 16 | system_exc_info = sys.exc_info 17 | sys.exc_info = patched_exc_info(system_exc_info) 18 | if not hasattr(sys, "system_exc_info"): 19 | sys.system_exc_info = system_exc_info 20 | 21 | 22 | def patched_reload(orig_reload): 23 | def pydev_debugger_reload(module): 24 | orig_reload(module) 25 | if module.__name__ == "sys": 26 | # if sys module was reloaded we should patch it again 27 | patch_sys_module() 28 | return pydev_debugger_reload 29 | 30 | 31 | def patch_reload(): 32 | try: 33 | import __builtin__ as builtins 34 | except ImportError: 35 | import builtins 36 | 37 | if hasattr(builtins, "reload"): 38 | sys.builtin_orig_reload = builtins.reload 39 | builtins.reload = patched_reload(sys.builtin_orig_reload) 40 | try: 41 | import imp 42 | sys.imp_orig_reload = imp.reload 43 | imp.reload = patched_reload(sys.imp_orig_reload) 44 | except: 45 | pass 46 | else: 47 | try: 48 | import importlib 49 | sys.importlib_orig_reload = importlib.reload 50 | importlib.reload = patched_reload(sys.importlib_orig_reload) 51 | except: 52 | pass 53 | 54 | del builtins 55 | 56 | 57 | def cancel_patches_in_sys_module(): 58 | sys.exc_info = sys.system_exc_info 59 | try: 60 | import __builtin__ as builtins 61 | except ImportError: 62 | import builtins 63 | 64 | if hasattr(sys, "builtin_orig_reload"): 65 | builtins.reload = sys.builtin_orig_reload 66 | 67 | if hasattr(sys, "imp_orig_reload"): 68 | import imp 69 | imp.reload = sys.imp_orig_reload 70 | 71 | if hasattr(sys, "importlib_orig_reload"): 72 | import importlib 73 | importlib.reload = sys.importlib_orig_reload 74 | 75 | del builtins 76 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_filter.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that changes filter(F, X) into list(filter(F, X)). 5 | 6 | We avoid the transformation if the filter() call is directly contained 7 | in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or 8 | for V in <>:. 9 | 10 | NOTE: This is still not correct if the original code was depending on 11 | filter(F, X) to return a string if X is a string and a tuple if X is a 12 | tuple. That would require type inference, which we don't do. Let 13 | Python 2.6 figure it out. 14 | """ 15 | 16 | # Local imports 17 | from ..pgen2 import token 18 | from .. import fixer_base 19 | from ..fixer_util import Name, Call, ListComp, in_special_context 20 | 21 | class FixFilter(fixer_base.ConditionalFix): 22 | BM_compatible = True 23 | 24 | PATTERN = """ 25 | filter_lambda=power< 26 | 'filter' 27 | trailer< 28 | '(' 29 | arglist< 30 | lambdef< 'lambda' 31 | (fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any 32 | > 33 | ',' 34 | it=any 35 | > 36 | ')' 37 | > 38 | > 39 | | 40 | power< 41 | 'filter' 42 | trailer< '(' arglist< none='None' ',' seq=any > ')' > 43 | > 44 | | 45 | power< 46 | 'filter' 47 | args=trailer< '(' [any] ')' > 48 | > 49 | """ 50 | 51 | skip_on = "future_builtins.filter" 52 | 53 | def transform(self, node, results): 54 | if self.should_skip(node): 55 | return 56 | 57 | if "filter_lambda" in results: 58 | new = ListComp(results.get("fp").clone(), 59 | results.get("fp").clone(), 60 | results.get("it").clone(), 61 | results.get("xp").clone()) 62 | 63 | elif "none" in results: 64 | new = ListComp(Name(u"_f"), 65 | Name(u"_f"), 66 | results["seq"].clone(), 67 | Name(u"_f")) 68 | 69 | else: 70 | if in_special_context(node): 71 | return None 72 | new = node.clone() 73 | new.prefix = u"" 74 | new = Call(Name(u"list"), [new]) 75 | new.prefix = node.prefix 76 | return new 77 | -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/ctypes/macholib/framework.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generic framework path manipulation 3 | """ 4 | 5 | import re 6 | 7 | __all__ = ['framework_info'] 8 | 9 | STRICT_FRAMEWORK_RE = re.compile(r"""(?x) 10 | (?P^.*)(?:^|/) 11 | (?P 12 | (?P\w+).framework/ 13 | (?:Versions/(?P[^/]+)/)? 14 | (?P=shortname) 15 | (?:_(?P[^_]+))? 16 | )$ 17 | """) 18 | 19 | def framework_info(filename): 20 | """ 21 | A framework name can take one of the following four forms: 22 | Location/Name.framework/Versions/SomeVersion/Name_Suffix 23 | Location/Name.framework/Versions/SomeVersion/Name 24 | Location/Name.framework/Name_Suffix 25 | Location/Name.framework/Name 26 | 27 | returns None if not found, or a mapping equivalent to: 28 | dict( 29 | location='Location', 30 | name='Name.framework/Versions/SomeVersion/Name_Suffix', 31 | shortname='Name', 32 | version='SomeVersion', 33 | suffix='Suffix', 34 | ) 35 | 36 | Note that SomeVersion and Suffix are optional and may be None 37 | if not present 38 | """ 39 | is_framework = STRICT_FRAMEWORK_RE.match(filename) 40 | if not is_framework: 41 | return None 42 | return is_framework.groupdict() 43 | 44 | def test_framework_info(): 45 | def d(location=None, name=None, shortname=None, version=None, suffix=None): 46 | return dict( 47 | location=location, 48 | name=name, 49 | shortname=shortname, 50 | version=version, 51 | suffix=suffix 52 | ) 53 | assert framework_info('completely/invalid') is None 54 | assert framework_info('completely/invalid/_debug') is None 55 | assert framework_info('P/F.framework') is None 56 | assert framework_info('P/F.framework/_debug') is None 57 | assert framework_info('P/F.framework/F') == d('P', 'F.framework/F', 'F') 58 | assert framework_info('P/F.framework/F_debug') == d('P', 'F.framework/F_debug', 'F', suffix='debug') 59 | assert framework_info('P/F.framework/Versions') is None 60 | assert framework_info('P/F.framework/Versions/A') is None 61 | assert framework_info('P/F.framework/Versions/A/F') == d('P', 'F.framework/Versions/A/F', 'F', 'A') 62 | assert framework_info('P/F.framework/Versions/A/F_debug') == d('P', 'F.framework/Versions/A/F_debug', 'F', 'A', 'debug') 63 | 64 | if __name__ == '__main__': 65 | test_framework_info() 66 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/winappdbg/plugins/do_exchain.py: -------------------------------------------------------------------------------- 1 | #!~/.wine/drive_c/Python25/python.exe 2 | # -*- coding: utf-8 -*- 3 | 4 | # Command line debugger using WinAppDbg 5 | # Show exception handlers list 6 | # Copyright (c) 2009-2014, Mario Vilas 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright notice, 13 | # this list of conditions and the following disclaimer. 14 | # * Redistributions in binary form must reproduce the above copyright 15 | # notice,this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # * Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | # POSSIBILITY OF SUCH DAMAGE. 32 | 33 | __revision__ = "$Id$" 34 | 35 | from winappdbg import HexDump, Table 36 | 37 | def do(self, arg): 38 | ".exchain - Show the SEH chain" 39 | thread = self.get_thread_from_prefix() 40 | print "Exception handlers for thread %d" % thread.get_tid() 41 | print 42 | table = Table() 43 | table.addRow("Block", "Function") 44 | bits = thread.get_bits() 45 | for (seh, seh_func) in thread.get_seh_chain(): 46 | if seh is not None: 47 | seh = HexDump.address(seh, bits) 48 | if seh_func is not None: 49 | seh_func = HexDump.address(seh_func, bits) 50 | table.addRow(seh, seh_func) 51 | print table.getOutput() 52 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_renames.py: -------------------------------------------------------------------------------- 1 | """Fix incompatible renames 2 | 3 | Fixes: 4 | * sys.maxint -> sys.maxsize 5 | """ 6 | # Author: Christian Heimes 7 | # based on Collin Winter's fix_import 8 | 9 | # Local imports 10 | from .. import fixer_base 11 | from ..fixer_util import Name, attr_chain 12 | 13 | MAPPING = {"sys": {"maxint" : "maxsize"}, 14 | } 15 | LOOKUP = {} 16 | 17 | def alternates(members): 18 | return "(" + "|".join(map(repr, members)) + ")" 19 | 20 | 21 | def build_pattern(): 22 | #bare = set() 23 | for module, replace in MAPPING.items(): 24 | for old_attr, new_attr in replace.items(): 25 | LOOKUP[(module, old_attr)] = new_attr 26 | #bare.add(module) 27 | #bare.add(old_attr) 28 | #yield """ 29 | # import_name< 'import' (module=%r 30 | # | dotted_as_names< any* module=%r any* >) > 31 | # """ % (module, module) 32 | yield """ 33 | import_from< 'from' module_name=%r 'import' 34 | ( attr_name=%r | import_as_name< attr_name=%r 'as' any >) > 35 | """ % (module, old_attr, old_attr) 36 | yield """ 37 | power< module_name=%r trailer< '.' attr_name=%r > any* > 38 | """ % (module, old_attr) 39 | #yield """bare_name=%s""" % alternates(bare) 40 | 41 | 42 | class FixRenames(fixer_base.BaseFix): 43 | BM_compatible = True 44 | PATTERN = "|".join(build_pattern()) 45 | 46 | order = "pre" # Pre-order tree traversal 47 | 48 | # Don't match the node if it's within another match 49 | def match(self, node): 50 | match = super(FixRenames, self).match 51 | results = match(node) 52 | if results: 53 | if any(match(obj) for obj in attr_chain(node, "parent")): 54 | return False 55 | return results 56 | return False 57 | 58 | #def start_tree(self, tree, filename): 59 | # super(FixRenames, self).start_tree(tree, filename) 60 | # self.replace = {} 61 | 62 | def transform(self, node, results): 63 | mod_name = results.get("module_name") 64 | attr_name = results.get("attr_name") 65 | #bare_name = results.get("bare_name") 66 | #import_mod = results.get("module") 67 | 68 | if mod_name and attr_name: 69 | new_attr = unicode(LOOKUP[(mod_name.value, attr_name.value)]) 70 | attr_name.replace(Name(new_attr, prefix=attr_name.prefix)) 71 | -------------------------------------------------------------------------------- /lib/pydev_ipython/qt_for_kernel.py: -------------------------------------------------------------------------------- 1 | """ Import Qt in a manner suitable for an IPython kernel. 2 | 3 | This is the import used for the `gui=qt` or `matplotlib=qt` initialization. 4 | 5 | Import Priority: 6 | 7 | if Qt4 has been imported anywhere else: 8 | use that 9 | 10 | if matplotlib has been imported and doesn't support v2 (<= 1.0.1): 11 | use PyQt4 @v1 12 | 13 | Next, ask ETS' QT_API env variable 14 | 15 | if QT_API not set: 16 | ask matplotlib via rcParams['backend.qt4'] 17 | if it said PyQt: 18 | use PyQt4 @v1 19 | elif it said PySide: 20 | use PySide 21 | 22 | else: (matplotlib said nothing) 23 | # this is the default path - nobody told us anything 24 | try: 25 | PyQt @v1 26 | except: 27 | fallback on PySide 28 | else: 29 | use PyQt @v2 or PySide, depending on QT_API 30 | because ETS doesn't work with PyQt @v1. 31 | 32 | """ 33 | 34 | import os 35 | import sys 36 | 37 | from pydev_ipython.version import check_version 38 | from pydev_ipython.qt_loaders import (load_qt, QT_API_PYSIDE, 39 | QT_API_PYQT, QT_API_PYQT_DEFAULT, 40 | loaded_api) 41 | 42 | #Constraints placed on an imported matplotlib 43 | def matplotlib_options(mpl): 44 | if mpl is None: 45 | return 46 | mpqt = mpl.rcParams.get('backend.qt4', None) 47 | if mpqt is None: 48 | return None 49 | if mpqt.lower() == 'pyside': 50 | return [QT_API_PYSIDE] 51 | elif mpqt.lower() == 'pyqt4': 52 | return [QT_API_PYQT_DEFAULT] 53 | raise ImportError("unhandled value for backend.qt4 from matplotlib: %r" % 54 | mpqt) 55 | 56 | def get_options(): 57 | """Return a list of acceptable QT APIs, in decreasing order of 58 | preference 59 | """ 60 | #already imported Qt somewhere. Use that 61 | loaded = loaded_api() 62 | if loaded is not None: 63 | return [loaded] 64 | 65 | mpl = sys.modules.get('matplotlib', None) 66 | 67 | if mpl is not None and not check_version(mpl.__version__, '1.0.2'): 68 | #1.0.1 only supports PyQt4 v1 69 | return [QT_API_PYQT_DEFAULT] 70 | 71 | if os.environ.get('QT_API', None) is None: 72 | #no ETS variable. Ask mpl, then use either 73 | return matplotlib_options(mpl) or [QT_API_PYQT_DEFAULT, QT_API_PYSIDE] 74 | 75 | #ETS variable present. Will fallback to external.qt 76 | return None 77 | 78 | api_opts = get_options() 79 | if api_opts is not None: 80 | QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts) 81 | 82 | else: # use ETS variable 83 | from pydev_ipython.qt import QtCore, QtGui, QtSvg, QT_API 84 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_exitfunc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Convert use of sys.exitfunc to use the atexit module. 3 | """ 4 | 5 | # Author: Benjamin Peterson 6 | 7 | from lib2to3 import pytree, fixer_base 8 | from lib2to3.fixer_util import Name, Attr, Call, Comma, Newline, syms 9 | 10 | 11 | class FixExitfunc(fixer_base.BaseFix): 12 | keep_line_order = True 13 | BM_compatible = True 14 | 15 | PATTERN = """ 16 | ( 17 | sys_import=import_name<'import' 18 | ('sys' 19 | | 20 | dotted_as_names< (any ',')* 'sys' (',' any)* > 21 | ) 22 | > 23 | | 24 | expr_stmt< 25 | power< 'sys' trailer< '.' 'exitfunc' > > 26 | '=' func=any > 27 | ) 28 | """ 29 | 30 | def __init__(self, *args): 31 | super(FixExitfunc, self).__init__(*args) 32 | 33 | def start_tree(self, tree, filename): 34 | super(FixExitfunc, self).start_tree(tree, filename) 35 | self.sys_import = None 36 | 37 | def transform(self, node, results): 38 | # First, find a the sys import. We'll just hope it's global scope. 39 | if "sys_import" in results: 40 | if self.sys_import is None: 41 | self.sys_import = results["sys_import"] 42 | return 43 | 44 | func = results["func"].clone() 45 | func.prefix = u"" 46 | register = pytree.Node(syms.power, 47 | Attr(Name(u"atexit"), Name(u"register")) 48 | ) 49 | call = Call(register, [func], node.prefix) 50 | node.replace(call) 51 | 52 | if self.sys_import is None: 53 | # That's interesting. 54 | self.warning(node, "Can't find sys import; Please add an atexit " 55 | "import at the top of your file.") 56 | return 57 | 58 | # Now add an atexit import after the sys import. 59 | names = self.sys_import.children[1] 60 | if names.type == syms.dotted_as_names: 61 | names.append_child(Comma()) 62 | names.append_child(Name(u"atexit", u" ")) 63 | else: 64 | containing_stmt = self.sys_import.parent 65 | position = containing_stmt.children.index(self.sys_import) 66 | stmt_container = containing_stmt.parent 67 | new_import = pytree.Node(syms.import_name, 68 | [Name(u"import"), Name(u"atexit", u" ")] 69 | ) 70 | new = pytree.Node(syms.simple_stmt, [new_import]) 71 | containing_stmt.insert_child(position + 1, Newline()) 72 | containing_stmt.insert_child(position + 2, new) 73 | -------------------------------------------------------------------------------- /lib/third_party/wrapped_for_pydev/ctypes/wintypes.py: -------------------------------------------------------------------------------- 1 | #@PydevCodeAnalysisIgnore 2 | # XXX This module needs cleanup. 3 | 4 | from ctypes import * 5 | 6 | DWORD = c_ulong 7 | WORD = c_ushort 8 | BYTE = c_byte 9 | 10 | ULONG = c_ulong 11 | LONG = c_long 12 | 13 | LARGE_INTEGER = c_longlong 14 | ULARGE_INTEGER = c_ulonglong 15 | 16 | 17 | HANDLE = c_ulong # in the header files: void * 18 | 19 | HWND = HANDLE 20 | HDC = HANDLE 21 | HMODULE = HANDLE 22 | HINSTANCE = HANDLE 23 | HRGN = HANDLE 24 | HTASK = HANDLE 25 | HKEY = HANDLE 26 | HPEN = HANDLE 27 | HGDIOBJ = HANDLE 28 | HMENU = HANDLE 29 | 30 | LCID = DWORD 31 | 32 | WPARAM = c_uint 33 | LPARAM = c_long 34 | 35 | BOOL = c_long 36 | VARIANT_BOOL = c_short 37 | 38 | LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p 39 | LPCWSTR = LPWSTR = c_wchar_p 40 | 41 | LPCSTR = LPSTR = c_char_p 42 | 43 | class RECT(Structure): 44 | _fields_ = [("left", c_long), 45 | ("top", c_long), 46 | ("right", c_long), 47 | ("bottom", c_long)] 48 | RECTL = RECT 49 | 50 | class POINT(Structure): 51 | _fields_ = [("x", c_long), 52 | ("y", c_long)] 53 | POINTL = POINT 54 | 55 | class SIZE(Structure): 56 | _fields_ = [("cx", c_long), 57 | ("cy", c_long)] 58 | SIZEL = SIZE 59 | 60 | def RGB(red, green, blue): 61 | return red + (green << 8) + (blue << 16) 62 | 63 | class FILETIME(Structure): 64 | _fields_ = [("dwLowDateTime", DWORD), 65 | ("dwHighDateTime", DWORD)] 66 | 67 | class MSG(Structure): 68 | _fields_ = [("hWnd", HWND), 69 | ("message", c_uint), 70 | ("wParam", WPARAM), 71 | ("lParam", LPARAM), 72 | ("time", DWORD), 73 | ("pt", POINT)] 74 | MAX_PATH = 260 75 | 76 | class WIN32_FIND_DATAA(Structure): 77 | _fields_ = [("dwFileAttributes", DWORD), 78 | ("ftCreationTime", FILETIME), 79 | ("ftLastAccessTime", FILETIME), 80 | ("ftLastWriteTime", FILETIME), 81 | ("nFileSizeHigh", DWORD), 82 | ("nFileSizeLow", DWORD), 83 | ("dwReserved0", DWORD), 84 | ("dwReserved1", DWORD), 85 | ("cFileName", c_char * MAX_PATH), 86 | ("cAlternameFileName", c_char * 14)] 87 | 88 | class WIN32_FIND_DATAW(Structure): 89 | _fields_ = [("dwFileAttributes", DWORD), 90 | ("ftCreationTime", FILETIME), 91 | ("ftLastAccessTime", FILETIME), 92 | ("ftLastWriteTime", FILETIME), 93 | ("nFileSizeHigh", DWORD), 94 | ("nFileSizeLow", DWORD), 95 | ("dwReserved0", DWORD), 96 | ("dwReserved1", DWORD), 97 | ("cFileName", c_wchar * MAX_PATH), 98 | ("cAlternameFileName", c_wchar * 14)] 99 | -------------------------------------------------------------------------------- /lib/pydev_ipython_console.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from pydev_console_utils import BaseInterpreterInterface 3 | 4 | import os 5 | 6 | os.environ['TERM'] = 'emacs' #to use proper page_more() for paging 7 | 8 | 9 | # Uncomment to force PyDev standard shell. 10 | # raise ImportError() 11 | 12 | from pydev_ipython_console_011 import get_pydev_frontend 13 | 14 | #======================================================================================================================= 15 | # InterpreterInterface 16 | #======================================================================================================================= 17 | class InterpreterInterface(BaseInterpreterInterface): 18 | ''' 19 | The methods in this class should be registered in the xml-rpc server. 20 | ''' 21 | 22 | def __init__(self, host, client_port, mainThread, show_banner=True): 23 | BaseInterpreterInterface.__init__(self, mainThread) 24 | self.client_port = client_port 25 | self.host = host 26 | self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner) 27 | self._input_error_printed = False 28 | self.notification_succeeded = False 29 | self.notification_tries = 0 30 | self.notification_max_tries = 3 31 | 32 | self.notify_about_magic() 33 | 34 | def get_greeting_msg(self): 35 | return self.interpreter.get_greeting_msg() 36 | 37 | def doAddExec(self, codeFragment): 38 | self.notify_about_magic() 39 | if (codeFragment.text.rstrip().endswith('??')): 40 | print('IPython-->') 41 | try: 42 | res = bool(self.interpreter.addExec(codeFragment.text)) 43 | finally: 44 | if (codeFragment.text.rstrip().endswith('??')): 45 | print('<--IPython') 46 | 47 | return res 48 | 49 | 50 | def getNamespace(self): 51 | return self.interpreter.getNamespace() 52 | 53 | 54 | def getCompletions(self, text, act_tok): 55 | return self.interpreter.getCompletions(text, act_tok) 56 | 57 | def close(self): 58 | sys.exit(0) 59 | 60 | 61 | def notify_about_magic(self): 62 | if not self.notification_succeeded: 63 | self.notification_tries+=1 64 | if self.notification_tries>self.notification_max_tries: 65 | return 66 | completions = self.getCompletions("%", "%") 67 | magic_commands = [x[0] for x in completions] 68 | 69 | server = self.get_server() 70 | 71 | if server is not None: 72 | try: 73 | server.NotifyAboutMagic(magic_commands, self.interpreter.is_automagic()) 74 | self.notification_succeeded = True 75 | except : 76 | self.notification_succeeded = False 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /lib/tests_python/test_save_locals.py: -------------------------------------------------------------------------------- 1 | import inspect 2 | import sys 3 | import unittest 4 | 5 | from pydevd_save_locals import save_locals 6 | 7 | 8 | def use_save_locals(name, value): 9 | """ 10 | Attempt to set the local of the given name to value, using locals_to_fast. 11 | """ 12 | frame = inspect.currentframe().f_back 13 | locals_dict = frame.f_locals 14 | locals_dict[name] = value 15 | 16 | save_locals(frame) 17 | 18 | 19 | def check_method(fn): 20 | """ 21 | A harness for testing methods that attempt to modify the values of locals on the stack. 22 | """ 23 | x = 1 24 | 25 | # The method 'fn' should attempt to set x = 2 in the current frame. 26 | fn('x', 2) 27 | 28 | return x 29 | 30 | 31 | 32 | class TestSetLocals(unittest.TestCase): 33 | """ 34 | Test setting locals in one function from another function using several approaches. 35 | """ 36 | 37 | 38 | def test_set_locals_using_save_locals(self): 39 | x = check_method(use_save_locals) 40 | self.assertEqual(x, 2) # Expected to succeed 41 | 42 | 43 | def test_frame_simple_change(self): 44 | frame = sys._getframe() 45 | a = 20 46 | frame.f_locals['a'] = 50 47 | save_locals(frame) 48 | self.assertEquals(50, a) 49 | 50 | 51 | def test_frame_co_freevars(self): 52 | 53 | outer_var = 20 54 | 55 | def func(): 56 | frame = sys._getframe() 57 | frame.f_locals['outer_var'] = 50 58 | save_locals(frame) 59 | self.assertEquals(50, outer_var) 60 | 61 | func() 62 | 63 | def test_frame_co_cellvars(self): 64 | 65 | def check_co_vars(a): 66 | frame = sys._getframe() 67 | def function2(): 68 | print(a) 69 | 70 | assert 'a' in frame.f_code.co_cellvars 71 | frame = sys._getframe() 72 | frame.f_locals['a'] = 50 73 | save_locals(frame) 74 | self.assertEquals(50, a) 75 | 76 | check_co_vars(1) 77 | 78 | 79 | def test_frame_change_in_inner_frame(self): 80 | def change(f): 81 | self.assert_(f is not sys._getframe()) 82 | f.f_locals['a']= 50 83 | save_locals(f) 84 | 85 | 86 | frame = sys._getframe() 87 | a = 20 88 | change(frame) 89 | self.assertEquals(50, a) 90 | 91 | 92 | if __name__ == '__main__': 93 | suite = unittest.TestSuite() 94 | # suite.addTest(TestSetLocals('test_set_locals_using_dict')) 95 | # #suite.addTest(Test('testCase10a')) 96 | # unittest.TextTestRunner(verbosity=3).run(suite) 97 | 98 | suite = unittest.makeSuite(TestSetLocals) 99 | unittest.TextTestRunner(verbosity=3).run(suite) 100 | -------------------------------------------------------------------------------- /lib/pydevd_plugin_utils.py: -------------------------------------------------------------------------------- 1 | import types 2 | 3 | import pydev_log 4 | import pydevd_trace_api 5 | from _pydev_imps._pydev_pluginbase import PluginBase 6 | from pydevd_constants import * # @UnusedWildImport 7 | 8 | def load_plugins(package): 9 | plugin_base = PluginBase(package=package) 10 | plugin_source = plugin_base.make_plugin_source(searchpath=[os.path.dirname(os.path.realpath(__file__)) + '/' + package], persist=True) 11 | plugins = [] 12 | for plugin in plugin_source.list_plugins(): 13 | loaded_plugin = None 14 | try: 15 | loaded_plugin = plugin_source.load_plugin(plugin) 16 | except: 17 | pydev_log.error("Failed to load plugin %s" % plugin, True) 18 | if loaded_plugin: 19 | plugins.append(loaded_plugin) 20 | 21 | return plugins 22 | 23 | 24 | def bind_func_to_method(func, obj, method_name): 25 | bound_method = types.MethodType(func, obj) 26 | 27 | setattr(obj, method_name, bound_method) 28 | return bound_method 29 | 30 | 31 | class PluginManager(object): 32 | def __init__(self, main_debugger): 33 | self.plugins = load_plugins('pydevd_plugins') 34 | self.active_plugins = [] 35 | self.main_debugger = main_debugger 36 | self.rebind_methods() 37 | 38 | def add_breakpoint(self, func_name, *args, **kwargs): 39 | # add breakpoint for plugin and remember which plugin to use in tracing 40 | for plugin in self.plugins: 41 | if hasattr(plugin, func_name): 42 | func = getattr(plugin, func_name) 43 | result = func(self, *args, **kwargs) 44 | if result: 45 | self.activate(plugin) 46 | 47 | return result 48 | return None 49 | 50 | def activate(self, plugin): 51 | if plugin not in self.active_plugins: 52 | self.active_plugins.append(plugin) 53 | self.rebind_methods() 54 | 55 | def rebind_methods(self): 56 | if len(self.active_plugins) == 0: 57 | self.bind_functions(pydevd_trace_api, getattr, pydevd_trace_api) 58 | elif len(self.active_plugins) == 1: 59 | self.bind_functions(pydevd_trace_api, getattr, self.active_plugins[0]) 60 | else: 61 | self.bind_functions(pydevd_trace_api, create_dispatch, self.active_plugins) 62 | 63 | def bind_functions(self, interface, function_factory, arg): 64 | for name in dir(interface): 65 | func = function_factory(arg, name) 66 | if type(func) == types.FunctionType: 67 | bind_func_to_method(func, self, name) 68 | 69 | 70 | def create_dispatch(obj, name): 71 | def dispatch(self, *args, **kwargs): 72 | result = None 73 | for p in self.active_plugins: 74 | r = getattr(p, name)(self, *args, **kwargs) 75 | if not result: 76 | result = r 77 | return result 78 | return dispatch 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /lib/pydevd_io.py: -------------------------------------------------------------------------------- 1 | import pydevd_constants #@UnusedImport -- defines False and True if not there. 2 | 3 | IS_PY3K = pydevd_constants.IS_PY3K 4 | 5 | class IORedirector: 6 | '''This class works to redirect the write function to many streams 7 | ''' 8 | 9 | def __init__(self, *args): 10 | self._redirectTo = args 11 | 12 | def write(self, s): 13 | for r in self._redirectTo: 14 | try: 15 | r.write(s) 16 | except: 17 | pass 18 | 19 | def isatty(self): 20 | return False 21 | 22 | def flush(self): 23 | for r in self._redirectTo: 24 | r.flush() 25 | 26 | def __getattr__(self, name): 27 | for r in self._redirectTo: 28 | if hasattr(r, name): 29 | return r.__getattribute__(name) 30 | raise AttributeError(name) 31 | 32 | class IOBuf: 33 | '''This class works as a replacement for stdio and stderr. 34 | It is a buffer and when its contents are requested, it will erase what 35 | 36 | it has so far so that the next return will not return the same contents again. 37 | ''' 38 | def __init__(self): 39 | self.buflist = [] 40 | import os 41 | self.encoding = os.environ.get('PYTHONIOENCODING', 'utf-8') 42 | 43 | def getvalue(self): 44 | b = self.buflist 45 | self.buflist = [] #clear it 46 | return ''.join(b) 47 | 48 | def write(self, s): 49 | if not IS_PY3K: 50 | if isinstance(s, unicode): 51 | s = s.encode(self.encoding) 52 | self.buflist.append(s) 53 | 54 | def isatty(self): 55 | return False 56 | 57 | def flush(self): 58 | pass 59 | 60 | def empty(self): 61 | return len(self.buflist) == 0 62 | 63 | class _RedirectionsHolder: 64 | _stack_stdout = [] 65 | _stack_stderr = [] 66 | 67 | 68 | def StartRedirect(keep_original_redirection=False, std='stdout'): 69 | ''' 70 | @param std: 'stdout', 'stderr', or 'both' 71 | ''' 72 | import sys 73 | buf = IOBuf() 74 | 75 | if std == 'both': 76 | config_stds = ['stdout', 'stderr'] 77 | else: 78 | config_stds = [std] 79 | 80 | for std in config_stds: 81 | original = getattr(sys, std) 82 | stack = getattr(_RedirectionsHolder, '_stack_%s' % std) 83 | stack.append(original) 84 | 85 | if keep_original_redirection: 86 | setattr(sys, std, IORedirector(buf, getattr(sys, std))) 87 | else: 88 | setattr(sys, std, buf) 89 | return buf 90 | 91 | 92 | def EndRedirect(std='stdout'): 93 | import sys 94 | if std == 'both': 95 | config_stds = ['stdout', 'stderr'] 96 | else: 97 | config_stds = [std] 98 | for std in config_stds: 99 | stack = getattr(_RedirectionsHolder, '_stack_%s' % std) 100 | setattr(sys, std, stack.pop()) 101 | 102 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_xrange.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that changes xrange(...) into range(...).""" 5 | 6 | # Local imports 7 | from .. import fixer_base 8 | from ..fixer_util import Name, Call, consuming_calls 9 | from .. import patcomp 10 | 11 | 12 | class FixXrange(fixer_base.BaseFix): 13 | BM_compatible = True 14 | PATTERN = """ 15 | power< 16 | (name='range'|name='xrange') trailer< '(' args=any ')' > 17 | rest=any* > 18 | """ 19 | 20 | def start_tree(self, tree, filename): 21 | super(FixXrange, self).start_tree(tree, filename) 22 | self.transformed_xranges = set() 23 | 24 | def finish_tree(self, tree, filename): 25 | self.transformed_xranges = None 26 | 27 | def transform(self, node, results): 28 | name = results["name"] 29 | if name.value == u"xrange": 30 | return self.transform_xrange(node, results) 31 | elif name.value == u"range": 32 | return self.transform_range(node, results) 33 | else: 34 | raise ValueError(repr(name)) 35 | 36 | def transform_xrange(self, node, results): 37 | name = results["name"] 38 | name.replace(Name(u"range", prefix=name.prefix)) 39 | # This prevents the new range call from being wrapped in a list later. 40 | self.transformed_xranges.add(id(node)) 41 | 42 | def transform_range(self, node, results): 43 | if (id(node) not in self.transformed_xranges and 44 | not self.in_special_context(node)): 45 | range_call = Call(Name(u"range"), [results["args"].clone()]) 46 | # Encase the range call in list(). 47 | list_call = Call(Name(u"list"), [range_call], 48 | prefix=node.prefix) 49 | # Put things that were after the range() call after the list call. 50 | for n in results["rest"]: 51 | list_call.append_child(n) 52 | return list_call 53 | 54 | P1 = "power< func=NAME trailer< '(' node=any ')' > any* >" 55 | p1 = patcomp.compile_pattern(P1) 56 | 57 | P2 = """for_stmt< 'for' any 'in' node=any ':' any* > 58 | | comp_for< 'for' any 'in' node=any any* > 59 | | comparison< any 'in' node=any any*> 60 | """ 61 | p2 = patcomp.compile_pattern(P2) 62 | 63 | def in_special_context(self, node): 64 | if node.parent is None: 65 | return False 66 | results = {} 67 | if (node.parent.parent is not None and 68 | self.p1.match(node.parent.parent, results) and 69 | results["node"] is node): 70 | # list(d.keys()) -> list(d.keys()), etc. 71 | return results["func"].value in consuming_calls 72 | # for ... in d.iterkeys() -> for ... in d.keys(), etc. 73 | return self.p2.match(node.parent, results) and results["node"] is node 74 | -------------------------------------------------------------------------------- /lib/pydev_imports.py: -------------------------------------------------------------------------------- 1 | from pydevd_constants import USE_LIB_COPY, izip 2 | 3 | 4 | try: 5 | try: 6 | if USE_LIB_COPY: 7 | from _pydev_imps import _pydev_xmlrpclib as xmlrpclib 8 | else: 9 | import xmlrpclib 10 | except ImportError: 11 | import xmlrpc.client as xmlrpclib 12 | except ImportError: 13 | from _pydev_imps import _pydev_xmlrpclib as xmlrpclib 14 | 15 | 16 | try: 17 | try: 18 | if USE_LIB_COPY: 19 | from _pydev_imps._pydev_SimpleXMLRPCServer import SimpleXMLRPCServer 20 | else: 21 | from SimpleXMLRPCServer import SimpleXMLRPCServer 22 | except ImportError: 23 | from xmlrpc.server import SimpleXMLRPCServer 24 | except ImportError: 25 | from _pydev_imps._pydev_SimpleXMLRPCServer import SimpleXMLRPCServer 26 | 27 | 28 | 29 | try: 30 | from StringIO import StringIO 31 | except ImportError: 32 | from io import StringIO 33 | 34 | 35 | try: 36 | execfile=execfile #Not in Py3k 37 | except NameError: 38 | from _pydev_imps._pydev_execfile import execfile 39 | 40 | 41 | try: 42 | if USE_LIB_COPY: 43 | from _pydev_imps import _pydev_Queue as _queue 44 | else: 45 | import Queue as _queue 46 | except: 47 | import queue as _queue #@UnresolvedImport 48 | 49 | 50 | try: 51 | from pydevd_exec import Exec 52 | except: 53 | from pydevd_exec2 import Exec 54 | 55 | try: 56 | from urllib import quote, quote_plus, unquote_plus 57 | except: 58 | from urllib.parse import quote, quote_plus, unquote_plus #@UnresolvedImport 59 | 60 | 61 | import os 62 | try: 63 | relpath = os.path.relpath 64 | except: 65 | # Only there from 2.6 onwards... let's provide a replacement. 66 | def _split_path(path): 67 | parts = [] 68 | loc = path 69 | 70 | while loc != os.curdir and loc != os.pardir: 71 | prev = loc 72 | loc, child = os.path.split(prev) 73 | if loc == prev: 74 | break 75 | 76 | parts.append(child) 77 | 78 | parts.append(loc) 79 | parts.reverse() 80 | return parts 81 | 82 | def relpath(path, start=None): 83 | if start is None: 84 | start = os.curdir 85 | origin = os.path.abspath(path) 86 | start = os.path.abspath(start) 87 | 88 | orig_list = _split_path(os.path.normcase(origin)) 89 | dest_list = _split_path(start) 90 | 91 | if orig_list[0] != os.path.normcase(dest_list[0]): 92 | return start 93 | 94 | i = 0 95 | for start_seg, dest_seg in izip(orig_list, dest_list): 96 | if start_seg != os.path.normcase(dest_seg): 97 | break 98 | i += 1 99 | 100 | segments = [os.pardir] * (len(orig_list) - i) 101 | segments += dest_list[i:] 102 | if len(segments) == 0: 103 | return os.curdir 104 | else: 105 | return os.path.join(*segments) 106 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/_test_attach_to_process_linux.py: -------------------------------------------------------------------------------- 1 | ''' 2 | This module is just for testing concepts. It should be erased later on. 3 | 4 | Experiments: 5 | 6 | // gdb -p 4957 7 | // call dlopen("/home/fabioz/Desktop/dev/PyDev.Debugger/pydevd_attach_to_process/linux/attach_linux.so", 2) 8 | // call dlsym($1, "hello") 9 | // call hello() 10 | 11 | 12 | // call open("/home/fabioz/Desktop/dev/PyDev.Debugger/pydevd_attach_to_process/linux/attach_linux.so", 2) 13 | // call mmap(0, 6672, 1 | 2 | 4, 1, 3 , 0) 14 | // add-symbol-file 15 | // cat /proc/pid/maps 16 | 17 | // call dlopen("/home/fabioz/Desktop/dev/PyDev.Debugger/pydevd_attach_to_process/linux/attach_linux.so", 1|8) 18 | // call dlsym($1, "hello") 19 | // call hello() 20 | ''' 21 | 22 | import subprocess 23 | import sys 24 | import os 25 | import time 26 | 27 | if __name__ == '__main__': 28 | 29 | linux_dir = os.path.join(os.path.dirname(__file__), 'linux') 30 | os.chdir(linux_dir) 31 | so_location = os.path.join(linux_dir, 'attach_linux.so') 32 | try: 33 | os.remove(so_location) 34 | except: 35 | pass 36 | subprocess.call('g++ -shared -o attach_linux.so -fPIC -nostartfiles attach_linux.c'.split()) 37 | print('Finished compiling') 38 | assert os.path.exists('/home/fabioz/Desktop/dev/PyDev.Debugger/pydevd_attach_to_process/linux/attach_linux.so') 39 | os.chdir(os.path.dirname(linux_dir)) 40 | # import attach_pydevd 41 | # attach_pydevd.main(attach_pydevd.process_command_line(['--pid', str(p.pid)])) 42 | p = subprocess.Popen([sys.executable, '-u', '_always_live_program.py']) 43 | print('Size of file: %s' % (os.stat(so_location).st_size)) 44 | 45 | #(gdb) set architecture 46 | # Requires an argument. Valid arguments are i386, i386:x86-64, i386:x64-32, i8086, i386:intel, i386:x86-64:intel, i386:x64-32:intel, i386:nacl, i386:x86-64:nacl, i386:x64-32:nacl, auto. 47 | 48 | cmd = [ 49 | 'gdb', 50 | '--pid', 51 | str(p.pid), 52 | '--batch', 53 | ] 54 | 55 | arch = 'i386:x86-64' 56 | if arch: 57 | cmd.extend(["--eval-command='set architecture %s'" % arch]) 58 | 59 | cmd.extend([ 60 | "--eval-command='call dlopen(\"/home/fabioz/Desktop/dev/PyDev.Debugger/pydevd_attach_to_process/linux/attach_linux.so\", 2)'", 61 | "--eval-command='call DoAttach(1, \"print(\\\"check11111check\\\")\", 0)'", 62 | #"--eval-command='call SetSysTraceFunc(1, 0)'", -- never call this way, always use "--command='...gdb_threads_settrace.py'", 63 | #So that threads are all stopped! 64 | "--command='/home/fabioz/Desktop/dev/PyDev.Debugger/pydevd_attach_to_process/linux/gdb_threads_settrace.py'", 65 | ]) 66 | 67 | cmd.extend(['--command=/home/fabioz/Desktop/dev/PyDev.Debugger/pydevd_attach_to_process/linux/gdb_threads_settrace.py']) 68 | 69 | 70 | print(' '.join(cmd)) 71 | time.sleep(.5) 72 | env = os.environ.copy() 73 | env.pop('PYTHONIOENCODING', None) 74 | env.pop('PYTHONPATH', None) 75 | p2 = subprocess.call(' '.join(cmd), env=env, shell=True) 76 | 77 | time.sleep(1) 78 | p.kill() 79 | -------------------------------------------------------------------------------- /lib/pydevd_attach_to_process/winappdbg/win32/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Copyright (c) 2009-2014, Mario Vilas 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, 11 | # this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice,this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # * Neither the name of the copyright holder nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | # POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """ 32 | Debugging API wrappers in ctypes. 33 | """ 34 | 35 | __revision__ = "$Id$" 36 | 37 | from winappdbg.win32 import defines 38 | from winappdbg.win32 import kernel32 39 | from winappdbg.win32 import user32 40 | from winappdbg.win32 import advapi32 41 | from winappdbg.win32 import wtsapi32 42 | from winappdbg.win32 import shell32 43 | from winappdbg.win32 import shlwapi 44 | from winappdbg.win32 import psapi 45 | from winappdbg.win32 import dbghelp 46 | from winappdbg.win32 import ntdll 47 | 48 | from winappdbg.win32.defines import * 49 | from winappdbg.win32.kernel32 import * 50 | from winappdbg.win32.user32 import * 51 | from winappdbg.win32.advapi32 import * 52 | from winappdbg.win32.wtsapi32 import * 53 | from winappdbg.win32.shell32 import * 54 | from winappdbg.win32.shlwapi import * 55 | from winappdbg.win32.psapi import * 56 | from winappdbg.win32.dbghelp import * 57 | from winappdbg.win32.ntdll import * 58 | 59 | # This calculates the list of exported symbols. 60 | _all = set() 61 | _all.update(defines._all) 62 | _all.update(kernel32._all) 63 | _all.update(user32._all) 64 | _all.update(advapi32._all) 65 | _all.update(wtsapi32._all) 66 | _all.update(shell32._all) 67 | _all.update(shlwapi._all) 68 | _all.update(psapi._all) 69 | _all.update(dbghelp._all) 70 | _all.update(ntdll._all) 71 | __all__ = [_x for _x in _all if not _x.startswith('_')] 72 | __all__.sort() 73 | -------------------------------------------------------------------------------- /lib/tests/test_pydev_ipython_010.py: -------------------------------------------------------------------------------- 1 | #TODO: This test no longer works (check if it should be fixed or removed altogether). 2 | 3 | #import unittest 4 | #import sys 5 | #import os 6 | ##make it as if we were executing from the directory above this one 7 | #sys.argv[0] = os.path.dirname(sys.argv[0]) 8 | ##twice the dirname to get the previous level from this file. 9 | #sys.path.insert(1, os.path.join(os.path.dirname(sys.argv[0]))) 10 | # 11 | #from pydev_localhost import get_localhost 12 | # 13 | # 14 | #IS_JYTHON = sys.platform.find('java') != -1 15 | # 16 | ##======================================================================================================================= 17 | ## TestCase 18 | ##======================================================================================================================= 19 | #class TestCase(unittest.TestCase): 20 | # 21 | # def setUp(self): 22 | # unittest.TestCase.setUp(self) 23 | # 24 | # def tearDown(self): 25 | # unittest.TestCase.tearDown(self) 26 | # 27 | # def testIPython(self): 28 | # try: 29 | # from pydev_ipython_console import PyDevFrontEnd 30 | # except: 31 | # if IS_JYTHON: 32 | # return 33 | # front_end = PyDevFrontEnd(get_localhost(), 0) 34 | # 35 | # front_end.input_buffer = 'if True:' 36 | # self.assert_(not front_end._on_enter()) 37 | # 38 | # front_end.input_buffer = 'if True:\n' + \ 39 | # front_end.continuation_prompt() + ' a = 10\n' 40 | # self.assert_(not front_end._on_enter()) 41 | # 42 | # 43 | # front_end.input_buffer = 'if True:\n' + \ 44 | # front_end.continuation_prompt() + ' a = 10\n\n' 45 | # self.assert_(front_end._on_enter()) 46 | # 47 | # 48 | ## front_end.input_buffer = ' print a' 49 | ## self.assert_(not front_end._on_enter()) 50 | ## front_end.input_buffer = '' 51 | ## self.assert_(front_end._on_enter()) 52 | # 53 | # 54 | ## front_end.input_buffer = 'a.' 55 | ## front_end.complete_current_input() 56 | ## front_end.input_buffer = 'if True:' 57 | ## front_end._on_enter() 58 | # front_end.input_buffer = 'a = 30' 59 | # front_end._on_enter() 60 | # front_end.input_buffer = 'print a' 61 | # front_end._on_enter() 62 | # front_end.input_buffer = 'a?' 63 | # front_end._on_enter() 64 | # print front_end.complete('%') 65 | # print front_end.complete('%e') 66 | # print front_end.complete('cd c:/t') 67 | # print front_end.complete('cd c:/temp/') 68 | ## front_end.input_buffer = 'print raw_input("press enter\\n")' 69 | ## front_end._on_enter() 70 | ## 71 | # 72 | ##======================================================================================================================= 73 | ## main 74 | ##======================================================================================================================= 75 | #if __name__ == '__main__': 76 | # if sys.platform.find('java') == -1: 77 | # #IPython not available for Jython 78 | # unittest.main() 79 | # else: 80 | # print('not supported on Jython') 81 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_print.py: -------------------------------------------------------------------------------- 1 | # Copyright 2006 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer for print. 5 | 6 | Change: 7 | 'print' into 'print()' 8 | 'print ...' into 'print(...)' 9 | 'print ... ,' into 'print(..., end=" ")' 10 | 'print >>x, ...' into 'print(..., file=x)' 11 | 12 | No changes are applied if print_function is imported from __future__ 13 | 14 | """ 15 | 16 | # Local imports 17 | from .. import patcomp 18 | from .. import pytree 19 | from ..pgen2 import token 20 | from .. import fixer_base 21 | from ..fixer_util import Name, Call, Comma, String, is_tuple 22 | 23 | 24 | parend_expr = patcomp.compile_pattern( 25 | """atom< '(' [atom|STRING|NAME] ')' >""" 26 | ) 27 | 28 | 29 | class FixPrint(fixer_base.BaseFix): 30 | 31 | BM_compatible = True 32 | 33 | PATTERN = """ 34 | simple_stmt< any* bare='print' any* > | print_stmt 35 | """ 36 | 37 | def transform(self, node, results): 38 | assert results 39 | 40 | bare_print = results.get("bare") 41 | 42 | if bare_print: 43 | # Special-case print all by itself 44 | bare_print.replace(Call(Name(u"print"), [], 45 | prefix=bare_print.prefix)) 46 | return 47 | assert node.children[0] == Name(u"print") 48 | args = node.children[1:] 49 | if len(args) == 1 and parend_expr.match(args[0]): 50 | # We don't want to keep sticking parens around an 51 | # already-parenthesised expression. 52 | return 53 | 54 | sep = end = file = None 55 | if args and args[-1] == Comma(): 56 | args = args[:-1] 57 | end = " " 58 | if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, u">>"): 59 | assert len(args) >= 2 60 | file = args[1].clone() 61 | args = args[3:] # Strip a possible comma after the file expression 62 | # Now synthesize a print(args, sep=..., end=..., file=...) node. 63 | l_args = [arg.clone() for arg in args] 64 | if l_args: 65 | l_args[0].prefix = u"" 66 | if sep is not None or end is not None or file is not None: 67 | if sep is not None: 68 | self.add_kwarg(l_args, u"sep", String(repr(sep))) 69 | if end is not None: 70 | self.add_kwarg(l_args, u"end", String(repr(end))) 71 | if file is not None: 72 | self.add_kwarg(l_args, u"file", file) 73 | n_stmt = Call(Name(u"print"), l_args) 74 | n_stmt.prefix = node.prefix 75 | return n_stmt 76 | 77 | def add_kwarg(self, l_nodes, s_kwd, n_expr): 78 | # XXX All this prefix-setting may lose comments (though rarely) 79 | n_expr.prefix = u"" 80 | n_argument = pytree.Node(self.syms.argument, 81 | (Name(s_kwd), 82 | pytree.Leaf(token.EQUAL, u"="), 83 | n_expr)) 84 | if l_nodes: 85 | l_nodes.append(Comma()) 86 | n_argument.prefix = u" " 87 | l_nodes.append(n_argument) 88 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_raise.py: -------------------------------------------------------------------------------- 1 | """Fixer for 'raise E, V, T' 2 | 3 | raise -> raise 4 | raise E -> raise E 5 | raise E, V -> raise E(V) 6 | raise E, V, T -> raise E(V).with_traceback(T) 7 | raise E, None, T -> raise E.with_traceback(T) 8 | 9 | raise (((E, E'), E''), E'''), V -> raise E(V) 10 | raise "foo", V, T -> warns about string exceptions 11 | 12 | 13 | CAVEATS: 14 | 1) "raise E, V" will be incorrectly translated if V is an exception 15 | instance. The correct Python 3 idiom is 16 | 17 | raise E from V 18 | 19 | but since we can't detect instance-hood by syntax alone and since 20 | any client code would have to be changed as well, we don't automate 21 | this. 22 | """ 23 | # Author: Collin Winter 24 | 25 | # Local imports 26 | from .. import pytree 27 | from ..pgen2 import token 28 | from .. import fixer_base 29 | from ..fixer_util import Name, Call, Attr, ArgList, is_tuple 30 | 31 | class FixRaise(fixer_base.BaseFix): 32 | 33 | BM_compatible = True 34 | PATTERN = """ 35 | raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] > 36 | """ 37 | 38 | def transform(self, node, results): 39 | syms = self.syms 40 | 41 | exc = results["exc"].clone() 42 | if exc.type == token.STRING: 43 | msg = "Python 3 does not support string exceptions" 44 | self.cannot_convert(node, msg) 45 | return 46 | 47 | # Python 2 supports 48 | # raise ((((E1, E2), E3), E4), E5), V 49 | # as a synonym for 50 | # raise E1, V 51 | # Since Python 3 will not support this, we recurse down any tuple 52 | # literals, always taking the first element. 53 | if is_tuple(exc): 54 | while is_tuple(exc): 55 | # exc.children[1:-1] is the unparenthesized tuple 56 | # exc.children[1].children[0] is the first element of the tuple 57 | exc = exc.children[1].children[0].clone() 58 | exc.prefix = u" " 59 | 60 | if "val" not in results: 61 | # One-argument raise 62 | new = pytree.Node(syms.raise_stmt, [Name(u"raise"), exc]) 63 | new.prefix = node.prefix 64 | return new 65 | 66 | val = results["val"].clone() 67 | if is_tuple(val): 68 | args = [c.clone() for c in val.children[1:-1]] 69 | else: 70 | val.prefix = u"" 71 | args = [val] 72 | 73 | if "tb" in results: 74 | tb = results["tb"].clone() 75 | tb.prefix = u"" 76 | 77 | e = exc 78 | # If there's a traceback and None is passed as the value, then don't 79 | # add a call, since the user probably just wants to add a 80 | # traceback. See issue #9661. 81 | if val.type != token.NAME or val.value != u"None": 82 | e = Call(exc, args) 83 | with_tb = Attr(e, Name(u'with_traceback')) + [ArgList([tb])] 84 | new = pytree.Node(syms.simple_stmt, [Name(u"raise")] + with_tb) 85 | new.prefix = node.prefix 86 | return new 87 | else: 88 | return pytree.Node(syms.raise_stmt, 89 | [Name(u"raise"), Call(exc, args)], 90 | prefix=node.prefix) 91 | -------------------------------------------------------------------------------- /lib/third_party/pep8/lib2to3/lib2to3/fixes/fix_map.py: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Google, Inc. All Rights Reserved. 2 | # Licensed to PSF under a Contributor Agreement. 3 | 4 | """Fixer that changes map(F, ...) into list(map(F, ...)) unless there 5 | exists a 'from future_builtins import map' statement in the top-level 6 | namespace. 7 | 8 | As a special case, map(None, X) is changed into list(X). (This is 9 | necessary because the semantics are changed in this case -- the new 10 | map(None, X) is equivalent to [(x,) for x in X].) 11 | 12 | We avoid the transformation (except for the special case mentioned 13 | above) if the map() call is directly contained in iter(<>), list(<>), 14 | tuple(<>), sorted(<>), ...join(<>), or for V in <>:. 15 | 16 | NOTE: This is still not correct if the original code was depending on 17 | map(F, X, Y, ...) to go on until the longest argument is exhausted, 18 | substituting None for missing values -- like zip(), it now stops as 19 | soon as the shortest argument is exhausted. 20 | """ 21 | 22 | # Local imports 23 | from ..pgen2 import token 24 | from .. import fixer_base 25 | from ..fixer_util import Name, Call, ListComp, in_special_context 26 | from ..pygram import python_symbols as syms 27 | 28 | class FixMap(fixer_base.ConditionalFix): 29 | BM_compatible = True 30 | 31 | PATTERN = """ 32 | map_none=power< 33 | 'map' 34 | trailer< '(' arglist< 'None' ',' arg=any [','] > ')' > 35 | > 36 | | 37 | map_lambda=power< 38 | 'map' 39 | trailer< 40 | '(' 41 | arglist< 42 | lambdef< 'lambda' 43 | (fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any 44 | > 45 | ',' 46 | it=any 47 | > 48 | ')' 49 | > 50 | > 51 | | 52 | power< 53 | 'map' trailer< '(' [arglist=any] ')' > 54 | > 55 | """ 56 | 57 | skip_on = 'future_builtins.map' 58 | 59 | def transform(self, node, results): 60 | if self.should_skip(node): 61 | return 62 | 63 | if node.parent.type == syms.simple_stmt: 64 | self.warning(node, "You should use a for loop here") 65 | new = node.clone() 66 | new.prefix = u"" 67 | new = Call(Name(u"list"), [new]) 68 | elif "map_lambda" in results: 69 | new = ListComp(results["xp"].clone(), 70 | results["fp"].clone(), 71 | results["it"].clone()) 72 | else: 73 | if "map_none" in results: 74 | new = results["arg"].clone() 75 | else: 76 | if "arglist" in results: 77 | args = results["arglist"] 78 | if args.type == syms.arglist and \ 79 | args.children[0].type == token.NAME and \ 80 | args.children[0].value == "None": 81 | self.warning(node, "cannot convert map(None, ...) " 82 | "with multiple arguments because map() " 83 | "now truncates to the shortest sequence") 84 | return 85 | if in_special_context(node): 86 | return None 87 | new = node.clone() 88 | new.prefix = u"" 89 | new = Call(Name(u"list"), [new]) 90 | new.prefix = node.prefix 91 | return new 92 | -------------------------------------------------------------------------------- /lib/_pydev_xmlrpc_hook.py: -------------------------------------------------------------------------------- 1 | from pydev_imports import SimpleXMLRPCServer 2 | from pydev_ipython.inputhook import get_inputhook, set_return_control_callback 3 | import select 4 | import sys 5 | 6 | select_fn = select.select 7 | if sys.platform.startswith('java'): 8 | select_fn = select.cpython_compatible_select 9 | 10 | class InputHookedXMLRPCServer(SimpleXMLRPCServer): 11 | ''' An XML-RPC Server that can run hooks while polling for new requests. 12 | 13 | This code was designed to work with IPython's inputhook methods and 14 | to allow Debug framework to have a place to run commands during idle 15 | too. 16 | ''' 17 | def __init__(self, *args, **kwargs): 18 | SimpleXMLRPCServer.__init__(self, *args, **kwargs) 19 | # Tell the inputhook mechanisms when control should be returned 20 | set_return_control_callback(self.return_control) 21 | self.debug_hook = None 22 | self.return_control_osc = False 23 | 24 | def return_control(self): 25 | ''' A function that the inputhooks can call (via inputhook.stdin_ready()) to find 26 | out if they should cede control and return ''' 27 | if self.debug_hook: 28 | # Some of the input hooks check return control without doing 29 | # a single operation, so we don't return True on every 30 | # call when the debug hook is in place to allow the GUI to run 31 | # XXX: Eventually the inputhook code will have diverged enough 32 | # from the IPython source that it will be worthwhile rewriting 33 | # it rather than pretending to maintain the old API 34 | self.return_control_osc = not self.return_control_osc 35 | if self.return_control_osc: 36 | return True 37 | r, unused_w, unused_e = select_fn([self], [], [], 0) 38 | return bool(r) 39 | 40 | def setDebugHook(self, debug_hook): 41 | self.debug_hook = debug_hook 42 | 43 | def serve_forever(self): 44 | ''' Serve forever, running defined hooks regularly and when idle. 45 | Does not support shutdown ''' 46 | inputhook = get_inputhook() 47 | while True: 48 | # Block for default 1/2 second when no GUI is in progress 49 | timeout = 0.5 50 | if self.debug_hook: 51 | self.debug_hook() 52 | timeout = 0.1 53 | if inputhook: 54 | try: 55 | inputhook() 56 | # The GUI has given us an opportunity to try receiving, normally 57 | # this happens because the input hook has already polled the 58 | # server has knows something is waiting 59 | timeout = 0.020 60 | except: 61 | inputhook = None 62 | r, unused_w, unused_e = select_fn([self], [], [], timeout) 63 | if self in r: 64 | try: 65 | self._handle_request_noblock() 66 | except AttributeError: 67 | # Older libraries do not support _handle_request_noblock, so fall 68 | # back to the handle_request version 69 | self.handle_request() 70 | # Running the request may have changed the inputhook in use 71 | inputhook = get_inputhook() 72 | 73 | def shutdown(self): 74 | raise NotImplementedError('InputHookedXMLRPCServer does not support shutdown') 75 | --------------------------------------------------------------------------------