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

C++ PyObject_GetAttr函数代码示例

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

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



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

示例1: method_get_doc

static PyObject *
method_get_doc(PyMethodObject *im, void *context)
{
    static PyObject *docstr;
    if (docstr == NULL) {
        docstr= PyUnicode_InternFromString("__doc__");
        if (docstr == NULL)
            return NULL;
    }
    return PyObject_GetAttr(im->im_func, docstr);
}
开发者ID:10sr,项目名称:cpython,代码行数:11,代码来源:classobject.c


示例2: Py_INCREF

static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    PyObject *typ;
    PyObject *tb = NULL;
    PyObject *val = NULL;
    PyObject *yf = gen->yieldfrom;

    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;

    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;

    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
            int err = __Pyx_Generator_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Generator_Undelegate(gen);
            if (err < 0)
                return __Pyx_Generator_SendEx(gen, NULL);
            goto throw_here;
        }
        gen->is_running = 1;
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Throw(yf, args);
        } else {
            PyObject *meth = PyObject_GetAttr(yf, PYIDENT("throw"));
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Generator_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            ret = PyObject_CallObject(meth, args);
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Generator_FinishDelegation(gen);
        }
        return ret;
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Generator_SendEx(gen, NULL);
}
开发者ID:Aeternam,项目名称:server_status,代码行数:54,代码来源:Generator.c


示例3: do_call_tc

static int
do_call_tc(pycbc_Connection *conn,
          PyObject *obj,
          PyObject *flags,
          PyObject **result,
          int mode)
{
    PyObject *meth = NULL;
    PyObject *args = NULL;
    PyObject *strlookup = NULL;
    int ret = -1;

    switch (mode) {
    case ENCODE_KEY:
        strlookup = pycbc_helpers.tcname_encode_key;
        args = PyTuple_Pack(1, obj);
        break;
    case DECODE_KEY:
        strlookup = pycbc_helpers.tcname_decode_key;
        args = PyTuple_Pack(1, obj);
        break;

    case ENCODE_VALUE:
        strlookup = pycbc_helpers.tcname_encode_value;
        args = PyTuple_Pack(2, obj, flags);
        break;

    case DECODE_VALUE:
        strlookup = pycbc_helpers.tcname_decode_value;
        args = PyTuple_Pack(2, obj, flags);
        break;
    }
    if (args == NULL) {
        PYCBC_EXC_WRAP(PYCBC_EXC_INTERNAL, 0, "Couldn't build arguments");
        goto GT_DONE;
    }

    meth = PyObject_GetAttr(conn->tc, strlookup);
    if (!meth) {
        PYCBC_EXC_WRAP_OBJ(PYCBC_EXC_ENCODING, 0,
                           "Couldn't find transcoder method",
                           conn->tc);
        goto GT_DONE;
    }
    *result = PyObject_Call(meth, args, NULL);
    if (*result) {
        ret = 0;
    }

    GT_DONE:
    Py_XDECREF(meth);
    Py_XDECREF(args);
    return ret;
}
开发者ID:esplorio,项目名称:couchbase-python-client,代码行数:54,代码来源:convert.c


示例4: generic_flush

/* flush the write buffer */
static int
generic_flush(genericstreamobject *self, int passdown)
{
    bufitem *current;
    PyObject *joined, *result;
    char *jptr;
    Py_ssize_t size;

    if (!self->write) {
        PyErr_SetString(PyExc_AttributeError,
            "This stream does not provide a write function"
        );
        return -1;
    }

    if (self->wbuf && self->wbuf_size > 0) {
        joined = PyString_FromStringAndSize(NULL, self->wbuf_size);
        jptr = PyString_AS_STRING(joined) + self->wbuf_size;
        current = self->wbuf;
        self->wbuf = NULL;
        self->wbuf_size = 0;
        while (current) {
            size = PyString_GET_SIZE(current->load);
            jptr -= size;
            (void)memcpy(jptr, PyString_AS_STRING(current->load),
                         (size_t)size);
            current = bufitem_del(current);
        }
        result = PyObject_CallFunction(self->write, "(O)", joined);
        Py_DECREF(joined);
        if (!result)
            return -1;
        Py_DECREF(result);
    }

    if (passdown) {
        if (!self->flush) {
            if (!(result = PyObject_GetAttr(self->ostream, flushproperty))) {
                if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                    return -1;
                PyErr_Clear();
                Py_INCREF(Py_None);
                self->flush = Py_None;
            }
            else
                self->flush = result;
        }
        if (    (self->flush != Py_None)
            && !(result = PyObject_CallObject(self->flush, NULL)))
            return -1;
    }

    return 0;
}
开发者ID:ndparker,项目名称:wtf,代码行数:55,代码来源:stream.c


示例5: instancemethod_get_doc

static PyObject *
instancemethod_get_doc(PyObject *self, void *context)
{
    static PyObject *docstr;
    if (docstr == NULL) {
        docstr = PyUnicode_InternFromString("__doc__");
        if (docstr == NULL)
            return NULL;
    }
    return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self), docstr);
}
开发者ID:10sr,项目名称:cpython,代码行数:11,代码来源:classobject.c


示例6: stop_event_loop

static void
stop_event_loop(lcb_io_opt_t io)
{
    PyObject *fn;
    pycbc_iops_t *pio = (pycbc_iops_t*)io;
    pio->in_loop = 0;

    fn = PyObject_GetAttr(pio->pyio, pycbc_helpers.ioname_stopwatch);
    PyObject_CallFunctionObjArgs(fn, NULL);

    Py_XDECREF(fn);
}
开发者ID:neilalbrock,项目名称:couchbase-python-client,代码行数:12,代码来源:iops.c


示例7: Checker_proxy

/*     def proxy(self, value): */
static PyObject *
Checker_proxy(Checker *self, PyObject *value)
{
  PyObject *checker, *r;

/*        if type(value) is Proxy: */
/*            return value */
  if ((PyObject*)(value->ob_type) == Proxy)
    {
      Py_INCREF(value);
      return value;
    }

/*         checker = getattr(value, '__Security_checker__', None) */
  checker = PyObject_GetAttr(value, str___Security_checker__);
/*         if checker is None: */
  if (checker == NULL)
    {
      PyErr_Clear();

/*             checker = selectChecker(value) */
      checker = selectChecker(NULL, value);
      if (checker == NULL)
        return NULL;

/*             if checker is None: */
/*                 return value */
      if (checker == Py_None)
        {
          Py_DECREF(checker);
          Py_INCREF(value);
          return value;
        }
    }
  else if (checker == Py_None)
    {
      PyObject *errv = Py_BuildValue("sO",
                                     "Invalid value, None. "
                                     "for security checker",
                                     value);
      if (errv != NULL)
        {
          PyErr_SetObject(PyExc_ValueError, errv);
          Py_DECREF(errv);
        }

      return NULL;
    }

  r = PyObject_CallFunctionObjArgs(Proxy, value, checker, NULL);
  Py_DECREF(checker);
  return r;
}
开发者ID:kislovm,项目名称:findburo,代码行数:54,代码来源:_zope_security_checker.c


示例8: default_owner_method

static PyObject*
default_owner_method( Member* member, PyObject* owner )
{
    if( !PyString_Check( member->default_context ) )
        return py_type_fail( "default owner method name must be a string" );
    PyObjectPtr callable( PyObject_GetAttr( owner, member->default_context ) );
    if( !callable )
        return 0;
    PyTuplePtr args( PyTuple_New( 0 ) );
    if( !args )
        return 0;
    return callable( args ).release();
}
开发者ID:enthought,项目名称:atom,代码行数:13,代码来源:memberfunctions.cpp


示例9: __Pyx_Globals

static PyObject* __Pyx_Globals(void) {
    Py_ssize_t i;
    //PyObject *d;
    PyObject *names = NULL;
    PyObject *globals = PyObject_GetAttrString($module_cname, "__dict__");
    if (!globals) {
        PyErr_SetString(PyExc_TypeError,
            "current module must have __dict__ attribute");
        goto bad;
    }
    names = PyObject_Dir($module_cname);
    if (!names)
        goto bad;
    for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject* name = PySequence_GetItem(names, i);
        if (!name)
            goto bad;
#else
        PyObject* name = PyList_GET_ITEM(names, i);
#endif
        if (!PyDict_Contains(globals, name)) {
            PyObject* value = PyObject_GetAttr($module_cname, name);
            if (!value) {
#if CYTHON_COMPILING_IN_PYPY
                Py_DECREF(name);
#endif
                goto bad;
            }
            if (PyDict_SetItem(globals, name, value) < 0) {
#if CYTHON_COMPILING_IN_PYPY
                Py_DECREF(name);
#endif
                Py_DECREF(value);
                goto bad;
            }
        }
#if CYTHON_COMPILING_IN_PYPY
        Py_DECREF(name);
#endif
    }
    Py_DECREF(names);
    return globals;
    // d = PyDictProxy_New(globals);
    // Py_DECREF(globals);
    // return d;
bad:
    Py_XDECREF(names);
    Py_XDECREF(globals);
    return NULL;
}
开发者ID:87,项目名称:cython,代码行数:51,代码来源:Builtins.c


示例10: Py_INCREF

  /* "/home/sean/Projects/WorldMill/src/mill/workspace.pyx":42
 *         ograpi.OGR_DS_Destroy(cogr_ds)
 *         
 *         return collections             # <<<<<<<<<<<<<< 
 * 
 *     property collections:
 */
  Py_INCREF(__pyx_v_collections);
  __pyx_r = __pyx_v_collections;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("mill.workspace.Workspace._read_collections");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_collections);
  Py_DECREF(__pyx_v_n);
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_layer_name);
  Py_DECREF(__pyx_v_collection);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_pf_4mill_9workspace_9Workspace_11collections___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4mill_9workspace_9Workspace_11collections___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/sean/Projects/WorldMill/src/mill/workspace.pyx":47
 *         # A lazy property
 *         def __get__(self):
 *             if not self._collections:             # <<<<<<<<<<<<<< 
 *                 self._collections = self._read_collections()
 *             return self._collections
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(((struct __pyx_obj_4mill_9workspace_Workspace *)__pyx_v_self)->_collections); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n__read_collections); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((struct __pyx_obj_4mill_9workspace_Workspace *)__pyx_v_self)->_collections);
    ((struct __pyx_obj_4mill_9workspace_Workspace *)__pyx_v_self)->_collections = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/sean/Projects/WorldMill/src/mill/workspace.pyx":49
 *             if not self._collections:
 *                 self._collections = self._read_collections()
 *             return self._collections             # <<<<<<<<<<<<<< 
 * 
 *     def __getitem__(self, name):
 */
  Py_INCREF(((struct __pyx_obj_4mill_9workspace_Workspace *)__pyx_v_self)->_collections);
  __pyx_r = ((struct __pyx_obj_4mill_9workspace_Workspace *)__pyx_v_self)->_collections;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("mill.workspace.Workspace.collections.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}
开发者ID:dandye,项目名称:worldmill,代码行数:81,代码来源:workspace.c


示例11: OSD_descr_get

static PyObject *
OSD_descr_get(PyObject *self, PyObject *inst, PyObject *cls)
{
  PyObject *provides;

  if (inst == NULL)
    return getObjectSpecification(NULL, cls);

  provides = PyObject_GetAttr(inst, str__provides__);
  if (provides != NULL)
    return provides;
  PyErr_Clear();
  return implementedBy(NULL, cls);
}
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:14,代码来源:_zope_interface_coptimizations.c


示例12: iobase_closed

static int
iobase_closed(PyObject *self)
{
    PyObject *res;
    int closed;
    /* This gets the derived attribute, which is *not* __IOBase_closed
       in most cases! */
    res = PyObject_GetAttr(self, _PyIO_str_closed);
    if (res == NULL)
        return 0;
    closed = PyObject_IsTrue(res);
    Py_DECREF(res);
    return closed;
}
开发者ID:GINK03,项目名称:StaticPython,代码行数:14,代码来源:iobase.c


示例13: if

/*
 * The descriptor's descriptor get slot.
 */
static PyObject *sipMethodDescr_descr_get(PyObject *self, PyObject *obj,
        PyObject *type)
{
    sipMethodDescr *md = (sipMethodDescr *)self;

    (void)type;

    if (obj == Py_None)
        obj = NULL;
    else if (md->mixin_name != NULL)
        obj = PyObject_GetAttr(obj, md->mixin_name);

    return PyCFunction_New(md->pmd, obj);
}
开发者ID:blackbelt544,项目名称:Scrapula,代码行数:17,代码来源:descriptors.c


示例14: SWIG_Python_str_FromChar

/* VTable implementation */
    PyObject *swig_get_method(size_t method_index, const char *method_name) const {
      PyObject *method = vtable[method_index];
      if (!method) {
        swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);
        method = PyObject_GetAttr(swig_get_self(), name);
        if (!method) {
          std::string msg = "Method in class OTNameLookup doesn't exist, undefined ";
          msg += method_name;
          Swig::DirectorMethodException::raise(msg.c_str());
        }
        vtable[method_index] = method;
      }
      return method;
    }
开发者ID:BugFreeSoftware,项目名称:Open-Transactions,代码行数:15,代码来源:OTAPI-python.hpp


示例15: verifying_changed

static PyObject *
verifying_changed(verify *self, PyObject *ignored)
{
  PyObject *t, *ro;

  verifying_clear(self);

  t = PyObject_GetAttr(OBJECT(self), str_registry);
  if (t == NULL)
    return NULL;
  ro = PyObject_GetAttr(t, strro);
  Py_DECREF(t);
  if (ro == NULL)
    return NULL;

  t = PyObject_CallFunctionObjArgs(OBJECT(&PyTuple_Type), ro, NULL);
  Py_DECREF(ro);
  if (t == NULL)
    return NULL;

  ro = PyTuple_GetSlice(t, 1, PyTuple_GET_SIZE(t));
  Py_DECREF(t);
  if (ro == NULL)
    return NULL;

  self->_verify_generations = _generations_tuple(ro);
  if (self->_verify_generations == NULL)
    {
      Py_DECREF(ro);
      return NULL;
    }

  self->_verify_ro = ro;

  Py_INCREF(Py_None);
  return Py_None;
}
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:37,代码来源:_zope_interface_coptimizations.c


示例16: decode_impl

static PyObject* decode_impl(PyObject* args) {
  PyObject* output_obj = NULL;
  PyObject* oprot = NULL;
  PyObject* typeargs = NULL;
  if (!PyArg_ParseTuple(args, "OOO", &output_obj, &oprot, &typeargs)) {
    return NULL;
  }

  T protocol;
#ifdef _MSC_VER
  // workaround strange VC++ 2015 bug where #else path does not compile
  int32_t default_limit = INT32_MAX;
#else
  int32_t default_limit = std::numeric_limits<int32_t>::max();
#endif
  protocol.setStringLengthLimit(
      as_long_then_delete(PyObject_GetAttr(oprot, INTERN_STRING(string_length_limit)),
                          default_limit));
  protocol.setContainerLengthLimit(
      as_long_then_delete(PyObject_GetAttr(oprot, INTERN_STRING(container_length_limit)),
                          default_limit));
  ScopedPyObject transport(PyObject_GetAttr(oprot, INTERN_STRING(trans)));
  if (!transport) {
    return NULL;
  }

  StructTypeArgs parsedargs;
  if (!parse_struct_args(&parsedargs, typeargs)) {
    return NULL;
  }

  if (!protocol.prepareDecodeBufferFromTransport(transport.get())) {
    return NULL;
  }

  return protocol.readStruct(output_obj, parsedargs.klass, parsedargs.spec);
}
开发者ID:917386389,项目名称:thrift,代码行数:37,代码来源:module.cpp


示例17: generic_close

/* Close the stream */
static int
generic_close(genericstreamobject *self)
{
    PyObject *tmp, *closefn;
    PyObject *ptype = NULL, *pvalue, *ptraceback;

    if (!(self->flags & GENERIC_STREAM_CLOSED)) {
        if (generic_flush(self, 0) == -1) {
            if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_Clear();
            }
            else {
                PyErr_Fetch(&ptype, &pvalue, &ptraceback);
                PyErr_Clear();
            }
        }
        self->flags |= GENERIC_STREAM_CLOSED;

        if (!(closefn = PyObject_GetAttr(self->ostream, closeproperty))) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                goto error;
            PyErr_Clear();
        }
        else {
            tmp = PyObject_CallObject(closefn, NULL);
            Py_DECREF(closefn);
            if (!tmp)
                goto error;
            Py_DECREF(tmp);
        }

        if (ptype)
            goto error;
    }
    return 0;

error:
    if (PyErr_Occurred()) {
        if (ptype) {
            Py_DECREF(ptype);
            Py_DECREF(pvalue);
            Py_DECREF(ptraceback);
        }
    }
    else {
        PyErr_Restore(ptype, pvalue, ptraceback);
    }
    return -1;
}
开发者ID:ndparker,项目名称:wtf,代码行数:50,代码来源:stream.c


示例18: post_validate_owner_method

static PyObject*
post_validate_owner_method( Member* member, PyObject* owner, PyObject* oldvalue, PyObject* newvalue )
{
    if( !PyString_Check( member->post_validate_context ) )
        return py_type_fail( "post validate owner method name must be a string" );
    PyObjectPtr callable( PyObject_GetAttr( owner, member->post_validate_context ) );
    if( !callable )
        return 0;
    PyTuplePtr args( PyTuple_New( 2 ) );
    if( !args )
        return 0;
    args.set_item( 0, newref( oldvalue ) );
    args.set_item( 1, newref( newvalue ) );
    return callable( args ).release();
}
开发者ID:enthought,项目名称:atom,代码行数:15,代码来源:memberfunctions.cpp


示例19: PyDict_New

  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":123 */
  __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cache);
  ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cache = __pyx_3;
  __pyx_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("Stemmer.Stemmer.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_algorithm);
  return __pyx_r;
}

static void __pyx_f_7Stemmer_7Stemmer___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_7Stemmer_7Stemmer___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF(__pyx_v_self);
  sb_stemmer_delete(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cobj);

  Py_DECREF(__pyx_v_self);
}

static int __pyx_f_7Stemmer_7Stemmer_12maxCacheSize___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_size); /*proto*/
static int __pyx_f_7Stemmer_7Stemmer_12maxCacheSize___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_size) {
  int __pyx_v_size;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_size = PyInt_AsLong(__pyx_arg_size); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}

  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":139 */
  ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->max_cache_size = __pyx_v_size;

  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":140 */
  __pyx_1 = (__pyx_v_size == 0);
  if (__pyx_1) {

    /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":141 */
    __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;}
    Py_DECREF(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cache);
    ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cache = __pyx_2;
    __pyx_2 = 0;

    /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":142 */
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}
    Py_DECREF(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter);
    ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n___purgeCache); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("Stemmer.Stemmer.maxCacheSize.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}
开发者ID:buriy,项目名称:pystemmer,代码行数:76,代码来源:Stemmer.c


示例20: pickle___reduce__

static PyObject *
pickle___reduce__(PyObject *self)
{
    PyObject *args=NULL, *bargs=NULL, *state=NULL, *getnewargs=NULL;
    int l, i;

    getnewargs = PyObject_GetAttr(self, py___getnewargs__);
    if (getnewargs)
    {
        bargs = PyObject_CallFunctionObjArgs(getnewargs, NULL);
        Py_DECREF(getnewargs);
        if (!bargs)
            return NULL;
        l = PyTuple_Size(bargs);
        if (l < 0)
            goto end;
    }
    else
    {
        PyErr_Clear();
        l = 0;
    }

    args = PyTuple_New(l+1);
    if (args == NULL)
        goto end;

    Py_INCREF(Py_TYPE(self));
    PyTuple_SET_ITEM(args, 0, (PyObject*)(Py_TYPE(self)));
    for (i = 0; i < l; i++)
    {
        Py_INCREF(PyTuple_GET_ITEM(bargs, i));
        PyTuple_SET_ITEM(args, i+1, PyTuple_GET_ITEM(bargs, i));
    }

    state = PyObject_CallMethodObjArgs(self, py___getstate__, NULL);
    if (!state)
        goto end;

    state = Py_BuildValue("(OON)", __newobj__, args, state);

end:
    Py_XDECREF(bargs);
    Py_XDECREF(args);

    return state;
}
开发者ID:zopefoundation,项目名称:persistent,代码行数:47,代码来源:cPersistence.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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