Skip to content

Distinguish byte-compiled files from MicroPython's #4703

@jepler

Description

@jepler

In #4697 a user mentioned using a version of mpy-cross built from micropython sources with CircuitPython. I don't think we ever guaranteed that the format of .mpy files was the same as our base version of micropython, though this has been true for a long time. I believe this will change with #4693, as we renumbered some of the flags in runtime0.h.

The .mpy file begins with two bytes: ASCII 'M', and then the bytecode version number (currently 4, will become 5 soon). I see two main ways to ensure we can distinguish our own files:

  • Change 'M' to 'C', or
  • Set the high bit in the version field (128|5 -> 133)

The purpose of the change would be to prevent users accidentally or intentionally bringing mpy files built with micropython's mpy-cross to circuitpython devices.

We could standardize on a ".cpy" extension at the same time, though this is likely to create a lot of tooling problems as well as making lots of updates in the learn system necessary.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions