Giter VIP home page Giter VIP logo

Comments (7)

dpgeorge avatar dpgeorge commented on July 3, 2024

There is currently no memory manager (no garbage collection) for the unix version, so that's why it eats memory. But it's certainly a bug that it runs an infinite loop.

from micropython.

dpgeorge avatar dpgeorge commented on July 3, 2024

Added proper nested exception handling, and basic exception type matching. Above code should now work.

from micropython.

pfalcon avatar pfalcon commented on July 3, 2024

Thanks for quick response, hope it doesn't steal cycles from hardware hacking ;-). (Though this particular issue is important enough, so I really appreciate looking into it).

Well, exception-throwing path now works (including on x86/32bit, will submit patch once cleaned up), but exception-free path leads to:

a = {1:2}
try:
    a[1]
except KeyError:
    print("caught")
./py exc.py 
py: ../py/vm.c:308: mp_execute_byte_code_2: Assertion `0' failed.
Aborted

Corresponding opcode doesn't appear to be implemented.

from micropython.

dpgeorge avatar dpgeorge commented on July 3, 2024

Yep, it's not fully implemented. Micro Python doesn't use reference counting (like CPython) so the action of push/pop blocks in the interpreter is a bit simpler for Micro Python. Thus, the byte code POP_BLOCK is probably only needed when exiting an exception handling block.

from micropython.

dpgeorge avatar dpgeorge commented on July 3, 2024

Okay, it should now work. There will still be issues with "finally" and "with" blocks.

from micropython.

pfalcon avatar pfalcon commented on July 3, 2024

Yes, confirmed working. Let's close and track finally/with somewhere else then. (Note that I didn't try to find which Python features don't work, just read that "It works only for 64-bit machines due to a small piece of x86-64 assembler for
the exception handling.", so after building for x86, I proceeded to test exactly exception handling ;-) ).

from micropython.

dpgeorge avatar dpgeorge commented on July 3, 2024

By "exception handling" I actually meant the underlying C exception handling that I'm using (nlr_jump). You don't see it, but it's working when you get a Python error, eg at the command line just type "foo" and it'll give you a NameError. That's using nlr_jump, written in assembler.

from micropython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.