Skip to content

Commit

Permalink
CA-184422: Fix json error encapsulation in generated python code
Browse files Browse the repository at this point in the history
If json is parsed, parse_-function should add an element rv['json']=True.
This is required so use_json can be true, as otherwise the json based error
encapsulation never kicks in.

Signed-off-by: Robert Breker <[email protected]>
  • Loading branch information
Robert Breker committed Oct 2, 2015
1 parent 50da866 commit bc2fce0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion generator/src/python.ml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ let commandline_parse env i m =
Line "# in --json mode we don't have any other arguments";
Line "if ('--json' in sys.argv or '-j' in sys.argv):";
Block [
Line "return json.loads(sys.stdin.readline(),)";
Line "jsondict = json.loads(sys.stdin.readline(),)";
Line "jsondict['json'] = True";
Line "return jsondict";
];
Line (sprintf "parser = argparse.ArgumentParser(description='%s')" m.Method.description);
Line "parser.add_argument('-j', '--json', action='store_const', const=True, default=False, help='Read json from stdin, print json to stdout', required=False)";
Expand Down

0 comments on commit bc2fce0

Please sign in to comment.