Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/amd-exec/stdlib-shadow.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / amd-exec / stdlib-shadow.py` 31 lines · 1259 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Reject stdlib-named sibling modules before instrument imports.""" 4 import pathlib 5 import subprocess 6 import sys 7 import tempfile 8 9 10 def check(directory): 11 found = sorted(p.stem for p in pathlib.Path(directory).glob('*.py') 12 if p.stem in sys.stdlib_module_names) 13 if found: 14 print(f'STDLIB-SHADOW FAIL directory={directory} names={found}') 15 return 1 16 print(f'STDLIB-SHADOW PASS directory={directory}') 17 return 0 18 19 20 if __name__ == '__main__': 21 if sys.argv[1] == 'test': 22 with tempfile.TemporaryDirectory(prefix='stdlib-shadow.') as tmp: 23 path = pathlib.Path(tmp) / 'token.py' 24 path.write_text('raise RuntimeError("shadow must never be imported")\n') 25 cmd = [sys.executable, '-I', __file__, tmp] 26 p = subprocess.run(cmd, capture_output=True, text=True) 27 print(f'command={cmd!r} exit={p.returncode}\n{p.stdout}{p.stderr}') 28 assert p.returncode == 1 and "names=['token']" in p.stdout, 'INVALID or missed shadow control' 29 print('CONTROL restored-token.py CAUGHT exit=1 before import') 30 sys.exit(check(sys.argv[2])) 31 sys.exit(check(sys.argv[1]))