MCPcopy Index your code
hub / github.com/python/cpython / _open_code_with_warning

Function _open_code_with_warning

Lib/_pyio.py:275–289  ·  view source on GitHub ↗

Opens the provided file with mode ``'rb'``. This function should be used when the intent is to treat the contents as executable code. ``path`` should be an absolute path. When supported by the runtime, this function can be hooked in order to allow embedders more control over co

(path)

Source from the content-addressed store, hash-verified

273# Define a default pure-Python implementation for open_code()
274# that does not allow hooks. Warn on first use. Defined for tests.
275def _open_code_with_warning(path):
276 """Opens the provided file with mode ``'rb'``. This function
277 should be used when the intent is to treat the contents as
278 executable code.
279
280 ``path`` should be an absolute path.
281
282 When supported by the runtime, this function can be hooked
283 in order to allow embedders more control over code files.
284 This functionality is not supported on the current runtime.
285 """
286 import warnings
287 warnings.warn("_pyio.open_code() may not be using hooks",
288 RuntimeWarning, 2)
289 return open(path, "rb")
290
291try:
292 open_code = io.open_code

Callers

nothing calls this directly

Calls 2

openFunction · 0.70
warnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…