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

C++ PyObject_SetAttrString函数代码示例

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

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



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

示例1: cdefer_Deferred__set_debug_stack

static int cdefer_Deferred__set_debug_stack(cdefer_Deferred *self, char *name) {
    int rc;
    PyObject *stack;

    stack = PyObject_CallObject(format_stack, NULL);
    if (!stack) {
        return -1;
    }
    rc = PyObject_SetAttrString(self->debuginfo, name, stack);
    Py_DECREF(stack);
    if (-1 == rc) {
        return -1;
    }
    return 0;
}
开发者ID:anrysev,项目名称:twisted,代码行数:15,代码来源:cdefer.c


示例2: Py_INCREF

/* Implementation of kleckner1 */

static PyObject *__pyx_f_9kleckner1_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9kleckner1_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_x)) return 0;
  Py_INCREF(__pyx_v_x);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static void __pyx_f_9kleckner1_g(int __pyx_v_x) {

}

static struct PyMethodDef __pyx_methods[] = {
  {"f", (PyCFunction)__pyx_f_9kleckner1_f, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initkleckner1(void); /*proto*/
PyMODINIT_FUNC initkleckner1(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("kleckner1", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/kleckner/kleckner1.pyx":4 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("kleckner1");
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:42,代码来源:kleckner1.c


示例3: srd_inst_start

/** @private */
SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di)
{
	PyObject *py_res;
	GSList *l;
	struct srd_decoder_inst *next_di;
	int ret;

	srd_dbg("Calling start() method on protocol decoder instance %s.",
			di->inst_id);

	/* Run self.start(). */
	if (!(py_res = PyObject_CallMethod(di->py_inst, "start", NULL))) {
		srd_exception_catch("Protocol decoder instance %s",
				di->inst_id);
		return SRD_ERR_PYTHON;
	}
	Py_DecRef(py_res);

	/* Set the initial pins based on self.initial_pins. */
	set_initial_pin_values(di);

	/* Set self.samplenum to 0. */
	PyObject_SetAttrString(di->py_inst, "samplenum", PyLong_FromLong(0));

	/* Set self.matches to None. */
	PyObject_SetAttrString(di->py_inst, "matches", Py_None);

	/* Start all the PDs stacked on top of this one. */
	for (l = di->next_di; l; l = l->next) {
		next_di = l->data;
		if ((ret = srd_inst_start(next_di)) != SRD_OK)
			return ret;
	}

	return SRD_OK;
}
开发者ID:zeldin,项目名称:libsigrokdecode,代码行数:37,代码来源:instance.c


示例4: PyComplex

void PyComplex(char *name, double value, double value2)
{
    PyObject *obj;

    obj = PyComplex_FromDoubles(value, value2);
    
    if(list_level>=0 && List[list_level]) {
        PyList_Append(List[list_level], obj);
        Py_DECREF(obj);    
        return;
    }

    PyObject_SetAttrString(interpreter_state->main_module, name, obj);
    Py_DECREF(obj);
}
开发者ID:pc,项目名称:pythonika,代码行数:15,代码来源:Pythonika.c


示例5: Py_INCREF

    /* "/Users/baas/src/cgkit/pyrex/pyx/_pointcloud.pyx":131 */
    __pyx_v_n += 1;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_pointcloud.writeDataPoints");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {"readDataPoints", (PyCFunction)__pyx_f_11_pointcloud_readDataPoints, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11_pointcloud_readDataPoints},
  {"writeDataPoints", (PyCFunction)__pyx_f_11_pointcloud_writeDataPoints, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11_pointcloud_writeDataPoints},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_pointcloud(void); /*proto*/
PyMODINIT_FUNC init_pointcloud(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_pointcloud", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};

  /* "/Users/baas/src/cgkit/pyrex/pyx/_pointcloud.pyx":90 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("_pointcloud");
}
开发者ID:npinto,项目名称:cgkit,代码行数:39,代码来源:_pointcloud.c


示例6: PyInteger

void PyInteger(char *name, long value)
{
    PyObject *obj;

    obj = PyLong_FromLong(value);
    
    if(list_level>=0 && List[list_level]) {
        PyList_Append(List[list_level], obj);
        Py_DECREF(obj);        
        return;
    }

    PyObject_SetAttrString(interpreter_state->main_module, name, obj);
    Py_DECREF(obj);
}
开发者ID:pc,项目名称:pythonika,代码行数:15,代码来源:Pythonika.c


示例7: py_set_attrs

static void py_set_attrs(PyObject *mod)
{
   DECL_ATTR_RETRO(B);
   DECL_ATTR_RETRO(Y);
   DECL_ATTR_RETRO(SELECT);
   DECL_ATTR_RETRO(START);
   DECL_ATTR_RETRO(UP);
   DECL_ATTR_RETRO(DOWN);
   DECL_ATTR_RETRO(LEFT);
   DECL_ATTR_RETRO(RIGHT);
   DECL_ATTR_RETRO(A);
   DECL_ATTR_RETRO(X);
   DECL_ATTR_RETRO(L);
   DECL_ATTR_RETRO(R);
   DECL_ATTR_RETRO(L2);
   DECL_ATTR_RETRO(R2);
   DECL_ATTR_RETRO(L3);
   DECL_ATTR_RETRO(R3);

   PyObject_SetAttrString(mod, "ANALOG_LEFT", PyLong_FromLong(RETRO_DEVICE_INDEX_ANALOG_LEFT));
   PyObject_SetAttrString(mod, "ANALOG_RIGHT", PyLong_FromLong(RETRO_DEVICE_INDEX_ANALOG_RIGHT));
   PyObject_SetAttrString(mod, "ANALOG_X", PyLong_FromLong(RETRO_DEVICE_ID_ANALOG_X));
   PyObject_SetAttrString(mod, "ANALOG_Y", PyLong_FromLong(RETRO_DEVICE_ID_ANALOG_Y));
}
开发者ID:demsullivan,项目名称:RetroArch,代码行数:24,代码来源:py_state.c


示例8: initMk4py

void initMk4py() {
  PyObject *m = Py_InitModule4("Mk4py", Mk4Methods, mk4py_module_documentation,
    0, PYTHON_API_VERSION);
  PyObject_SetAttrString(m, "version", PyString_FromString("2.4.9.7"));
  PyObject_SetAttrString(m, "ViewType", (PyObject*) &PyViewtype);
  PyObject_SetAttrString(m, "ViewerType", (PyObject*) &PyViewertype);
  PyObject_SetAttrString(m, "ROViewerType", (PyObject*) &PyROViewertype);
  PyObject_SetAttrString(m, "RowRefType", (PyObject*) &PyRowReftype);
  PyObject_SetAttrString(m, "RORowRefType", (PyObject*) &PyRORowReftype);
}
开发者ID:azynheira,项目名称:metakit,代码行数:10,代码来源:PyStorage.cpp


示例9: delete_invalid_lists

void delete_invalid_lists( PyObject* pobj )
{
    PyObject* pclass = NULL;
    PyObject* plist = NULL;
    PyObject* temp;
    int i, d, n;

    pclass = PyObject_GetAttrString( pobj, "__class__" );
    if ( pclass == NULL )
	goto done;

    plist = PyObject_GetAttrString( pclass, "invalid" );
    if ( plist == NULL )
	goto done;

    if ( !PyList_Check( plist ) ) goto done;

    n = PyList_Size( plist );
    if ( n == 0 ) goto done;
#if 0
    printf( "deleting old displaylists: " );
#endif
    for ( i = 0; i < n; ++i )
    {
	temp = PyList_GetItem( plist, i );
	if ( PyInt_Check( temp ) ) {
	    d = PyInt_AsLong( temp );
            glDeleteLists( d, 1 );
        } else if ( PyTuple_Check( temp ) ) {
	    d = PyInt_AsLong( PyTuple_GetItem( temp, 0 ) );
            glDeleteLists( d, 1 );
	} else { 
	    fprintf( stderr, "delete_invalid_lists:  bad cache value\n" );
        }
#if 0
	printf( " %d", d );
#endif
    }
#if 0
    printf( "\n" );
#endif

    PyObject_SetAttrString( pclass, "invalid", PyList_New(0) );
    
 done:
    Py_XDECREF( pclass );
    Py_XDECREF( plist );
}
开发者ID:gcross,项目名称:QC-Talks,代码行数:48,代码来源:dr_path.c


示例10: pygpgme_context_genkey

static PyObject *
pygpgme_context_genkey(PyGpgmeContext *self, PyObject *args)
{
    PyObject *py_pubkey = Py_None, *py_seckey = Py_None;
    const char *parms;
    gpgme_data_t pubkey = NULL, seckey = NULL;
    PyObject *result;
    gpgme_error_t err;

    if (!PyArg_ParseTuple(args, "z|OO", &parms, &py_pubkey, &py_seckey))
        return NULL;

    if (pygpgme_data_new(&pubkey, py_pubkey))
        return NULL;

    if (pygpgme_data_new(&seckey, py_seckey)) {
        gpgme_data_release(pubkey);
        return NULL;
    }

    Py_BEGIN_ALLOW_THREADS;
    err = gpgme_op_genkey(self->ctx, parms, pubkey, seckey);
    Py_END_ALLOW_THREADS;

    gpgme_data_release(seckey);
    gpgme_data_release(pubkey);
    result = pygpgme_genkey_result(self->ctx);

    if (pygpgme_check_error(err)) {
        PyObject *err_type, *err_value, *err_traceback;

        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;

        if (result != NULL) {
            PyObject_SetAttrString(err_value, "result", result);
            Py_DECREF(result);
        }
    end:
        PyErr_Restore(err_type, err_value, err_traceback);
        return NULL;
    }

    return (PyObject *) result;
}
开发者ID:andreimacavei,项目名称:pygpgme,代码行数:48,代码来源:pygpgme-context.c


示例11: channel_read

static PyObject *
channel_read(SSH2_ChannelObj *self, PyObject *args)
{
	int ret;
	int bufsiz;
	int stream_id = 0;
	PyObject *buf;

	if (!PyArg_ParseTuple(args, "i|i:read", &bufsiz, &stream_id))
		return NULL;

	if (bufsiz < 0) {
		PyErr_SetString(PyExc_ValueError, "negative size");
		return NULL;
	}

	if ((buf = PyBytes_FromStringAndSize(NULL, bufsiz)) == NULL)
		return NULL;

	Py_BEGIN_ALLOW_THREADS
	ret = libssh2_channel_read_ex(self->channel, stream_id, PyBytes_AS_STRING(buf), bufsiz);
	Py_END_ALLOW_THREADS

	if (ret < 0) {
		Py_DECREF(buf);

		/* We have to work around a bug in libssh2, that _libssh2_error() is not
		 * called by libssh2_channel_read_ex() when the transport layer returns
		 * LIBSSH2_ERROR_EAGAIN. So in that case the last error is not set and
		 * the RAISE_SSH2_ERROR macro will not be able to raise the correct exception.
		 * Thanks to Daniel Stenberg, who has fixed that issue now (see 2db4863).
		 * However in order that our bindings work correctly with older versions
		 * of libssh2, we need the workaround below. */
		if (ret == LIBSSH2_ERROR_EAGAIN) {
			PyObject *exc;
			PyObject *value;

			exc = PyObject_CallFunction(SSH2_Error, "s", "Would block");
			value=Py_BuildValue("i", ret);
			PyObject_SetAttrString(exc, "errno", value);
			PyErr_SetObject(SSH2_Error, exc);
			Py_DECREF(exc);
			Py_DECREF(value);
			return NULL;
		}

		RAISE_SSH2_ERROR(self->session)
	}
开发者ID:elektro79,项目名称:ssh4py,代码行数:48,代码来源:channel.c


示例12: PyTuple_New

    /*else*/ {
      __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
      Py_INCREF(__pyx_v_d2);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_d2);
      Py_INCREF(__pyx_v_p21);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_p21);
      Py_INCREF(__pyx_v_p22);
      PyTuple_SET_ITEM(__pyx_6, 2, __pyx_v_p22);
      __pyx_r = __pyx_6;
      __pyx_6 = 0;
      goto __pyx_L0;
    }
    __pyx_L16:;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  __Pyx_AddTraceback("closestpair.closest_pair");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_min_p1);
  Py_DECREF(__pyx_v_min_p2);
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_point);
  Py_DECREF(__pyx_v_point2);
  Py_DECREF(__pyx_v_d);
  Py_DECREF(__pyx_v_split);
  Py_DECREF(__pyx_v_d1);
  Py_DECREF(__pyx_v_p11);
  Py_DECREF(__pyx_v_p12);
  Py_DECREF(__pyx_v_d2);
  Py_DECREF(__pyx_v_p21);
  Py_DECREF(__pyx_v_p22);
  Py_DECREF(__pyx_v_points_in_strip);
  Py_DECREF(__pyx_v_split_at);
  Py_DECREF(__pyx_v_max_i);
  Py_DECREF(__pyx_v_sd);
  Py_DECREF(__pyx_v_points);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_append, "append"},
  {&__pyx_n_closest_pair, "closest_pair"},
  {&__pyx_n_distance, "distance"},
  {&__pyx_n_min, "min"},
  {&__pyx_n_sort, "sort"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k1p, __pyx_k1, sizeof(__pyx_k1)},
  {0, 0, 0}
};

static struct PyMethodDef __pyx_methods[] = {
  {"distance", (PyCFunction)__pyx_f_11closestpair_distance, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11closestpair_distance},
  {"closest_pair", (PyCFunction)__pyx_f_11closestpair_closest_pair, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11closestpair_closest_pair},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initclosestpair(void); /*proto*/
PyMODINIT_FUNC initclosestpair(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("closestpair", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};

  /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":6 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("closestpair");
}
开发者ID:EricSchles,项目名称:djangopeople,代码行数:90,代码来源:closestpair.c


示例13: initgtop

PyMODINIT_FUNC
initgtop(void)
{
	PyObject* module;

	glibtop_init();

	Py_AtExit(gtop_at_exit);

	module = Py_InitModule("gtop", (PyMethodDef*) gtop_methods);
	PyType_Ready((PyTypeObject*) &StructType);
	PyObject_SetAttrString(module, "_Struct", (void*) &StructType);

	register_constants(module);
	PyModule_AddObject(module, "siglist", build_siglist());
}
开发者ID:ZevenOS,项目名称:wnck-patches,代码行数:16,代码来源:gtop.c


示例14: psyco_errors_set

void
psyco_errors_set(PyObject *type)
{
    int i;
    char *name;

    for (i = 0; exctable[i].name; i++) {
        if (NULL == exctable[i].exc) { continue; }

        /* the name is the part after the last dot */
        name = strrchr(exctable[i].name, '.');
        name = name ? name + 1 : exctable[i].name;

        PyObject_SetAttrString(type, name, *exctable[i].exc);
    }
}
开发者ID:JonathanRRogers,项目名称:psycopg2,代码行数:16,代码来源:psycopgmodule.c


示例15: PyUnicodeString

void PyUnicodeString(char *name, unsigned short *value, long len)
{
    PyObject *obj;
    

    obj = PyUnicode_FromUnicode((unsigned short *)value, len);

    if(list_level>=0 && List[list_level]) {        
        PyList_Append(List[list_level], obj);
        Py_DECREF(obj);
        return;
    }

    PyObject_SetAttrString( interpreter_state->main_module, name, obj);
    Py_DECREF(obj);
}
开发者ID:pc,项目名称:pythonika,代码行数:16,代码来源:Pythonika.c


示例16: PP_Set_Member

int
PP_Set_Member(PyObject *pobject, const char *attrname,
                  const char *argfmt,  ... /* arg,... */ )    /* convert to python */
{
    int result;
    PyObject *pval;
    va_list argslist;                             /* "pobject.attrname = v" */
    va_start(argslist, argfmt);
    Py_Initialize();                              /* init if first time */
    pval = Py_VaBuildValue(argfmt, argslist);     /* input: C->Python */
    if (pval == NULL) 
        return -1;
    result = PyObject_SetAttrString(pobject, attrname, pval);     /* setattr */
    Py_DECREF(pval); 
    return result;
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:16,代码来源:PyTools.c


示例17: iobase_close

static PyObject *
iobase_close(PyObject *self, PyObject *args)
{
    PyObject *res;

    if (IS_CLOSED(self))
        Py_RETURN_NONE;

    res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
    PyObject_SetAttrString(self, "__IOBase_closed", Py_True);
    if (res == NULL) {
        return NULL;
    }
    Py_XDECREF(res);
    Py_RETURN_NONE;
}
开发者ID:GINK03,项目名称:StaticPython,代码行数:16,代码来源:iobase.c


示例18: __pyx_init_filenames

/* Implementation of anonymousenum */

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initanonymousenum(void); /*proto*/
PyMODINIT_FUNC initanonymousenum(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("anonymousenum", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};

  /* "/Local/Projects/D/Pyrex/Source/Tests/7/anonymousenum.pyx":6 */
  __pyx_v_13anonymousenum_i = __pyx_e_13anonymousenum_spam;
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("anonymousenum");
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:25,代码来源:anonymousenum.c


示例19: PyErr_SyntaxLocation

void
PyErr_SyntaxLocation(const char *filename, int lineno)
{
	PyObject *exc, *v, *tb, *tmp;

	/* add attributes for the line number and filename for the error */
	PyErr_Fetch(&exc, &v, &tb);
	PyErr_NormalizeException(&exc, &v, &tb);
	/* XXX check that it is, indeed, a syntax error */
	tmp = PyInt_FromLong(lineno);
	if (tmp == NULL)
		PyErr_Clear();
	else {
		if (PyObject_SetAttrString(v, "lineno", tmp))
			PyErr_Clear();
		Py_DECREF(tmp);
	}
	if (filename != NULL) {
		tmp = PyString_FromString(filename);
		if (tmp == NULL)
			PyErr_Clear();
		else {
			if (PyObject_SetAttrString(v, "filename", tmp))
				PyErr_Clear();
			Py_DECREF(tmp);
		}

		tmp = PyErr_ProgramText(filename, lineno);
		if (tmp) {
			PyObject_SetAttrString(v, "text", tmp);
			Py_DECREF(tmp);
		}
	}
	if (PyObject_SetAttrString(v, "offset", Py_None)) {
		PyErr_Clear();
	}
	if (exc != PyExc_SyntaxError) {
		if (!PyObject_HasAttrString(v, "msg")) {
			tmp = PyObject_Str(v);
			if (tmp) {
				if (PyObject_SetAttrString(v, "msg", tmp))
					PyErr_Clear();
				Py_DECREF(tmp);
			} else {
				PyErr_Clear();
			}
		}
		if (!PyObject_HasAttrString(v, "print_file_and_line")) {
			if (PyObject_SetAttrString(v, "print_file_and_line",
						   Py_None))
				PyErr_Clear();
		}
	}
	PyErr_Restore(exc, v, tb);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:55,代码来源:errors.c


示例20: unpickle

PyObject *
unpickle(PyObject *obj, int *offset)
{
	// Return value: New Reference
	PyObject *input = NULL;
	PyObject *cPickle = NULL;
	PyObject *unpickler = NULL;
	PyObject *result = NULL;

	cPickle = PyImport_ImportModule("cPickle");
	if(!cPickle)
		return NULL;

	input = PycStringIO->NewInput(obj);
	if(!input)
		goto fail;

	unpickler = PyObject_CallMethod(cPickle, "Unpickler", "(O)", input);
	if(!unpickler)
		goto fail;

	if(!find_global_func)
	{
		PyErr_SetString(PyExc_RuntimeError, "No find_global function set. Use _set_find_global_func()");
		goto fail;
	}

	if(PyObject_SetAttrString(unpickler, "find_global", find_global_func) == -1)
	{
		PyErr_SetString(PyExc_RuntimeError, "Unpickler initialization failed");
		goto fail;
	}

	if(*offset)
	{
		// seek to desired position.
		Py_XDECREF(PyObject_CallMethod(cPickle, "seek", "(i)", *offset));
	}

	result = PyObject_CallMethod(unpickler, "load", NULL);

fail:
	Py_XDECREF(cPickle);
	Py_XDECREF(input);
	Py_XDECREF(unpickler);
	return result;
}
开发者ID:blitzmann,项目名称:reverence,代码行数:47,代码来源:marshal.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PyObject_Str函数代码示例发布时间:2022-05-30
下一篇:
C++ PyObject_SetAttr函数代码示例发布时间: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