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

Cannot catch ImportError #244

Open
kj7rrv opened this issue Dec 14, 2020 · 2 comments
Open

Cannot catch ImportError #244

kj7rrv opened this issue Dec 14, 2020 · 2 comments

Comments

@kj7rrv
Copy link

kj7rrv commented Dec 14, 2020

I'm trying to make a Python program that works in both CPython and RapydScript. The code itself works in both, but it currently needs shlex. If I could catch ImportError, I would just wrap "import shlex" in a try-catch and use a custom shlex.split() if that failed, but "try: ... except ImportError: ..." appears to have no effect.

@valq7711
Copy link
Collaborator

Hi!
The problem is that RS imports all at compile time. There is async import, this should help:
#241

@valq7711
Copy link
Collaborator

Also you can just make shim-files like common.py and common.pyj that will import lang-specific modules and then use it as

import common
common.shlex.split(...)

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

2 participants