Snapshot idea/138.1029 from git://git.jetbrains.org/idea/community.git

Update from idea/138.538 to idea/138.1029

Change-Id: I828f829a968439a99ec67640990c18ff7c9b58ce
diff --git a/python/helpers/packaging_tool.py b/python/helpers/packaging_tool.py
index c66cbcb..9101a16 100644
--- a/python/helpers/packaging_tool.py
+++ b/python/helpers/packaging_tool.py
@@ -21,7 +21,7 @@
 
 
 def usage():
-    sys.stderr.write('Usage: packaging_tool.py <list|install|uninstall|pyvenv>\n')
+    sys.stderr.write('Usage: packaging_tool.py <list|search|install|uninstall|pyvenv>\n')
     sys.stderr.flush()
     exit(ERROR_WRONG_USAGE)
 
@@ -58,6 +58,13 @@
         error_no_pip()
     return pip.main(['install'] + pkgs)
 
+def do_search(pkgs):
+    try:
+        import pip
+    except ImportError:
+        error_no_pip()
+    return pip.main(['search'] + pkgs)
+
 
 def do_uninstall(pkgs):
     try:
@@ -115,6 +122,11 @@
             if len(sys.argv) != 2:
                 usage()
             do_list()
+        elif cmd == 'search':
+            if len(sys.argv) < 2:
+                usage()
+            pkgs = sys.argv[2:]
+            do_search(pkgs)
         elif cmd == 'install':
             if len(sys.argv) < 2:
                 usage()
diff --git a/python/helpers/pycharm_generator_utils/module_redeclarator.py b/python/helpers/pycharm_generator_utils/module_redeclarator.py
index 0e96b9c..3af1961 100644
--- a/python/helpers/pycharm_generator_utils/module_redeclarator.py
+++ b/python/helpers/pycharm_generator_utils/module_redeclarator.py
@@ -120,7 +120,7 @@
         init = None
         try:
             if self.split_modules:
-                mod_path = self.outfile.strip(".py")
+                mod_path = module_to_package_name(self.outfile)
 
                 fname = build_output_name(mod_path, "__init__")
                 init = fopen(fname, "w")
@@ -1093,3 +1093,7 @@
             for mod_name in sorted_no_case(self.hidden_imports.keys()):
                 out(0, 'import ', mod_name, ' as ', self.hidden_imports[mod_name])
             out(0, "") # empty line after group
+
+
+def module_to_package_name(module_name):
+    return re.sub(r"(.*)\.py$", r"\1", module_name)
diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py
index 4a509d0..2077903 100644
--- a/python/helpers/pydev/pydevd.py
+++ b/python/helpers/pydev/pydevd.py
@@ -814,7 +814,7 @@
                         del self.exception_set[exception]
                         self.always_exception_set.remove(exception)
                     except:
-                        pydev_log.debug("Error while removing exception"%sys.exc_info()[0]);
+                        pydev_log.debug("Error while removing exception %s"%sys.exc_info()[0]);
                     update_exception_hook(self)
 
                 elif cmd_id == CMD_LOAD_SOURCE: