mathialo / bython

Python with braces. Because python is awesome, but whitespace is awful.
MIT License
2.13k stars 54 forks source link

Curly brackets #24

Open marqroldan opened 6 years ago

marqroldan commented 6 years ago

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!

mathialo commented 6 years ago

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.

Aareon commented 6 years ago

Looks like a non-issue following the edit @hyvraine

mathialo commented 6 years ago

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.

marqroldan commented 6 years ago

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.

mathialo commented 6 years ago

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.