Skip to content

Commit 1b9b4e8

Browse files
committed
- Document parameter mode for the compile_restricted functions (fixes
#157)
1 parent a3d5a38 commit 1b9b4e8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Changes
44
5.1a0 (unreleased)
55
------------------
66

7+
- Document parameter ``mode`` for the ``compile_restricted`` functions
8+
(`#157 <https://github.com/zopefoundation/RestrictedPython/issues/157>`_)
9+
710
- Fix documentation for ``compile_restricted_function``
811
(`#158 <https://github.com/zopefoundation/RestrictedPython/issues/158>`_)
912

docs/usage/api.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ API overview
1111

1212
:param source: (required). the source code that should be compiled
1313
:param filename: (optional). defaults to ``'<unknown>'``
14-
:param mode: (optional). defaults to ``'exec'``
14+
:param mode: (optional). Use ``'exec'``, ``'eval'``, ``'single'`` or ``'function'``. defaults to ``'exec'``
1515
:param flags: (optional). defaults to ``0``
1616
:param dont_inherit: (optional). defaults to ``False``
1717
:param policy: (optional). defaults to ``RestrictingNodeTransformer``
@@ -27,6 +27,7 @@ API overview
2727
:module: RestrictedPython
2828

2929
Compiles source code into interpretable byte code with ``mode='exec'``.
30+
Use mode ``'exec'`` if the source contains a sequence of statements.
3031
The meaning and defaults of the parameters are the same as in
3132
``compile_restricted``.
3233

@@ -36,6 +37,7 @@ API overview
3637
:module: RestrictedPython
3738

3839
Compiles source code into interpretable byte code with ``mode='eval'``.
40+
Use mode ``'eval'`` if the source contains a single expression.
3941
The meaning and defaults of the parameters are the same as in
4042
``compile_restricted``.
4143

@@ -45,6 +47,7 @@ API overview
4547
:module: RestrictedPython
4648

4749
Compiles source code into interpretable byte code with ``mode='eval'``.
50+
Use mode ``'single'`` if the source contains a single interactive statement.
4851
The meaning and defaults of the parameters are the same as in
4952
``compile_restricted``.
5053

@@ -54,6 +57,7 @@ API overview
5457
:module: RestrictedPython
5558

5659
Compiles source code into interpretable byte code with ``mode='function'``.
60+
Use mode ``'function'`` for full functions.
5761

5862
:param p: (required). a string representing the function parameters
5963
:param body: (required). the function body

0 commit comments

Comments
 (0)