From b8c8e49d26d42f2e5fb7e05ec847bad555288c2e Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 4 Apr 2012 12:59:58 +0200 Subject: [PATCH 1/6] Fixed detaching for remote debug. --- .../python/debugger/pydev/RemoteDebugger.java | 20 ++++++++++--------- .../python/debugger/PyDebugProcess.java | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java index 9b248bf87fbf..2e1ab983bc2f 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java @@ -77,15 +77,17 @@ public class RemoteDebugger implements ProcessDebugger { //it is closed in close() method on process termination } - try { - final DebuggerReader reader = new DebuggerReader(); - ApplicationManager.getApplication().executeOnPooledThread(reader); - } - catch (Exception e) { - synchronized (mySocketObject) { - mySocket.close(); + if (myConnected) { + try { + final DebuggerReader reader = new DebuggerReader(); + ApplicationManager.getApplication().executeOnPooledThread(reader); + } + catch (Exception e) { + synchronized (mySocketObject) { + mySocket.close(); + } + throw e; } - throw e; } } @@ -350,7 +352,7 @@ public class RemoteDebugger implements ProcessDebugger { myServerSocket.close(); } catch (IOException e) { - //skip + LOG.warn("Error closing socket", e); } } disconnect(); diff --git a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java index c3b16f8f60d4..98e3c2592d7c 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java @@ -205,6 +205,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr myDebugger.run(); } catch (final Exception e) { + myWaitingForConnection = false; myProcessHandler.destroyProcess(); if (!myClosing) { invokeLater(new Runnable() { From cdeacd941bb70dcf83cc868439604693da989311 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 4 Apr 2012 13:59:28 +0200 Subject: [PATCH 2/6] Fixed path case normalization on remote win with pycharm on unix (PY-4244). --- python/helpers/pydev/pydevd_file_utils.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/python/helpers/pydev/pydevd_file_utils.py b/python/helpers/pydev/pydevd_file_utils.py index 9e65a0036bdf..7840539d46b0 100644 --- a/python/helpers/pydev/pydevd_file_utils.py +++ b/python/helpers/pydev/pydevd_file_utils.py @@ -47,7 +47,7 @@ import sys import traceback -normcase = os.path.normcase + basename = os.path.basename exists = os.path.exists join = os.path.join @@ -78,6 +78,17 @@ NORM_FILENAME_AND_BASE_CONTAINER = {} NORM_FILENAME_TO_SERVER_CONTAINER = {} NORM_FILENAME_TO_CLIENT_CONTAINER = {} + +pycharm_os = None + +def normcase(file): + global pycharm_os + if pycharm_os == 'UNIX': + return file + else: + return os.path.normcase(file) + + def _NormFile(filename): try: return NORM_FILENAME_CONTAINER[filename] @@ -264,6 +275,6 @@ def GetFilenameAndBase(frame): f = frame.f_code.co_filename return GetFileNameAndBaseFromFile(f) -def set_pycharm_os(pycharm_os): - if pycharm_os == 'UNIX': - normcase = lambda x: x \ No newline at end of file +def set_pycharm_os(os): + global pycharm_os + pycharm_os = os From 64138dc3c10cd87d58af6229eabbb4d4af15335d Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Wed, 4 Apr 2012 17:08:51 +0400 Subject: [PATCH 3/6] Skeletons for builtin exceptions should go to the 'exceptions' module (PY-5882, PY-6136) --- python/helpers/generator3.py | 37 ++++++++++++++++------------- python/helpers/required_gen_version | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/python/helpers/generator3.py b/python/helpers/generator3.py index 8005889f13fa..0bf03fe5f2d5 100644 --- a/python/helpers/generator3.py +++ b/python/helpers/generator3.py @@ -24,7 +24,7 @@ but seemingly no one uses them in C extensions yet anyway. # * re.search-bound, ~30% time, in likes of builtins and _gtk with complex docstrings. # None of this can seemingly be easily helped. Maybe there's a simpler and faster parser library? -VERSION = "1.104" # Must be a number-dot-number string, updated with each change that affects generated skeletons +VERSION = "1.105" # Must be a number-dot-number string, updated with each change that affects generated skeletons # Note: DON'T FORGET TO UPDATE! VERSION_CONTROL_HEADER_FORMAT = '# from %s by generator %s' @@ -911,6 +911,7 @@ class ModuleRedeclarator(object): } if version[0] < 3: + PREDEFINED_MOD_CLASS_SIGS[("exceptions", "BaseException", "__unicode__")] = ("(self)", UNICODE_LIT) PREDEFINED_MOD_CLASS_SIGS[("itertools", "product", "__init__")] = ("(self, *iterables, **kwargs)", LIST_LIT) else: PREDEFINED_MOD_CLASS_SIGS[("itertools", "product", "__init__")] = ("(self, *iterables, repeat=1)", LIST_LIT) @@ -936,36 +937,20 @@ class ModuleRedeclarator(object): KNOWN_PROPS = { BUILTIN_MOD_NAME: { ("object", '__class__'): ('r', G_TYPE), - ("BaseException", '__dict__'): ('r', G_DICT), - ("BaseException", 'message'): ('rwd', G_STR), - ("BaseException", 'args'): ('r', G_TUPLE), ('complex', 'real'): ('r', G_FLOAT), ('complex', 'imag'): ('r', G_FLOAT), - ("EnvironmentError", 'errno'): ('rwd', G_INT), - ("EnvironmentError", 'message'): ('rwd', G_STR), - ("EnvironmentError", 'strerror'): ('rwd', G_INT), - ("EnvironmentError", 'filename'): ('rwd', G_STR), ("file", 'softspace'): ('r', G_BOOL), ("file", 'name'): ('r', G_STR), ("file", 'encoding'): ('r', G_STR), ("file", 'mode'): ('r', G_STR), ("file", 'closed'): ('r', G_BOOL), ("file", 'newlines'): ('r', G_STR), - ("SyntaxError", 'text'): ('rwd', G_STR), - ("SyntaxError", 'print_file_and_line'): ('rwd', G_BOOL), - ("SyntaxError", 'filename'): ('rwd', G_STR), - ("SyntaxError", 'lineno'): ('rwd', G_INT), - ("SyntaxError", 'offset'): ('rwd', G_INT), - ("SyntaxError", 'msg'): ('rwd', G_STR), - ("SyntaxError", 'message'): ('rwd', G_STR), ("slice", 'start'): ('r', G_INT), ("slice", 'step'): ('r', G_INT), ("slice", 'stop'): ('r', G_INT), ("super", '__thisclass__'): ('r', G_TYPE), ("super", '__self__'): ('r', G_TYPE), ("super", '__self_class__'): ('r', G_TYPE), - ("SystemExit", 'message'): ('rwd', G_STR), - ("SystemExit", 'code'): ('rwd', G_OBJECT), ("type", '__basicsize__'): ('r', G_INT), ("type", '__itemsize__'): ('r', G_INT), ("type", '__base__'): ('r', G_TYPE), @@ -976,6 +961,24 @@ class ModuleRedeclarator(object): ("type", '__dict__'): ('r', G_DICT), ("type", '__name__'): ('r', G_STR), ("type", '__weakrefoffset__'): ('r', G_INT), + }, + "exceptions": { + ("BaseException", '__dict__'): ('r', G_DICT), + ("BaseException", 'message'): ('rwd', G_STR), + ("BaseException", 'args'): ('r', G_TUPLE), + ("EnvironmentError", 'errno'): ('rwd', G_INT), + ("EnvironmentError", 'message'): ('rwd', G_STR), + ("EnvironmentError", 'strerror'): ('rwd', G_INT), + ("EnvironmentError", 'filename'): ('rwd', G_STR), + ("SyntaxError", 'text'): ('rwd', G_STR), + ("SyntaxError", 'print_file_and_line'): ('rwd', G_BOOL), + ("SyntaxError", 'filename'): ('rwd', G_STR), + ("SyntaxError", 'lineno'): ('rwd', G_INT), + ("SyntaxError", 'offset'): ('rwd', G_INT), + ("SyntaxError", 'msg'): ('rwd', G_STR), + ("SyntaxError", 'message'): ('rwd', G_STR), + ("SystemExit", 'message'): ('rwd', G_STR), + ("SystemExit", 'code'): ('rwd', G_OBJECT), ("UnicodeDecodeError", '__basicsize__'): None, ("UnicodeDecodeError", '__itemsize__'): None, ("UnicodeDecodeError", '__base__'): None, diff --git a/python/helpers/required_gen_version b/python/helpers/required_gen_version index 9a0b0992fe71..41cf1e9cf5ad 100644 --- a/python/helpers/required_gen_version +++ b/python/helpers/required_gen_version @@ -6,7 +6,7 @@ (default) 1.92 # anything not explicitly marked -(built-in) 1.104 # skeletons of all built-in modules are built together +(built-in) 1.105 # skeletons of all built-in modules are built together # Note: modules like itertools, etc are "(built-in)" and are ignored if given separately _fileio 1.101 From b7eaf5045b5f4e6f7349e4ff5c4baad63ab6e6de Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 4 Apr 2012 16:48:30 +0200 Subject: [PATCH 4/6] don't use atexit, causes problems. --- python/helpers/pydev/pydevd.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index f3db4cee36d6..e41eb51c2b33 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -1226,9 +1226,7 @@ def _locked_settrace(host, stdoutToServer, stderrToServer, port, suspend, trace_ except: pass - #sys.exitfunc = exit_hook - import atexit - atexit.register(exit_hook) + sys.exitfunc = exit_hook PyDBCommandThread(debugger).start() From abb6ad98593a44adb65b4a3438110b4145636471 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Wed, 4 Apr 2012 20:08:09 +0400 Subject: [PATCH 5/6] Fixed stub and AST mismatch: don't create stubs for named parameters inside lambda --- .../com/jetbrains/python/psi/PyFileElementType.java | 2 +- .../psi/impl/stubs/PyNamedParameterElementType.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/psi/PyFileElementType.java b/python/src/com/jetbrains/python/psi/PyFileElementType.java index bf7948e2d630..e086ba379c2c 100644 --- a/python/src/com/jetbrains/python/psi/PyFileElementType.java +++ b/python/src/com/jetbrains/python/psi/PyFileElementType.java @@ -44,7 +44,7 @@ public class PyFileElementType extends IStubFileElementType { @Override public int getStubVersion() { - return 42; + return 43; } @Nullable diff --git a/python/src/com/jetbrains/python/psi/impl/stubs/PyNamedParameterElementType.java b/python/src/com/jetbrains/python/psi/impl/stubs/PyNamedParameterElementType.java index 6f6429832d58..a415b71cdff0 100644 --- a/python/src/com/jetbrains/python/psi/impl/stubs/PyNamedParameterElementType.java +++ b/python/src/com/jetbrains/python/psi/impl/stubs/PyNamedParameterElementType.java @@ -67,6 +67,18 @@ public class PyNamedParameterElementType extends PyStubElementType Date: Wed, 4 Apr 2012 21:29:56 +0400 Subject: [PATCH 6/6] Fixed TypeError when skeletons generation fails (PY-5810) --- python/helpers/generator3.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/helpers/generator3.py b/python/helpers/generator3.py index 0bf03fe5f2d5..70babb96d1a8 100644 --- a/python/helpers/generator3.py +++ b/python/helpers/generator3.py @@ -2423,14 +2423,15 @@ def processOne(name, mod_file_name, doing_builtins): subfile.close() except: exctype, value = sys.exc_info()[:2] - msg = "Failed to process %r while %s: %s" % (name, _current_action, str(value)) - report(msg) + msg = "Failed to process %r while %s: %s" + args = name, _current_action, str(value) + report(msg, *args) if outfile is not None and not outfile.closed: outfile.write("# encoding: %s\n" % OUT_ENCODING) outfile.write("# module %s\n" % name) outfile.write(VERSION_CONTROL_HEADER_FORMAT % (mod_file_name, VERSION)) outfile.write("\n\n") - outfile.write("# Skeleton generation error:\n#\n# " + msg + "\n") + outfile.write("# Skeleton generation error:\n#\n# " + (msg % args) + "\n") if debug_mode: if sys.platform == 'cli': traceback.print_exc(file=sys.stderr)