Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for issue #437 #464

Merged
merged 1 commit into from
Feb 19, 2023
Merged

fix for issue #437 #464

merged 1 commit into from
Feb 19, 2023

Conversation

russtoku
Copy link
Contributor

I think I've solved the problem with embedded newline characters in Python source code. All of the examples in dev/python/sandbox.py evaluate correctly. I haven't tried it with other Python files yet. Just wanted to get something working for others to try on their code.

@Olical
Copy link
Owner

Olical commented Feb 19, 2023

So definitely an improvement! Although I've found another edge case 😬 I'm worried there will be many while we have to mess with new lines in any capacity.

def newline_in_function_bug():
    return 'hey\n\n' + "\\n" + '\n' + 'ho'

newline_in_function_bug() # 'hey\n\n\nho'

The \\n should result in a \n being printed inside the string, but not an actual newline, a separate \ and n character if I'm not mistaken? I'll have a look at your changes some more and see if I can add to it to catch this too.

Really I need to actually rewrite the stdio support from the ground up so we can deal with these things in a better way.

@Olical
Copy link
Owner

Olical commented Feb 19, 2023

The output from a plain Python REPL:

>>> def newline_in_function_bug():
...     return 'hey\n\n' + "\\n" + '\n' + 'ho'
... 
>>> newline_in_function_bug()
'hey\n\n\\n\nho'

@Olical
Copy link
Owner

Olical commented Feb 19, 2023

cunning plan

Olical added a commit that referenced this pull request Feb 19, 2023
… REPL, fix various Python code encoding bugs! Success! I think! #464 #437
@Olical Olical merged commit 525420b into Olical:develop Feb 19, 2023
@Olical
Copy link
Owner

Olical commented Feb 19, 2023

Cunning plan, executed. Base64 encode the source in Lua, decode it within the REPL, never deal with encoding issues again. 🚀

We still have two eval styles depending on if you're evaluating an "expression" or not... maybe we can just delete those now and just have the one system?

@russtoku
Copy link
Contributor Author

Awesome! Many thanks!

@russtoku russtoku deleted the develop branch February 20, 2023 00:19
@russtoku russtoku restored the develop branch February 20, 2023 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants