• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyObject_Repr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PyObject_Repr函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_Repr函数的具体用法?C++ PyObject_Repr怎么用?C++ PyObject_Repr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PyObject_Repr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Snmp_repr

static PyObject*
Snmp_repr(SnmpObject *self)
{
	PyObject *peer = NULL, *community = NULL, *rpeer = NULL,
	    *rcommunity = NULL, *result;
	if ((peer = PyString_FromString(self->ss->peername)) == NULL)
		return NULL;
	if ((community = PyString_FromString((char*)self->ss->community)) == NULL)
		goto reprerror;
	if ((rpeer = PyObject_Repr(peer)) == NULL)
		goto reprerror;
	if ((rcommunity = PyObject_Repr(community)) == NULL)
		goto reprerror;
	result = PyString_FromFormat("%s(host=%s, community=%s, version=%d)",
	    self->ob_type->tp_name,
	    PyString_AsString(rpeer),
	    PyString_AsString(rcommunity),
	    (self->ss->version == SNMP_VERSION_1)?1:2);
	Py_DECREF(rpeer);
	Py_DECREF(peer);
	Py_DECREF(rcommunity);
	Py_DECREF(community);
	return result;
reprerror:
	Py_XDECREF(rpeer);
	Py_XDECREF(peer);
	Py_XDECREF(rcommunity);
	Py_XDECREF(community);
	return NULL;
}
开发者ID:arielsalvo,项目名称:wiremaps,代码行数:30,代码来源:snmp.c


示例2: igraphmodule_Edge_repr

/** \ingroup python_interface_edge
 * \brief Formats an \c igraph.Edge object as a string
 * 
 * \return the formatted textual representation as a \c PyObject
 */
PyObject* igraphmodule_Edge_repr(igraphmodule_EdgeObject *self) {
  PyObject *s;
  PyObject *attrs;
#ifndef IGRAPH_PYTHON3
  PyObject *grepr, *drepr;
#endif

  attrs = igraphmodule_Edge_attributes(self);
  if (attrs == 0)
    return NULL;

#ifdef IGRAPH_PYTHON3
  s = PyUnicode_FromFormat("igraph.Edge(%R, %ld, %R)",
      (PyObject*)self->gref, (long int)self->idx, attrs);
  Py_DECREF(attrs);
#else
  grepr=PyObject_Repr((PyObject*)self->gref);
  drepr=PyObject_Repr(attrs);
  Py_DECREF(attrs);
  if (!grepr || !drepr) {
    Py_XDECREF(grepr);
    Py_XDECREF(drepr);
    return NULL;
  }
  s=PyString_FromFormat("igraph.Edge(%s, %ld, %s)", PyString_AsString(grepr),
    (long int)self->idx, PyString_AsString(drepr));
  Py_DECREF(grepr);
  Py_DECREF(drepr);
#endif
  return s;
}
开发者ID:CansenJIANG,项目名称:igraph,代码行数:36,代码来源:edgeobject.c


示例3: html_State_repr

static PyObject *
html_State_repr(html_State *self) {
    PyObject *bold = NULL, *italic = NULL, *lang = NULL, *ans = NULL;
    bold = PyObject_Repr(self->is_bold); italic = PyObject_Repr(self->is_italic); lang = PyObject_Repr(self->current_lang);
    if (bold && italic && lang)
        ans = PyString_FromFormat("State(bold=%s, italic=%s, lang=%s)", PyString_AS_STRING(bold), PyString_AS_STRING(italic), PyString_AS_STRING(lang));
    Py_XDECREF(bold); Py_XDECREF(italic); Py_XDECREF(lang);
    return ans;
}
开发者ID:AEliu,项目名称:calibre,代码行数:9,代码来源:html.c


示例4: html_Tag_repr

static PyObject *
html_Tag_repr(html_Tag *self) {
    PyObject *name = NULL, *bold = NULL, *italic = NULL, *lang = NULL, *ans = NULL;
    name = PyObject_Repr(self->name); bold = PyObject_Repr(self->bold); italic = PyObject_Repr(self->italic); lang = PyObject_Repr(self->lang);
    if (name && bold && italic && lang)
        ans = PyString_FromFormat("Tag(%s, bold=%s, italic=%s, lang=%s)", PyString_AS_STRING(name), PyString_AS_STRING(bold), PyString_AS_STRING(italic), PyString_AS_STRING(lang));
    Py_XDECREF(name); Py_XDECREF(bold); Py_XDECREF(italic); Py_XDECREF(lang);
    return ans;
}
开发者ID:AEliu,项目名称:calibre,代码行数:9,代码来源:html.c


示例5: PyList_New

static PyObject *pair_repr(PyObject *self) {
  PyObject *tmp = NULL;
  PyObject *col = PyList_New(0);
  PyObject *found = PyDict_New();
  size_t index = 0;

  PyObject *rest = self;
  PyObject *rest_id;

  PyList_Append(col, _str_cons_paren);

  while (rest->ob_type == &SibPairType) {
    rest_id = PyLong_FromVoidPtr(rest);

    if (PyDict_Contains(found, rest_id)) {
      /* recursive pair detected */
      PyList_Append(col, _str_recursive_true);

      if (rest != self) {
	tmp = PyDict_GetItem(found, rest_id);
	PyList_Insert(col, PyLong_AsSize_t(tmp) - 1, _str_cons_paren);
	PyList_Append(col, _str_close_paren);
      }
      Py_DECREF(rest_id);
      rest = NULL;
      break;

    } else {
      index += 2;

      tmp = PyLong_FromSize_t(index);
      PyDict_SetItem(found, rest_id, tmp);
      Py_DECREF(tmp);

      tmp = PyObject_Repr(SibPair_CAR(rest));
      PyList_Append(col, tmp);
      PyList_Append(col, _str_comma_space);
      Py_DECREF(tmp);

      rest = SibPair_CDR(rest);
      Py_DECREF(rest_id);
    }
  }

  if (rest) {
    PyList_Append(col, PyObject_Repr(rest));
  }

  PyList_Append(col, _str_close_paren);

  tmp = PyUnicode_Join(_str_empty, col);
  Py_DECREF(col);
  Py_DECREF(found);

  return tmp;
}
开发者ID:obriencj,项目名称:python-sibilant,代码行数:56,代码来源:pair.c


示例6: contextvar_tp_repr

static PyObject *
contextvar_tp_repr(PyContextVar *self)
{
    _PyUnicodeWriter writer;

    _PyUnicodeWriter_Init(&writer);

    if (_PyUnicodeWriter_WriteASCIIString(
            &writer, "<ContextVar name=", 17) < 0)
    {
        goto error;
    }

    PyObject *name = PyObject_Repr(self->var_name);
    if (name == NULL) {
        goto error;
    }
    if (_PyUnicodeWriter_WriteStr(&writer, name) < 0) {
        Py_DECREF(name);
        goto error;
    }
    Py_DECREF(name);

    if (self->var_default != NULL) {
        if (_PyUnicodeWriter_WriteASCIIString(&writer, " default=", 9) < 0) {
            goto error;
        }

        PyObject *def = PyObject_Repr(self->var_default);
        if (def == NULL) {
            goto error;
        }
        if (_PyUnicodeWriter_WriteStr(&writer, def) < 0) {
            Py_DECREF(def);
            goto error;
        }
        Py_DECREF(def);
    }

    PyObject *addr = PyUnicode_FromFormat(" at %p>", self);
    if (addr == NULL) {
        goto error;
    }
    if (_PyUnicodeWriter_WriteStr(&writer, addr) < 0) {
        Py_DECREF(addr);
        goto error;
    }
    Py_DECREF(addr);

    return _PyUnicodeWriter_Finish(&writer);

error:
    _PyUnicodeWriter_Dealloc(&writer);
    return NULL;
}
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:55,代码来源:context.c


示例7: PLyObject_AsString

/*
 * Convert Python object to C string in server encoding.
 */
char *
PLyObject_AsString(PyObject *plrv)
{
	PyObject   *plrv_bo;
	char	   *plrv_sc;
	size_t		plen;
	size_t		slen;

	if (PyUnicode_Check(plrv))
		plrv_bo = PLyUnicode_Bytes(plrv);
	else if (PyFloat_Check(plrv))
	{
		/* use repr() for floats, str() is lossy */
#if PY_MAJOR_VERSION >= 3
		PyObject   *s = PyObject_Repr(plrv);

		plrv_bo = PLyUnicode_Bytes(s);
		Py_XDECREF(s);
#else
		plrv_bo = PyObject_Repr(plrv);
#endif
	}
	else
	{
#if PY_MAJOR_VERSION >= 3
		PyObject   *s = PyObject_Str(plrv);

		plrv_bo = PLyUnicode_Bytes(s);
		Py_XDECREF(s);
#else
		plrv_bo = PyObject_Str(plrv);
#endif
	}
	if (!plrv_bo)
		PLy_elog(ERROR, "could not create string representation of Python object");

	plrv_sc = pstrdup(PyBytes_AsString(plrv_bo));
	plen = PyBytes_Size(plrv_bo);
	slen = strlen(plrv_sc);

	Py_XDECREF(plrv_bo);

	if (slen < plen)
		ereport(ERROR,
				(errcode(ERRCODE_DATATYPE_MISMATCH),
				 errmsg("could not convert Python object into cstring: Python string representation appears to contain null bytes")));
	else if (slen > plen)
		elog(ERROR, "could not convert Python object into cstring: Python string longer than reported length");
	pg_verifymbstr(plrv_sc, slen, false);

	return plrv_sc;
}
开发者ID:ArgenBarbie,项目名称:postgresql-9.5.0,代码行数:55,代码来源:plpy_typeio.c


示例8: pystring_concat_repr

void
pystring_concat_repr(PyObject **pystr, PyObject *obj)
{
#if PY_MAJOR_VERSION >= 3
    PyObject *repr = PyObject_Repr(obj);
    PyObject *newstr = PyUnicode_Concat(*pystr, repr);
    Py_DECREF(repr);
    Py_DECREF(*pystr);
    *pystr = newstr;
#else
    PyString_ConcatAndDel(pystr, PyObject_Repr(obj));
#endif
}
开发者ID:MariusDieckmann,项目名称:pyavroc,代码行数:13,代码来源:util.c


示例9: print_dict

void print_dict(PyObject *dict)
{
	PyObject *key, *value;
	Py_ssize_t pos = 0;
	while (PyDict_Next(dict, &pos, &key, &value)) {
		PyObject* k_str_exc_type = PyObject_Repr(key);
		PyObject* k_pyStr = PyUnicode_AsEncodedString(k_str_exc_type, "utf-8", "Error ~");
		printf("key:%s ---> ", (const char *)PyBytes_AS_STRING(k_pyStr));

		PyObject* v_str_exc_type = PyObject_Repr(value);
		PyObject* v_pyStr = PyUnicode_AsEncodedString(v_str_exc_type, "utf-8", "Error ~");
		printf("value:%s\n", PyBytes_AsString(v_pyStr));
	}
}
开发者ID:studiot-jp,项目名称:packet_generator,代码行数:14,代码来源:gettcp.c


示例10: PyUnicode_FromString

static PyObject *slot_QSizeF___repr__(PyObject *sipSelf)
{
    QSizeF *sipCpp = reinterpret_cast<QSizeF *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_QSizeF));

    if (!sipCpp)
        return 0;


    {
        {
            PyObject * sipRes = 0;

#line 116 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\sip/QtCore/qsize.sip"
        if (sipCpp->isNull())
        {
        #if PY_MAJOR_VERSION >= 3
            sipRes = PyUnicode_FromString("PyQt5.QtCore.QSizeF()");
        #else
            sipRes = PyString_FromString("PyQt5.QtCore.QSizeF()");
        #endif
        }
        else
        {
            PyObject *w = PyFloat_FromDouble(sipCpp->width());
            PyObject *h = PyFloat_FromDouble(sipCpp->height());
        
            if (w && h)
            {
        #if PY_MAJOR_VERSION >= 3
                sipRes = PyUnicode_FromFormat("PyQt5.QtCore.QSizeF(%R, %R)", w, h);
        #else
                sipRes = PyString_FromString("PyQt5.QtCore.QSizeF(");
                PyString_ConcatAndDel(&sipRes, PyObject_Repr(w));
                PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
                PyString_ConcatAndDel(&sipRes, PyObject_Repr(h));
                PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
        #endif
            }
        
            Py_XDECREF(w);
            Py_XDECREF(h);
        }
#line 872 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtCore/sipQtCoreQSizeF.cpp"

            return sipRes;
        }
    }

    return 0;
}
开发者ID:rff255,项目名称:python-qt5,代码行数:50,代码来源:sipQtCoreQSizeF.cpp


示例11: rpObjectectGetName

/*
Returns the name of the Python object which this instance wraps.

If it cannot determine a reasonable name it just gives up.
*/
static
VALUE rpObjectectGetName(VALUE self)
{
	//It only makes sense to query a python object if the interpreter is running.
	if(Py_IsInitialized())
	{
		PyObject *pObject,*pName,*pRepr;
		VALUE rName;
		
		pObject = rpObjectGetPyObject(self);
		
		
		pName = PyObject_GetAttrString(pObject,"__name__");
		
		if(!pName)
		{
			PyErr_Clear();
			
			pName = PyObject_GetAttrString(pObject,"__class__");
	 		pRepr = PyObject_Repr(pName);
			rName = ptorString(pRepr);
			Py_XDECREF(pRepr);
			
			return rb_str_concat(rb_str_new2("An instance of "), rName);
			if(!pName)
			{
				PyErr_Clear();
				
				pName = PyObject_Repr(pObject);
				
				if(!pName)
				{
					PyErr_Clear();
					return rb_str_new2("__Unnameable__");
				}
			}
		}
		
		rName = ptorString(pName);
		
		Py_XDECREF(pName);
		
		return rName;
	}
	
	return rb_str_new2("__FREED__");

}
开发者ID:hltbra,项目名称:rubypython,代码行数:53,代码来源:rp_object.c


示例12: PyFloat_FromDouble

static PyObject *slot_QQuaternion___repr__(PyObject *sipSelf)
{
    QQuaternion *sipCpp = reinterpret_cast<QQuaternion *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_QQuaternion));

    if (!sipCpp)
        return 0;


    {
        {
            PyObject * sipRes = 0;

#line 45 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\sip/QtGui/qquaternion.sip"
        PyObject *scalar = PyFloat_FromDouble(sipCpp->scalar());
        PyObject *x = PyFloat_FromDouble(sipCpp->x());
        PyObject *y = PyFloat_FromDouble(sipCpp->y());
        PyObject *z = PyFloat_FromDouble(sipCpp->z());
        
        if (scalar && x && y && z)
        {
        #if PY_MAJOR_VERSION >= 3
            sipRes = PyUnicode_FromFormat("PyQt5.QtGui.QQuaternion(%R, %R, %R, %R)",
                    scalar, x, y, z);
        #else
            sipRes = PyString_FromString("PyQt5.QtGui.QQuaternion(");
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(scalar));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(x));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(y));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(z));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
        #endif
        }
        
        Py_XDECREF(scalar);
        Py_XDECREF(x);
        Py_XDECREF(y);
        Py_XDECREF(z);
#line 1111 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtGui/sipQtGuiQQuaternion.cpp"

            return sipRes;
        }
    }

    return 0;
}
开发者ID:rff255,项目名称:python-qt5,代码行数:48,代码来源:sipQtGuiQQuaternion.cpp


示例13: ax25_address_repr

static PyObject *
ax25_address_repr(ax25_address_object* self)
{
    PyObject *b, *r, *f;
    
    b = PyBytes_FromStringAndSize(self->field.ax25_call, 7);
    if (b == NULL)
        return NULL;

    r = PyObject_Repr(b);
    if (r == NULL) {
        Py_DECREF(b);
        return NULL;
    }

    f = PyUnicode_FromFormat("<ax25_address %U>", r);
    if (f == NULL) {
        Py_DECREF(r);
        Py_DECREF(b);
        return NULL;
    }

    Py_DECREF(r);
    Py_DECREF(b);
    return f;
}
开发者ID:alejolp,项目名称:python-amateurradio,代码行数:26,代码来源:amateurradio.c


示例14: PyObject_Repr

void OutputHook::call(std::string name, boost::python::object obj)
{
    Hooks::checkName(name);

    auto repr_ = PyObject_Repr(obj.ptr());
    if (PyErr_Occurred())
    {
        PyErr_Clear();
        throw Hooks::Exception("Failed to get __repr__ of argument");
    }
    auto repr = std::string(PyUnicode_AsUTF8(repr_));
    Py_DECREF(repr_);

    PyObject* g = Py_BuildValue(
            "{sO}", "__builtins__", PyEval_GetBuiltins());
    node->parent->loadDatumHooks(g);
    auto out = PyRun_String(repr.c_str(), Py_eval_input, g, g);
    Py_DECREF(g);
    Py_XDECREF(out);
    if (PyErr_Occurred())
    {
        PyErr_Clear();
        throw Hooks::Exception("Could not evaluate __repr__ of output");
    }

    const bool result = node->makeDatum(
            name, obj.ptr()->ob_type, Datum::SIGIL_OUTPUT + repr, true);

    if (!result)
        throw Hooks::Exception("Datum was already defined in this script.");
}
开发者ID:CreativeLabs0X3CF,项目名称:antimony,代码行数:31,代码来源:output.cpp


示例15: castToPyObject

configParserStruct::pythonParser::containerForVariables configParserStruct::pythonParser::listOfVariables( void *Object )
{
  containerForVariables Result;
  
  if ( Object == NULL )
    return Result;

  PyObject *Dict = castToPyObject(Object);

  if ( ! PyDict_Check( Dict ) )
    return Result;

  PyObject *KeysList = PyDict_Keys( Dict );
  Py_ssize_t KeysListSize = PyList_Size( KeysList );

  for ( ptrdiff_t Index = 0; Index < static_cast<ptrdiff_t>(KeysListSize); Index++ )
  {
    PyObject *Key = PyList_GetItem( KeysList, Index );
    PyObject *KeyRepr = PyObject_Repr( Key );
    std::string KeyString = dequoteString( PyString_AsString( KeyRepr ), "'" );
    PyObject *Item = PyDict_GetItem( Dict, Key );
    if ( PyDict_Check(Item) )
    {
      containerForVariables ListOfItemsinSubDict = listOfVariables( Item );
      for ( containerForVariables::const_iterator i = ListOfItemsinSubDict.begin(); i != ListOfItemsinSubDict.end(); ++i )
        Result.insert( KeyString + structSeparator() + *i );
    } else {
      Result.insert( KeyString );
    } 
  }

  return Result;
}
开发者ID:EKhilkevitch,项目名称:configParserStruct,代码行数:33,代码来源:pythonparser.cpp


示例16: pyg_remove_emission_hook

static PyObject *
pyg_remove_emission_hook(PyGObject *self, PyObject *args)
{
    PyObject *pygtype;
    char *name;
    guint signal_id;
    gulong hook_id;
    GType gtype;
    
    if (!PyArg_ParseTuple(args, "Osk:gobject.remove_emission_hook",
			  &pygtype, &name, &hook_id))
	return NULL;
    
    if ((gtype = pyg_type_from_object(pygtype)) == 0) {
	return NULL;
    }
    
    if (!g_signal_parse_name(name, gtype, &signal_id, NULL, TRUE)) {
	PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s",
		     PyString_AsString(PyObject_Repr((PyObject*)self)),
		     name);
	return NULL;
    }

    g_signal_remove_emission_hook(signal_id, hook_id);
    
    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:Schevo,项目名称:kiwi,代码行数:29,代码来源:_kiwi.c


示例17: Variable_GetValue

//-----------------------------------------------------------------------------
// Variable_Repr()
//   Return a string representation of the variable.
//-----------------------------------------------------------------------------
static PyObject *Variable_Repr(
    udt_Variable *self)                 // variable to return the string for
{
    PyObject *valueRepr, *value, *module, *name, *result, *format, *formatArgs;

    value = Variable_GetValue(self, 0);
    if (!value)
        return NULL;
    valueRepr = PyObject_Repr(value);
    Py_DECREF(value);
    if (!valueRepr)
        return NULL;
    format = ceString_FromAscii("<%s.%s with value %s>");
    if (!format) {
        Py_DECREF(valueRepr);
        return NULL;
    }
    if (GetModuleAndName(Py_TYPE(self), &module, &name) < 0) {
        Py_DECREF(valueRepr);
        Py_DECREF(format);
        return NULL;
    }
    formatArgs = PyTuple_Pack(3, module, name, valueRepr);
    Py_DECREF(module);
    Py_DECREF(name);
    Py_DECREF(valueRepr);
    if (!formatArgs) {
        Py_DECREF(format);
        return NULL;
    }
    result = ceString_Format(format, formatArgs);
    Py_DECREF(format);
    Py_DECREF(formatArgs);
    return result;
}
开发者ID:JoyceYL,项目名称:coolblue-ceodbc,代码行数:39,代码来源:Variable.c


示例18: PyObject_Unicode

PyObject *
PyObject_Unicode(PyObject *v)
{
	PyObject *res;
	PyObject *func;
	PyObject *str;
	static PyObject *unicodestr;

	if (v == NULL) {
		res = PyString_FromString("<NULL>");
		if (res == NULL)
			return NULL;
		str = PyUnicode_FromEncodedObject(res, NULL, "strict");
		Py_DECREF(res);
		return str;
	} else if (PyUnicode_CheckExact(v)) {
		Py_INCREF(v);
		return v;
	}
	/* XXX As soon as we have a tp_unicode slot, we should
	   check this before trying the __unicode__
	   method. */
	if (unicodestr == NULL) {
		unicodestr= PyString_InternFromString("__unicode__");
		if (unicodestr == NULL)
			return NULL;
	}
	func = PyObject_GetAttr(v, unicodestr);
	if (func != NULL) {
		res = PyEval_CallObject(func, (PyObject *)NULL);
		Py_DECREF(func);
	}
	else {
		PyErr_Clear();
		if (PyUnicode_Check(v)) {
			/* For a Unicode subtype that's didn't overwrite __unicode__,
			   return a true Unicode object with the same data. */
			return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(v),
			                             PyUnicode_GET_SIZE(v));
		}
		if (PyString_CheckExact(v)) {
			Py_INCREF(v);
			res = v;
		}
		else {
			if (v->ob_type->tp_str != NULL)
				res = (*v->ob_type->tp_str)(v);
			else
				res = PyObject_Repr(v);
		}
	}
	if (res == NULL)
		return NULL;
	if (!PyUnicode_Check(res)) {
		str = PyUnicode_FromEncodedObject(res, NULL, "strict");
		Py_DECREF(res);
		res = str;
	}
	return res;
}
开发者ID:Charlian,项目名称:python-cobra,代码行数:60,代码来源:object.c


示例19: Array_tp_repr

static PyObject *
Array_tp_repr(DBusPyArray *self)
{
    PyObject *parent_repr = (PyList_Type.tp_repr)((PyObject *)self);
    PyObject *sig_repr = PyObject_Repr(self->signature);
    PyObject *my_repr = NULL;
    long variant_level = self->variant_level;

    if (!parent_repr) goto finally;
    if (!sig_repr) goto finally;
    if (variant_level > 0) {
        my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, "
                                       "variant_level=%ld)",
                                       Py_TYPE(&self->super)->tp_name,
                                       REPRV(parent_repr),
                                       REPRV(sig_repr),
                                       variant_level);
    }
    else {
        my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)",
                                       Py_TYPE(&self->super)->tp_name,
                                       REPRV(parent_repr),
                                       REPRV(sig_repr));
    }
finally:
    Py_CLEAR(parent_repr);
    Py_CLEAR(sig_repr);
    return my_repr;
}
开发者ID:smcv,项目名称:dbus-python,代码行数:29,代码来源:containers.c


示例20: sllistnode_repr

static PyObject* sllistnode_repr(SLListNodeObject* self)
{
    PyObject* str = NULL;
    PyObject* tmp_str;

    str = Py23String_FromString("<sllistnode(");
    if (str == NULL)
        goto str_alloc_error;

    tmp_str = PyObject_Repr(self->value);
    if (tmp_str == NULL)
        goto str_alloc_error;
    Py23String_ConcatAndDel(&str, tmp_str);

    tmp_str = Py23String_FromString(")>");
    if (tmp_str == NULL)
        goto str_alloc_error;
    Py23String_ConcatAndDel(&str, tmp_str);

    return str;

str_alloc_error:
    Py_XDECREF(str);
    PyErr_SetString(PyExc_RuntimeError, "Failed to create string");
    return NULL;
}
开发者ID:ajakubek,项目名称:python-llist,代码行数:26,代码来源:sllist.c



注:本文中的PyObject_Repr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyObject_RichCompare函数代码示例发布时间:2022-05-30
下一篇:
C++ PyObject_New函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap