Skip to content

Commit bce08bd

Browse files
brittanyreymeta-codesync[bot]
authored andcommitted
Repair lazy-imports patch queue broken by D107679841
Summary: D107679841 corrupted `third-party/python/3.14/patches/16-lazy-imports/lazy-imports.patch`, breaking patch application (`validate_patch_integrity`). It had three defects: 1. **Malformed hunk count** in the `Lib/importlib/__init__.py` hunk. The change grew the body by 8 lines (added `_UNSET = object()` plus blanks, and replaced one `return` with the `kwargs` block) but only bumped the hunk header `53 -> 59` (+6). With the count short by 2, `patch` stopped early and reported `malformed patch at line 3669: """Call the invalidate_caches() method...`. 2. **`_UNSET` placed inconsistently.** The patch inserted `_UNSET = object()` just before `set_lazy_imports`, while `patched/Lib/importlib/__init__.py` (and the 3.12 file) place it at the top, right after `from ._bootstrap import __import__`. This made `pristine+patches` diverge from `patched/`. The hunk is now regenerated directly from `diff(pristine, patched)` (`@@ -59,6 +59,60 @@`, `_UNSET` at the top). 3. **New test file missing from `patched/`.** The diff added a creation hunk for `Lib/test/lazyimports/set_lazy_imports_excluding_preserves_eager.py` to the `.patch` but never committed the file to the `patched/` subtree, and that creation hunk also miscounted (`+1,20` for a 23-line file). The file is now added (byte-for-byte from the patch) and the count corrected to `+1,23`. Reviewed By: itamaro Differential Revision: D108370070 fbshipit-source-id: 7856a2c6e104a68cdfe2903c3945caa484e5a966
1 parent ccebbb4 commit bce08bd

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) Meta, Inc. and its affiliates. All Rights Reserved
2+
# File added for Lazy Imports
3+
4+
import self
5+
import importlib
6+
7+
original = importlib.set_lazy_imports(
8+
True,
9+
excluding=["test.lazyimports.data.excluding.bar"],
10+
eager={"sentinel.preserved"},
11+
)
12+
try:
13+
previous = importlib.set_lazy_imports(
14+
excluding=["test.lazyimports.data.excluding.foo"]
15+
)
16+
self.assertEqual(previous[1], ["test.lazyimports.data.excluding.bar"])
17+
self.assertEqual(previous[2], {"sentinel.preserved"})
18+
19+
current = importlib.set_lazy_imports(True)
20+
self.assertEqual(current[1], ["test.lazyimports.data.excluding.foo"])
21+
self.assertEqual(current[2], {"sentinel.preserved"})
22+
finally:
23+
importlib.set_lazy_imports(*original)

0 commit comments

Comments
 (0)