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: printing a string with strange characters loops forever
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, eryksun, svild
Priority: normal Keywords:

Created on 2022-02-25 15:49 by svild, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg414010 - (view) Author: svilen dobrev (svild) Date: 2022-02-25 15:49
$ python
Python 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a= "Betrag gr\xc3\xb6\xc3\x9fer als Betrag der Original-Transaktion"
>>> a
'Betrag gröÃ\x9fer als Betrag der Original-Transaktion'
>>> print(a)
Betrag gröÃ~ 

---------------

And above waits forever. Does not consume resources, but does not hear Ctrl-C. Ctrl-\ kills it.

The string above is just a byte string of the utf-8 representation, with forgotten "b" infront of it.
msg414031 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2022-02-25 18:40
The ordinal range 0x80-0x9F is the C1 control code set [1]. Ordinal 0x9F is "Application Program Command" (APC). The command must be terminated by ordinal 0x9C, "String Terminator" (ST). For example, "\x9f Some Command \x9c". 

In Gnome Terminal, after executing print('\x9f'), an APC command without a terminator, typing Ctrl+L still works to clear the screen and get back to a prompt.

[1] https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_controls
msg414041 - (view) Author: svilen dobrev (svild) Date: 2022-02-25 21:15
aha. ctrl-s also closes it.
seems kind-of ( ctrl-q - ctrl-s )
 https://en.wikipedia.org/wiki/Software_flow_control

thanks, closing this.
msg414108 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2022-02-26 14:39
Note that the original issue seems to be that you had bytes but pasted it as a unicode string.  This works:

>>> b = b'Betrag gr\xc3\xb6\xc3\x9fer als Betrag der Original-Transaktion'
>>> s = b.decode('utf-8')
>>> print(s)
Betrag größer als Betrag der Original-Transaktion
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 91011
2022-02-26 14:39:48eric.araujosetnosy: + eric.araujo
messages: + msg414108
2022-02-25 21:15:29svildsetstatus: open -> closed
resolution: not a bug
messages: + msg414041

stage: resolved
2022-02-25 18:40:38eryksunsetnosy: + eryksun
messages: + msg414031
2022-02-25 15:49:37svildcreate