diff options
author | John Ehresman <jpe@wingware.com> | 2010-04-16 14:50:04 -0400 |
---|---|---|
committer | John Ehresman <jpe@wingware.com> | 2010-04-16 14:50:04 -0400 |
commit | 9debda32a5877b582e93592c9a2f750d1cac9c20 (patch) | |
tree | abfe130879fe1efe90f6152b46263fc50ca06ad3 | |
parent | e5774f5c9ff8301c799eb46f911450f94a01f47b (diff) | |
download | pygobject-9debda32a5877b582e93592c9a2f750d1cac9c20.tar.gz |
Rename _PyUnicode macros to PYGLIB_PyUnicode
30 files changed, 179 insertions, 177 deletions
diff --git a/codegen/libcodegen/argtypes.py b/codegen/libcodegen/argtypes.py index c8252bb7..b506ce6e 100644 --- a/codegen/libcodegen/argtypes.py +++ b/codegen/libcodegen/argtypes.py @@ -109,7 +109,7 @@ class StringArg(ArgType): # have to free result ... info.varlist.add('gchar', '*ret') info.codeafter.append(' if (ret) {\n' + - ' PyObject *py_ret = _PyUnicode_FromString(ret);\n' + + ' PyObject *py_ret = PYGLIB_PyUnicode_FromString(ret);\n' + ' g_free(ret);\n' + ' return py_ret;\n' + ' }\n' + @@ -118,7 +118,7 @@ class StringArg(ArgType): else: info.varlist.add('const gchar', '*ret') info.codeafter.append(' if (ret)\n' + - ' return _PyUnicode_FromString(ret);\n'+ + ' return PYGLIB_PyUnicode_FromString(ret);\n'+ ' Py_INCREF(Py_None);\n' + ' return Py_None;') @@ -151,7 +151,7 @@ class CharArg(ArgType): info.add_parselist('c', ['&' + pname], [pname]) def write_return(self, ptype, ownsreturn, info): info.varlist.add('gchar', 'ret') - info.codeafter.append(' return _PyUnicode_FromStringAndSize(&ret, 1);') + info.codeafter.append(' return PYGLIB_PyUnicode_FromStringAndSize(&ret, 1);') class GUniCharArg(ArgType): ret_tmpl = ('#if !defined(Py_UNICODE_SIZE) || Py_UNICODE_SIZE == 2\n' ' if (ret > 0xffff) {\n' @@ -694,7 +694,7 @@ class AtomArg(IntArg): info.varlist.add('PyObject *', 'py_ret') info.varlist.add('gchar *', 'name') info.codeafter.append(' name = gdk_atom_name(ret);\n' - ' py_ret = _PyUnicode_FromString(name);\n' + ' py_ret = PYGLIB_PyUnicode_FromString(name);\n' ' g_free(name);\n' ' return py_ret;') diff --git a/codegen/libcodegen/codegen.py b/codegen/libcodegen/codegen.py index 538a68c9..9fa203ea 100644 --- a/codegen/libcodegen/codegen.py +++ b/codegen/libcodegen/codegen.py @@ -740,19 +740,19 @@ _wrap__get_symbol_names(PyObject *self) """) for obj, bases in writer.get_classes(): self.fp.write(' PyList_Append(pylist, ' - '_PyUnicode_FromString("%s"));\n' % (obj.name)) + 'PYGLIB_PyUnicode_FromString("%s"));\n' % (obj.name)) for name, cname, flags, docstring in functions: self.fp.write(' PyList_Append(pylist, ' - '_PyUnicode_FromString("%s"));\n' % (name)) + 'PYGLIB_PyUnicode_FromString("%s"));\n' % (name)) for enum in writer.get_enums(): self.fp.write(' PyList_Append(pylist, ' - '_PyUnicode_FromString("%s"));\n' % (enum.name)) + 'PYGLIB_PyUnicode_FromString("%s"));\n' % (enum.name)) for nick, value in enum.values: name = value[len(self.overrides.modulename)+1:] self.fp.write(' PyList_Append(pylist, ' - '_PyUnicode_FromString("%s"));\n' % (name)) + 'PYGLIB_PyUnicode_FromString("%s"));\n' % (name)) self.fp.write(" return pylist;\n}\n\n"); @@ -770,7 +770,7 @@ _wrap__get_symbol(PyObject *self, PyObject *args) return NULL; if (!modulename) - modulename = _PyUnicode_FromString("%s"); + modulename = PYGLIB_PyUnicode_FromString("%s"); if (!module) module = PyDict_GetItemString(d, "__module__"); diff --git a/codegen/libcodegen/reversewrapper.py b/codegen/libcodegen/reversewrapper.py index 27ebb2e7..cfbb7561 100644 --- a/codegen/libcodegen/reversewrapper.py +++ b/codegen/libcodegen/reversewrapper.py @@ -404,13 +404,13 @@ class StringParam(Parameter): if self.props.get('optional', False): self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name) self.wrapper.write_code(code=("if (%s)\n" - " py_%s = _PyUnicode_FromString(%s);\n" + " py_%s = PYGLIB_PyUnicode_FromString(%s);\n" % (self.name, self.name, self.name)), cleanup=("Py_XDECREF(py_%s);" % self.name)) self.wrapper.add_pyargv_item("py_%s" % self.name, optional=True) else: self.wrapper.add_declaration("PyObject *py_%s;" % self.name) - self.wrapper.write_code(code=("py_%s = _PyUnicode_FromString(%s);" % + self.wrapper.write_code(code=("py_%s = PYGLIB_PyUnicode_FromString(%s);" % (self.name, self.name)), cleanup=("Py_DECREF(py_%s);" % self.name), failure_expression=("!py_%s" % self.name)) diff --git a/gio/gappinfo.override b/gio/gappinfo.override index 81caf8e8..0598aff2 100644 --- a/gio/gappinfo.override +++ b/gio/gappinfo.override @@ -202,7 +202,7 @@ _wrap_g_app_info_tp_repr(PyGObject *self) Py_TYPE(self)->tp_name, self, name ? name : "UNKNOWN NAME"); - result = _PyUnicode_FromString(representation); + result = PYGLIB_PyUnicode_FromString(representation); g_free(representation); return result; } diff --git a/gio/gapplaunchcontext.override b/gio/gapplaunchcontext.override index 2e307023..ec5d93bf 100644 --- a/gio/gapplaunchcontext.override +++ b/gio/gapplaunchcontext.override @@ -53,7 +53,7 @@ _wrap_g_app_launch_context_get_display(PyGObject *self, g_list_free(file_list); if (ret) - return _PyUnicode_FromString(ret); + return PYGLIB_PyUnicode_FromString(ret); Py_INCREF(Py_None); return Py_None; @@ -92,7 +92,7 @@ _wrap_g_app_launch_context_get_startup_notify_id(PyGObject *self, g_list_free(file_list); if (ret) - return _PyUnicode_FromString(ret); + return PYGLIB_PyUnicode_FromString(ret); Py_INCREF(Py_None); return Py_None; diff --git a/gio/gdatainputstream.override b/gio/gdatainputstream.override index d2b78ae1..e0fc3d07 100644 --- a/gio/gdatainputstream.override +++ b/gio/gdatainputstream.override @@ -49,7 +49,7 @@ _wrap_g_data_input_stream_read_line(PyGObject *self, if (pyg_error_check(&error)) return NULL; - py_line = _PyUnicode_FromStringAndSize(line, length); + py_line = PYGLIB_PyUnicode_FromStringAndSize(line, length); g_free(line); return py_line; } @@ -128,7 +128,7 @@ _wrap_g_data_input_stream_read_line_finish(PyGObject *self, if (pyg_error_check(&error)) return NULL; - py_line = _PyUnicode_FromStringAndSize(line, length); + py_line = PYGLIB_PyUnicode_FromStringAndSize(line, length); g_free(line); return py_line; } @@ -162,7 +162,7 @@ _wrap_g_data_input_stream_read_until(PyGObject *self, if (pyg_error_check(&error)) return NULL; - py_line = _PyUnicode_FromStringAndSize(line, length); + py_line = PYGLIB_PyUnicode_FromStringAndSize(line, length); g_free(line); return py_line; } @@ -244,7 +244,7 @@ _wrap_g_data_input_stream_read_until_finish(PyGObject *self, if (pyg_error_check(&error)) return NULL; - py_line = _PyUnicode_FromStringAndSize(line, length); + py_line = PYGLIB_PyUnicode_FromStringAndSize(line, length); g_free(line); return py_line; } diff --git a/gio/gdrive.override b/gio/gdrive.override index bea860ad..7ec8e1c3 100644 --- a/gio/gdrive.override +++ b/gio/gdrive.override @@ -160,7 +160,7 @@ _wrap_g_drive_tp_repr(PyGObject *self) else representation = g_strdup_printf("<%s at %p: UNKNOWN NAME>", Py_TYPE(self)->tp_name, self); - result = _PyUnicode_FromString(representation); + result = PYGLIB_PyUnicode_FromString(representation); g_free(representation); return result; } diff --git a/gio/gfile.override b/gio/gfile.override index 4b147987..c68e0a57 100644 --- a/gio/gfile.override +++ b/gio/gfile.override @@ -1342,7 +1342,7 @@ _wrap_g_file_replace_contents(PyGObject *self, PyObject *args, PyObject *kwargs) return NULL; if (ret) { - py_ret = _PyUnicode_FromString(new_etag); + py_ret = PYGLIB_PyUnicode_FromString(new_etag); } else { py_ret = Py_None; Py_INCREF(py_ret); @@ -1378,7 +1378,7 @@ _wrap_g_file_replace_contents_finish(PyGObject *self, PyObject *args, PyObject * return NULL; if (ret) { - py_ret = _PyUnicode_FromString(etag_out); + py_ret = PYGLIB_PyUnicode_FromString(etag_out); return py_ret; } else { py_ret = Py_None; @@ -1504,7 +1504,7 @@ _wrap_g_file_tp_repr(PyGObject *self) else representation = g_strdup_printf("<%s at %p: UNKNOWN URI>", Py_TYPE(self)->tp_name, self); - result = _PyUnicode_FromString(representation); + result = PYGLIB_PyUnicode_FromString(representation); g_free(representation); return result; } diff --git a/gio/gfileattribute.override b/gio/gfileattribute.override index 41294b92..713490dd 100644 --- a/gio/gfileattribute.override +++ b/gio/gfileattribute.override @@ -52,7 +52,7 @@ pyg_file_attribute_info__get_name(PyObject *self, void *closure) ret = ((PyGFileAttributeInfo*)self)->info->name; if (ret) - return _PyUnicode_FromString(ret); + return PYGLIB_PyUnicode_FromString(ret); Py_INCREF(Py_None); return Py_None; } diff --git a/gio/gfileinfo.override b/gio/gfileinfo.override index a0b17d9a..a56e2544 100644 --- a/gio/gfileinfo.override +++ b/gio/gfileinfo.override @@ -64,7 +64,7 @@ _wrap_g_file_info_list_attributes(PyGObject *self, ret = PyList_New(0); n = names; while (n && *n) { - PyObject *item = _PyUnicode_FromString(n[0]); + PyObject *item = PYGLIB_PyUnicode_FromString(n[0]); PyList_Append(ret, item); Py_DECREF(item); diff --git a/gio/gicon.override b/gio/gicon.override index 675ab492..18b764c6 100644 --- a/gio/gicon.override +++ b/gio/gicon.override @@ -183,7 +183,7 @@ _wrap_g_file_icon_tp_repr(PyGObject *self) else representation = g_strdup_printf("<%s at %p: UNKNOWN URI>", Py_TYPE(self)->tp_name, self); - result = _PyUnicode_FromString(representation); + result = PYGLIB_PyUnicode_FromString(representation); g_free(representation); return result; } @@ -202,9 +202,9 @@ _wrap_g_themed_icon_new(PyGObject *self, PyObject *args, PyObject *kwargs) kwlist, &name, &use_default_fallbacks)) return -1; - if (_PyUnicode_Check(name)) { + if (PYGLIB_PyUnicode_Check(name)) { pygobject_construct(self, - "name", _PyUnicode_AsString(name), + "name", PYGLIB_PyUnicode_AsString(name), "use-default-fallbacks", use_default_fallbacks, NULL); return 0; } @@ -218,8 +218,8 @@ _wrap_g_themed_icon_new(PyGObject *self, PyObject *args, PyObject *kwargs) for (k = 0; k < length; k++) { PyObject *str = PyTuple_GetItem(tuple, k); - if (str && _PyUnicode_Check(str)) - names[k] = _PyUnicode_AsString(str); + if (str && PYGLIB_PyUnicode_Check(str)) + names[k] = PYGLIB_PyUnicode_AsString(str); else { Py_DECREF(tuple); g_free(names); @@ -257,7 +257,7 @@ _wrap_g_themed_icon_get_names(PyGObject *self) ret = PyList_New(0); while (names && *names) { - PyObject *item = _PyUnicode_FromString(names[0]); + PyObject *item = PYGLIB_PyUnicode_FromString(names[0]); PyList_Append(ret, item); Py_DECREF(item); @@ -290,7 +290,7 @@ _wrap_g_themed_icon_tp_repr(PyGObject *self) } g_string_append(representation, ">"); - result = _PyUnicode_FromString(representation->str); + result = PYGLIB_PyUnicode_FromString(representation->str); g_string_free(representation, TRUE); return result; } diff --git a/gio/gio.override b/gio/gio.override index c9a40fd8..6eba49f2 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -353,7 +353,7 @@ _wrap_g_content_type_guess(PyGObject *self, PyObject *args, PyObject *kwargs) ret = Py_BuildValue("zN", type, PyBool_FromLong(result_uncertain)); } else { - ret = _PyUnicode_FromString(type); + ret = PYGLIB_PyUnicode_FromString(type); } g_free(type); @@ -371,7 +371,7 @@ _wrap_g_vfs_get_supported_uri_schemes(PyGObject *self) ret = PyList_New(0); while (names && *names) { - PyObject *item = _PyUnicode_FromString(names[0]); + PyObject *item = PYGLIB_PyUnicode_FromString(names[0]); PyList_Append(ret, item); Py_DECREF(item); @@ -393,7 +393,7 @@ _wrap_g_content_types_get_registered(PyObject *self) ret = PyList_New(0); for (l = list; l; l = l->next) { char *content_type = l->data; - PyObject *string = _PyUnicode_FromString(content_type); + PyObject *string = PYGLIB_PyUnicode_FromString(content_type); PyList_Append(ret, string); Py_DECREF(string); g_free(content_type); diff --git a/gio/gmount.override b/gio/gmount.override index 3aa6303b..3a994d15 100644 --- a/gio/gmount.override +++ b/gio/gmount.override @@ -340,7 +340,7 @@ _wrap_g_mount_tp_repr(PyGObject *self) g_free(name); g_free(uuid); - result = _PyUnicode_FromString(representation); + result = PYGLIB_PyUnicode_FromString(representation); g_free(representation); return result; } diff --git a/gio/gvolume.override b/gio/gvolume.override index 9aa50f86..3bef4a14 100644 --- a/gio/gvolume.override +++ b/gio/gvolume.override @@ -154,7 +154,7 @@ _wrap_g_volume_tp_repr(PyGObject *self) else representation = g_strdup_printf("<%s at %p: UNKNOWN NAME>", Py_TYPE(self)->tp_name, self); - result = _PyUnicode_FromString(representation); + result = PYGLIB_PyUnicode_FromString(representation); g_free(representation); return result; } diff --git a/gio/pygio-utils.c b/gio/pygio-utils.c index f51040cd..b1cfa42d 100644 --- a/gio/pygio-utils.c +++ b/gio/pygio-utils.c @@ -116,13 +116,13 @@ pygio_pylist_to_uri_glist(PyObject *pyfile_list) len = PySequence_Size(pyfile_list); for (i = 0; i < len; i++) { item = PySequence_GetItem(pyfile_list, i); - if (!_PyUnicode_Check(item)) { + if (!PYGLIB_PyUnicode_Check(item)) { PyErr_SetString(PyExc_TypeError, "files must be strings"); g_list_free(file_list); return NULL; } - file_list = g_list_prepend(file_list, _PyUnicode_AsString(item)); + file_list = g_list_prepend(file_list, PYGLIB_PyUnicode_AsString(item)); } file_list = g_list_reverse(file_list); @@ -145,7 +145,7 @@ strv_to_pylist (char **strv) list = PyList_New (len); for (i = 0; i < len; i++) - PyList_SetItem (list, i, _PyUnicode_FromString (strv[i])); + PyList_SetItem (list, i, PYGLIB_PyUnicode_FromString (strv[i])); return list; } @@ -191,7 +191,7 @@ pylist_to_strv (PyObject *list, return FALSE; } - if (!_PyUnicode_Check (item)) + if (!PYGLIB_PyUnicode_Check (item)) { Py_DECREF (item); g_strfreev (ret); @@ -199,7 +199,7 @@ pylist_to_strv (PyObject *list, return FALSE; } - ret[i] = g_strdup (_PyUnicode_AsString (item)); + ret[i] = g_strdup (PYGLIB_PyUnicode_AsString (item)); Py_DECREF (item); } diff --git a/glib/glibmodule.c b/glib/glibmodule.c index af2d05c0..39aa2382 100644 --- a/glib/glibmodule.c +++ b/glib/glibmodule.c @@ -68,13 +68,13 @@ get_handler_priority(gint *priority, PyObject *kwargs) } pos = 0; PyDict_Next(kwargs, &pos, &key, &val); - if (!_PyUnicode_Check(key)) { + if (!PYGLIB_PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "keyword argument name is not a string"); return -1; } - if (strcmp(_PyUnicode_AsString(key), "priority") != 0) { + if (strcmp(PYGLIB_PyUnicode_AsString(key), "priority") != 0) { PyErr_SetString(PyExc_TypeError, "only 'priority' keyword argument accepted"); return -1; @@ -402,7 +402,7 @@ pyglib_markup_escape_text(PyObject *unused, PyObject *args, PyObject *kwargs) return NULL; text_out = g_markup_escape_text(text_in, text_size); - retval = _PyUnicode_FromString(text_out); + retval = PYGLIB_PyUnicode_FromString(text_out); g_free(text_out); return retval; } @@ -422,7 +422,7 @@ pyglib_get_user_cache_dir(PyObject *self) const char *path = g_get_user_cache_dir(); if (path) - return _PyUnicode_FromString(path); + return PYGLIB_PyUnicode_FromString(path); else { Py_INCREF(Py_None); return Py_None; @@ -435,7 +435,7 @@ pyglib_get_user_config_dir(PyObject *self) const char *path = g_get_user_config_dir(); if (path) - return _PyUnicode_FromString(path); + return PYGLIB_PyUnicode_FromString(path); else { Py_INCREF(Py_None); return Py_None; @@ -448,7 +448,7 @@ pyglib_get_user_data_dir(PyObject *self) const char *path = g_get_user_data_dir(); if (path) - return _PyUnicode_FromString(path); + return PYGLIB_PyUnicode_FromString(path); else { Py_INCREF(Py_None); return Py_None; @@ -469,7 +469,7 @@ pyglib_get_user_special_dir(PyObject *unused, PyObject *args, PyObject *kwargs) path = g_get_user_special_dir(directory); if (path) - return _PyUnicode_FromString(path); + return PYGLIB_PyUnicode_FromString(path); else { Py_INCREF(Py_None); return Py_None; @@ -535,7 +535,7 @@ pyglib_filename_from_utf8(PyObject *self, PyObject *args) g_free(filename); return NULL; } - py_filename = _PyUnicode_FromStringAndSize(filename, bytes_written); + py_filename = PYGLIB_PyUnicode_FromStringAndSize(filename, bytes_written); g_free(filename); return py_filename; } @@ -551,22 +551,22 @@ pyglib_get_application_name(PyObject *self) Py_INCREF(Py_None); return Py_None; } - return _PyUnicode_FromString(name); + return PYGLIB_PyUnicode_FromString(name); } static PyObject* pyglib_set_application_name(PyObject *self, PyObject *arg) { - if (!_PyUnicode_Check(arg)) { + if (!PYGLIB_PyUnicode_Check(arg)) { PyObject *repr = PyObject_Repr(arg); - const char *repr_ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char *repr_ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "first argument must be a string, not '%s'", (repr_ptr ? repr_ptr : "<?>")); Py_CLEAR(repr); return NULL; } - g_set_application_name(_PyUnicode_AS_STRING(arg)); + g_set_application_name(PYGLIB_PyUnicode_AsString(arg)); Py_INCREF(Py_None); return Py_None; } @@ -581,22 +581,22 @@ pyglib_get_prgname(PyObject *self) Py_INCREF(Py_None); return Py_None; } - return _PyUnicode_FromString(name); + return PYGLIB_PyUnicode_FromString(name); } static PyObject* pyglib_set_prgname(PyObject *self, PyObject *arg) { - if (!_PyUnicode_Check(arg)) { + if (!PYGLIB_PyUnicode_Check(arg)) { PyObject *repr = PyObject_Repr(arg); - const char *repr_ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char *repr_ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "first argument must be a string, not '%s'", (repr_ptr ? repr_ptr : "<?>")); Py_CLEAR(repr); return NULL; } - g_set_prgname(_PyUnicode_AS_STRING(arg)); + g_set_prgname(PYGLIB_PyUnicode_AsString(arg)); Py_INCREF(Py_None); return Py_None; } @@ -614,7 +614,7 @@ pyglib_find_program_in_path(PyObject *unused, PyObject *args, PyObject *kwargs) return NULL; ret = g_find_program_in_path(program); - retval = _PyUnicode_FromString(ret); + retval = PYGLIB_PyUnicode_FromString(ret); g_free(ret); return retval; } diff --git a/glib/pygiochannel.c b/glib/pygiochannel.c index 45ccf526..d588862e 100644 --- a/glib/pygiochannel.c +++ b/glib/pygiochannel.c @@ -38,7 +38,7 @@ py_io_channel_next(PyGIOChannel *self) return NULL; } - ret_obj = _PyUnicode_FromStringAndSize(str_return, length); + ret_obj = PYGLIB_PyUnicode_FromStringAndSize(str_return, length); g_free(str_return); return ret_obj; } @@ -168,7 +168,7 @@ py_io_channel_get_encoding(PyGIOChannel* self) return Py_None; } - return _PyUnicode_FromString(encoding); + return PYGLIB_PyUnicode_FromString(encoding); } #define CHUNK_SIZE (8 * 1024) @@ -187,7 +187,7 @@ py_io_channel_read_chars(PyGIOChannel* self, PyObject *args, PyObject *kwargs) return NULL; if (max_count == 0) - return _PyUnicode_FromString(""); + return PYGLIB_PyUnicode_FromString(""); while (status == G_IO_STATUS_NORMAL && (max_count == -1 || total_read < max_count)) { @@ -298,13 +298,16 @@ py_io_channel_write_lines(PyGIOChannel* self, PyObject *args, PyObject *kwargs) PyErr_Clear(); goto normal_exit; } - if (!_PyUnicode_Check(value)) { + if (!PYGLIB_PyUnicode_Check(value)) { PyErr_SetString(PyExc_TypeError, "glib.IOChannel.writelines must" " be sequence/iterator of strings"); Py_DECREF(iter); return NULL; } - _PyUnicode_AsStringAndSize(value, &buf, &buf_len); + if (PYGLIB_PyUnicode_AsStringAndSize(value, &buf, &buf_len) != 0) { + Py_DECREF(iter); + return NULL; + } pyglib_unblock_threads(); status = g_io_channel_write_chars(self->channel, buf, buf_len, &count, &error); pyglib_unblock_threads(); @@ -558,7 +561,7 @@ py_io_channel_read_line(PyGIOChannel* self, PyObject *args, PyObject *kwargs) &terminator_pos, &error); if (pyglib_error_check(&error)) return NULL; - ret_obj = _PyUnicode_FromStringAndSize(str_return, length); + ret_obj = PYGLIB_PyUnicode_FromStringAndSize(str_return, length); g_free(str_return); return ret_obj; } @@ -587,7 +590,7 @@ py_io_channel_read_lines(PyGIOChannel* self, PyObject *args, PyObject *kwargs) Py_DECREF(line); return NULL; } - line = _PyUnicode_FromStringAndSize(str_return, length); + line = PYGLIB_PyUnicode_FromStringAndSize(str_return, length); g_free(str_return); if (PyList_Append(list, line)) { Py_DECREF(line); diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h index bea7d6b3..62c441e1 100644 --- a/glib/pyglib-python-compat.h +++ b/glib/pyglib-python-compat.h @@ -85,15 +85,15 @@ static int _pyglib_init_##modname(PyObject *module) /* Compilation on Python 2.x */ #if PY_VERSION_HEX < 0x03000000 #define RO READONLY -#define _PyUnicode_Check PyString_Check -#define _PyUnicode_AsString PyString_AsString -#define _PyUnicode_AsStringAndSize PyString_AsStringAndSize -#define _PyUnicode_FromString PyString_FromString -#define _PyUnicode_FromStringAndSize PyString_FromStringAndSize -#define _PyUnicode_FromFormat PyString_FromFormat -#define _PyUnicode_AS_STRING PyString_AS_STRING -#define _PyUnicode_GET_SIZE PyString_GET_SIZE -#define _PyUnicode_Type PyString_Type +#define PYGLIB_PyUnicode_Check PyString_Check +#define PYGLIB_PyUnicode_AsString PyString_AsString +#define PYGLIB_PyUnicode_AsStringAndSize PyString_AsStringAndSize +#define PYGLIB_PyUnicode_FromString PyString_FromString +#define PYGLIB_PyUnicode_FromStringAndSize PyString_FromStringAndSize +#define PYGLIB_PyUnicode_FromFormat PyString_FromFormat +#define PYGLIB_PyUnicode_AS_STRING PyString_AS_STRING +#define PYGLIB_PyUnicode_GET_SIZE PyString_GET_SIZE +#define PYGLIB_PyUnicode_Type PyString_Type #define PYGLIB_PyBytes_FromStringAndSize PyString_FromStringAndSize #define PYGLIB_PyBytes_Resize _PyString_Resize @@ -173,16 +173,16 @@ PyTypeObject symbol = { \ return; \ PyDict_SetItemString(d, name, (PyObject *)&type); -#define _PyUnicode_Check PyUnicode_Check -#define _PyUnicode_AsString _PyUnicode_AsString -#define _PyUnicode_AsStringAndSize(obj, buf, size) _PyUnicode_AsStringAndSize(obj, size) -#define _PyUnicode_FromString PyUnicode_FromString -#define _PyUnicode_FromStringAndSize PyUnicode_FromStringAndSize -#define _PyUnicode_FromFormat PyUnicode_FromFormat -#define _PyUnicode_AS_STRING _PyUnicode_AsString -#define _PyUnicode_GET_SIZE PyUnicode_GET_SIZE -#define _PyUnicode_Resize PyUnicode_Resize -#define _PyUnicode_Type PyUnicode_Type +#define PYGLIB_PyUnicode_Check PyUnicode_Check +#define PYGLIB_PyUnicode_AsString _PyUnicode_AsString +#define PYGLIB_PyUnicode_AsStringAndSize(obj, buf, size) \ + (((*(buf) = _PyUnicode_AsStringAndSize(obj, size)) != NULL) ? 0 : -1) +#define PYGLIB_PyUnicode_FromString PyUnicode_FromString +#define PYGLIB_PyUnicode_FromStringAndSize PyUnicode_FromStringAndSize +#define PYGLIB_PyUnicode_FromFormat PyUnicode_FromFormat +#define PYGLIB_PyUnicode_GET_SIZE PyUnicode_GET_SIZE +#define PYGLIB_PyUnicode_Resize PyUnicode_Resize +#define PYGLIB_PyUnicode_Type PyUnicode_Type #define _PyLong_Check PyLong_Check #define _PyLong_FromLong PyLong_FromLong #define _PyLong_AsLong PyLong_AsLong diff --git a/glib/pyglib.c b/glib/pyglib.c index 118497e3..6b8ded21 100644 --- a/glib/pyglib.c +++ b/glib/pyglib.c @@ -273,7 +273,7 @@ pyglib_error_check(GError **error) if ((*error)->domain) { PyObject_SetAttrString(exc_instance, "domain", - d=_PyUnicode_FromString(g_quark_to_string((*error)->domain))); + d=PYGLIB_PyUnicode_FromString(g_quark_to_string((*error)->domain))); Py_DECREF(d); } else @@ -285,7 +285,7 @@ pyglib_error_check(GError **error) if ((*error)->message) { PyObject_SetAttrString(exc_instance, "message", - d=_PyUnicode_FromString((*error)->message)); + d=PYGLIB_PyUnicode_FromString((*error)->message)); Py_DECREF(d); } else { PyObject_SetAttrString(exc_instance, "message", Py_None); @@ -338,13 +338,13 @@ pyglib_gerror_exception_check(GError **error) Py_XDECREF(traceback); py_message = PyObject_GetAttrString(value, "message"); - if (!py_message || !_PyUnicode_Check(py_message)) { + if (!py_message || !PYGLIB_PyUnicode_Check(py_message)) { bad_gerror_message = "glib.GError instances must have a 'message' string attribute"; goto bad_gerror; } py_domain = PyObject_GetAttrString(value, "domain"); - if (!py_domain || !_PyUnicode_Check(py_domain)) { + if (!py_domain || !PYGLIB_PyUnicode_Check(py_domain)) { bad_gerror_message = "glib.GError instances must have a 'domain' string attribute"; Py_DECREF(py_message); goto bad_gerror; @@ -358,8 +358,8 @@ pyglib_gerror_exception_check(GError **error) goto bad_gerror; } - g_set_error(error, g_quark_from_string(_PyUnicode_AsString(py_domain)), - _PyLong_AsLong(py_code), _PyUnicode_AsString(py_message)); + g_set_error(error, g_quark_from_string(PYGLIB_PyUnicode_AsString(py_domain)), + _PyLong_AsLong(py_code), PYGLIB_PyUnicode_AsString(py_message)); Py_DECREF(py_message); Py_DECREF(py_code); diff --git a/glib/pygoptioncontext.c b/glib/pygoptioncontext.c index b93026bc..1d67ac53 100644 --- a/glib/pygoptioncontext.c +++ b/glib/pygoptioncontext.c @@ -98,7 +98,7 @@ pyg_option_context_parse(PyGOptionContext *self, for (pos = 0; pos < argv_length; pos++) { arg = PyList_GetItem(argv, pos); - argv_content[pos] = g_strdup(_PyUnicode_AsString(arg)); + argv_content[pos] = g_strdup(PYGLIB_PyUnicode_AsString(arg)); if (argv_content[pos] == NULL) { g_strfreev(argv_content); @@ -126,7 +126,7 @@ pyg_option_context_parse(PyGOptionContext *self, new_argv = PyList_New(g_strv_length(argv_content)); for (pos = 0; pos < argv_length; pos++) { - arg = _PyUnicode_FromString(argv_content[pos]); + arg = PYGLIB_PyUnicode_FromString(argv_content[pos]); PyList_SetItem(new_argv, pos, arg); } diff --git a/glib/pygsource.c b/glib/pygsource.c index 8ac165ee..5dabd3c2 100644 --- a/glib/pygsource.c +++ b/glib/pygsource.c @@ -82,7 +82,7 @@ source_repr(PyGSource *self, const char *type) g_snprintf(buf, sizeof(buf), "<%s glib source at 0x%lx>", desc, (long) self); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static PyObject * @@ -652,7 +652,7 @@ pyg_poll_fd_dealloc(PyGPollFD *self) static PyObject * pyg_poll_fd_repr(PyGPollFD *self) { - return _PyUnicode_FromFormat("<GPollFD %d (%d) at 0x%lx>", + return PYGLIB_PyUnicode_FromFormat("<GPollFD %d (%d) at 0x%lx>", self->pollfd.fd, self->pollfd.events, (long)self); } diff --git a/glib/pygspawn.c b/glib/pygspawn.c index dcfade66..4483e07c 100644 --- a/glib/pygspawn.c +++ b/glib/pygspawn.c @@ -150,7 +150,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) argv = g_new0(char *, len + 1); for (i = 0; i < len; ++i) { PyObject *tmp = PySequence_ITEM(pyargv, i); - if (!_PyUnicode_Check(tmp)) { + if (!PYGLIB_PyUnicode_Check(tmp)) { PyErr_SetString(PyExc_TypeError, "glib.spawn_async: " "first argument must be a sequence of strings"); @@ -158,7 +158,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) Py_XDECREF(tmp); return NULL; } - argv[i] = _PyUnicode_AsString(tmp); + argv[i] = PYGLIB_PyUnicode_AsString(tmp); Py_DECREF(tmp); } @@ -175,7 +175,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) envp = g_new0(char *, len + 1); for (i = 0; i < len; ++i) { PyObject *tmp = PySequence_ITEM(pyenvp, i); - if (!_PyUnicode_Check(tmp)) { + if (!PYGLIB_PyUnicode_Check(tmp)) { PyErr_SetString(PyExc_TypeError, "glib.spawn_async: " "second argument must be a sequence of strings"); @@ -184,7 +184,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) g_free(argv); return NULL; } - envp[i] = _PyUnicode_AsString(tmp); + envp[i] = PYGLIB_PyUnicode_AsString(tmp); Py_DECREF(tmp); } } diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 790f4e10..e7cea4e0 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -116,7 +116,7 @@ pyg_type_name (PyObject *self, PyObject *args) return NULL; name = g_type_name(type); if (name) - return _PyUnicode_FromString(name); + return PYGLIB_PyUnicode_FromString(name); PyErr_SetString(PyExc_RuntimeError, "unknown typecode"); return NULL; } @@ -140,7 +140,7 @@ pyg_type_from_name (PyObject *self, PyObject *args) if (type != 0) return pyg_type_wrapper_new(type); repr = PyObject_Repr((PyObject*)self); - repr_ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + repr_ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_RuntimeError, "%s: unknown type name: %s", (repr_ptr ? repr_ptr : "<?>"), name); Py_CLEAR(repr); @@ -342,7 +342,7 @@ _pyg_signal_accumulator(GSignalInvocationHint *ihint, state = pyglib_gil_state_ensure(); if (ihint->detail) - py_detail = _PyUnicode_FromString(g_quark_to_string(ihint->detail)); + py_detail = PYGLIB_PyUnicode_FromString(g_quark_to_string(ihint->detail)); else { Py_INCREF(Py_None); py_detail = Py_None; @@ -501,17 +501,17 @@ add_signals (GType instance_type, PyObject *signals) const gchar *signal_name; gchar *signal_name_canon, *c; - if (!_PyUnicode_Check(key)) { + if (!PYGLIB_PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "__gsignals__ keys must be strings"); ret = FALSE; break; } - signal_name = _PyUnicode_AsString (key); + signal_name = PYGLIB_PyUnicode_AsString (key); if (value == Py_None || - (_PyUnicode_Check(value) && - !strcmp(_PyUnicode_AsString(value), "override"))) + (PYGLIB_PyUnicode_Check(value) && + !strcmp(PYGLIB_PyUnicode_AsString(value), "override"))) { /* canonicalize signal name, replacing '-' with '_' */ signal_name_canon = g_strdup(signal_name); @@ -823,13 +823,13 @@ add_properties (GType instance_type, PyObject *properties) /* values are of format (type,nick,blurb, type_specific_args, flags) */ - if (!_PyUnicode_Check(key)) { + if (!PYGLIB_PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "__gproperties__ keys must be strings"); ret = FALSE; break; } - prop_name = _PyUnicode_AsString (key); + prop_name = PYGLIB_PyUnicode_AsString (key); if (!PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, @@ -882,14 +882,14 @@ add_properties (GType instance_type, PyObject *properties) PyObject *type, *value, *traceback; ret = FALSE; PyErr_Fetch(&type, &value, &traceback); - if (_PyUnicode_Check(value)) { + if (PYGLIB_PyUnicode_Check(value)) { char msg[256]; g_snprintf(msg, 256, "%s (while registering property '%s' for GType '%s')", - _PyUnicode_AsString(value), + PYGLIB_PyUnicode_AsString(value), prop_name, g_type_name(instance_type)); Py_DECREF(value); - value = _PyUnicode_FromString(msg); + value = PYGLIB_PyUnicode_FromString(msg); } PyErr_Restore(type, value, traceback); break; @@ -979,8 +979,8 @@ get_type_name_for_class(PyTypeObject *class) g_free(type_name); snprintf(name_serial_str, 16, "-v%i", name_serial); module = PyObject_GetAttrString((PyObject *)class, "__module__"); - if (module && _PyUnicode_Check(module)) { - type_name = g_strconcat(_PyUnicode_AsString(module), ".", + if (module && PYGLIB_PyUnicode_Check(module)) { + type_name = g_strconcat(PYGLIB_PyUnicode_AsString(module), ".", class->tp_name, name_serial > 1 ? name_serial_str : NULL, NULL); @@ -1421,7 +1421,7 @@ pyg_signal_list_names (PyObject *self, PyObject *args, PyObject *kwargs) if (list != NULL) { for (i = 0; i < n; i++) PyTuple_SetItem(list, i, - _PyUnicode_FromString(g_signal_name(ids[i]))); + PYGLIB_PyUnicode_FromString(g_signal_name(ids[i]))); } g_free(ids); @@ -1540,7 +1540,7 @@ pyg_signal_name (PyObject *self, PyObject *args, PyObject *kwargs) return NULL; signal_name = g_signal_name(id); if (signal_name) - return _PyUnicode_FromString(signal_name); + return PYGLIB_PyUnicode_FromString(signal_name); Py_INCREF(Py_None); return Py_None; @@ -1614,7 +1614,7 @@ pyg_signal_query (PyObject *self, PyObject *args, PyObject *kwargs) } PyTuple_SET_ITEM(py_query, 0, _PyLong_FromLong(query.signal_id)); - PyTuple_SET_ITEM(py_query, 1, _PyUnicode_FromString(query.signal_name)); + PyTuple_SET_ITEM(py_query, 1, PYGLIB_PyUnicode_FromString(query.signal_name)); PyTuple_SET_ITEM(py_query, 2, pyg_type_wrapper_new(query.itype)); PyTuple_SET_ITEM(py_query, 3, _PyLong_FromLong(query.signal_flags)); PyTuple_SET_ITEM(py_query, 4, pyg_type_wrapper_new(query.return_type)); @@ -1727,7 +1727,7 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs) params = g_new0(GParameter, PyDict_Size(kwargs)); while (PyDict_Next (kwargs, &pos, &key, &value)) { GParamSpec *pspec; - const gchar *key_str = _PyUnicode_AsString (key); + const gchar *key_str = PYGLIB_PyUnicode_AsString (key); pspec = g_object_class_find_property (class, key_str); if (!pspec) { @@ -1930,7 +1930,7 @@ pyg_add_emission_hook(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, gtype, &sigid, &detail, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char *repr_ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char *repr_ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (repr_ptr ? repr_ptr : "<?>"), name); Py_CLEAR(repr); @@ -1971,7 +1971,7 @@ pyg_remove_emission_hook(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, gtype, &signal_id, NULL, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char *repr_ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char *repr_ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (repr_ptr ? repr_ptr : "<?>"), name); Py_CLEAR(repr); diff --git a/gobject/pygboxed.c b/gobject/pygboxed.c index e464dede..0fa3608f 100644 --- a/gobject/pygboxed.c +++ b/gobject/pygboxed.c @@ -74,7 +74,7 @@ pyg_boxed_repr(PyGBoxed *self) g_snprintf(buf, sizeof(buf), "<%s at 0x%lx>", g_type_name(self->gtype), (long)self->boxed); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static int diff --git a/gobject/pygenum.c b/gobject/pygenum.c index 633c7eb0..c8c14fbc 100644 --- a/gobject/pygenum.c +++ b/gobject/pygenum.c @@ -93,7 +93,7 @@ pyg_enum_repr(PyGEnum *self) g_type_class_unref(enum_class); - return _PyUnicode_FromString(tmp); + return PYGLIB_PyUnicode_FromString(tmp); } static PyObject * @@ -237,7 +237,7 @@ pyg_enum_add (PyObject * module, if (module) PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict, "__module__", - _PyUnicode_FromString(PyModule_GetName(module))); + PYGLIB_PyUnicode_FromString(PyModule_GetName(module))); g_type_set_qdata(gtype, pygenum_class_key, stub); @@ -306,7 +306,7 @@ pyg_enum_get_value_name(PyGEnum *self, void *closure) enum_value = g_enum_get_value(enum_class, _PyLong_AS_LONG(self)); - retval = _PyUnicode_FromString(enum_value->value_name); + retval = PYGLIB_PyUnicode_FromString(enum_value->value_name); g_type_class_unref(enum_class); return retval; @@ -324,7 +324,7 @@ pyg_enum_get_value_nick(PyGEnum *self, void *closure) enum_value = g_enum_get_value(enum_class, _PyLong_AS_LONG(self)); - retval = _PyUnicode_FromString(enum_value->value_nick); + retval = PYGLIB_PyUnicode_FromString(enum_value->value_nick); g_type_class_unref(enum_class); return retval; diff --git a/gobject/pygflags.c b/gobject/pygflags.c index a71a9801..3be5583c 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -121,7 +121,7 @@ pyg_flags_repr(PyGFlags *self) g_type_name(self->gtype)); g_free(tmp); - pyretval = _PyUnicode_FromString(retval); + pyretval = PYGLIB_PyUnicode_FromString(retval); g_free(retval); return pyretval; @@ -256,7 +256,7 @@ pyg_flags_add (PyObject * module, if (module) { PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict, "__module__", - _PyUnicode_FromString(PyModule_GetName(module))); + PYGLIB_PyUnicode_FromString(PyModule_GetName(module))); /* Add it to the module name space */ PyModule_AddObject(module, (char*)typename, stub); @@ -356,7 +356,7 @@ pyg_flags_get_first_value_name(PyGFlags *self, void *closure) g_assert(G_IS_FLAGS_CLASS(flags_class)); flags_value = g_flags_get_first_value(flags_class, _PyLong_AS_LONG(self)); if (flags_value) - retval = _PyUnicode_FromString(flags_value->value_name); + retval = PYGLIB_PyUnicode_FromString(flags_value->value_name); else { retval = Py_None; Py_INCREF(Py_None); @@ -378,7 +378,7 @@ pyg_flags_get_first_value_nick(PyGFlags *self, void *closure) flags_value = g_flags_get_first_value(flags_class, _PyLong_AS_LONG(self)); if (flags_value) - retval = _PyUnicode_FromString(flags_value->value_nick); + retval = PYGLIB_PyUnicode_FromString(flags_value->value_nick); else { retval = Py_None; Py_INCREF(Py_None); @@ -401,7 +401,7 @@ pyg_flags_get_value_names(PyGFlags *self, void *closure) retval = PyList_New(0); for (i = 0; i < flags_class->n_values; i++) if ((_PyLong_AS_LONG(self) & flags_class->values[i].value) == flags_class->values[i].value) - PyList_Append(retval, _PyUnicode_FromString(flags_class->values[i].value_name)); + PyList_Append(retval, PYGLIB_PyUnicode_FromString(flags_class->values[i].value_name)); g_type_class_unref(flags_class); @@ -421,7 +421,7 @@ pyg_flags_get_value_nicks(PyGFlags *self, void *closure) retval = PyList_New(0); for (i = 0; i < flags_class->n_values; i++) if ((_PyLong_AS_LONG(self) & flags_class->values[i].value) == flags_class->values[i].value) - PyList_Append(retval, _PyUnicode_FromString(flags_class->values[i].value_nick)); + PyList_Append(retval, PYGLIB_PyUnicode_FromString(flags_class->values[i].value_nick)); g_type_class_unref(flags_class); diff --git a/gobject/pygobject.c b/gobject/pygobject.c index 7170bb06..590bdbdf 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -242,7 +242,7 @@ build_parameter_list(GObjectClass *class) name = g_strdup(g_param_spec_get_name(props[i])); /* hyphens cannot belong in identifiers */ g_strdelimit(name, "-", '_'); - prop_str = _PyUnicode_FromString(name); + prop_str = PYGLIB_PyUnicode_FromString(name); PyList_SetItem(props_list, i, prop_str); g_free(name); @@ -263,7 +263,7 @@ PyGProps_getattro(PyGProps *self, PyObject *attr) GValue value = { 0, }; PyObject *ret; - attr_name = _PyUnicode_AsString(attr); + attr_name = PYGLIB_PyUnicode_AsString(attr); if (!attr_name) { PyErr_Clear(); return PyObject_GenericGetAttr((PyObject *)self, attr); @@ -353,7 +353,7 @@ PyGProps_setattro(PyGProps *self, PyObject *attr, PyObject *pvalue) return -1; } - attr_name = _PyUnicode_AsString(attr); + attr_name = PYGLIB_PyUnicode_AsString(attr); if (!attr_name) { PyErr_Clear(); return PyObject_GenericSetAttr((PyObject *)self, attr, pvalue); @@ -525,7 +525,7 @@ pygobject_register_class(PyObject *dict, const gchar *type_name, */ s = strrchr(type->tp_name, '.'); if (s != NULL) { - mod_name = _PyUnicode_FromStringAndSize(type->tp_name, (int)(s - type->tp_name)); + mod_name = PYGLIB_PyUnicode_FromStringAndSize(type->tp_name, (int)(s - type->tp_name)); PyDict_SetItemString(type->tp_dict, "__module__", mod_name); Py_DECREF(mod_name); } @@ -1054,7 +1054,7 @@ pygobject_repr(PyGObject *self) (long)self, self->obj ? G_OBJECT_TYPE_NAME(self->obj) : "uninitialized", (long)self->obj); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } @@ -1146,7 +1146,7 @@ pygobject_init(PyGObject *self, PyObject *args, PyObject *kwargs) params = g_new0(GParameter, PyDict_Size(kwargs)); while (PyDict_Next (kwargs, &pos, &key, &value)) { GParamSpec *pspec; - gchar *key_str = _PyUnicode_AsString(key); + gchar *key_str = PYGLIB_PyUnicode_AsString(key); pspec = g_object_class_find_property (class, key_str); if (!pspec) { @@ -1252,13 +1252,13 @@ pygobject_get_properties(PyGObject *self, PyObject *args) GValue value = { 0 }; PyObject *item; - if (!_PyUnicode_Check(py_property)) { + if (!PYGLIB_PyUnicode_Check(py_property)) { PyErr_SetString(PyExc_TypeError, "Expected string argument for property."); return NULL; } - property_name = _PyUnicode_AsString(py_property); + property_name = PYGLIB_PyUnicode_AsString(py_property); pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(self->obj), property_name); @@ -1332,7 +1332,7 @@ pygobject_set_properties(PyGObject *self, PyObject *args, PyObject *kwargs) pos = 0; while (kwargs && PyDict_Next (kwargs, &pos, &key, &value)) { - gchar *key_str = _PyUnicode_AsString(key); + gchar *key_str = PYGLIB_PyUnicode_AsString(key); GParamSpec *pspec; pspec = g_object_class_find_property(class, key_str); @@ -1469,7 +1469,7 @@ pygobject_connect(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (ptr ? ptr : "<?>"), name); Py_CLEAR(repr); @@ -1520,7 +1520,7 @@ pygobject_connect_after(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (ptr ? ptr : "<?>"), name); Py_CLEAR(repr); @@ -1571,7 +1571,7 @@ pygobject_connect_object(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (ptr ? ptr : "<?>"), name); Py_CLEAR(repr); @@ -1622,7 +1622,7 @@ pygobject_connect_object_after(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (ptr ? ptr : "<?>"), name); Py_CLEAR(repr); @@ -1723,7 +1723,7 @@ pygobject_emit(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &signal_id, &detail, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (ptr ? ptr : "<?>"), name); Py_CLEAR(repr); @@ -1801,7 +1801,7 @@ pygobject_stop_emission(PyGObject *self, PyObject *args) if (!g_signal_parse_name(signal, G_OBJECT_TYPE(self->obj), &signal_id, &detail, TRUE)) { PyObject *repr = PyObject_Repr((PyObject*)self); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", (ptr ? ptr : "<?>"), signal); Py_CLEAR(repr); @@ -1951,7 +1951,7 @@ pygobject_disconnect_by_func(PyGObject *self, PyObject *args) closure = gclosure_from_pyfunc(self, pyfunc); if (!closure) { PyObject *repr = PyObject_Repr(pyfunc); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "nothing connected to %s", (ptr ? ptr : "<?>")); Py_CLEAR(repr); @@ -1986,7 +1986,7 @@ pygobject_handler_block_by_func(PyGObject *self, PyObject *args) closure = gclosure_from_pyfunc(self, pyfunc); if (!closure) { PyObject *repr = PyObject_Repr(pyfunc); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "nothing connected to %s", (ptr ? ptr : "<?>")); Py_CLEAR(repr); @@ -2021,7 +2021,7 @@ pygobject_handler_unblock_by_func(PyGObject *self, PyObject *args) closure = gclosure_from_pyfunc(self, pyfunc); if (!closure) { PyObject *repr = PyObject_Repr(pyfunc); - const char* ptr = (repr ? _PyUnicode_AsString(repr) : "<?>"); + const char* ptr = (repr ? PYGLIB_PyUnicode_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "nothing connected to %s", (ptr ? ptr : "<?>")); Py_CLEAR(repr); @@ -2324,7 +2324,7 @@ pygobject_object_register_types(PyObject *d) descr = PyObject_New(PyObject, &PyGPropsDescr_Type); PyDict_SetItemString(PyGObject_Type.tp_dict, "props", descr); PyDict_SetItemString(PyGObject_Type.tp_dict, "__module__", - o=_PyUnicode_FromString("gobject._gobject")); + o=PYGLIB_PyUnicode_FromString("gobject._gobject")); Py_DECREF(o); /* GPropsIter */ diff --git a/gobject/pygparamspec.c b/gobject/pygparamspec.c index 403ec167..5a43b225 100644 --- a/gobject/pygparamspec.c +++ b/gobject/pygparamspec.c @@ -59,7 +59,7 @@ pyg_param_spec_repr(PyGParamSpec *self) g_snprintf(buf, sizeof(buf), "<%s '%s'>", G_PARAM_SPEC_TYPE_NAME(self->pspec), g_param_spec_get_name(self->pspec)); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static void @@ -140,7 +140,7 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) "maximum", "minimum", "name", "nick", "owner_type", "value_type"); } else if (!strcmp(attr, "default_value")) { - return _PyUnicode_FromFormat( + return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_CHAR(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { return _PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->minimum); @@ -155,7 +155,7 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) "name", "nick", "owner_type", "value_type"); } else if (!strcmp(attr, "default_value")) { - return _PyUnicode_FromFormat( + return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_UCHAR(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { return _PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->minimum); @@ -258,7 +258,7 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) "flags", "name", "nick", "owner_type", "value_type"); } else if (!strcmp(attr, "default_value")) { - return _PyUnicode_FromFormat( + return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_UNICHAR(pspec)->default_value); } } else if (G_IS_PARAM_SPEC_ENUM(pspec)) { diff --git a/gobject/pygpointer.c b/gobject/pygpointer.c index ff2590e4..f5c58fb6 100644 --- a/gobject/pygpointer.c +++ b/gobject/pygpointer.c @@ -67,7 +67,7 @@ pyg_pointer_repr(PyGPointer *self) g_snprintf(buf, sizeof(buf), "<%s at 0x%lx>", g_type_name(self->gtype), (long)self->pointer); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static int diff --git a/gobject/pygtype.c b/gobject/pygtype.c index 7734c3b2..868f2736 100644 --- a/gobject/pygtype.c +++ b/gobject/pygtype.c @@ -66,7 +66,7 @@ pyg_type_wrapper_repr(PyGTypeWrapper *self) g_snprintf(buf, sizeof(buf), "<GType %s (%lu)>", name?name:"invalid", (unsigned long int) self->type); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static void @@ -139,7 +139,7 @@ static PyObject * _wrap_g_type_wrapper__get_name(PyGTypeWrapper *self, void *closure) { const char *name = g_type_name(self->type); - return _PyUnicode_FromString(name ? name : "invalid"); + return PYGLIB_PyUnicode_FromString(name ? name : "invalid"); } static PyObject * @@ -383,7 +383,7 @@ pyg_type_from_object(PyObject *obj) return G_TYPE_LONG; else if (tp == &PyFloat_Type) return G_TYPE_DOUBLE; - else if (tp == &_PyUnicode_Type) + else if (tp == &PYGLIB_PyUnicode_Type) return G_TYPE_STRING; else if (tp == &PyBaseObject_Type) return PY_TYPE_OBJECT; @@ -394,8 +394,8 @@ pyg_type_from_object(PyObject *obj) } /* handle strings */ - if (_PyUnicode_Check(obj)) { - gchar *name = _PyUnicode_AsString(obj); + if (PYGLIB_PyUnicode_Check(obj)) { + gchar *name = PYGLIB_PyUnicode_AsString(obj); type = _pyg_type_from_name(name); if (type != 0) { @@ -464,9 +464,9 @@ pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val) g_type_name(enum_type), g_type_name(((PyGEnum *) obj)->gtype)); } - } else if (_PyUnicode_Check(obj)) { + } else if (PYGLIB_PyUnicode_Check(obj)) { GEnumValue *info; - char *str = _PyUnicode_AsString(obj); + char *str = PYGLIB_PyUnicode_AsString(obj); if (enum_type != G_TYPE_NONE) eclass = G_ENUM_CLASS(g_type_class_ref(enum_type)); @@ -524,9 +524,9 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, gint *val) } else if (PyLong_Check(obj)) { *val = PyLong_AsLongLong(obj); res = 0; - } else if (_PyUnicode_Check(obj)) { + } else if (PYGLIB_PyUnicode_Check(obj)) { GFlagsValue *info; - char *str = _PyUnicode_AsString(obj); + char *str = PYGLIB_PyUnicode_AsString(obj); if (flag_type != G_TYPE_NONE) fclass = G_FLAGS_CLASS(g_type_class_ref(flag_type)); @@ -562,7 +562,7 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, gint *val) for (i = 0; i < len; i++) { PyObject *item = PyTuple_GetItem(obj, i); - char *str = _PyUnicode_AsString(item); + char *str = PYGLIB_PyUnicode_AsString(item); GFlagsValue *info = g_flags_get_value_by_name(fclass, str); if (!info) @@ -737,7 +737,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) break; case G_TYPE_CHAR: if ((tmp = PyObject_Str(obj))) - g_value_set_char(value, _PyUnicode_AsString(tmp)[0]); + g_value_set_char(value, PYGLIB_PyUnicode_AsString(tmp)[0]); else { PyErr_Clear(); return -1; @@ -753,7 +753,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) else return -1; } else if ((tmp = PyObject_Str(obj))) { - g_value_set_uchar(value, _PyUnicode_AsString(tmp)[0]); + g_value_set_uchar(value, PYGLIB_PyUnicode_AsString(tmp)[0]); Py_DECREF(tmp); } else { PyErr_Clear(); @@ -836,7 +836,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) if (obj == Py_None) g_value_set_string(value, NULL); else if ((tmp = PyObject_Str(obj))) { - g_value_set_string(value, _PyUnicode_AsString(tmp)); + g_value_set_string(value, PYGLIB_PyUnicode_AsString(tmp)); Py_DECREF(tmp); } else { PyErr_Clear(); @@ -881,13 +881,12 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) else if (PySequence_Check(obj) && G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY)) return pyg_value_array_from_pyobject(value, obj, NULL); - else if (_PyUnicode_Check(obj) && + else if (PYGLIB_PyUnicode_Check(obj) && G_VALUE_HOLDS(value, G_TYPE_GSTRING)) { GString *string; char *buffer; Py_ssize_t len; - buffer = _PyUnicode_AsStringAndSize(obj, &buffer, &len); - if (buffer == NULL) + if (PYGLIB_PyUnicode_AsStringAndSize(obj, &buffer, &len) != 0) return -1; string = g_string_new_len(buffer, len); g_value_set_boxed(value, string); @@ -957,11 +956,11 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) break; case G_TYPE_CHAR: { gint8 val = g_value_get_char(value); - return _PyUnicode_FromStringAndSize((char *)&val, 1); + return PYGLIB_PyUnicode_FromStringAndSize((char *)&val, 1); } case G_TYPE_UCHAR: { guint8 val = g_value_get_uchar(value); - return _PyUnicode_FromStringAndSize((char *)&val, 1); + return PYGLIB_PyUnicode_FromStringAndSize((char *)&val, 1); } case G_TYPE_BOOLEAN: { return PyBool_FromLong(g_value_get_boolean(value)); @@ -1022,7 +1021,7 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) const gchar *str = g_value_get_string(value); if (str) - return _PyUnicode_FromString(str); + return PYGLIB_PyUnicode_FromString(str); Py_INCREF(Py_None); return Py_None; } @@ -1052,7 +1051,7 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) return ret; } else if (G_VALUE_HOLDS(value, G_TYPE_GSTRING)) { GString *string = (GString *) g_value_get_boxed(value); - PyObject *ret = _PyUnicode_FromStringAndSize(string->str, string->len); + PyObject *ret = PYGLIB_PyUnicode_FromStringAndSize(string->str, string->len); return ret; } bm = pyg_type_lookup(G_VALUE_TYPE(value)); @@ -1528,7 +1527,7 @@ object_doc_descr_get(PyObject *self, PyObject *obj, PyObject *type) g_array_free(parents, TRUE); } - pystring = _PyUnicode_FromStringAndSize(string->str, string->len); + pystring = PYGLIB_PyUnicode_FromStringAndSize(string->str, string->len); g_string_free(string, TRUE); return pystring; } @@ -1726,7 +1725,7 @@ _pyg_strv_from_gvalue(const GValue *value) } py_argv = PyList_New(argc); for (i = 0; i < argc; ++i) - PyList_SET_ITEM(py_argv, i, _PyUnicode_FromString(argv[i])); + PyList_SET_ITEM(py_argv, i, PYGLIB_PyUnicode_FromString(argv[i])); return py_argv; } @@ -1741,11 +1740,11 @@ _pyg_strv_to_gvalue(GValue *value, PyObject *obj) argc = PySequence_Length(obj); for (i = 0; i < argc; ++i) - if (!_PyUnicode_Check(PySequence_Fast_GET_ITEM(obj, i))) + if (!PYGLIB_PyUnicode_Check(PySequence_Fast_GET_ITEM(obj, i))) return -1; argv = g_new(gchar *, argc + 1); for (i = 0; i < argc; ++i) - argv[i] = g_strdup(_PyUnicode_AsString(PySequence_Fast_GET_ITEM(obj, i))); + argv[i] = g_strdup(PYGLIB_PyUnicode_AsString(PySequence_Fast_GET_ITEM(obj, i))); argv[i] = NULL; g_value_take_boxed(value, argv); return 0; |