This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: when \\u in byte_string ,byte_string.decode('raw_unicode_escape') maybe has problem
Type: behavior Stage:
Components: Unicode Versions: Python 3.7
process
Status: open 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 2022-04-11 14:59 by admin.

Messages (2)
msg360691 - (view) Author: YPf (yayiba1223) Date: 2020-01-25 15:17
>>> path=r'C:\Users\Administrator\Desktop'
>>> path.encode('raw_unicode_escape')
b'C:\\Users\\Administrator\\Desktop'
>>> path.encode('raw_unicode_escape').decode('raw_unicode_escape')
Traceback (most recent call last):
  File "<pyshell#48>", line 1, in <module>
    path.encode('raw_unicode_escape').decode('raw_unicode_escape')
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.
History
Date User Action Args
2022-04-11 14:59:25adminsetstatus: pending -> open
github: 83635
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