summaryrefslogtreecommitdiff
path: root/tests/basics/sys1.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-10-30 16:26:11 +1100
committerDamien George <damien.p.george@gmail.com>2019-11-04 16:00:41 +1100
commit80df377e9512ac839ab19192ff1897ba30be098b (patch)
treec71992889747d7db37dcb24135852242d92e4e8d /tests/basics/sys1.py
parentf4601af10a4e1f1a588596ed1bb76cb7578ab726 (diff)
py/modsys: Report .mpy version in sys.implementation.
This commit adds a sys.implementation.mpy entry when the system supports importing .mpy files. This entry is a 16-bit integer which encodes two bytes of information from the header of .mpy files that are supported by the system being run: the second and third bytes, .mpy version, and flags and native architecture. This allows determining the supported .mpy file dynamically by code, and also for the user to find it out by inspecting this value. It's further possible to dynamically detect if the system supports importing .mpy files by `hasattr(sys.implementation, 'mpy')`.
Diffstat (limited to 'tests/basics/sys1.py')
-rw-r--r--tests/basics/sys1.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/basics/sys1.py b/tests/basics/sys1.py
index ab9138024..095824afa 100644
--- a/tests/basics/sys1.py
+++ b/tests/basics/sys1.py
@@ -18,3 +18,9 @@ try:
except AttributeError:
# Effectively skip subtests
print(True)
+
+if hasattr(sys.implementation, 'mpy'):
+ print(type(sys.implementation.mpy))
+else:
+ # Effectively skip subtests
+ print(int)