Anonymous committed 6ae8e2e

needed by subprocess module on Linux and OS X: added hack to get back buffer() builtin

  • Participants
  • Parent commits 02c8812

Comments (0)

Files changed (1)

     # This module is just too important for development.
     # The second part of this hack is in which adds
     # important environment variables like PATH etc.
-    if not on_production_server:
+    if have_appserver and not on_production_server:
             from google.appengine.api.mail_stub import subprocess
             sys.modules['subprocess'] = subprocess
+            try:
+                # subprocess in Python 2.5 on Linux and OS X uses the buffer()
+                # builtin which unfortunately gets removed by the GAE SDK, so
+                # we have to get it back with this ugly hack 
+                import inspect
+                sys.modules['subprocess'].buffer = inspect.currentframe().f_back.f_back.f_back.f_locals['old_builtin']['buffer']
+            except:
+                pass
         except ImportError:
             import logging
             logging.warn('Could not add the subprocess module to the sandbox.')