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)
| 273 | # Define a default pure-Python implementation for open_code() |
| 274 | # that does not allow hooks. Warn on first use. Defined for tests. |
| 275 | def _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 | |
| 291 | try: |
| 292 | open_code = io.open_code |