_monkeypatches.py 780 B

123456789101112131415161718192021
  1. import six
  2. from six.moves import copyreg
  3. if six.PY2:
  4. from urlparse import urlparse
  5. # workaround for https://bugs.python.org/issue9374 - Python < 2.7.4
  6. if urlparse('s3://bucket/key?key=value').query != 'key=value':
  7. from urlparse import uses_query
  8. uses_query.append('s3')
  9. # Undo what Twisted's perspective broker adds to pickle register
  10. # to prevent bugs like Twisted#7989 while serializing requests
  11. import twisted.persisted.styles # NOQA
  12. # Remove only entries with twisted serializers for non-twisted types.
  13. for k, v in frozenset(copyreg.dispatch_table.items()):
  14. if not str(getattr(k, '__module__', '')).startswith('twisted') \
  15. and str(getattr(v, '__module__', '')).startswith('twisted'):
  16. copyreg.dispatch_table.pop(k)