Issue #15230: Update runpy docs to clarify a couple of points that came up in this...
authorNick Coghlan <ncoghlan@gmail.com>
Sat, 14 Jul 2012 14:36:39 +0000 (00:36 +1000)
committerNick Coghlan <ncoghlan@gmail.com>
Sat, 14 Jul 2012 14:36:39 +0000 (00:36 +1000)
Doc/library/runpy.rst
Misc/NEWS

index 4df622cb1f882e60e5a999994f42e227cdd55a38..6919bc0c37b7e90b58c7e0383daf7656533179be 100644 (file)
@@ -14,6 +14,15 @@ importing them first. Its main use is to implement the :option:`-m` command
 line switch that allows scripts to be located using the Python module
 namespace rather than the filesystem.
 
+Note that this is *not* a sandbox module - all code is executed in the
+current process, and any side effects (such as cached imports of other
+modules) will remain in place after the functions have returned.
+
+Furthermore, any functions and classes defined by the executed code are not
+guaranteed to work correctly after a :mod:`runpy` function has returned.
+If that limitation is not acceptable for a given use case, :mod:`importlib`
+is likely to be a more suitable choice than this module.
+
 The :mod:`runpy` module provides two functions:
 
 
@@ -141,3 +150,5 @@ The :mod:`runpy` module provides two functions:
       PEP written and implemented by Nick Coghlan.
 
    :ref:`using-on-general` - CPython command line details
+
+   The :func:`importlib.import_module` function
index 1b2f4f41eb65e071a5fe7875cd7409b303b3b86c..81665e39da05f3d2ce85bcc968759a1d7e951511 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -384,6 +384,9 @@ Build
 Documentation
 -------------
 
+- Issue #15230: Clearly document some of the limitations of the runpy
+  module and nudge readers towards importlib when appropriate.
+
 - Issue #13557: Clarify effect of giving two different namespaces to exec or
   execfile().