Skip to content

Bug(expr): repr_sh and repr_py do not match the Python functions RFC 0006 names for them #313

Description

@uberware

Summary

RFC 0006 defines repr_sh by reference to Python's shlex.quote and repr_py by reference
to Python's repr. Neither output matches for inputs containing a single quote:

Input "it's" Named Python function produces Implementation produces
repr_sh 'it'"'"'s' (shlex.quote) "it's"
repr_py "it's" (repr switches quote style) 'it\'s' (always single-quote, escapes)

repr_sh's output here is still shell-safe — this is a conformance/portability question
rather than a safety one: two implementations both "following shlex.quote" will embed
different bytes into command lines, which matters the moment output is compared, cached, or
hashed.

Versions

  • openjd-model 0.11.1 and 0.11.2 from PyPI
  • openjd-rs main at 1a89f3a — still reproduces

Reproduction

import shlex
from openjd.expr import parse_expression
r = parse_expression("repr_sh(\"it's\")").evaluate_with_metrics()
print(str(r.value), "vs", shlex.quote("it's"))
r = parse_expression("repr_py(\"it's\")").evaluate_with_metrics()
print(str(r.value), "vs", repr("it's"))

Suggested resolution

Either match the named functions byte-for-byte, or reword the spec to name the property
(shell-safe quoting; Python-literal round-tripping) rather than the function. Happy to file
against the spec instead if that's the preferred fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions