int XsltRoot_Init(PyObject *module) { PyTypeObject *type; PyObject *dict, *constant; /* Initialize constants */ setup_string = PyString_FromString("setup"); if (setup_string == NULL) return -1; validate_string = PyString_FromString("validate"); if (validate_string == NULL) return -1; prime_string = PyString_FromString("prime"); if (prime_string == NULL) return -1; teardown_string = PyString_FromString("teardown"); if (teardown_string == NULL) return -1; type = &XsltRoot_Type; type->tp_base = &XsltNode_Type; if (PyType_Ready(type) < 0) return -1; if (PyModule_AddObject(module, "xslt_root", (PyObject *)type)) return -1; /* Assign "class" constants */ dict = XsltRoot_Type.tp_dict; /* nodeName = "#document" */ constant = PyUnicode_DecodeASCII("#document", 9, NULL); if (constant == NULL) return -1; if (PyDict_SetItemString(dict, "nodeName", constant)) return -1; Py_DECREF(constant); return 0; }
static PyObject *meth_QMetaClassInfo_value(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { const QMetaClassInfo *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QMetaClassInfo, &sipCpp)) { const char*sipRes; Py_BEGIN_ALLOW_THREADS sipRes = sipCpp->value(); Py_END_ALLOW_THREADS if (sipRes == NULL) { Py_INCREF(Py_None); return Py_None; } return PyUnicode_DecodeASCII(sipRes, strlen(sipRes), NULL); } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QMetaClassInfo, sipName_value, doc_QMetaClassInfo_value); return NULL; }
int DomletteComment_Init(PyObject *module) { PyObject *dict, *value; DomletteComment_Type.tp_base = &DomletteCharacterData_Type; if (PyType_Ready(&DomletteComment_Type) < 0) return -1; dict = DomletteComment_Type.tp_dict; value = PyInt_FromLong(COMMENT_NODE); if (value == NULL) return -1; if (PyDict_SetItemString(dict, "nodeType", value)) return -1; Py_DECREF(value); value = PyUnicode_DecodeASCII("#comment", (Py_ssize_t)8, NULL); if (value == NULL) return -1; if (PyDict_SetItemString(dict, "nodeName", value)) return -1; Py_DECREF(value); Py_INCREF(&DomletteComment_Type); return PyModule_AddObject(module, "Comment", (PyObject*) &DomletteComment_Type); }
int DomletteDocumentFragment_Init(PyObject *module) { PyObject *dict, *value; DomletteDocumentFragment_Type.tp_base = &DomletteNode_Type; if (PyType_Ready(&DomletteDocumentFragment_Type) < 0) return -1; dict = DomletteDocumentFragment_Type.tp_dict; value = PyInt_FromLong(DOCUMENT_FRAGMENT_NODE); if (value == NULL) return -1; if (PyDict_SetItemString(dict, "nodeType", value)) return -1; Py_DECREF(value); value = PyUnicode_DecodeASCII("#document-fragment", (Py_ssize_t)18, NULL); if (value == NULL) return -1; if (PyDict_SetItemString(dict, "nodeName", value)) return -1; Py_DECREF(value); Py_INCREF(&DomletteDocumentFragment_Type); return PyModule_AddObject(module, "DocumentFragment", (PyObject*) &DomletteDocumentFragment_Type); }
PyObject * git_oid_to_py_str(const git_oid *oid) { char hex[GIT_OID_HEXSZ]; git_oid_fmt(hex, oid); return PyUnicode_DecodeASCII(hex, GIT_OID_HEXSZ, "strict"); }
static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; }
/* annotate exception with encrypt_result data */ static void decode_encrypt_result(PyGpgmeContext *self) { PyObject *err_type, *err_value, *err_traceback; gpgme_encrypt_result_t res; gpgme_invalid_key_t key; PyObject *list; PyErr_Fetch(&err_type, &err_value, &err_traceback); PyErr_NormalizeException(&err_type, &err_value, &err_traceback); if (!PyErr_GivenExceptionMatches(err_type, pygpgme_error)) goto end; res = gpgme_op_encrypt_result(self->ctx); if (res == NULL) goto end; list = PyList_New(0); for (key = res->invalid_recipients; key != NULL; key = key->next) { PyObject *item, *py_fpr, *err; if (key->fpr) py_fpr = PyUnicode_DecodeASCII(key->fpr, strlen(key->fpr), "replace"); else { py_fpr = Py_None; Py_INCREF(py_fpr); } err = pygpgme_error_object(key->reason); item = Py_BuildValue("(NN)", py_fpr, err); PyList_Append(list, item); Py_DECREF(item); } PyObject_SetAttrString(err_value, "invalid_recipients", list); Py_DECREF(list); end: PyErr_Restore(err_type, err_value, err_traceback); }
int PyString_IsEqualToASCIIString(PyObject* py_string, const char* c_string) { PyObject* c_string_conv; int result; if (PyString_Check(py_string)) { return strcmp(PyString_AS_STRING(py_string), c_string) == 0; } if (!PyUnicode_Check(py_string)) return 0; c_string_conv = PyUnicode_DecodeASCII(c_string, strlen(c_string), "strict"); if (c_string_conv == 0) return 0; result = (PyUnicode_Compare(py_string, c_string_conv) == 0); Py_DECREF(c_string_conv); return result; }
static int _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt) { if (src == NULL) *target = PyUnicode_DecodeASCII(dflt, strlen(dflt), NULL); else { if (src == Py_None) *target = NULL; else if (!IS_BASESTRING(src)) { PyErr_Format(PyExc_TypeError, "\"%s\" must be a string", name); return -1; } else { Py_XDECREF(*target); Py_INCREF(src); *target = src; } } return 0; }
static int _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt) { if (src == NULL) *target = PyUnicode_DecodeASCII(dflt, strlen(dflt), NULL); else { if (src == Py_None) *target = NULL; else if (!PyUnicode_Check(src)) { PyErr_Format(PyExc_TypeError, "\"%s\" must be a string", name); return -1; } else { if (PyUnicode_READY(src) == -1) return -1; Py_INCREF(src); Py_XSETREF(*target, src); } } return 0; }
static PyObject *Py_convert_to_svg(PyObject *self, PyObject *args, PyObject *kwds) { py::PathIterator path; agg::trans_affine trans; agg::rect_d cliprect; PyObject *simplifyobj; bool simplify = false; int precision; if (!PyArg_ParseTuple(args, "O&O&O&Oi:convert_to_svg", &convert_path, &path, &convert_trans_affine, &trans, &convert_rect, &cliprect, &simplifyobj, &precision)) { return NULL; } if (simplifyobj == Py_None) { simplify = path.should_simplify(); } else if (PyObject_IsTrue(simplifyobj)) { simplify = true; } size_t buffersize = path.total_vertices() * (precision + 5) * 4; std::string buffer; buffer.reserve(buffersize); CALL_CPP("convert_to_svg", (convert_to_svg(path, trans, cliprect, simplify, precision, &buffer[0], &buffersize))); return PyUnicode_DecodeASCII(&buffer[0], buffersize, ""); }
//--------------------------------------------------------------------------- PyObject* ToPyObject(const char *Str) { return PyUnicode_DecodeASCII(Str, strlen(Str), NULL); }
static PyObject * pygpgme_context_sign(PyGpgmeContext *self, PyObject *args) { PyObject *py_plain, *py_sig; gpgme_data_t plain, sig; int sig_mode = GPGME_SIG_MODE_NORMAL; gpgme_error_t err; gpgme_sign_result_t result; if (!PyArg_ParseTuple(args, "OO|i", &py_plain, &py_sig, &sig_mode)) return NULL; if (pygpgme_data_new(&plain, py_plain)) return NULL; if (pygpgme_data_new(&sig, py_sig)) { gpgme_data_release(plain); return NULL; } Py_BEGIN_ALLOW_THREADS; err = gpgme_op_sign(self->ctx, plain, sig, sig_mode); Py_END_ALLOW_THREADS; gpgme_data_release(plain); gpgme_data_release(sig); result = gpgme_op_sign_result(self->ctx); /* annotate exception */ if (pygpgme_check_error(err)) { PyObject *err_type, *err_value, *err_traceback; PyObject *list; gpgme_invalid_key_t key; PyErr_Fetch(&err_type, &err_value, &err_traceback); PyErr_NormalizeException(&err_type, &err_value, &err_traceback); if (result == NULL) goto end; if (!PyErr_GivenExceptionMatches(err_type, pygpgme_error)) goto end; list = PyList_New(0); for (key = result->invalid_signers; key != NULL; key = key->next) { PyObject *item, *py_fpr, *err; if (key->fpr) py_fpr = PyUnicode_DecodeASCII(key->fpr, strlen(key->fpr), "replace"); else { py_fpr = Py_None; Py_INCREF(py_fpr); } err = pygpgme_error_object(key->reason); item = Py_BuildValue("(NN)", py_fpr, err); PyList_Append(list, item); Py_DECREF(item); } PyObject_SetAttrString(err_value, "invalid_signers", list); Py_DECREF(list); list = pygpgme_newsiglist_new(result->signatures); PyObject_SetAttrString(err_value, "signatures", list); Py_DECREF(list); end: PyErr_Restore(err_type, err_value, err_traceback); return NULL; } if (result) return pygpgme_newsiglist_new(result->signatures); else return PyList_New(0); }
static PyObject *object_to_string(PyObject *object) { PyObject *result = NULL; if (PyUnicode_Check(object)) { Py_INCREF(object); result = object; } else if (PyString_Check(object)) { /* Python DOM binding: string objects must be UTF-8 */ result = PyUnicode_FromEncodedObject(object, "UTF-8", "strict"); } else if (PyFloat_Check(object)) { double d = PyFloat_AS_DOUBLE(object); if (PyNumber_Finite(object)) { if (floor(d) == d) { /* Format as integer */ PyObject *num = PyNumber_Long(object); if (!num) return NULL; result = PyObject_Unicode(num); Py_DECREF(num); } else { /* worst case length calc to ensure no buffer overrun: fmt = %#.<prec>g buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp for any double rep.) len = 1 + prec + 1 + 2 + 5 = 9 + prec If prec=0 the effective precision is 1 (the leading digit is always given), therefore increase by one to 10+prec. */ char buf[32]; /* only 10 + 12 + '\0' is needed, more than enough */ int len; len = sprintf(buf, "%0.12g", d); result = PyUnicode_DecodeASCII(buf, len, "strict"); } } else if (PyNumber_IsNaN(object)) { result = PyUnicode_DecodeASCII("NaN", 3, "strict"); } else if (d < 0) { result = PyUnicode_DecodeASCII("-Infinity", 9, "strict"); } else { result = PyUnicode_DecodeASCII("Infinity", 8, "strict"); } } else if (PyBoolean_Check(object)) { if (PyObject_IsTrue(object)) result = PyUnicode_DecodeASCII("true", 4, "strict"); else result = PyUnicode_DecodeASCII("false", 5, "strict"); } else if (PyInt_Check(object) || PyLong_Check(object)) { result = PyObject_Unicode(object); } else if (PyList_Check(object)) { if (PyList_GET_SIZE(object)) result = object_to_string(PyList_GET_ITEM(object, 0)); else result = PyUnicode_FromUnicode(NULL, 0); } else { /* check for pre-computed string value */ result = PyObject_GetAttrString(object, "stringValue"); if (result == NULL) { /* assume a DOM node, node_to_string() returns empty string if not */ PyErr_Clear(); result = node_to_string(object); } } return result; }
static PyObject *DecodeString (UMTypeInfo *ti, char *value, size_t cbValue) { //FIXME: This code must be endiness aware of system isn't little endian switch (ti->charset) { case MCS_big5_chinese_ci://1, case MCS_big5_bin://84, case MCS_dec8_swedish_ci://3, case MCS_dec8_bin://69, case MCS_cp850_general_ci://4, case MCS_cp850_bin://80, case MCS_hp8_english_ci://6, case MCS_hp8_bin://72, case MCS_koi8r_general_ci://7, case MCS_koi8r_bin://74, break; case MCS_latin1_german1_ci://5, case MCS_latin1_swedish_ci://8, case MCS_latin1_danish_ci://15, case MCS_latin1_german2_ci://31, case MCS_latin1_bin://47, case MCS_latin1_general_ci://48, case MCS_latin1_general_cs://49, case MCS_latin1_spanish_ci://94, return PyUnicode_DecodeLatin1 (value, cbValue, NULL); case MCS_latin2_czech_cs:// 2, case MCS_latin2_general_ci://9, case MCS_latin2_hungarian_ci://21, case MCS_latin2_croatian_ci://27, case MCS_latin2_bin://77, case MCS_swe7_swedish_ci://10, case MCS_swe7_bin://82, break; case MCS_ascii_general_ci://11, case MCS_ascii_bin://65, return PyUnicode_DecodeASCII(value, cbValue, NULL); case MCS_ujis_japanese_ci://12, case MCS_ujis_bin://91, case MCS_sjis_japanese_ci://13, case MCS_sjis_bin://88, case MCS_hebrew_general_ci://16, case MCS_hebrew_bin://71, case MCS_tis620_thai_ci://18, case MCS_tis620_bin://89, case MCS_euckr_korean_ci://19, case MCS_euckr_bin://85, case MCS_koi8u_general_ci://22, case MCS_koi8u_bin://75, case MCS_gb2312_chinese_ci://24, case MCS_gb2312_bin://86, case MCS_greek_general_ci://25, case MCS_greek_bin://70, break; case MCS_cp1250_general_ci://26, case MCS_cp1250_czech_cs://34, case MCS_cp1250_croatian_ci://44, case MCS_cp1250_bin://66, case MCS_cp1250_polish_ci://99, return PyUnicode_Decode(value, cbValue, "cp1250", NULL); case MCS_gbk_chinese_ci://28, case MCS_gbk_bin://87, case MCS_latin5_turkish_ci://30, case MCS_latin5_bin://78, case MCS_armscii8_general_ci://32, case MCS_armscii8_bin://64, break; case MCS_utf8_general_ci://33, case MCS_utf8_bin://83, case MCS_utf8_unicode_ci://192, case MCS_utf8_icelandic_ci://193, case MCS_utf8_latvian_ci://194, case MCS_utf8_romanian_ci://195, case MCS_utf8_slovenian_ci://196, case MCS_utf8_polish_ci://197, case MCS_utf8_estonian_ci://198, case MCS_utf8_spanish_ci://199, case MCS_utf8_swedish_ci://200, case MCS_utf8_turkish_ci://201, case MCS_utf8_czech_ci://202, case MCS_utf8_danish_ci://203, case MCS_utf8_lithuanian_ci://204, case MCS_utf8_slovak_ci://205, case MCS_utf8_spanish2_ci://206, case MCS_utf8_roman_ci://207, case MCS_utf8_persian_ci://208, case MCS_utf8_esperanto_ci://209, case MCS_utf8_hungarian_ci://210, case MCS_utf8_sinhala_ci://211, return PyUnicode_DecodeUTF8 (value, cbValue, NULL); case MCS_ucs2_general_ci://35, case MCS_ucs2_bin://90, case MCS_ucs2_unicode_ci://128, case MCS_ucs2_icelandic_ci://129, case MCS_ucs2_latvian_ci://130, case MCS_ucs2_romanian_ci://131, case MCS_ucs2_slovenian_ci://132, case MCS_ucs2_polish_ci://133, case MCS_ucs2_estonian_ci://134, case MCS_ucs2_spanish_ci://135, case MCS_ucs2_swedish_ci://136, case MCS_ucs2_turkish_ci://137, case MCS_ucs2_czech_ci://138, case MCS_ucs2_danish_ci://139, case MCS_ucs2_lithuanian_ci://140, case MCS_ucs2_slovak_ci://141, case MCS_ucs2_spanish2_ci://142, case MCS_ucs2_roman_ci://143, case MCS_ucs2_persian_ci://144, case MCS_ucs2_esperanto_ci://145, case MCS_ucs2_hungarian_ci://146, case MCS_ucs2_sinhala_ci://147, break; case MCS_cp866_general_ci://36, case MCS_cp866_bin://68, case MCS_keybcs2_general_ci://37, case MCS_keybcs2_bin://73, case MCS_macce_general_ci://38, case MCS_macce_bin://43, case MCS_macroman_general_ci://39, case MCS_macroman_bin://53, case MCS_cp852_general_ci://40, case MCS_cp852_bin://81, case MCS_latin7_estonian_cs://20, case MCS_latin7_general_ci://41, case MCS_latin7_general_cs://42, case MCS_latin7_bin://79, case MCS_utf8mb4_general_ci://45, case MCS_utf8mb4_bin://46, case MCS_utf8mb4_unicode_ci://224, case MCS_utf8mb4_icelandic_ci://225, case MCS_utf8mb4_latvian_ci://226, case MCS_utf8mb4_romanian_ci://227, case MCS_utf8mb4_slovenian_ci://228, case MCS_utf8mb4_polish_ci://229, case MCS_utf8mb4_estonian_ci://230, case MCS_utf8mb4_spanish_ci://231, case MCS_utf8mb4_swedish_ci://232, case MCS_utf8mb4_turkish_ci://233, case MCS_utf8mb4_czech_ci://234, case MCS_utf8mb4_danish_ci://235, case MCS_utf8mb4_lithuanian_ci://236, case MCS_utf8mb4_slovak_ci://237, case MCS_utf8mb4_spanish2_ci://238, case MCS_utf8mb4_roman_ci://239, case MCS_utf8mb4_persian_ci://240, case MCS_utf8mb4_esperanto_ci://241, case MCS_utf8mb4_hungarian_ci://242, case MCS_utf8mb4_sinhala_ci://243, case MCS_cp1251_bulgarian_ci://14, case MCS_cp1251_ukrainian_ci://23, case MCS_cp1251_bin://50, case MCS_cp1251_general_ci://51, case MCS_cp1251_general_cs://52, break; case MCS_utf16_general_ci://54, case MCS_utf16_bin://55, case MCS_utf16_unicode_ci://101, case MCS_utf16_icelandic_ci://102, case MCS_utf16_latvian_ci://103, case MCS_utf16_romanian_ci://104, case MCS_utf16_slovenian_ci://105, case MCS_utf16_polish_ci://106, case MCS_utf16_estonian_ci://107, case MCS_utf16_spanish_ci://108, case MCS_utf16_swedish_ci://109, case MCS_utf16_turkish_ci://110, case MCS_utf16_czech_ci://111, case MCS_utf16_danish_ci://112, case MCS_utf16_lithuanian_ci://113, case MCS_utf16_slovak_ci://114, case MCS_utf16_spanish2_ci://115, case MCS_utf16_roman_ci://116, case MCS_utf16_persian_ci://117, case MCS_utf16_esperanto_ci://118, case MCS_utf16_hungarian_ci://119, case MCS_utf16_sinhala_ci://120, //return PyUnicode_DecodeUTF16(value, cbValue / 2, NULL, NULL); break; case MCS_cp1256_general_ci://57, case MCS_cp1256_bin://67, break; case MCS_cp1257_lithuanian_ci://29, case MCS_cp1257_bin://58, case MCS_cp1257_general_ci://59, break; case MCS_utf32_general_ci://60, case MCS_utf32_bin://61, case MCS_utf32_unicode_ci://160, case MCS_utf32_icelandic_ci://161, case MCS_utf32_latvian_ci://162, case MCS_utf32_romanian_ci://163, case MCS_utf32_slovenian_ci://164, case MCS_utf32_polish_ci://165, case MCS_utf32_estonian_ci://166, case MCS_utf32_spanish_ci://167, case MCS_utf32_swedish_ci://168, case MCS_utf32_turkish_ci://169, case MCS_utf32_czech_ci://170, case MCS_utf32_danish_ci://171, case MCS_utf32_lithuanian_ci://172, case MCS_utf32_slovak_ci://173, case MCS_utf32_spanish2_ci://174, case MCS_utf32_roman_ci://175, case MCS_utf32_persian_ci://176, case MCS_utf32_esperanto_ci://177, case MCS_utf32_hungarian_ci://178, case MCS_utf32_sinhala_ci://179, //return PyUnicode_DecodeUTF32 (value, cbValue / 4, NULL, NULL); break; case MCS_geostd8_general_ci://92, case MCS_geostd8_bin://93, case MCS_cp932_japanese_ci://95, case MCS_cp932_bin://96, case MCS_eucjpms_japanese_ci://97, case MCS_eucjpms_bin://98, break; case MCS_binary: return PyString_FromStringAndSize(value, cbValue); default: break; } return PyErr_Format (PyExc_ValueError, "Unsupported character set %d when decoding string", (int) ti->charset); }
static PyObject * pygpgme_context_encrypt_sign(PyGpgmeContext *self, PyObject *args) { PyObject *py_recp, *py_plain, *py_cipher, *recp_seq = NULL, *result = NULL; int flags, i, length; gpgme_key_t *recp = NULL; gpgme_data_t plain = NULL, cipher = NULL; gpgme_error_t err; gpgme_sign_result_t sign_result; if (!PyArg_ParseTuple(args, "OiOO", &py_recp, &flags, &py_plain, &py_cipher)) goto end; recp_seq = PySequence_Fast(py_recp, "first argument must be a sequence"); if (recp_seq == NULL) goto end; length = PySequence_Fast_GET_SIZE(recp_seq); recp = malloc((length + 1) * sizeof (gpgme_key_t)); for (i = 0; i < length; i++) { PyObject *item = PySequence_Fast_GET_ITEM(recp_seq, i); if (!PyObject_TypeCheck(item, &PyGpgmeKey_Type)) { PyErr_SetString(PyExc_TypeError, "items in first argument " "must be gpgme.Key objects"); goto end; } recp[i] = ((PyGpgmeKey *)item)->key; } recp[i] = NULL; if (pygpgme_data_new(&plain, py_plain)) goto end; if (pygpgme_data_new(&cipher, py_cipher)) goto end; Py_BEGIN_ALLOW_THREADS; err = gpgme_op_encrypt_sign(self->ctx, recp, flags, plain, cipher); Py_END_ALLOW_THREADS; sign_result = gpgme_op_sign_result(self->ctx); /* annotate exception */ if (pygpgme_check_error(err)) { PyObject *err_type, *err_value, *err_traceback; PyObject *list; gpgme_invalid_key_t key; decode_encrypt_result(self); PyErr_Fetch(&err_type, &err_value, &err_traceback); PyErr_NormalizeException(&err_type, &err_value, &err_traceback); if (sign_result == NULL) goto error_end; if (!PyErr_GivenExceptionMatches(err_type, pygpgme_error)) goto error_end; list = PyList_New(0); for (key = sign_result->invalid_signers; key != NULL; key = key->next) { PyObject *item, *py_fpr, *err; if (key->fpr) py_fpr = PyUnicode_DecodeASCII(key->fpr, strlen(key->fpr), "replace"); else { py_fpr = Py_None; Py_INCREF(py_fpr); } err = pygpgme_error_object(key->reason); item = Py_BuildValue("(NN)", py_fpr, err); PyList_Append(list, item); Py_DECREF(item); } PyObject_SetAttrString(err_value, "invalid_signers", list); Py_DECREF(list); list = pygpgme_newsiglist_new(sign_result->signatures); PyObject_SetAttrString(err_value, "signatures", list); Py_DECREF(list); error_end: PyErr_Restore(err_type, err_value, err_traceback); goto end; } if (sign_result) result = pygpgme_newsiglist_new(sign_result->signatures); else result = PyList_New(0); end: if (recp != NULL) free(recp); Py_XDECREF(recp_seq); if (plain != NULL) gpgme_data_release(plain); if (cipher != NULL) gpgme_data_release(cipher); return result; }
static PyObject *meth_QSGMaterialShader_attributeNames(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; PyObject *sipOrigSelf = sipSelf; { const QSGMaterialShader *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QSGMaterialShader, &sipCpp)) { PyObject * sipRes = 0; int sipIsErr = 0; if (!sipOrigSelf) { sipAbstractMethod(sipName_QSGMaterialShader, sipName_attributeNames); return NULL; } #line 73 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\sip/QtQuick/qsgmaterial.sip" const char * const *names = sipCpp->attributeNames(); SIP_SSIZE_T nr_names = 0; if (names) while (names[nr_names]) ++nr_names; sipRes = PyList_New(nr_names); if (!sipRes) sipIsErr = 1; else for (SIP_SSIZE_T i = 0; i < nr_names; ++i) { const char *name = names[i]; PyObject *el; #if PY_MAJOR_VERSION >= 3 el = PyUnicode_DecodeASCII(name, strlen(name), 0); #else el = PyString_FromString(name); #endif if (!el) { Py_DECREF(sipRes); sipIsErr = 1; break; } PyList_SET_ITEM(sipRes, i, el); } #line 410 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtQuick/sipQtQuickQSGMaterialShader.cpp" if (sipIsErr) return 0; return sipRes; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QSGMaterialShader, sipName_attributeNames, doc_QSGMaterialShader_attributeNames); return NULL; }