Skip to content

Using \N after exiting and restarting results in a function signature mismatch #69

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

Closed
treyhunner opened this issue Mar 31, 2022 · 4 comments

Comments

@treyhunner
Copy link

Series of steps which reveal the bug:

  1. Click Start REPL button
  2. Type print("\N{digit nine}") and hit Enter
  3. See that 9 printed out
  4. Type exit() and hit Enter (to exit the process)
  5. Click Start REPL button again
  6. Type print("\N{digit nine}") and hit Enter
  7. Watch the process hang and an error message print to the console (this is the bug)

image

Similar series of working steps (notice no \N{...} was used)

  1. Click Start REPL button
  2. Type print("9") and hit Enter
  3. See that 9 printed out
  4. Type exit() and hit Enter (to exit the process)
  5. Click Start REPL button again
  6. Type print("9") and hint Enter
  7. See that 9 printed out

image


Context

This might seem like a strange bug to care about, but it's causing my Python pastebin site (which now runs Python code in-browser) to fail on some code examples. Specifically the "Run in Browser" button works the first time it's pressed but hangs the second time it's pressed. Here's a page that demonstrates the issue.

@pmp-p
Copy link
Contributor

pmp-p commented Mar 31, 2022

i'm definitively not sure but it could be because of running in inspect mode https://github.com/ethanhs/python-wasm/blob/cef91af7ded9ff456eec633f346e085a9ccb038a/browser-ui/index.js#L22 where the interpreter may still persist after the first exit() and take a different code path for init.

@tiran
Copy link
Collaborator

tiran commented Mar 31, 2022

With some additional magic (-gsource-map linker flag and Chromium C/C++ DWARF extension) I was able to pin point the location. The issue is much more interesting than I initially thought. In fact you have found a bug in CPython.

python.js:219 Uncaught RuntimeError: null function or function signature mismatch
    at _PyUnicode_DecodeUnicodeEscapeInternal (unicodeobject.c:6493:25)
    at decode_unicode_with_escapes (string_parser.c:121:13)
    at _PyPegen_parsestr (string_parser.c:273:1)
    at strings_rule (action_helpers.c:901:20)
    at atom_rule (parser.c:14293:27)
    at primary_rule (parser.c:13916:17)
    at await_primary_rule (parser.c:13666:17)
    at factor_rule (parser.c:13542:29)
    at term_rule (parser.c:13330:17)
    at sum_rule (parser.c:13044:17)

@tiran
Copy link
Collaborator

tiran commented Mar 31, 2022

Fixed in python/cpython#32212

@emmatyping
Copy link
Owner

I can confirm that this is fixed in the live REPL (which now is up to date!)

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

No branches or pull requests

4 participants