Title: token module should define __all__
Type: Stage: patch review
Components: Library (Lib) Versions: Python 3.2
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: belopolsky, fdrake
Priority: normal Keywords: patch

Created on 2010-11-11 04:06 by belopolsky, last changed 2010-11-11 14:11 by belopolsky. This issue is now closed.

File name Uploaded Description Edit
token-all.diff belopolsky, 2010-11-11 04:06
Messages (3)
msg120938 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-11-11 04:06
The token module appears to be designed to be used with import *.  In fact it is used this way in the tokenize module.  However it does not define __all__ and as a result, from token import * leaks symbol "main":

>>> import tokenize
>>> tokenize.main.__module__

Attached patch adds token.__all__ and "modernizes" generation of the tok_name dictionary.

I also renamed main to _main because it is hard to imagine that any user code would ever want to use it.
msg120949 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2010-11-11 13:47
Normally, I'd recommend leaving the "main" name alone, but in the case of modules that use it as an tool for module maintenance (symbol, token), I don't think it matters either way.

Ok to commit.
msg120952 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-11-11 14:10
Committed revision 86410.
Date User Action Args
2010-11-11 14:11:27belopolskysetstatus: open -> closed
2010-11-11 14:10:41belopolskysetmessages: + msg120952
2010-11-11 13:47:29fdrakesetnosy: + fdrake
messages: + msg120949

assignee: belopolsky
resolution: accepted
2010-11-11 04:06:52belopolskycreate