homepage

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 ezio.melotti
Recipients Nate Soares, ezio.melotti, vstinner
Date 2017年06月26日.19:27:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498505267.77.0.672939265921.issue30772@psf.upfronthosting.co.za>
In-reply-to
Content
I can reproduce the issue:
$ cat foo.py 
BB = 1
__all__ = ['BB']
$ 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 "<string>", line 1, in <module>
AttributeError: module 'foo' has no attribute 'BB
(Note the ascii 'BB' in the dir(foo))
There's also an easier way to reproduce it:
>>> BB= 3
>>> BB
3
>>> BB
3
>>> globals()['BB']
3
>>> globals()['BB']
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
KeyError: 'BB'
>>> globals()
{'__name__': '__main__', '__spec__': None, '__builtins__': <module 'builtins' (built-in)>, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__doc__': None, 'BB': 3, '__package__': None}
>>> class Foo:
... B B= 3
... 
>>> Foo.BB
3
>>> Foo.BB
3
It seems the 'BB' gets normalized to 'BB' when it's an identifier, but not when it's a string. I'm not sure why this happens though.
History
Date User Action Args
2017年06月26日 19:27:47ezio.melottisetrecipients: + ezio.melotti, vstinner, Nate Soares
2017年06月26日 19:27:47ezio.melottisetmessageid: <1498505267.77.0.672939265921.issue30772@psf.upfronthosting.co.za>
2017年06月26日 19:27:47ezio.melottilinkissue30772 messages
2017年06月26日 19:27:47ezio.melotticreate

AltStyle によって変換されたページ (->オリジナル) /