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

Issue

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)

Solution

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.



Answered By - Ture Pålsson
Answer Checked By - Mary Flores (Python.Easybugfix Volunteer)

Related Posts

Post a Comment