process_gireactornocompat.py 721 B

123456789101112131415161718192021
  1. import sys
  2. # Override theSystemPath so it throws KeyError on gi.pygtkcompat:
  3. from twisted.python import modules
  4. modules.theSystemPath = modules.PythonPath([], moduleDict={})
  5. # Now, when we import gireactor it shouldn't use pygtkcompat, and should
  6. # instead prevent gobject from being importable:
  7. from twisted.internet import gireactor
  8. for name in gireactor._PYGTK_MODULES:
  9. if sys.modules[name] is not None:
  10. sys.stdout.write("failure, sys.modules[%r] is %r, instead of None" %
  11. (name, sys.modules["gobject"]))
  12. sys.exit(0)
  13. try:
  14. import gobject
  15. except ImportError:
  16. sys.stdout.write("success")
  17. else:
  18. sys.stdout.write("failure: %s was imported" % (gobject.__path__,))