[issue31726] Missing token.COMMENT
Franck Pommereau
report at bugs.python.org
Sun Oct 8 12:38:09 EDT 2017
Franck Pommereau <franck.pommereau at gmail.com> added the comment:
I've just launched ipython3 (installed with pip):
$ ipython3
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import token, tokenize, io
In [2]: token.BACKQUOTE
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-ebc28b79826c> in <module>()
----> 1 token.BACKQUOTE
AttributeError: 'module' object has no attribute 'BACKQUOTE'
In [3]: _tok = next(tokenize.tokenize(io.BytesIO(b"").readline))
In [4]: token.tok_name[_tok.type] = "BACKQUOTE"
In [5]: for number, name in token.tok_name.items() :
...: if not hasattr(token, name) :
...: print(name, "=", number)
...:
COMMENT = 54
NL = 55
BACKQUOTE = 56
ATEQUAL = 57
COMMENT = 58
If instead I use python3 as provided by my Linux Mint, the result is different indeed:
$ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import token, tokenize, io
>>> token.BACKQUOTE
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'BACKQUOTE'
>>> _tok = next(tokenize.tokenize(io.BytesIO(b"").readline))
>>> token.tok_name[_tok.type] = "BACKQUOTE"
>>> for number, name in token.tok_name.items() :
... if not hasattr(token, name) :
... print(name, "=", number)
...
COMMENT = 54
NL = 55
BACKQUOTE = 56
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31726>
_______________________________________
More information about the Python-bugs-list
mailing list