Skip to content

Escape-baseline keys are fragile across Python versions (comprehension frame names, PEP 709) #945

Description

@mwcraig

Follow-up from PR #942 (review item P2, #942 (review)).

Baseline keys in ccdproc/tests/array_escape_baseline.txt include the frame function name of the escape site. Those names are not stable across Python versions:

  • List comprehensions have their own frame named <listcomp> on Python < 3.12, but are inlined into the enclosing function on 3.12+ (PEP 709), so the same escape keys differently depending on the interpreter.
  • Generator expressions and lambdas key as <genexpr> / <lambda> on all versions, which are ambiguous within a file.

The enforce CI job (py312-alldeps-dask-enforce) runs on Python 3.12, so a contributor who regenerates the baseline with CCDPROC_WRITE_ESCAPE_BASELINE=1 on Python 3.11 produces mismatched keys: CI then reports spurious NEW-escape failures (the 3.12 spelling is missing) plus spurious stale entries (the 3.11 spelling is never observed).

Fix options:

  1. Normalize comprehension-style frame names (<listcomp>, <setcomp>, <dictcomp>, and possibly <genexpr>/<lambda>) to the enclosing function's name when recording escape sites, so keys match across versions; or
  2. Document a Python floor (>= 3.12) for baseline regeneration in docs/array_api.rst and in the baseline file header, and optionally have write mode refuse to run on older interpreters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions