bython icon indicating copy to clipboard operation
bython copied to clipboard

Curly brackets

Open marqroldan opened this issue 5 years ago • 5 comments

Hi! I'm not a pro at using Python but there seems to be a parsing error for arguments with Bython I'm trying to pass JSON string as an argument, which works if you use python but breaks when using Bython, the whitespaces and/or the double-quotes in the argument breaks.

sample JSON argument that breaks: '{"1": [1,2]}'

when the output is printed from sys.argv, it becomes {1:[1,2]} thereby breaks the load function of the JSON

EDIT:

The argument above should have backslashes before the double quotes for it to work properly :)

Thanks!

marqroldan avatar Oct 18 '18 03:10 marqroldan

Can you please post a code snippet that exhibits this behavior? :slightly_smiling_face: I can look into it, but I need an example that breaks as I am not too familiar with loading JSON in Python.

mathialo avatar Oct 30 '18 14:10 mathialo

Looks like a non-issue following the edit @hyvraine

Aareon avatar Oct 31 '18 15:10 Aareon

Yeah, I was a bit confused on whether it still has an issue or not. I will close the issue if no further details is provided in a couple of days.

mathialo avatar Nov 01 '18 14:11 mathialo

Apologies for the confusion. I'll close this issue within the day, but is it possible to have Bython accept arguments enclosed with double quotes ignore the double quotes inside it? So there wouldn't be a need to escape the argument. Please let me know how I can help, I'm still new to Python but if you could point me to the right direction (or file) I'll gladly make my own modification and do a PR if everything is working as expected.

P.S. Thank you for creating this wonderful program! Saved me the frustration.

marqroldan avatar Nov 01 '18 23:11 marqroldan

Oh, I think I see the problem now. If the arguments are interpreted differently by bython and python, I would consider it a bug, and escaping characters are simply a workaround.

The parts responsible for executing python files (which is where the arguments are handled) are lines 137 through 158 in scripts/bython. Feel free to look into it yourself, I might do it at some point if I have the time.

mathialo avatar Nov 02 '18 08:11 mathialo