PY-38490 Fix debugging when special symbols are in file path

(cherry picked from commit c69c6d560f47552b736cd530106447de19e85e90)

GitOrigin-RevId: a29879d863e635020caf4322f8378b5789246a93
This commit is contained in:
Andrey Lisin
2019-11-15 16:31:36 +00:00
committed by intellij-monorepo-bot
parent 9abfa7cb67
commit 5997fbedf0
5 changed files with 32 additions and 3 deletions
@@ -734,7 +734,7 @@ class NetCommandFactory:
# Note: variables are all gotten 'on-demand'.
append('<frame id="%s" name="%s" ' % (my_id , make_valid_xml_value(method_name)))
append('file="%s" line="%s">' % (quote(make_valid_xml_value(my_file), '/>_= \t'), lineno))
append('file="%s" line="%s">' % (make_valid_xml_value(my_file), lineno))
append("</frame>")
curr_frame = curr_frame.f_back
except:
@@ -28,7 +28,8 @@ public class ProtocolParser {
if (!"call_signature".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <call_signature>, found " + reader.getNodeName());
}
final String file = readString(reader, "file", "");
String file = reader.getAttribute("file");
if (file == null) file = "";
final String name = readString(reader, "name", "");
PySignature signature = new PySignature(file, name);
@@ -209,7 +210,7 @@ public class ProtocolParser {
final String id = readString(reader, "id", null);
final String name = readString(reader, "name", null);
final String file = readString(reader, "file", null);
final String file = reader.getAttribute("file");
final int line = readInt(reader, "line", 0);
return new PyStackFrameInfo(threadId, id, name, positionConverter.convertPythonToFrame(file, line));
@@ -0,0 +1,4 @@
from __future__ import print_function
x = 42
print("Hello, World")
@@ -188,6 +188,10 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
return convertToList(myDebugProcess.loadFrame());
}
protected PyStackFrame getCurrentStackFrame() {
return (PyStackFrame) myDebugProcess.getSession().getCurrentStackFrame();
}
protected String computeValueAsync(List<PyDebugValue> debugValues, String name) throws PyDebuggerException, InterruptedException {
final PyDebugValue debugValue = findDebugValueByName(debugValues, name);
assert debugValue != null;
@@ -2173,4 +2173,24 @@ public class PythonDebuggerTest extends PyEnvTestCase {
}
});
}
@Test
public void testPathWithAmpersand() {
runPythonTest(new PyDebuggerTask("/debug/", "test_path_with_&.py") {
@Override
public void before() {
toggleBreakpoint(getFilePath(getScriptName()), 3);
}
@Override
public void testing() throws Exception {
waitForPause();
// Source position can be `null` because of troubles while decoding the message from the debugger.
// The troubles can be a result of an unescaped symbol, wrongly encoded message, etc.
assertNotNull(getCurrentStackFrame().getSourcePosition());
resume();
waitForTerminate();
}
});
}
}