[issue42852] pprint fails in transformming non-breaking space

2021-01-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution: fixed -> not a bug

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42852] pprint fails in transformming non-breaking space

2021-01-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42852] pprint fails in transformming non-breaking space

2021-01-07 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

By the way, there is no need to use the u'' prefix on strings in Python 3.

Unfortunately, I think this is a case where pprint doesn't meet your 
expectations. pprint is designed to print the repr of a string, while regular 
print prints the human-visible str:

>>> print(repr('\240 hello'))
'\xa0 hello'
>>> print('\240 hello')
  hello

Its not just non-breaking space, it also includes ASCII characters:


>>> print(repr('\01 hello'))
'\x01 hello'
>>> print('\01 hello')
 hello
>>> pprint.pprint('\01 hello')
'\x01 hello'


So this is intentional behaviour, not a bug. If you want to change the 
behaviour, it will probably require a re-design of the way strings are printed 
by the pprint module.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42852] pprint fails in transformming non-breaking space

2021-01-07 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42852] pprint fails in transformming non-breaking space

2021-01-06 Thread Xinmeng Xia


New submission from Xinmeng Xia :

"pprint" can transform unicode like "print". However, pprint fails to transform 
non-breaking space('\240') . See the following example:

Python 3.10.0a2 (default, Nov 24 2020, 14:18:46) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

Example 1(Results as expected):
-
>>> import pprint
>>> print(u'\041 hello')
! hello
>>> pprint.pprint(u'\041 hello')
'! hello'

Example 2(Results not as expected):
-
>>> print(u'\240 hello')
  hello
>>> pprint.pprint(u'\240 hello')
'\xa0 hello'

Expected output: the output of pprint.pprint(u'\240 hello') should be 
consistent with output of print(u'\240 hello')

--
components: Unicode
messages: 384564
nosy: ezio.melotti, vstinner, xxm
priority: normal
severity: normal
status: open
title: pprint fails in transformming non-breaking space
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com