Skip to content

Commit d74c6ee

Browse files
authored
Merge pull request #155 from kbase/sdkdev
Fix python server overquoting
2 parents 8c204c8 + c02cb18 commit d74c6ee

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/main/resources/us/kbase/sdk/templates/python_server.vm.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ class JSONRPCServiceCustom(JSONRPCService):
130130
newerr = JSONServerError()
131131
newerr.trace = traceback.format_exc()
132132
if len(e.args) == 1:
133-
newerr.data = repr(e.args[0])
133+
# repr adds single quotes around string arguments which is not what we want.
134+
if isinstance(e.args[0], str):
135+
# this is pretty much the only case that regularly happens
136+
# not sure if the other two cases happen anywhere in KBase
137+
newerr.data = str(e.args[0])
138+
else:
139+
newerr.data = repr(e.args[0])
134140
else:
135141
newerr.data = repr(e.args)
136142
raise newerr

src/test/java/us/kbase/test/sdk/scripts/TypeGeneratorTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,6 @@ public void testIncludsAndMultiModules2() throws Exception {
326326

327327
@Test
328328
public void testAsyncMethods() throws Exception {
329-
// TODO PYTHONSERVER Revert the change that causes errors to be repr'd rather than
330-
// str'd. Causes extra quotes around the string, which made this
331-
// test fail. Fix Test12.java.properties when done.
332329
// TODO TESTREINSTATEMENT see the comments in test12.spec.properties
333330
int testNum = 12;
334331
File workDir = prepareWorkDir(testNum);

src/test/resources/us/kbase/test/sdk/scripts/Test12.java.properties

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ public class Test12 {
3535
client.throwErrorOnServerSide("Special async error");
3636
Assert.fail("Method shouldn't work because there is an exception on server side");
3737
} catch (Throwable ex) {
38-
// TODO PYTHONSERVER Revert the change that causes errors to be repr'd rather than
39-
// str'd. Causes extra quotes around the string.
40-
String msg = "Special async error";
41-
boolean pass = ex.getMessage().equals(msg) || ex.getMessage().equals("'" + msg + "'");
42-
Assert.assertTrue("See test code for error, sigh", pass);
43-
//Assert.assertEquals("'Special async error'", ex.getMessage());
38+
Assert.assertEquals("Special async error", ex.getMessage());
4439
}
4540
}
4641

0 commit comments

Comments
 (0)