Skip to content

Commit 1c4b478

Browse files
committed
Add _io.open_code
1 parent b221f58 commit 1c4b478

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

vm/Lib/python_builtins/_io.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,21 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
264264
raise
265265

266266

267+
def open_code(path):
268+
"""Opens the provided file with mode ``'rb'``. This function
269+
should be used when the intent is to treat the contents as
270+
executable code.
271+
272+
``path`` should be an absolute path.
273+
274+
When supported by the runtime, this function can be hooked
275+
in order to allow embedders more control over code files.
276+
This functionality is not supported on the current runtime.
277+
"""
278+
# XXX RustPython TODO: hooks?
279+
return open(path, "rb")
280+
281+
267282
class DocDescriptor:
268283
"""Helper for builtins.open.__doc__
269284
"""

0 commit comments

Comments
 (0)