Skip to content

Commit 59c5d41

Browse files
committed
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 <damien@micropython.org>
1 parent 4004782 commit 59c5d41

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎docs/library/sys.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Constants
7070

7171
* *name* - string "micropython"
7272
* *version* - tuple (major, minor, micro), e.g. (1, 7, 0)
73+
* *_mpy* - supported mpy file-format version (optional attribute)
7374

7475
This object is the recommended way to distinguish MicroPython from other
7576
Python implementations (note that it still may not exist in the very

‎docs/reference/mpyfiles.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Compatibility is based on the following:
4444
loading it must support execution of that architecture's code.
4545

4646
If a MicroPython system supports importing .mpy files then the
47-
``sys.implementation.mpy`` field will exist and return an integer which
47+
``sys.implementation._mpy`` field will exist and return an integer which
4848
encodes the version (lower 8 bits), features and native architecture.
4949

5050
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:
5858
by executing::
5959

6060
import sys
61-
sys_mpy = sys.implementation.mpy
61+
sys_mpy = sys.implementation._mpy
6262
arch = [None, 'x86', 'x64',
6363
'armv6', 'armv6m', 'armv7m', 'armv7em', 'armv7emsp', 'armv7emdp',
6464
'xtensa', 'xtensawin'][sys_mpy >> 10]

‎py/modsys.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ STATIC const qstr impl_fields[] = {
8484
MP_QSTR_name,
8585
MP_QSTR_version,
8686
#if MICROPY_PERSISTENT_CODE_LOAD
87-
MP_QSTR_mpy,
87+
MP_QSTR__mpy,
8888
#endif
8989
};
9090
STATIC MP_DEFINE_ATTRTUPLE(

0 commit comments

Comments
 (0)