chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemd-python: some python3 and bug fixes
[elogind.git]
/
src
/
python-systemd
/
_reader.c
diff --git
a/src/python-systemd/_reader.c
b/src/python-systemd/_reader.c
index 06bdf1694e90291d5413763e73ad29482c25fee0..ae3d77cfe9ef2fdc678d010ebd1e903dffd11f0f 100644
(file)
--- a/
src/python-systemd/_reader.c
+++ b/
src/python-systemd/_reader.c
@@
-383,7
+383,7
@@
Journal_seek(Journal *self, PyObject *args, PyObject *keywds)
&offset, &whence))
return NULL;
&offset, &whence))
return NULL;
- PyObject *
arg
;
+ PyObject *
result=NULL
;
if (whence == SEEK_SET){
int r;
Py_BEGIN_ALLOW_THREADS
if (whence == SEEK_SET){
int r;
Py_BEGIN_ALLOW_THREADS
@@
-394,10
+394,10
@@
Journal_seek(Journal *self, PyObject *args, PyObject *keywds)
return NULL;
}
if (offset > 0LL) {
return NULL;
}
if (offset > 0LL) {
-
Py_DECREF(PyObject_CallMethod((PyObject *)self, "get_next", "L", offset)
);
+
result = PyObject_CallMethod((PyObject *)self, "get_next", "L", offset
);
}
}else if (whence == SEEK_CUR){
}
}else if (whence == SEEK_CUR){
-
Py_DECREF(PyObject_CallMethod((PyObject *)self, "get_next", "L", offset)
);
+
result = PyObject_CallMethod((PyObject *)self, "get_next", "L", offset
);
}else if (whence == SEEK_END){
int r;
Py_BEGIN_ALLOW_THREADS
}else if (whence == SEEK_END){
int r;
Py_BEGIN_ALLOW_THREADS
@@
-407,14
+407,19
@@
Journal_seek(Journal *self, PyObject *args, PyObject *keywds)
PyErr_SetString(PyExc_RuntimeError, "Error seeking to tail");
return NULL;
}
PyErr_SetString(PyExc_RuntimeError, "Error seeking to tail");
return NULL;
}
- Py_DECREF(PyObject_CallMethod((PyObject *)self, "get_next", "L", -1LL));
if (offset < 0LL) {
if (offset < 0LL) {
- Py_DECREF(PyObject_CallMethod((PyObject *)self, "get_next", "L", offset));
+ result = PyObject_CallMethod((PyObject *)self, "get_next", "L", offset);
+ }else{
+ result = PyObject_CallMethod((PyObject *)self, "get_next", "L", -1LL);
}
}else{
PyErr_SetString(PyExc_ValueError, "Invalid value for whence");
}
}else{
PyErr_SetString(PyExc_ValueError, "Invalid value for whence");
- return NULL;
}
}
+
+ if (result)
+ Py_DECREF(result);
+ if (PyErr_Occurred())
+ return NULL;
Py_RETURN_NONE;
}
Py_RETURN_NONE;
}
@@
-607,7
+612,7
@@
Journal_iter(PyObject *self)
static PyObject *
Journal_iternext(PyObject *self)
{
static PyObject *
Journal_iternext(PyObject *self)
{
- PyObject *dict
, *arg
;
+ PyObject *dict;
Py_ssize_t dict_size;
dict = PyObject_CallMethod(self, "get_next", "");
Py_ssize_t dict_size;
dict = PyObject_CallMethod(self, "get_next", "");