[issue30772] If I make an attribute "[a unicode version of B]", it gets assigned to "[ascii B]", and so on.

2017-06-28 Thread Brett Cannon

Changes by Brett Cannon :


--
resolution:  -> not a bug
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



[issue30772] If I make an attribute "[a unicode version of B]", it gets assigned to "[ascii B]", and so on.

2017-06-27 Thread Steven D'Aprano

Changes by Steven D'Aprano :


--
nosy: +steven.daprano

___
Python tracker 

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



[issue30772] If I make an attribute "[a unicode version of B]", it gets assigned to "[ascii B]", and so on.

2017-06-26 Thread Matthew Barnett

Matthew Barnett added the comment:

See PEP 3131 -- Supporting Non-ASCII Identifiers

It says: """All identifiers are converted into the normal form NFKC while 
parsing; comparison of identifiers is based on NFKC."""

>>> import unicodedata
>>> unicodedata.name(unicodedata.normalize('NFKC', '\N{MATHEMATICAL 
>>> DOUBLE-STRUCK CAPITAL B}'))
'LATIN CAPITAL LETTER B'

--
nosy: +mrabarnett

___
Python tracker 

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



[issue30772] If I make an attribute "[a unicode version of B]", it gets assigned to "[ascii B]", and so on.

2017-06-26 Thread Ezio Melotti

Ezio Melotti added the comment:

I can reproduce the issue:
$ cat foo.py 
픹픹 = 1
__all__ = ['픹픹']

$ python3 -c 'import foo; print(dir(foo)); from foo import *'
['BB', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', 
'__loader__', '__name__', '__package__', '__spec__']
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: module 'foo' has no attribute '픹픹

(Note the ascii 'BB' in the dir(foo))


There's also an easier way to reproduce it:
>>> 픹픹= 3
>>> 픹픹
3
>>> BB
3
>>> globals()['BB']
3
>>> globals()['픹픹']
Traceback (most recent call last):
  File "", line 1, in 
KeyError: '픹픹'
>>> globals()
{'__name__': '__main__', '__spec__': None, '__builtins__': , '__loader__': , 
'__doc__': None, 'BB': 3, '__package__': None}
>>> class Foo:
... 픹  픹= 3
... 
>>> Foo.픹픹
3
>>> Foo.BB
3

It seems the '픹픹' gets normalized to 'BB' when it's an identifier, but not when 
it's a string.  I'm not sure why this happens though.

--

___
Python tracker 

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



[issue30772] If I make an attribute "[a unicode version of B]", it gets assigned to "[ascii B]", and so on.

2017-06-26 Thread Nate Soares

New submission from Nate Soares:

[NOTE: In this comment, I use BB to mean unicode character 0x1D539, b/c the 
issue tracker won't let me submit a comment with unicode characters in it.]

Directory structure:

repro/
  foo.py
  test_foo.py

Contents of foo.py:
BB = 1
__all__ = ['BB']

Contents of test_foo.py:
from .foo import *

Error message:
AttributeError: module 'repro.foo' has no attribute 'BB'

If I change foo.py to have `__all__ = ['B']` (note that 'B' is not the same as 
'BB'), then everything works "fine", modulo the fact that now foo.B is a thing 
and foo.BB is not a thing.

[Recall that in the above, BB is a placeholder for U+1D539, which the 
issuetracker prevents me from writing here.]

--
components: Unicode
messages: 296928
nosy: Nate Soares, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: If I make an attribute "[a unicode version of B]", it gets assigned to 
"[ascii B]", and so on.
versions: Python 3.6

___
Python tracker 

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