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: 'import traceback' Causes a Crash
Type: behavior Stage: resolved
Components: macOS Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: bichanna, kumaraditya, ned.deily, ronaldoussoren, steven.daprano
Priority: normal Keywords:

Created on 2022-01-10 05:35 by bichanna, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg410187 - (view) Author: bichanna (bichanna) Date: 2022-01-10 05:35
I was developing a programming language using Python, and I had a 'token.py' file. After changing the name of the file, the issue was solved.

I am sure that my 'token.py' caused the error.

Here's the traceback I got:
Traceback (most recent call last):
  File "/some/path/main.py", line 2, in <module>
    from parser import Parser
  File "/some/path/parser.py", line 3, in <module>
    import traceback
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/traceback.py", line 5, in <module>
    import linecache
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/linecache.py", line 11, in <module>
    import tokenize
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tokenize.py", line 35, in <module>
    from token import EXACT_TOKEN_TYPES
ImportError: cannot import name 'EXACT_TOKEN_TYPES' from 'token' (/some/path/token.py)
msg410189 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2022-01-10 06:45
Python has a token module so you should use any other name for your module.
msg410191 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2022-01-10 07:16
Your module token.py "shadowed" the stdlib token.py, and prevented it from being seen until you changed the name.
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90482
2022-01-10 07:16:24steven.dapranosetstatus: open -> closed

type: crash -> behavior

nosy: + steven.daprano
messages: + msg410191
resolution: not a bug
stage: resolved
2022-01-10 06:45:35kumaradityasetnosy: + kumaraditya
messages: + msg410189
2022-01-10 05:35:37bichannacreate