Commits

JanKanis committed 2193c8b Draft

more useful exception messages

Comments (0)

Files changed (1)

inotify/_inotify.c

 	if (argc == -1)
 		goto bail;
 	if (argc > 1) {
-		PyErr_SetString(PyExc_TypeError, "read() takes exactly 1 positional argument but more were given");
+		PyErr_Format(PyExc_TypeError, "read() takes exactly 1 positional argument but %i were given", argc);
 		goto bail;
 	}
 #endif
 	if (ctor_args == NULL)
 		goto bail;
 
-	Py_BEGIN_ALLOW_THREADS
+	Py_BEGIN_ALLOW_THREADS;
 	ioctl_retval = ioctl(fd, FIONREAD, &readable);
-	Py_END_ALLOW_THREADS
+	Py_END_ALLOW_THREADS;
 
 	if (ioctl_retval < 0) {
 		PyErr_SetFromErrno(PyExc_OSError);
 
 		Py_BEGIN_ALLOW_THREADS
 		nread = read(fd, buffer + pos, toread);
-		Py_END_ALLOW_THREADS
+		Py_END_ALLOW_THREADS;
 
 		if (nread == -1) {
 			PyErr_SetFromErrno(PyExc_OSError);
 						in->len >= readable - (read_total - nread + pos + INE_SIZE)) {
 					// This is not supposed to happen, unless we are reading
 					// garbage. Maybe the fd wasn't an inotify fd?
-					PyErr_SetString(PyExc_TypeError, "python-inotify internal error: " 
-							"read value from inotify fd seems to be garbage, "
-							"are you sure this is the right fd?");
+					PyErr_Format(PyExc_TypeError, "python-inotify internal error: " 
+							"read value from fd %i seems to be garbage, "
+							"are you sure this is the right fd?", fd);
 					goto bail;
 				}
 				// we read a partial message