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: some non-ascii charcters link to same identifier/data
Type: behavior Stage: resolved
Components: Unicode Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: PrometheusPi, ezio.melotti, steven.daprano, vstinner
Priority: normal Keywords:

Created on 2019-10-28 11:08 by PrometheusPi, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg355525 - (view) Author: Richard Pausch (PrometheusPi) Date: 2019-10-28 11:07
The issue was first reported in https://github.com/ipython/ipython/issues/11918. 

Some non-ascii characters like φ (\u03c6) and ϕ (\u03d5) map/link to the same data/identifier. 

```python
ϕ = 1
φ = 2
print(ϕ) # results in 2 - should be 1
print(φ) # results in 2
```

It has so far been shown to occur both in python 3.6 and 3.7.
msg355539 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-10-28 13:21
This is an intentional feature: identifiers are normalised using NFKC normalization.

    py> from dis import dis
    py> dis(compile('ϕ=1', '', 'single'))
      1           0 LOAD_CONST               0 (1)
                  3 STORE_NAME               0 (φ)
                  6 LOAD_CONST               1 (None)
                  9 RETURN_VALUE
    py> from unicodedata import normalize
    py> normalize('NFKC', 'ϕ')
    'φ'


So not a bug.
msg355540 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-10-28 13:23
Its also documented here:

https://docs.python.org/3/reference/lexical_analysis.html#identifiers
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82793
2019-10-28 13:23:12steven.dapranosetstatus: open -> closed
resolution: not a bug
messages: + msg355540

stage: resolved
2019-10-28 13:21:05steven.dapranosetnosy: + steven.daprano
messages: + msg355539
2019-10-28 13:04:25PrometheusPisetnosy: + ezio.melotti, vstinner
components: + Unicode
2019-10-28 11:08:00PrometheusPicreate