From 59c5d4161120db28bc6cbc7653f2e7fdb4a87370 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 26 Apr 2022 17:23:29 +1000 Subject: [PATCH] py/modsys: Rename sys.implementation.mpy to sys.implementation._mpy. Per CPython docs, non-standard attributes must begin with an underscore. Signed-off-by: Damien George --- docs/library/sys.rst | 1 + docs/reference/mpyfiles.rst | 4 ++-- py/modsys.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/library/sys.rst b/docs/library/sys.rst index a2d55fecbb..1186af6134 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -70,6 +70,7 @@ Constants * *name* - string "micropython" * *version* - tuple (major, minor, micro), e.g. (1, 7, 0) + * *_mpy* - supported mpy file-format version (optional attribute) This object is the recommended way to distinguish MicroPython from other Python implementations (note that it still may not exist in the very diff --git a/docs/reference/mpyfiles.rst b/docs/reference/mpyfiles.rst index 6ba7389cf0..9d6388741e 100644 --- a/docs/reference/mpyfiles.rst +++ b/docs/reference/mpyfiles.rst @@ -44,7 +44,7 @@ Compatibility is based on the following: loading it must support execution of that architecture's code. If a MicroPython system supports importing .mpy files then the -``sys.implementation.mpy`` field will exist and return an integer which +``sys.implementation._mpy`` field will exist and return an integer which encodes the version (lower 8 bits), features and native architecture. Trying to import an .mpy file that fails one of the first four tests will @@ -58,7 +58,7 @@ If importing an .mpy file fails then try the following: by executing:: import sys - sys_mpy = sys.implementation.mpy + sys_mpy = sys.implementation._mpy arch = [None, 'x86', 'x64', 'armv6', 'armv6m', 'armv7m', 'armv7em', 'armv7emsp', 'armv7emdp', 'xtensa', 'xtensawin'][sys_mpy >> 10] diff --git a/py/modsys.c b/py/modsys.c index bdc4d69733..12f3f00264 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -84,7 +84,7 @@ STATIC const qstr impl_fields[] = { MP_QSTR_name, MP_QSTR_version, #if MICROPY_PERSISTENT_CODE_LOAD - MP_QSTR_mpy, + MP_QSTR__mpy, #endif }; STATIC MP_DEFINE_ATTRTUPLE(