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.

Author maxbachmann
Recipients eryksun, ezio.melotti, maxbachmann, steven.daprano, vstinner
Date 2021-09-05.14:51:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1630853502.43.0.702299323838.issue45105@roundup.psfhosted.org>
In-reply-to
Content
> That is using Python 3.9 in the xfce4-terminal. Which xterm are you using?

This was in the default gnome terminal that is pre-installed on Fedora 34 and on windows I directly opened the Python Terminal. I just installed xfce4-terminal on my Fedora 34 machine which has exactly the same behavior for me that I had in the gnome terminal.

> But regardless, I cannot replicate the behavior you show where list(s) is different from indexing the characters one by one.

That is what surprised me the most. I just ran into this because this was somehow generated when fuzz testing my code using hypothesis (which uncovered an unrelated bug in my application). However I was quite confused by the character order when debugging it.

My original case was:
```
s1='00ĀĀĀĀ'
s2='9010𐤀000\x8dÀĀĀĀ222Ā'
parts = [s2[max(0, i) : min(len(s2), i+len(s1))] for i in range(-len(s1), len(s2))]
for part in parts:
    print(list(part))
```
which produced
```
[]
['9']
['9', '0']
['9', '0', '1']
['9', '0', '1', '0']
['9', '0', '1', '0', '𐤀']
['9', '0', '1', '0', '𐤀', '0']
['0', '1', '0', '𐤀', '0', '0']
['1', '0', '𐤀', '0', '0', '0']
['0', '𐤀', '0', '0', '0', '\x8d']
['𐤀', '0', '0', '0', '\x8d', 'À']
['0', '0', '0', '\x8d', 'À', 'Ā']
['0', '0', '\x8d', 'À', 'Ā', 'Ā']
['0', '\x8d', 'À', 'Ā', 'Ā', 'Ā']
['\x8d', 'À', 'Ā', 'Ā', 'Ā', '2']
['À', 'Ā', 'Ā', 'Ā', '2', '2']
['Ā', 'Ā', 'Ā', '2', '2', '2']
['Ā', 'Ā', '2', '2', '2', 'Ā']
['Ā', '2', '2', '2', 'Ā']
['2', '2', '2', 'Ā']
['2', '2', 'Ā']
['2', 'Ā']
['ĀÀ]
```
which has a missing single quote:
  - ['ĀÀ]
changing direction of characters including commas:
  - ['1', '0', '𐤀', '0', '0', '0']
changing direction back:
  - ['𐤀', '0', '0', '0', '\x8d', 'À']

> AFAICT, there is no bug here. It's just confusing how Unicode right-to-left characters in the repr() can modify how it's displayed in the console/terminal.

Yes it appears the same confusion occurs in other applications like Firefox and VS Code.
Thanks at @eryksun and @steven.daprano for testing and telling me about Bidirectional writing in Unicode (The more I know about Unicode the more it scares me)
History
Date User Action Args
2021-09-05 14:51:42maxbachmannsetrecipients: + maxbachmann, vstinner, ezio.melotti, steven.daprano, eryksun
2021-09-05 14:51:42maxbachmannsetmessageid: <1630853502.43.0.702299323838.issue45105@roundup.psfhosted.org>
2021-09-05 14:51:42maxbachmannlinkissue45105 messages
2021-09-05 14:51:42maxbachmanncreate