[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35221] trunk/blender/release/scripts: lazy load pydoc module.

Campbell Barton ideasman42 at gmail.com
Sun Feb 27 15:08:33 CET 2011


Revision: 35221
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35221
Author:   campbellbarton
Date:     2011-02-27 14:08:33 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
lazy load pydoc module. move help() replacement into console code rather then on startup since importing pydoc pulls in lots of other modules too.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy/__init__.py
    trunk/blender/release/scripts/op/console_python.py

Modified: trunk/blender/release/scripts/modules/bpy/__init__.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/__init__.py	2011-02-27 14:01:09 UTC (rev 35220)
+++ trunk/blender/release/scripts/modules/bpy/__init__.py	2011-02-27 14:08:33 UTC (rev 35221)
@@ -37,18 +37,6 @@
 
 def _main():
 
-    ## security issue, dont allow the $CWD in the path.
-    ## note: this removes "" but not "." which are the same, security
-    ## people need to explain how this is even a fix.
-    # _sys.path[:] = filter(None, _sys.path)
-
-    # because of how the console works. we need our own help() pager func.
-    # replace the bold function because it adds crazy chars
-    import pydoc
-    pydoc.getpager = lambda: pydoc.plainpager
-    pydoc.Helper.getline = lambda self, prompt: None
-    pydoc.TextDoc.use_bold = lambda self, text: text
-
     # Possibly temp. addons path
     from os.path import join, dirname, normpath
     _sys.path.append(normpath(join(dirname(__file__), "..", "..", "addons", "modules")))

Modified: trunk/blender/release/scripts/op/console_python.py
===================================================================
--- trunk/blender/release/scripts/op/console_python.py	2011-02-27 14:01:09 UTC (rev 35220)
+++ trunk/blender/release/scripts/op/console_python.py	2011-02-27 14:08:33 UTC (rev 35221)
@@ -33,6 +33,20 @@
             type=text_type)
 
 
+def replace_help(namespace):
+    def _help(value):
+        # because of how the console works. we need our own help() pager func.
+        # replace the bold function because it adds crazy chars
+        import pydoc
+        pydoc.getpager = lambda: pydoc.plainpager
+        pydoc.Helper.getline = lambda self, prompt: None
+        pydoc.TextDoc.use_bold = lambda self, text: text
+
+        help(value)
+
+    namespace["help"] = _help
+
+
 def get_console(console_id):
     '''
     helper function for console operators
@@ -83,6 +97,8 @@
         namespace["bpy"] = bpy
         namespace["C"] = bpy.context
 
+        replace_help(namespace)
+
         console = InteractiveConsole(locals=namespace, filename="<blender_console>")
 
         console.push("from mathutils import *")




More information about the Bf-blender-cvs mailing list