Issue2884
Created on 2020-04-26.00:18:02 by stefan.richthofer, last changed 2020-04-26.01:04:43 by stefan.richthofer.
msg13040 (view) |
Author: Stefan Richthofer (stefan.richthofer) |
Date: 2020-04-26.00:18:02 |
|
I tried a lib that makes some use of the future module. It failed on these lines:
from future import standard_library
standard_library.install_aliases()
I quickly identified the cause is in this line in future.utils.surrogateescape.py: encoded = u('[abc\udcff]')
u is a function in surrogateescape.py
Anyway. The actual cause can be easily written as this line:
'[abc\udcff]'.decode('unicode_escape')
Execute this line directly in Jython 2.7.2 or CPython 2.7 to reproduce. (It works e.g. in CPython 2.7.12) This reproduces the issue independently from future. In Jython you will get the following error:
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 4-10: illegal Unicode character
|
msg13044 (view) |
Author: Stefan Richthofer (stefan.richthofer) |
Date: 2020-04-26.01:04:43 |
|
For the record: I can get it working by modifying the future module as follows:
In standard_library.install_aliases()
out-comment the "Hack for urllib" like so:
# Hack for urllib so it appears to have the same structure on Py2 as on Py3
#import urllib
#from future.backports.urllib import request
#from future.backports.urllib import response
#from future.backports.urllib import parse
#from future.backports.urllib import error
#from future.backports.urllib import robotparser
#urllib.request = request
#urllib.response = response
#urllib.parse = parse
#urllib.error = error
#urllib.robotparser = robotparser
#sys.modules['urllib.request'] = request
#sys.modules['urllib.response'] = response
#sys.modules['urllib.parse'] = parse
#sys.modules['urllib.error'] = error
#sys.modules['urllib.robotparser'] = robotparser
No doubt, this nukes some part of future. But for my usecase, it appears, urllib is not required.
|
|
Date |
User |
Action |
Args |
2020-04-26 01:04:43 | stefan.richthofer | set | messages:
+ msg13044 |
2020-04-26 00:24:20 | stefan.richthofer | set | messages:
- msg13042 |
2020-04-26 00:22:45 | stefan.richthofer | set | messages:
+ msg13042 |
2020-04-26 00:18:03 | stefan.richthofer | create | |
|