how to trouble shoot - RuntimeError: Open Failed

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Sep 6 11:27:14 EDT 2013


On Fri, 06 Sep 2013 08:00:13 -0700, stas poritskiy wrote:

> hey guys,
> I am working on application. App is processing a list of files in
> folders. Folders act as a NEW-LOOP. so if all files in one folder had
> been worked on, file is then saved and next folder is picked up. it
> works fine only if i have a SINGLE folder, however, when another folder
> is there, i get this RuntimeError: Open Failed. I checked if those could
> be the files by leaving only single (another folder), however all was
> fine. Questions - How can i trouble shoot what is causing the problem? i
> don't know where to begin.

You should ALWAYS begin with the entire traceback, not just the last 
line. Everything starting with:

Traceback (most recent call last):


and ending with the last line, which in your case will be something like 
"RuntimeError: Open failed". The most important part is that the 
traceback will actually show you the line that fails.

Secondly, whose code is this? I assume it is code you have written. In 
that case, do you have something like this in your code?

try:
    blah blah blah  # whatever, doesn't matter what this is
except:
    raise RuntimeError("Open failed")


If so, take it out immediately! All you are doing is catching a *useful* 
exception that Python generates, and replacing it with an utterly useless 
exception that does nothing but hide the true cause of the problem and 
make debugging much more difficult.


That will do to start. If you still need help, please copy and paste the 
entire traceback. Also, demonstrating a *minimal* amount of code that 
causes this error will help. Although this is written for Java 
programmers, the same principles apply to Python code too:

http://sscce.org/


-- 
Steven



More information about the Python-list mailing list