Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
better error if sys.stderr is None
Browse files Browse the repository at this point in the history
Issue #21497: faulthandler functions now raise a better error if
sys.stderr is None: RuntimeError("sys.stderr is None") instead of
AttributeError("'NoneType' object has no attribute 'fileno'").

Set also version to 2.4.
  • Loading branch information
haypoenovance committed Sep 24, 2014
1 parent 6a5a523 commit ceede93
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ faulthandler.__version__ is the module version as a string (e.g. "2.0").
Changelog
=========

Version 2.4
-----------

* Python issue #21497: faulthandler functions now raise a better error if
``sys.stderr`` is ``None``: RuntimeError("sys.stderr is None") instead of
AttributeError("'NoneType' object has no attribute 'fileno'").

Version 2.3 (2013-12-17)
------------------------

Expand Down
8 changes: 6 additions & 2 deletions faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "pythread.h"
#include <signal.h>

#define VERSION 0x203
#define VERSION 0x204

/* Allocate at maximum 100 MB of the stack to raise the stack overflow */
#define STACK_OVERFLOW_MAX_SIZE (100*1024*1024)
Expand Down Expand Up @@ -157,6 +157,10 @@ faulthandler_get_fileno(PyObject *file, int *p_fd)
PyErr_SetString(PyExc_RuntimeError, "unable to get sys.stderr");
return NULL;
}
if (file == Py_None) {
PyErr_SetString(PyExc_RuntimeError, "sys.stderr is None");
return NULL;
}
}

result = PyObject_CallMethod(file, "fileno", "");
Expand Down Expand Up @@ -316,7 +320,7 @@ faulthandler_fatal_error(int signum)
return;
}
#endif
/* call the previous signal handler: it is called immediatly if we use
/* call the previous signal handler: it is called immediately if we use
sigaction() thanks to SA_NODEFER flag, otherwise it is deferred */
raise(signum);
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
print("ERROR: faulthandler is a builtin module since Python 3.3")
sys.exit(1)

VERSION = "2.3"
VERSION = "2.4"

FILES = ['faulthandler.c', 'traceback.c']

Expand Down

0 comments on commit ceede93

Please sign in to comment.