* [tip:perf/core] perf python: Use exception to propagate errors
@ 2011-06-03 13:36 tip-bot for Arnaldo Carvalho de Melo
0 siblings, 0 replies; only message in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2011-06-03 13:36 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, eranian, paulus, acme, hpa, mingo, peterz, efault,
fweisbec, tglx
Commit-ID: 5c6970af2f4be4e04b06fe78214f6809777a8354
Gitweb: http://git.kernel.org/tip/5c6970af2f4be4e04b06fe78214f6809777a8354
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Thu, 2 Jun 2011 10:55:10 -0300
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 2 Jun 2011 10:55:10 -0300
perf python: Use exception to propagate errors
We were using pr_debug to tell the user about not being able to parse a sample
where we should really use the python way of reporting errors: exceptions.
Fixes this problem:
[root@emilia ~]# python
>>> import perf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/acme/git/build/perf/python/perf.so: undefined symbol: eprintf
>>>
[root@emilia ~]
As we want to keep the objects linked in the python binding (and in the future
in a shared library) minimal.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-m9dba9kaluas0kq8r58z191c@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/python.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 69436b3..2dd1698 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -694,14 +694,12 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
err = perf_event__parse_sample(event, first->attr.sample_type,
perf_sample_size(first->attr.sample_type),
sample_id_all, &pevent->sample);
- if (err) {
- pr_err("Can't parse sample, err = %d\n", err);
- goto end;
- }
-
+ if (err)
+ return PyErr_Format(PyExc_OSError,
+ "perf: can't parse sample, err=%d", err);
return pyevent;
}
-end:
+
Py_INCREF(Py_None);
return Py_None;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-06-03 13:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-03 13:36 [tip:perf/core] perf python: Use exception to propagate errors tip-bot for Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome