Issue2884

classification
Title: Issue with unicode_escape blocks use of future
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7.2
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: stefan.richthofer
Priority: normal Keywords:

Created on 2020-04-26.00:18:02 by stefan.richthofer, last changed 2020-04-26.01:04:43 by stefan.richthofer.

Messages
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.
History
Date User Action Args
2020-04-26 01:04:43stefan.richthofersetmessages: + msg13044
2020-04-26 00:24:20stefan.richthofersetmessages: - msg13042
2020-04-26 00:22:45stefan.richthofersetmessages: + msg13042
2020-04-26 00:18:03stefan.richthofercreate