Rev 1049: Fix imports of python modules. in file:///data/jelmer/bzr-svn/cext/
Jelmer Vernooij
jelmer at samba.org
Mon Jun 2 19:58:49 BST 2008
At file:///data/jelmer/bzr-svn/cext/
------------------------------------------------------------
revno: 1049
revision-id: jelmer at samba.org-20080602185848-y829w4ttmwxdsgsy
parent: jelmer at samba.org-20080602174759-60ftadjyjha0lhj6
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: cext
timestamp: Mon 2008-06-02 20:58:48 +0200
message:
Fix imports of python modules.
modified:
client.c client.pyx-20080313235339-wbyjbw2namuiql8f-1
core.c core.pyx-20080313210413-17k59slolpfe5kdq-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
repos.c repos.pyx-20080314114432-g2b5lqe776tkbl4k-1
util.h util.h-20080531154025-s8ef6ej9tytsnkkw-2
wc.c wc.pyx-20080313142018-10l8l23vha2j9e6b-1
=== modified file 'client.c'
--- a/client.c 2008-05-31 19:43:52 +0000
+++ b/client.c 2008-06-02 18:58:48 +0000
@@ -24,6 +24,8 @@
#include "util.h"
+PyAPI_DATA(PyTypeObject) Client_Type;
+
static bool to_opt_revision(PyObject *arg, svn_opt_revision_t *ret)
{
if (PyInt_Check(arg)) {
@@ -83,8 +85,6 @@
return Py_BuildValue("(izz)", ci->revision, ci->date, ci->author);
}
-PyAPI_DATA(PyTypeObject) Client_Type;
-
typedef struct {
PyObject_HEAD
svn_client_ctx_t *client;
@@ -391,7 +391,7 @@
};
PyTypeObject Client_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "client.Client",
.tp_basicsize = sizeof(ClientObject),
.tp_methods = client_methods,
=== modified file 'core.c'
--- a/core.c 2008-06-02 17:12:25 +0000
+++ b/core.c 2008-06-02 18:58:48 +0000
@@ -47,10 +47,9 @@
}
PyTypeObject SubversionExceptionType = {
- PyObject_HEAD_INIT(&PyExc_BaseException) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "core.SubversionException",
.tp_basicsize = sizeof(SubversionExceptionObject),
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_new = SubversionException_new,
};
@@ -145,7 +144,4 @@
PyModule_AddObject(mod, "NODE_FILE", PyInt_FromLong(svn_node_file));
PyModule_AddObject(mod, "NODE_UNKNOWN", PyInt_FromLong(svn_node_unknown));
PyModule_AddObject(mod, "NODE_NONE", PyInt_FromLong(svn_node_none));
-
- PyModule_AddObject(mod, "SubversionException", (PyObject *)&SubversionExceptionType);
- Py_INCREF(&SubversionExceptionType);
}
=== modified file 'ra.c'
--- a/ra.c 2008-06-02 17:47:59 +0000
+++ b/ra.c 2008-06-02 18:58:48 +0000
@@ -186,7 +186,7 @@
}
PyTypeObject Reporter_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "ra.Reporter",
.tp_methods = reporter_methods,
.tp_dealloc = reporter_dealloc,
@@ -225,7 +225,7 @@
} TxDeltaWindowHandlerObject;
PyTypeObject TxDeltaWindowHandler_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "ra.TxDeltaWindowHandler",
.tp_call = NULL, /* FIXME */
};
@@ -282,7 +282,7 @@
};
PyTypeObject FileEditor_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "ra.FileEditor",
.tp_methods = py_file_editor_methods,
.tp_dealloc = py_editor_dealloc,
@@ -447,7 +447,7 @@
};
PyTypeObject DirectoryEditor_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "ra.DirEditor",
.tp_methods = py_dir_editor_methods,
.tp_dealloc = py_editor_dealloc,
@@ -512,7 +512,7 @@
};
PyTypeObject Editor_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "ra.Editor",
.tp_methods = py_editor_methods,
.tp_dealloc = py_editor_dealloc,
@@ -526,7 +526,7 @@
PyObject *version(PyObject *self)
{
const svn_version_t *ver = svn_ra_version();
- return Py_BuildValue("(iiii)", ver->major, ver->minor,
+ return Py_BuildValue("(iiis)", ver->major, ver->minor,
ver->patch, ver->tag);
}
@@ -774,7 +774,7 @@
typedef struct {
svn_ra_session_t *ra;
apr_pool_t *pool;
- PyObject *url;
+ char *url;
PyObject *progress_func;
AuthObject *auth;
} RemoteAccessObject;
@@ -782,7 +782,7 @@
static PyObject *ra_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
char *kwnames[] = { "url", "progress_cb", "auth", "config", NULL };
- PyObject *url;
+ char *url;
PyObject *progress_cb = Py_None;
AuthObject *auth = (AuthObject *)Py_None;
PyObject *config = Py_None;
@@ -792,7 +792,7 @@
Py_ssize_t idx = 0;
PyObject *key, *value;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOO", kwnames, &url, &progress_cb, (PyObject **)&auth, &config))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|OOO", kwnames, &url, &progress_cb, (PyObject **)&auth, &config))
return NULL;
ret = PyObject_New(RemoteAccessObject, &RemoteAccess_Type);
@@ -806,10 +806,9 @@
Py_INCREF(auth);
}
- ret->url = url;
- Py_INCREF(url);
ret->auth = auth;
ret->pool = Pool(NULL);
+ ret->url = apr_pstrdup(ret->pool, url);
if (!check_error(svn_ra_create_callbacks(&callbacks2, ret->pool))) {
apr_pool_destroy(ret->pool);
PyObject_Del(ret);
@@ -825,7 +824,7 @@
apr_hash_set(config_hash, PyString_AsString(key),
PyString_Size(key), PyString_AsString(value));
}
- if (!check_error(svn_ra_open2(&ret->ra, PyString_AsString(url),
+ if (!check_error(svn_ra_open2(&ret->ra, url,
callbacks2, NULL, config_hash, ret->pool))) {
apr_pool_destroy(ret->pool);
PyObject_Del(ret);
@@ -1184,7 +1183,7 @@
char *capability;
apr_pool_t *temp_pool;
RemoteAccessObject *ra = (RemoteAccessObject *)self;
- int has;
+ int has = 0;
if (!PyArg_ParseTuple(args, "s", &capability))
return NULL;
@@ -1195,6 +1194,7 @@
svn_ra_has_capability(ra->ra, &has, capability, temp_pool));
#else
PyErr_SetNone(PyExc_NotImplementedError);
+ return NULL;
#endif
apr_pool_destroy(temp_pool);
return PyBool_FromLong(has);
@@ -1361,7 +1361,6 @@
static void ra_dealloc(PyObject *self)
{
RemoteAccessObject *ra = (RemoteAccessObject *)self;
- Py_DECREF(ra->url);
apr_pool_destroy(ra->pool);
Py_DECREF(ra->auth);
}
@@ -1369,7 +1368,7 @@
static PyObject *ra_repr(PyObject *self)
{
RemoteAccessObject *ra = (RemoteAccessObject *)self;
- return PyString_FromFormat("RemoteAccess(%s)", PyString_AsString(ra->url));
+ return PyString_FromFormat("RemoteAccess(%s)", ra->url);
}
static PyMethodDef ra_methods[] = {
@@ -1397,8 +1396,9 @@
};
PyTypeObject RemoteAccess_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "ra.RemoteAccess",
+ .tp_basicsize = sizeof(RemoteAccessObject),
.tp_new = ra_new,
.tp_dealloc = ra_dealloc,
.tp_repr = ra_repr,
@@ -1418,7 +1418,7 @@
}
PyTypeObject AuthProvider_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "ra.AuthProvider",
.tp_dealloc = auth_provider_dealloc,
};
@@ -1491,7 +1491,7 @@
}
PyTypeObject Auth_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_new = auth_init,
.tp_dealloc = auth_dealloc,
.tp_name = "ra.Auth",
@@ -1693,9 +1693,37 @@
void initra(void)
{
PyObject *mod;
+
+ if (PyType_Ready(&RemoteAccess_Type) < 0)
+ return;
+
+ if (PyType_Ready(&Editor_Type) < 0)
+ return;
+
+ if (PyType_Ready(&FileEditor_Type) < 0)
+ return;
+
+ if (PyType_Ready(&DirectoryEditor_Type) < 0)
+ return;
+
+ if (PyType_Ready(&Reporter_Type) < 0)
+ return;
+
+ if (PyType_Ready(&TxDeltaWindowHandler_Type) < 0)
+ return;
+
+ if (PyType_Ready(&Auth_Type) < 0)
+ return;
+
+ if (PyType_Ready(&AuthProvider_Type) < 0)
+ return;
+
apr_initialize();
mod = Py_InitModule3("ra", ra_module_methods, "Remote Access");
if (mod == NULL)
return;
+
+ PyModule_AddObject(mod, "RemoteAccess", (PyObject *)&RemoteAccess_Type);
+ Py_INCREF(&RemoteAccess_Type);
}
=== modified file 'repos.c'
--- a/repos.c 2008-06-02 17:12:25 +0000
+++ b/repos.c 2008-06-02 18:58:48 +0000
@@ -131,7 +131,7 @@
};
PyTypeObject Repository_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "repos.Repository",
.tp_dealloc = repos_dealloc,
.tp_methods = repos_methods,
@@ -142,6 +142,9 @@
{
PyObject *mod;
+ if (PyType_Ready(&Repository_Type) < 0)
+ return;
+
apr_initialize();
mod = Py_InitModule3("repos", repos_module_methods, "Local repository management");
@@ -151,4 +154,7 @@
PyModule_AddObject(mod, "LOAD_UUID_DEFAULT", PyLong_FromLong(0));
PyModule_AddObject(mod, "LOAD_UUID_IGNORE", PyLong_FromLong(1));
PyModule_AddObject(mod, "LOAD_UUID_FORCE", PyLong_FromLong(2));
+
+ PyModule_AddObject(mod, "Repository", (PyObject *)&Repository_Type);
+ Py_INCREF(&Repository_Type);
}
=== modified file 'util.h'
--- a/util.h 2008-06-02 17:12:25 +0000
+++ b/util.h 2008-06-02 18:58:48 +0000
@@ -21,7 +21,7 @@
#define _BZR_SVN_UTIL_H_
apr_pool_t *Pool(apr_pool_t *parent);
-bool check_error(svn_error_t *error);
+__attribute__((warn_unused_result)) bool check_error(svn_error_t *error);
apr_array_header_t *string_list_to_apr_array(apr_pool_t *pool, PyObject *l);
PyObject *prop_hash_to_dict(apr_hash_t *props);
svn_error_t *py_svn_log_wrapper(void *baton, apr_hash_t *changed_paths,
=== modified file 'wc.c'
--- a/wc.c 2008-06-02 17:47:59 +0000
+++ b/wc.c 2008-06-02 18:58:48 +0000
@@ -100,7 +100,7 @@
static PyObject *version(PyObject *self)
{
const svn_version_t *ver = svn_wc_version();
- return Py_BuildValue("(iiii)", ver->major, ver->minor,
+ return Py_BuildValue("(iiis)", ver->major, ver->minor,
ver->patch, ver->tag);
}
@@ -135,7 +135,7 @@
}
PyTypeObject Entry_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "wc.Entry",
.tp_basicsize = sizeof(EntryObject),
.tp_dealloc = entry_dealloc,
@@ -260,7 +260,7 @@
return NULL;
temp_pool = Pool(admobj->pool);
- check_error(svn_wc_entries_read(&entries, admobj->adm,
+ RUN_SVN_WITH_POOL(temp_pool, svn_wc_entries_read(&entries, admobj->adm,
show_hidden, temp_pool));
py_entries = PyDict_New();
idx = apr_hash_first(temp_pool, entries);
@@ -332,11 +332,11 @@
return NULL;
temp_pool = Pool(admobj->pool);
- check_error(svn_wc_get_prop_diffs(&propchanges, &original_props,
+ RUN_SVN_WITH_POOL(temp_pool, svn_wc_get_prop_diffs(&propchanges, &original_props,
path, admobj->adm, temp_pool));
py_propchanges = PyList_New(propchanges->nelts);
for (i = 0; i < propchanges->nelts; i++) {
- el = (svn_prop_t *)propchanges->elts[i];
+ el = (svn_prop_t *)(propchanges->elts + (i * propchanges->elt_size));
PyList_SetItem(py_propchanges, i,
Py_BuildValue("(ss#)", el->name, el->value->data, el->value->len));
}
@@ -458,11 +458,14 @@
pool = Pool(NULL);
latest_revnum = (svn_revnum_t *)apr_palloc(pool, sizeof(svn_revnum_t));
- check_error(svn_wc_get_update_editor2(latest_revnum, admobj->adm, target,
+ if (!check_error(svn_wc_get_update_editor2(latest_revnum, admobj->adm, target,
use_commit_times, recurse, py_wc_notify_func, (void *)notify_func,
py_cancel_func, (void *)cancel_func, diff3_cmd, &editor, &edit_baton,
- NULL, pool));
- return new_editor(editor, edit_baton, pool);
+ NULL, pool))) {
+ apr_pool_destroy(pool);
+ return NULL;
+ }
+ return new_editor_object(editor, edit_baton, pool, &Editor_Type);
}
static PyObject *adm_close(PyObject *self)
@@ -500,7 +503,7 @@
};
PyTypeObject Adm_Type = {
- PyObject_HEAD_INIT(NULL) 0,
+ PyObject_HEAD_INIT(&PyType_Type) 0,
.tp_name = "wc.Adm",
.tp_basicsize = sizeof(AdmObject),
.tp_new = adm_init,
@@ -528,7 +531,7 @@
return NULL;
temp_pool = Pool(NULL);
- check_error(svn_wc_revision_status(&revstatus, wc_path, trail_url,
+ RUN_SVN_WITH_POOL(temp_pool, svn_wc_revision_status(&revstatus, wc_path, trail_url,
committed, py_cancel_func, cancel_func, temp_pool));
ret = Py_BuildValue("(llbb)", revstatus->min_rev, revstatus->max_rev,
revstatus->switched, revstatus->modified);
@@ -613,7 +616,7 @@
hash_config = apr_hash_make(pool);
while (PyDict_Next(config, &idx, &pyk, &pyv))
apr_hash_set(hash_config, (char *)PyString_AsString(pyk), PyString_Size(pyk), (char *)PyString_AsString(pyv));
- check_error(svn_wc_get_default_ignores(&patterns, hash_config, pool));
+ RUN_SVN_WITH_POOL(pool, svn_wc_get_default_ignores(&patterns, hash_config, pool));
ret = PyList_New(patterns->nelts);
pattern = (char **)apr_array_pop(patterns);
while (pattern != NULL) {
@@ -677,6 +680,12 @@
{
PyObject *mod;
+ if (PyType_Check(&Entry_Type) < 0)
+ return;
+
+ if (PyType_Check(&Adm_Type) < 0)
+ return;
+
apr_initialize();
mod = Py_InitModule3("wc", wc_methods, "Working Copies");
@@ -687,4 +696,7 @@
PyModule_AddObject(mod, "SCHEDULE_ADD", PyLong_FromLong(1));
PyModule_AddObject(mod, "SCHEDULE_DELETE", PyLong_FromLong(2));
PyModule_AddObject(mod, "SCHEDULE_REPLACE", PyLong_FromLong(3));
+
+ PyModule_AddObject(mod, "Adm", (PyObject *)&Adm_Type);
+ Py_INCREF(&Adm_Type);
}
More information about the bazaar-commits
mailing list