forked from pool/python-jsonpickle
(gh#jsonpickle/jsonpickle#281). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-jsonpickle?expand=0&rev=16
42 lines
1.1 KiB
Diff
42 lines
1.1 KiB
Diff
--- a/jsonpickle/handlers.py
|
|
+++ b/jsonpickle/handlers.py
|
|
@@ -10,7 +10,9 @@ A handler can be bound to other types by
|
|
from __future__ import absolute_import, division, unicode_literals
|
|
import copy
|
|
import datetime
|
|
+import io
|
|
import re
|
|
+import sys
|
|
import threading
|
|
import uuid
|
|
|
|
@@ -254,3 +256,18 @@ class LockHandler(BaseHandler):
|
|
|
|
_lock = threading.Lock()
|
|
LockHandler.handles(_lock.__class__)
|
|
+
|
|
+
|
|
+class TextIOHandler(BaseHandler):
|
|
+ """Serialize file descriptors as None because we cannot roundtrip"""
|
|
+
|
|
+ def flatten(self, obj, data):
|
|
+ return None
|
|
+
|
|
+ def restore(self, data):
|
|
+ """Restore should never get called because flatten() returns None"""
|
|
+ raise AssertionError('Restoring IO.TextIOHandler is not supported')
|
|
+
|
|
+
|
|
+if sys.version_info >= (3, 8):
|
|
+ TextIOHandler.handles(io.TextIOWrapper)
|
|
--- a/requirements-dev.txt
|
|
+++ b/requirements-dev.txt
|
|
@@ -12,5 +12,5 @@ pytest
|
|
pytest-cov
|
|
simplejson
|
|
sqlalchemy
|
|
-ujson
|
|
-yajl; sys_platform != 'win32'
|
|
+ujson; python_version < '3.8'
|
|
+yajl; sys_platform != 'win32' and python_version < '3.8'
|