From a21767d96f4f56ee71cb41853da6167bcd0ee540 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Thu, 22 Sep 2016 15:00:29 +0300 Subject: [PATCH] Debugger refactoring: get rid of "import *" statements --- .../_pydev_bundle/pydev_console_utils.py | 5 ++- .../_pydevd_bundle/pydevd_breakpoints.py | 2 +- .../pydev/_pydevd_bundle/pydevd_comm.py | 32 ++++++++++--------- .../pydev/_pydevd_bundle/pydevd_console.py | 2 +- .../pydev/_pydevd_bundle/pydevd_constants.py | 2 -- .../_pydevd_bundle/pydevd_custom_frames.py | 8 ++--- .../_pydevd_bundle/pydevd_traceproperty.py | 2 +- .../pydev/_pydevd_bundle/pydevd_tracing.py | 2 +- .../pydev/_pydevd_bundle/pydevd_vars.py | 5 ++- .../pydev/_pydevd_bundle/pydevd_xml.py | 2 +- python/helpers/pydev/pydev_run_in_console.py | 6 +++- python/helpers/pydev/pydevd_file_utils.py | 3 +- 12 files changed, 38 insertions(+), 33 deletions(-) diff --git a/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py b/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py index 4ad420baea9a..fccb8b417fb4 100644 --- a/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py +++ b/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py @@ -1,10 +1,13 @@ +import os +import sys +import traceback from _pydev_bundle.pydev_imports import xmlrpclib, _queue, Exec from _pydev_bundle._pydev_calltip_util import get_description from _pydev_imps._pydev_saved_modules import thread from _pydevd_bundle import pydevd_vars from _pydevd_bundle import pydevd_xml from _pydevd_bundle.pydevd_constants import IS_JYTHON -from _pydevd_bundle.pydevd_utils import * # @UnusedWildImport +from _pydevd_bundle.pydevd_utils import to_string # ======================================================================================================================= diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py b/python/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py index 7c1cce196331..c25655086bb3 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py @@ -1,4 +1,4 @@ -from _pydevd_bundle.pydevd_constants import * +from _pydevd_bundle.pydevd_constants import dict_iter_values, IS_PY24 from _pydevd_bundle import pydevd_tracing import sys from _pydev_bundle import pydev_log diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py b/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py index 1c3f2a3ee69a..eae9cc8408ce 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py @@ -64,7 +64,7 @@ from _pydev_imps._pydev_saved_modules import thread from _pydev_imps._pydev_saved_modules import threading from _pydev_imps._pydev_saved_modules import socket from socket import socket, AF_INET, SOCK_STREAM, SHUT_RD, SHUT_WR -from _pydevd_bundle.pydevd_constants import * #@UnusedWildImport +from _pydevd_bundle.pydevd_constants import DebugInfoHolder, dict_contains, get_thread_id, IS_JYTHON, IS_PY2, IS_PY3K, STATE_RUN try: from urllib import quote_plus, unquote, unquote_plus @@ -72,9 +72,11 @@ except: from urllib.parse import quote_plus, unquote, unquote_plus #@Reimport @UnresolvedImport import pydevconsole from _pydevd_bundle import pydevd_vars +from _pydevd_bundle import pydevd_xml from _pydevd_bundle import pydevd_tracing from _pydevd_bundle import pydevd_vm_type import pydevd_file_utils +import sys import traceback from _pydevd_bundle.pydevd_utils import quote_smart as quote, compare_object_attrs, cmp_to_key, to_string from _pydev_bundle import pydev_log @@ -542,7 +544,7 @@ class NetCommandFactory: def _thread_to_xml(self, thread): """ thread information as XML """ - name = pydevd_vars.make_valid_xml_value(thread.getName()) + name = pydevd_xml.make_valid_xml_value(thread.getName()) cmdText = '' % (quote(name), get_thread_id(thread)) return cmdText @@ -558,7 +560,7 @@ class NetCommandFactory: def make_custom_frame_created_message(self, frameId, frameDescription): - frameDescription = pydevd_vars.make_valid_xml_value(frameDescription) + frameDescription = pydevd_xml.make_valid_xml_value(frameDescription) cmdText = '' % (frameDescription, frameId) return NetCommand(CMD_THREAD_CREATE, 0, cmdText) @@ -593,7 +595,7 @@ class NetCommandFactory: v = v[0:MAX_IO_MSG_SIZE] v += '...' - v = pydevd_vars.make_valid_xml_value(quote(v, '/>_= \t')) + v = pydevd_xml.make_valid_xml_value(quote(v, '/>_= \t')) net = NetCommand(str(CMD_WRITE_TO_CONSOLE), 0, '' % (v, ctx)) except: net = self.make_error_message(0, get_exception_traceback_str()) @@ -625,7 +627,7 @@ class NetCommandFactory: """ cmd_text_list = [""] append = cmd_text_list.append - make_valid_xml_value = pydevd_vars.make_valid_xml_value + make_valid_xml_value = pydevd_xml.make_valid_xml_value if message: message = make_valid_xml_value(message) @@ -663,7 +665,7 @@ class NetCommandFactory: #print "line is ", myLine #the variables are all gotten 'on-demand' - #variables = pydevd_vars.frame_vars_to_xml(curr_frame.f_locals) + #variables = pydevd_xml.frame_vars_to_xml(curr_frame.f_locals) variables = '' append('_= \t')) + description = pydevd_xml.make_valid_xml_value(quote(description, '/>_= \t')) description_xml = '' % description cmd = dbg.cmd_factory.make_get_description_message(self.sequence, description_xml) dbg.writer.add_command(cmd) @@ -1188,7 +1190,7 @@ class InternalGetBreakpointException(InternalThreadCommand): try: callstack = "" - makeValid = pydevd_vars.make_valid_xml_value + makeValid = pydevd_xml.make_valid_xml_value for filename, line, methodname, methodobj in self.stacktrace: if file_system_encoding.lower() != "utf-8" and hasattr(filename, "decode"): @@ -1374,7 +1376,7 @@ class InternalConsoleExec(InternalThreadCommand): result = pydevconsole.console_exec(self.thread_id, self.frame_id, self.expression, dbg) xml = "" - xml += pydevd_vars.var_to_xml(result, "") + xml += pydevd_xml.var_to_xml(result, "") xml += "" cmd = dbg.cmd_factory.make_evaluate_expression_message(self.sequence, xml) dbg.writer.add_command(cmd) diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_console.py b/python/helpers/pydev/_pydevd_bundle/pydevd_console.py index b48daae2703a..31ad549a4ce7 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_console.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_console.py @@ -11,7 +11,7 @@ from _pydev_bundle.pydev_override import overrides from _pydevd_bundle import pydevd_save_locals from _pydevd_bundle.pydevd_io import IOBuf from _pydevd_bundle.pydevd_tracing import get_exception_traceback_str -from _pydevd_bundle.pydevd_vars import make_valid_xml_value +from _pydevd_bundle.pydevd_xml import make_valid_xml_value CONSOLE_OUTPUT = "output" CONSOLE_ERROR = "error" diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py index 5ecdaeb85a65..2efae0b8e7ed 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py @@ -138,8 +138,6 @@ if USE_LIB_COPY: protect_libraries_from_patching() -from _pydev_imps._pydev_saved_modules import threading - from _pydev_imps._pydev_saved_modules import thread _nextThreadIdLock = thread.allocate_lock() diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_custom_frames.py b/python/helpers/pydev/_pydevd_bundle/pydevd_custom_frames.py index 79f77fd914ff..b3386f9f0476 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_custom_frames.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_custom_frames.py @@ -1,7 +1,7 @@ -from _pydevd_bundle.pydevd_constants import * #@UnusedWildImport +from _pydevd_bundle.pydevd_constants import dict_pop, get_thread_id, Null from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame -from _pydev_imps._pydev_saved_modules import thread -threadingCurrentThread = threading.currentThread +from _pydev_imps._pydev_saved_modules import thread, threading +import sys DEBUG = False @@ -63,7 +63,7 @@ class CustomFrame: def add_custom_frame(frame, name, thread_id): CustomFramesContainer.custom_frames_lock.acquire() try: - curr_thread_id = get_thread_id(threadingCurrentThread()) + curr_thread_id = get_thread_id(threading.currentThread()) next_id = CustomFramesContainer._next_frame_id = CustomFramesContainer._next_frame_id + 1 # Note: the frame id kept contains an id and thread information on the thread where the frame was added diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_traceproperty.py b/python/helpers/pydev/_pydevd_bundle/pydevd_traceproperty.py index 25d29dc46ad3..a49b8074ae8f 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_traceproperty.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_traceproperty.py @@ -1,7 +1,7 @@ '''For debug purpose we are replacing actual builtin property by the debug property ''' from _pydevd_bundle.pydevd_comm import get_global_debugger -from _pydevd_bundle.pydevd_constants import * #@UnusedWildImport +from _pydevd_bundle.pydevd_constants import DebugInfoHolder, IS_PY3K from _pydevd_bundle import pydevd_tracing #======================================================================================================================= diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_tracing.py b/python/helpers/pydev/_pydevd_bundle/pydevd_tracing.py index c1c5a0fdb939..8027d585b97c 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_tracing.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_tracing.py @@ -1,4 +1,4 @@ -from _pydevd_bundle.pydevd_constants import * #@UnusedWildImport +from _pydevd_bundle.pydevd_constants import get_frame from _pydev_imps._pydev_saved_modules import thread try: diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_vars.py b/python/helpers/pydev/_pydevd_bundle/pydevd_vars.py index c56faea1515c..dd9e7e933d99 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_vars.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_vars.py @@ -2,11 +2,10 @@ resolution/conversion to XML. """ import pickle -from _pydevd_bundle.pydevd_constants import * # @UnusedWildImport -from types import * # @UnusedWildImport +from _pydevd_bundle.pydevd_constants import dict_contains, get_frame, get_thread_id from _pydevd_bundle.pydevd_custom_frames import get_custom_frame -from _pydevd_bundle.pydevd_xml import * +from _pydevd_bundle.pydevd_xml import ExceptionOnEvaluate, get_type, var_to_xml from _pydev_imps._pydev_saved_modules import thread try: diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_xml.py b/python/helpers/pydev/_pydevd_bundle/pydevd_xml.py index 284ab1bac3d4..7c1a87b3c891 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_xml.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_xml.py @@ -2,7 +2,7 @@ from _pydev_bundle import pydev_log import traceback from _pydevd_bundle import pydevd_resolver import sys -from _pydevd_bundle.pydevd_constants import * #@UnusedWildImport +from _pydevd_bundle.pydevd_constants import dict_keys, IS_PY3K, MAXIMUM_VARIABLE_REPRESENTATION_SIZE, RETURN_VALUES_DICT from _pydev_bundle.pydev_imports import quote diff --git a/python/helpers/pydev/pydev_run_in_console.py b/python/helpers/pydev/pydev_run_in_console.py index e16f473b742f..02f90b4c265c 100644 --- a/python/helpers/pydev/pydev_run_in_console.py +++ b/python/helpers/pydev/pydev_run_in_console.py @@ -1,7 +1,11 @@ ''' Entry point module to run a file in the interactive console. ''' -from pydevconsole import * +import os +import sys +from pydevconsole import do_exit, InterpreterInterface, process_exec_queue, start_console_server +from _pydev_bundle.pydev_console_utils import BaseStdIn +from _pydev_imps._pydev_saved_modules import threading from _pydev_bundle import pydev_imports from _pydevd_bundle.pydevd_utils import save_main_module diff --git a/python/helpers/pydev/pydevd_file_utils.py b/python/helpers/pydev/pydevd_file_utils.py index 1cb6f518fc1d..8fc67c16abfc 100644 --- a/python/helpers/pydev/pydevd_file_utils.py +++ b/python/helpers/pydev/pydevd_file_utils.py @@ -41,12 +41,11 @@ -from _pydevd_bundle.pydevd_constants import * #@UnusedWildImport +from _pydevd_bundle.pydevd_constants import IS_PY2, IS_PY3K from _pydev_bundle._pydev_filesystem_encoding import getfilesystemencoding import os.path import sys import traceback -import types os_normcase = os.path.normcase basename = os.path.basename