Title: when \\u in byte_string ,byte_string.decode('raw_unicode_escape') maybe has problem
Type: behavior Stage:
Components: Unicode Versions: Python 3.7
Status: pending Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: SilentGhost, ezio.melotti, vstinner, yayiba1223
Priority: normal Keywords:

Created on 2020-01-25 15:17 by yayiba1223, last changed 2020-01-25 15:36 by SilentGhost.

Messages (2)
msg360691 - (view) Author: YPf (yayiba1223) Date: 2020-01-25 15:17
>>> path=r'C:\Users\Administrator\Desktop'
>>> path.encode('raw_unicode_escape')
>>> path.encode('raw_unicode_escape').decode('raw_unicode_escape')
Traceback (most recent call last):
  File "<pyshell#48>", line 1, in <module>
UnicodeDecodeError: 'rawunicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
msg360692 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2020-01-25 15:36
Why are you using this type of encoding on this bytes object? It specifically says in its description that "Existing backslashes are not escaped in any way.". If you'd use unicode_escape instead, you would be able to round-trip back to your original string.
Date User Action Args
2020-01-25 15:36:04SilentGhostsetstatus: open -> pending

nosy: + SilentGhost, ezio.melotti, vstinner
messages: + msg360692

components: + Unicode
type: behavior
2020-01-25 15:17:41yayiba1223create