1

For testing purposes, I created a file with bytes 0xc2 0x90, representing Unicode code point 0x90 in UTF-8 encoding.

I can cat this file without an issue, but trying to print the string written from it, or the corresponding literal, or the string created in other way...

Python 3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('\x90')

results in the terminal hanging. The program doesn't even respond to Ctrl-C.

The same happens for several other individual characters, with no pattern that I can discern.

Even stranger:

>>> for i in range(150): print(chr(i))

This succeeds, even though one of the characters printed will be the 0x90 character in question. If I end the range at 156 instead, it will hang again, but interruptibly.

I can't find any rhyme or reason to this behaviour. I understand that I am trying to display control characters and that this could potentially cause the terminal output to look strange, for the cursor to jump around etc.; but I don't expect a hard terminal hang. And again, the output differs from what I get when trying to display the characters in other ways (like cat).

What is going on, and what should I try next to fix it? I am using the built-in Python 3.8.10 installation on Linux Mint (20.3, Una), kernel version 5.4.0-109-generic.

0 Answers0