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

datetime.strptime becomes None after first run in WASM environment #101026

Closed
treyhunner opened this issue Jan 14, 2023 · 4 comments
Closed

datetime.strptime becomes None after first run in WASM environment #101026

treyhunner opened this issue Jan 14, 2023 · 4 comments
Labels
OS-wasi type-bug An unexpected behavior, bug, or error

Comments

@treyhunner
Copy link
Member

Bug report

The following code runs correctly the first time but then complains that datetime.strptime is of type NoneType the second time the code is run within the same browser session.

"""Demonstrates WASM issue with datetime.strptime."""
from datetime import datetime

print(datetime.strptime("2023-01-13", "%Y-%m-%d"))
print(datetime.strptime("2023-01-13", "%Y-%m-%d"))

Live example here: https://pym.dev/p/2g6wn/

Note that running datetime.strptime twice doesn't cause an issue. The issue seems to be due to exiting Python and then re-entering it. For example in an interactive session, one would need to call exit() and then start the interactive session again in the same browser window (example here).

>>> from datetime import datetime
>>> datetime.strptime("2023", "%Y")
datetime.datetime(2023, 1, 1, 0, 0)
>>> exit()  # The REPL is automatically re-entered after this
>>> from datetime import datetime
>>> datetime.strptime("2023", "%Y")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable

Your environment

CPython 3.11.0 compiled to Emscripten for the browser.

@treyhunner treyhunner added the type-bug An unexpected behavior, bug, or error label Jan 14, 2023
@brettcannon
Copy link
Member

How are you re-initializing the Python runtime between sessions?

@treyhunner
Copy link
Member Author

To re-initialize I'm posting a run message to the web worker, which calls callMain(event.data.args) again.

@abalkin
Copy link
Member

abalkin commented Feb 9, 2023

This looks like another manifestation of the issue reported at GH-71587.

@brettcannon
Copy link
Member

I think @abalkin is right as to the cause, so I'm closing this as a duplicate.

@brettcannon brettcannon closed this as not planned Won't fix, can't repro, duplicate, stale Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-wasi type-bug An unexpected behavior, bug, or error
Projects
Archived in project
Development

No branches or pull requests

4 participants