Repository navigation
Python 3.15 support. Under 3.15 the expander could not be imported at all, so nothing macro-enabled would run; it sails again, and the unparser has learned the two syntax additions that come with the new version.
New:
- Python 3.15 is supported.
- mcpyrate now imports at all under 3.15.
importlib'sSourceFileLoader.source_to_code— the method the expander replaces in order to hook compilation — gained a positionalfullnameparameter, so the replacement raisedTypeErrorand nothing macro-enabled could be imported. unparsehandles the new syntax: lazy imports (lazy import x,lazy from x import y) and unpacking in comprehensions ({**mapping for x in xs},[*items for item in xs], and the set and generator forms).- Syntax warnings from macro-enabled modules can now be filtered by module name, through
-Worwarnings.filterwarnings(..., module=...), the same as warnings from ordinary modules. mcpyrate calls the built-incompileitself, so it now passes 3.15's newmodule=argument along; without it the warnings machinery falls back to guessing a dotted name from the file path. - A lazy macro-import is an error.
lazy from mymacros import macros, ..., and the dialect-import equivalent, now raiseSyntaxError. The expander consumes a macro-import at macro-expansion time, so deferring one cannot mean anything — and since the statement is rewritten into an ordinary import, accepting it would have discarded thelazywithout saying so.
- mcpyrate now imports at all under 3.15.
Fixed:
- The optimization level the caller asks for is now honoured.
source_to_xcodeaccepted it and then dropped it, which went unnoticed because the import path only ever passes-1, meaning "use the interpreter's level".py_compileandcompileall -opass an explicit level, so ahead-of-time compilation of macro-enabled code silently produced bytecode at the interpreter's level rather than the requested one. unparseno longer crashes on a hand-builtImportFromthat omitslevel. The field is optional in the AST, so a node constructed in a macro without it haslevel=None, and unparsing raisedTypeError. Parsed nodes always carry an int, so this only affected generated code.
Changed:
requires-pythonnow declares an upper bound,>=3.10,<3.16. mcpyrate manipulates the AST and replaces part of the import machinery, so a new Python release can break it in ways a version-agnostic package never sees — as 3.15 did. The ceiling means a future Python has to be tested and released for, rather than silently installed onto.