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

[Bug] Import does not work in V3.2 release for some scripts #873

Closed
laurensvalk opened this issue Dec 22, 2022 · 4 comments
Closed

[Bug] Import does not work in V3.2 release for some scripts #873

laurensvalk opened this issue Dec 22, 2022 · 4 comments
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime)

Comments

@laurensvalk
Copy link
Member

Describe the bug
Importing does not work in some cases. I found a reproducible case that appears to hinge on async appearing somewhere in the code, even if it isn't used.

The following reproduces it always in Pybricks Code:

my_module.py

data = 123

my_main.py

from my_module import data

async def hello():
    print("hello")

print(data)

Running the latter gives

ImportError: no module named 'my_module'
@laurensvalk laurensvalk added bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) labels Dec 22, 2022
@dlech
Copy link
Member

dlech commented Dec 22, 2022

Any errors in the browser console? Does it work with pybricksdev?

@laurensvalk
Copy link
Member Author

No errors in console. Pybricksdev test is scheduled for Friday.

@dlech
Copy link
Member

dlech commented Dec 22, 2022

Apparently errors for this are only enabled in development builds. I get this error in the console:

Error: Parse error on line 3:
... import dataasync def hello():    pri
---------------------^
Expecting 'NEWLINE', '(', ')', ':', ',', '=', '*', '**', ';', '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '**=', '//=', 'from', '.', 'as', 'if', 'else', 'for', 'in', 'or', 'and', 'not', '<', '>', '==', '>=', '<=', '!=', 'is', '|', '^', '&', '<<', '>>', '+', '-', '/', '%', '//', '[', ']', '}', got 'def'
    at Parser.parseError (python3.js:603:1)
    at Parser.parse (python3.js:670:1)
    at exports.parse (python3.js:1256:1)
    at parse (python-parser.ts:30:1)
    at findImportedModules (lib.ts:86:1)
    at handleCompileMulti6 (sagas.ts:151:1)
    at handleCompileMulti6.next (<anonymous>)
    at next (redux-saga-core.esm.js:1157:1)
    at currCb (redux-saga-core.esm.js:1251:1)
    at takeCb (redux-saga-core.esm.js:503:1)

I guess the parsing library we are using has a problem with async syntax?

dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 22, 2022
This makes it easier for users to diagnose errors.

Issue: pybricks/support#873
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 22, 2022
The package we were using was only for Python 3.4 and didn't include
async/await which broke imports in any script that used async/await.

Fixes: pybricks/support#873
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 22, 2022
This makes it easier for users to diagnose errors.

Issue: pybricks/support#873
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 22, 2022
The package we were using was only for Python 3.4 and didn't include
async/await which broke imports in any script that used async/await.

Fixes: pybricks/support#873
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 22, 2022
This makes it easier for users to diagnose errors.

Issue: pybricks/support#873
@dlech
Copy link
Member

dlech commented Dec 22, 2022

It turns out the parser library we are using in Pybricks Code was developed against Python 3.4, so any newer Python features supported by MicroPython need to be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime)
Projects
None yet
Development

No branches or pull requests

2 participants