From 9e88e64777321e045239ce1ab4556372bc034077 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Tue, 19 Apr 2016 16:50:18 +0300 Subject: [PATCH] Minors in pull request #382 (https://github.com/JetBrains/intellij-community/pull/382) --- python/helpers/pydev/pydevd_file_utils.py | 28 ++++++++++--------- .../env/python/PythonDebuggerTest.java | 14 ++-------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/python/helpers/pydev/pydevd_file_utils.py b/python/helpers/pydev/pydevd_file_utils.py index d0237d224745..9c26b8e57949 100644 --- a/python/helpers/pydev/pydevd_file_utils.py +++ b/python/helpers/pydev/pydevd_file_utils.py @@ -73,24 +73,26 @@ PATHS_FROM_ECLIPSE_TO_PYTHON = [] normcase = os_normcase # May be rebound on set_ide_os -import types -str_to_unicode = types.UnicodeType + +CTYPES_AVAILABLE = True +try: + import ctypes +except ImportError: + CTYPES_AVAILABLE = False + + def convert_to_long_pathname(filename): - return filename -if os.name == 'nt': - try: - import ctypes - except ImportError: - pass + if sys.platform != "win32": + return filename else: - def convert_to_long_pathname(filename): + if CTYPES_AVAILABLE: buf = ctypes.create_unicode_buffer(260) GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW - rv = GetLongPathName(str_to_unicode(filename), buf , 260) - if rv == 0 or rv > 260: - return filename - else: + rv = GetLongPathName(types.UnicodeType(filename), buf, 260) + if rv != 0 and rv <= 260: return buf.value.encode(getfilesystemencoding()) + return filename + def norm_case(filename): # `normcase` doesn't lower case on Python 2 for non-English locale, but Java side does it, diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index 2d6364a70f88..beb4510cb1b3 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -544,8 +544,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { public void testWinEggDebug() throws Exception { - if (!SystemInfo.isWindows) - { + if (UsefulTestCase.IS_UNDER_TEAMCITY && !SystemInfo.isWindows) { return; // Only needs to run on windows } runPythonTest(new PyDebuggerTask("/debug", "test_winegg.py") { @@ -580,27 +579,21 @@ public class PythonDebuggerTest extends PyEnvTestCase { public Set getTags() { return ImmutableSet.of("-jython"); //TODO: fix that for Jython if anybody needs it } - - }); } public void testWinLongName() throws Exception { - if (!SystemInfo.isWindows) - { + if (UsefulTestCase.IS_UNDER_TEAMCITY && !SystemInfo.isWindows) { return; // Only needs to run on windows } runPythonTest(new PyDebuggerTask("/debug", "long_n~1.py") { @Override public void before() throws Exception { - String scriptPath = getScriptPath(); String longPath = FileUtil .toSystemDependentName((new File(scriptPath).getCanonicalPath())); LocalFileSystem.getInstance().refreshAndFindFileByPath(longPath); toggleBreakpoint(longPath, 2); - - } @Override @@ -608,7 +601,6 @@ public class PythonDebuggerTest extends PyEnvTestCase { waitForPause(); eval("x").hasValue("10"); resume(); - } @NotNull @@ -616,8 +608,6 @@ public class PythonDebuggerTest extends PyEnvTestCase { public Set getTags() { return ImmutableSet.of("-jython"); //TODO: fix that for Jython if anybody needs it } - - }); }