Dark Launch

Python simulate an imported module

Fake a module import by adding a fake module to sys.modules.

Python
import sys
 
class FakeModule(object):
    PIPE = None
    Popen = None
sys.modules['subprocess'] = FakeModule

Now the following python import from nltk will not fail on App Engine:

Python
from subprocess import PIPE, Popen

Fixes: "ImportError: cannot import name PIPE"