diff options
author | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-07-24 13:39:58 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-07-24 13:39:58 +0000 |
commit | 8705f6df461e5964994be3086b514844f29f56fd (patch) | |
tree | 4a08bbaadd4d1198540cee9ce2c1cf9d2edf54c0 /subvertpy | |
parent | 8e15cf0c137a3d3805ad07babcddfe603e477727 (diff) |
Remove some uses of PyString.
Diffstat (limited to 'subvertpy')
-rw-r--r-- | subvertpy/_ra.c | 19 | ||||
-rw-r--r-- | subvertpy/editor.c | 4 | ||||
-rw-r--r-- | subvertpy/util.c | 2 |
3 files changed, 17 insertions, 8 deletions
diff --git a/subvertpy/_ra.c b/subvertpy/_ra.c index 951bdbb2..917bfee6 100644 --- a/subvertpy/_ra.c +++ b/subvertpy/_ra.c @@ -883,7 +883,7 @@ static PyObject *ra_get_repos_root(PyObject *self) apr_pool_destroy(temp_pool); } - return PyString_FromString(ra->root); + return PyUnicode_FromString(ra->root); } /** @@ -905,7 +905,7 @@ static PyObject *ra_get_url(PyObject *self, void *closure) RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_session_url(ra->ra, &url, temp_pool)); - r = PyString_FromString(url); + r = PyUnicode_FromString(url); apr_pool_destroy(temp_pool); @@ -1338,7 +1338,7 @@ static PyObject *get_commit_editor(PyObject *self, PyObject *args, PyObject *kwa goto fail_prep; } apr_hash_set(hash_lock_tokens, PyBytes_AsString(k), - PyString_Size(k), PyBytes_AsString(v)); + PyBytes_Size(k), PyBytes_AsString(v)); } } @@ -1924,8 +1924,17 @@ static PyObject *ra_get_locations(PyObject *self, PyObject *args) for (idx = apr_hash_first(temp_pool, hash_locations); idx != NULL; idx = apr_hash_next(idx)) { + PyObject *py_key, *py_val; apr_hash_this(idx, (const void **)&key, &klen, (void **)&val); - if (PyDict_SetItem(ret, py_from_svn_revnum(*key), PyString_FromString(val)) != 0) { + py_key = py_from_svn_revnum(*key); + if (py_key == NULL) { + goto fail_conv; + } + py_val = PyUnicode_FromString(val); + if (py_val == NULL) { + goto fail_conv; + } + if (PyDict_SetItem(ret, py_key, py_val) != 0) { goto fail_conv; } } @@ -2522,7 +2531,7 @@ static PyObject *auth_get_parameter(PyObject *self, PyObject *args) return PyLong_FromLong(*((apr_uint32_t *)value)); } else if (!strcmp(name, SVN_AUTH_PARAM_DEFAULT_USERNAME) || !strcmp(name, SVN_AUTH_PARAM_DEFAULT_PASSWORD)) { - return PyString_FromString((const char *)value); + return PyUnicode_FromString((const char *)value); } else { PyErr_Format(PyExc_TypeError, "Unsupported auth parameter %s", name); return NULL; diff --git a/subvertpy/editor.c b/subvertpy/editor.c index 4daffdb5..b425de0c 100644 --- a/subvertpy/editor.c +++ b/subvertpy/editor.c @@ -1148,8 +1148,8 @@ svn_error_t *py_txdelta_window_handler(svn_txdelta_window_t *window, void *baton } } if (window->new_data != NULL && window->new_data->data != NULL) { - py_new_data = PyString_FromStringAndSize(window->new_data->data, - window->new_data->len); + py_new_data = PyBytes_FromStringAndSize(window->new_data->data, + window->new_data->len); } else { py_new_data = Py_None; Py_INCREF(py_new_data); diff --git a/subvertpy/util.c b/subvertpy/util.c index 1841a436..7ba20b55 100644 --- a/subvertpy/util.c +++ b/subvertpy/util.c @@ -339,7 +339,7 @@ bool string_list_to_apr_array(apr_pool_t *pool, PyObject *l, apr_array_header_t } for (i = 0; i < PyList_GET_SIZE(l); i++) { PyObject *item = PyList_GET_ITEM(l, i); - if (!PyString_Check(item)) { + if (!PyUnicode_Check(item) && !PyBytes_Check(item)) { PyErr_Format(PyExc_TypeError, "Expected list of strings, item was %s", item->ob_type->tp_name); return false; } |