Open
Description
I'm seeing this behaviour in Python 3:
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
...
In [1]: s = b"fo\xf6\x65\xe9\x62a"
In [2]: s.decode('utf-8', 'surrogateescape')
Out[2]: 'fo\udcf6e\udce9ba'
In [3]: s.decode('utf-8', 'surrogateescape').encode('utf-8', 'surrogateescape') == s
Out[3]: True
And I expected Python 2 to behave the same, after I use python-future's surrogateescape. This, however, is not the case:
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
...
In [1]: from future.utils.surrogateescape import register_surrogateescape
In [2]: register_surrogateescape()
In [3]: s = b"fo\xf6\x65\xe9\x62a"
In [4]: s.decode('utf-8', 'surrogateescape').encode('utf-8', 'surrogateescape')
...: == s
Out[4]: False
In [5]: s.decode('utf-8', 'surrogateescape').encode('utf-8', 'surrogateescape')
Out[5]: 'fo\xed\xb3\xb6e\xed\xb3\xa9ba'
I expected the values to be the same.