简体   繁体   中英

What does 'File "<string>"' stands for on python debugger and traceback?

Eventually, when I am in a debug session, the current file is named "<string>". What I would expect to see is the name of the module where the debugger is currently on.

The same happens on the traceback:

Traceback (most recent call last):
  ...
  File "~/project_x/app/services/contacts.py", line 23, in find_account
  account = self._account_repo.get_by_id(id)
  File "<string>", line 2, in get_by_id
  File "~/project_x/lib/python3.7/site-packages/pony/orm/core.py", li
ne 528, in new_func
    result = func(*args, **kwargs)

It means that the code came from something that was not a file, but a string. My guess would be an exec() call, but maybe there are other ways of getting the same effect. The previous stack frame might give some clues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM