rjgoyln opened a new pull request, #70943:
URL: https://github.com/apache/airflow/pull/70943
## Summary
`airflow.utils.yaml` documents that YAML operations use the libyaml C
implementation whenever it is available. `safe_load` and `dump` honour that;
`FullLoader` never has. The module's `__getattr__` looks up `CFullLoader` and
then discards the result, so execution falls through to the generic delegation
and the caller always receives the pure-Python loader:
```python
if name == "FullLoader":
getattr(yaml, "CFullLoader", yaml.FullLoader) # result discarded
return getattr(yaml, name)
```
The branch has been dead since it was added in `7daebefd153` (March 2021).
The module has since been copied into `airflow.sdk` and `airflowctl.ctl.utils`,
and both copies carry the same defect.
## Change
`FullLoader` now returns the value it was already computing, so it resolves
to `CFullLoader` when libyaml is present and to the pure-Python loader
otherwise. All three copies are fixed.
Unifying the three copies is deliberately out of scope;
`airflowctl/ctl/utils/yaml.py` already carries a TODO tracking that work.
## Tests
One test per copy asserts that `FullLoader` resolves to the C
implementation. `CFullLoader` is injected rather than assumed, so the result
does not depend on whether the machine running the tests has libyaml compiled
in. Each test fails without its corresponding one-line fix.
## Behavior change
Nothing in this repository reads `FullLoader` through these wrappers, so no
in-tree behaviour changes. For external callers the returned class does change
identity, and that distinction is worth stating: `CFullLoader` does not see
constructors registered through `yaml.add_constructor(tag, fn)`, which binds to
the pure-Python `Loader`, `FullLoader`, and `UnsafeLoader` only. Code combining
custom constructors with this module's `FullLoader` would notice — though the
faster loader is what the module always advertised.
I have not added a newsfragment, since there are no in-tree consumers. Happy
to add one if you read the class-identity change as user-facing.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 5)
Generated-by: Claude Code (Opus 5) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]