1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Policy test: runtime sources must not write to stderr outside the emitter's sink.
The spec's CLI Event Framing sanctions one path to stderr — the emitter's own
formatted diagnostic sink (``CliEmitter.finite`` / ``CliEmitter.from_output_to``
hand ``sys.stderr`` to the emitter, which routes ``error``/``progress``/``log``
through it). Merely referencing ``sys.stderr`` to pass it as that sink is allowed.
What stays forbidden is *ad-hoc* stderr writes that bypass the formatter:
``sys.stderr.write(...)`` / ``.writelines(...)`` and ``print(..., file=sys.stderr)``.
"""
# Forbid ad-hoc stderr writes that bypass the emitter's formatted sink. A bare
# `sys.stderr` reference (handing the stream to CliEmitter as its diagnostic
# sink) is the sanctioned exception and intentionally not matched here.
=
= . /
=
assert ,
: =
assert not , +
# Sanctioned: handing sys.stderr to the emitter as its diagnostic sink.
assert not
assert not
assert not
# Forbidden: ad-hoc stderr writes that bypass the emitter.
assert
assert
assert