mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 04:30:24 +01:00
extmod/modmarshal: Add new marshal module.
This commit implements a small subset of the CPython `marshal` module. It implements `marshal.dumps()` and `marshal.loads()`, but only supports (un)marshalling code objects at this stage. The semantics match CPython, except that the actual marshalled bytes is not compatible with CPython's marshalled bytes. The module is enabled at the everything level (only on the unix coverage build at this stage). Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
21
tests/extmod/marshal_micropython.py
Normal file
21
tests/extmod/marshal_micropython.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Test the marshal module, MicroPython-specific functionality.
|
||||
|
||||
try:
|
||||
import marshal
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
def test_function_with_children(self):
|
||||
# Can't marshal a function with children (in this case the module has a child function f).
|
||||
code = compile("def f(): pass", "", "exec")
|
||||
with self.assertRaises(ValueError):
|
||||
marshal.dumps(code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user