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

C++ PyUnicode_DecodeFSDefault函数代码示例

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

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



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

示例1: getFileData

PyObject* getFileData(int argc, char *argv[])
{
    PyObject *BioModule = PyImport_ImportModule("Bio");
    const char *filename, *filetype, *pycmdToRun;
    filename = (const char *)PyUnicode_DecodeFSDefault(argv[1]);
    filetype = (const char *)PyUnicode_DecodeFSDefault(argv[2]);
    std::string cmdToRun = "import Bio\nBio.SeqIO.parse(";
    cmdToRun = cmdToRun + filename + std::string(",") + filetype;
    pycmdToRun = cmdToRun.c_str();

    wchar_t *program = Py_DecodeLocale(argv[0], NULL);
    if (program == NULL) {
        fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
        exit(1);
    }
    
    Py_SetProgramName(program);  /* optional but recommended */
    Py_Initialize();
    PyObject* filedata;
    filedata = PyRun_String(pycmdToRun, 0, NULL, NULL);
    Py_DECREF(filename);
    Py_DECREF(filetype);
    Py_Finalize();
    PyMem_RawFree(program);

    return filedata;
}
开发者ID:BMJHayward,项目名称:navtome,代码行数:27,代码来源:biopythonParser.cpp


示例2: psutil_proc_name_and_args

/*
 * Return process name and args as a Python tuple.
 */
static PyObject *
psutil_proc_name_and_args(PyObject *self, PyObject *args) {
    int pid;
    char path[1000];
    psinfo_t info;
    const char *procfs_path;
    PyObject *py_name;
    PyObject *py_args;

    if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
        return NULL;
    sprintf(path, "%s/%i/psinfo", procfs_path, pid);
    if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
        return NULL;

#if PY_MAJOR_VERSION >= 3
    py_name = PyUnicode_DecodeFSDefault(info.pr_fname);
    if (!py_name)
        return NULL;
    py_args = PyUnicode_DecodeFSDefault(info.pr_psargs);
    if (!py_args)
        return NULL;
    return Py_BuildValue("OO", py_name, py_args);
#else
    return Py_BuildValue("ss", info.pr_fname, info.pr_psargs);
#endif
}
开发者ID:Alren-huang,项目名称:psutil,代码行数:30,代码来源:_psutil_sunos.c


示例3: psutil_proc_name_and_args

/*
 * Return process name and args as a Python tuple.
 */
static PyObject *
psutil_proc_name_and_args(PyObject *self, PyObject *args) {
    int pid;
    char path[1000];
    psinfo_t info;
    const char *procfs_path;
    PyObject *py_name = NULL;
    PyObject *py_args = NULL;
    PyObject *py_retlist = NULL;

    if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
        return NULL;
    sprintf(path, "%s/%i/psinfo", procfs_path, pid);
    if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
        return NULL;

    py_name = PyUnicode_DecodeFSDefault(info.pr_fname);
    if (!py_name)
        goto error;
    py_args = PyUnicode_DecodeFSDefault(info.pr_psargs);
    if (!py_args)
        goto error;
    py_retlist = Py_BuildValue("OO", py_name, py_args);
    if (!py_retlist)
        goto error;
    Py_DECREF(py_name);
    Py_DECREF(py_args);
    return py_retlist;

error:
    Py_XDECREF(py_name);
    Py_XDECREF(py_args);
    Py_XDECREF(py_retlist);
    return NULL;
}
开发者ID:jomann09,项目名称:psutil,代码行数:38,代码来源:_psutil_sunos.c


示例4: psutil_users

/*
 * Return users currently connected on the system.
 */
static PyObject *
psutil_users(PyObject *self, PyObject *args) {
    struct utmpx *ut;
    PyObject *py_tuple = NULL;
    PyObject *py_username = NULL;
    PyObject *py_tty = NULL;
    PyObject *py_hostname = NULL;
    PyObject *py_user_proc = NULL;
    PyObject *py_retlist = PyList_New(0);

    if (py_retlist == NULL)
        return NULL;

    setutxent();
    while (NULL != (ut = getutxent())) {
        if (ut->ut_type == USER_PROCESS)
            py_user_proc = Py_True;
        else
            py_user_proc = Py_False;
        py_username = PyUnicode_DecodeFSDefault(ut->ut_user);
        if (! py_username)
            goto error;
        py_tty = PyUnicode_DecodeFSDefault(ut->ut_line);
        if (! py_tty)
            goto error;
        py_hostname = PyUnicode_DecodeFSDefault(ut->ut_host);
        if (! py_hostname)
            goto error;
        py_tuple = Py_BuildValue(
            "(OOOfOi)",
            py_username,              // username
            py_tty,                   // tty
            py_hostname,              // hostname
            (float)ut->ut_tv.tv_sec,  // tstamp
            py_user_proc,             // (bool) user process
            ut->ut_pid                // process id
        );
        if (py_tuple == NULL)
            goto error;
        if (PyList_Append(py_retlist, py_tuple))
            goto error;
        Py_DECREF(py_username);
        Py_DECREF(py_tty);
        Py_DECREF(py_hostname);
        Py_DECREF(py_tuple);
    }
    endutxent();

    return py_retlist;

error:
    Py_XDECREF(py_username);
    Py_XDECREF(py_tty);
    Py_XDECREF(py_hostname);
    Py_XDECREF(py_tuple);
    Py_DECREF(py_retlist);
    endutxent();
    return NULL;
}
开发者ID:jomann09,项目名称:psutil,代码行数:62,代码来源:_psutil_sunos.c


示例5: psutil_disk_partitions

/*
 * Return disk mounted partitions as a list of tuples including device,
 * mount point and filesystem type.
 */
static PyObject *
psutil_disk_partitions(PyObject *self, PyObject *args) {
    FILE *file;
    struct mnttab mt;
    PyObject *py_dev = NULL;
    PyObject *py_mountp = NULL;
    PyObject *py_tuple = NULL;
    PyObject *py_retlist = PyList_New(0);

    if (py_retlist == NULL)
        return NULL;

    file = fopen(MNTTAB, "rb");
    if (file == NULL) {
        PyErr_SetFromErrno(PyExc_OSError);
        goto error;
    }

    while (getmntent(file, &mt) == 0) {
        py_dev = PyUnicode_DecodeFSDefault(mt.mnt_special);
        if (! py_dev)
            goto error;
        py_mountp = PyUnicode_DecodeFSDefault(mt.mnt_mountp);
        if (! py_mountp)
            goto error;
        py_tuple = Py_BuildValue(
            "(OOss)",
            py_dev,           // device
            py_mountp,        // mount point
            mt.mnt_fstype,    // fs type
            mt.mnt_mntopts);  // options
        if (py_tuple == NULL)
            goto error;
        if (PyList_Append(py_retlist, py_tuple))
            goto error;
        Py_DECREF(py_dev);
        Py_DECREF(py_mountp);
        Py_DECREF(py_tuple);
    }
    fclose(file);
    return py_retlist;

error:
    Py_XDECREF(py_dev);
    Py_XDECREF(py_mountp);
    Py_XDECREF(py_tuple);
    Py_DECREF(py_retlist);
    if (file != NULL)
        fclose(file);
    return NULL;
}
开发者ID:jomann09,项目名称:psutil,代码行数:55,代码来源:_psutil_sunos.c


示例6: mkgrent

static PyObject *
mkgrent(struct group *p)
{
    int setIndex = 0;
    PyObject *v = PyStructSequence_New(&StructGrpType), *w;
    char **member;

    if (v == NULL)
        return NULL;

    if ((w = PyList_New(0)) == NULL) {
        Py_DECREF(v);
        return NULL;
    }
    for (member = p->gr_mem; *member != NULL; member++) {
        PyObject *x = PyUnicode_DecodeFSDefault(*member);
        if (x == NULL || PyList_Append(w, x) != 0) {
            Py_XDECREF(x);
            Py_DECREF(w);
            Py_DECREF(v);
            return NULL;
        }
        Py_DECREF(x);
    }

#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
    SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_name));
#ifdef __VMS
    SET(setIndex++, Py_None);
    Py_INCREF(Py_None);
#else
    if (p->gr_passwd)
            SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_passwd));
    else {
            SET(setIndex++, Py_None);
            Py_INCREF(Py_None);
    }
#endif
    SET(setIndex++, PyLong_FromLong((long) p->gr_gid));
    SET(setIndex++, w);
#undef SET

    if (PyErr_Occurred()) {
        Py_DECREF(v);
        return NULL;
    }

    return v;
}
开发者ID:Anzumana,项目名称:cpython,代码行数:49,代码来源:grpmodule.c


示例7: _py_append_local_extension_path

static void
_py_append_local_extension_path(PyObject *path)
{
	assert(path != NULL);
	assert(PyList_Check(path));

	char localpath[PATH_MAX];

	if(path_builder_local_extensions(localpath, PATH_MAX))
	{
		DEBUGF("python", "Appending local extension directory to Python path: %s", localpath);

		PyObject *location = PyUnicode_DecodeFSDefault(localpath);

		if(location)
		{
			PyList_Append(path, location);
		}
		else
		{
			fprintf(stderr, "Invalid encoding: %s\n", localpath);
		}
	}
	else
	{
		WARNING("python", "Couldn't build local extension path.");
	}
}
开发者ID:20centaurifux,项目名称:efind,代码行数:28,代码来源:py-ext-backend.c


示例8: PyErr_SetString

// FIXME: add string array support
static PyObject *mx2char(const mxArray *pArray)
{
  size_t buflen;
  char *buf;
  PyObject *lRetval;
  if (mxGetM(pArray) > 1) {
    PyErr_SetString(mlabraw_error, "Only 1 Dimensional strings are currently supported");
    return NULL;
  }
  buflen = mxGetN(pArray) + 1;

  //buf = (char *)mxCalloc(buflen, sizeof(char));
  //pyassert(buf, "Out of MATLAB(TM) memory");
  //if (mxGetString(pArray, buf, buflen)) {
    //PyErr_SetString(mlabraw_error, "Unable to extract MATLAB(TM) string");
    //mxFree(buf);
    //return NULL;
  //}

  buf = mxArrayToString(pArray);
  if (!buf) {
    PyErr_SetString(mlabraw_error, "Unable to extract MATLAB(TM) string");
    mxFree(buf);
    return NULL;
  }

#ifdef PY3K
  lRetval = PyUnicode_DecodeFSDefault(buf);
#else
  lRetval = (PyStringObject *)PyString_FromString(buf);
#endif
  mxFree(buf);
  return lRetval;
	error_return: return NULL;
}
开发者ID:Answeror,项目名称:mlabwrap,代码行数:36,代码来源:mlabraw.cpp


示例9: if

// PyDoc_STRVAR(bpy_user_resource_doc[]= // now in bpy/utils.py
static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
	char *type;
	char *subdir= NULL;
	int folder_id;
	static const char *kwlist[]= {"type", "subdir", NULL};

	char *path;

	if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s:user_resource", (char **)kwlist, &type, &subdir))
		return NULL;
	
	/* stupid string compare */
	if     (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
	else if (!strcmp(type, "CONFIG"))   folder_id= BLENDER_USER_CONFIG;
	else if (!strcmp(type, "SCRIPTS"))  folder_id= BLENDER_USER_SCRIPTS;
	else if (!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
	else {
		PyErr_SetString(PyExc_ValueError, "invalid resource argument");
		return NULL;
	}
	
	/* same logic as BLI_get_folder_create(), but best leave it up to the script author to create */
	path= BLI_get_folder(folder_id, subdir);

	if (!path)
		path= BLI_get_user_folder_notest(folder_id, subdir);

	return PyUnicode_DecodeFSDefault(path ? path : "");
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:31,代码来源:bpy.c


示例10: SplitFilename

PyObject*  CGenethonDoc::setPythonPath(CString& fileName) {
    CString filePath;
    CString appName;
    SplitFilename(fileName, &filePath, &appName);

    PyObject* sysPath = PySys_GetObject("path");
    PyObject* pyPath = PyUnicode_FromString(filePath);
    PyList_Append(sysPath, pyPath);
    Py_DECREF(pyPath);
    pyPath = PyUnicode_FromString("c:/users/karl/Anaconda3");
    PyList_Append(sysPath, pyPath);
    Py_DECREF(pyPath);
    pyPath = PyUnicode_FromString("c:/users/karl/Anaconda3/Lib");
    PyList_Append(sysPath, pyPath);
    Py_DECREF(pyPath);
    pyPath = PyUnicode_FromString("c:/users/karl/Anaconda3/Dlls");
    PyList_Append(sysPath, pyPath);
    Py_DECREF(pyPath);
    pyPath = PyUnicode_FromString("c:/users/karl/Anaconda3/Lib/site-packages");
    PyList_Append(sysPath, pyPath);
    Py_DECREF(pyPath);

    PyObject*pName = PyUnicode_DecodeFSDefault(appName);
    PyObject*pModule = PyImport_Import(pName);
    Py_DECREF(pName);

    return pModule;
}
开发者ID:karlnicholas,项目名称:GeneThon,代码行数:28,代码来源:GenethonDoc.cpp


示例11: pyalpm_package_get_files

static PyObject* pyalpm_package_get_files(AlpmPackage *self, void *closure) {
  const alpm_filelist_t *flist = NULL;
  PyObject *result = NULL;

  CHECK_IF_INITIALIZED();

  flist = alpm_pkg_get_files(self->c_data);
  if (!flist)
    Py_RETURN_NONE;
  else {
    ssize_t i;
    result = PyList_New((Py_ssize_t)flist->count);
    for (i = 0; i < (ssize_t)flist->count; i++) {
      const alpm_file_t *file = flist->files + i;
      PyObject *filename = PyUnicode_DecodeFSDefault(file->name);
      PyObject *filesize = PyLong_FromLongLong(file->size);
      PyObject *filemode = PyLong_FromUnsignedLong(file->mode);
      PyObject *item = PyTuple_New(3);
      if (item && filename && filesize && filemode) {
        PyTuple_SET_ITEM(item, 0, filename);
        PyTuple_SET_ITEM(item, 1, filesize);
        PyTuple_SET_ITEM(item, 2, filemode);
        PyList_SET_ITEM(result, i, item);
      } else {
        Py_CLEAR(item);
        Py_CLEAR(filename);
        Py_CLEAR(filesize);
        Py_CLEAR(filemode);
        return NULL;
      }
    }
  }
  return result;
}
开发者ID:vadmium,项目名称:pyalpm,代码行数:34,代码来源:package.c


示例12: PyErr_WarnExplicit

int
PyErr_WarnExplicit(PyObject *category, const char *text,
                   const char *filename_str, int lineno,
                   const char *module_str, PyObject *registry)
{
    PyObject *message = PyUnicode_FromString(text);
    PyObject *filename = PyUnicode_DecodeFSDefault(filename_str);
    PyObject *module = NULL;
    int ret = -1;

    if (message == NULL || filename == NULL)
        goto exit;
    if (module_str != NULL) {
        module = PyUnicode_FromString(module_str);
        if (module == NULL)
            goto exit;
    }

    ret = PyErr_WarnExplicitObject(category, message, filename, lineno,
                                   module, registry);

 exit:
    Py_XDECREF(message);
    Py_XDECREF(module);
    Py_XDECREF(filename);
    return ret;
}
开发者ID:PiJoules,项目名称:cpython-modified,代码行数:27,代码来源:_warnings.c


示例13: PyRun_FileExFlags

PyObject *
PyRun_FileExFlags(FILE *fp, const char *filename_str, int start, PyObject *globals,
                  PyObject *locals, int closeit, PyCompilerFlags *flags)
{
    PyObject *ret = NULL;
    mod_ty mod;
    PyArena *arena = NULL;
    PyObject *filename;

    filename = PyUnicode_DecodeFSDefault(filename_str);
    if (filename == NULL)
        goto exit;

    arena = PyArena_New();
    if (arena == NULL)
        goto exit;

    mod = PyParser_ASTFromFileObject(fp, filename, NULL, start, 0, 0,
                                     flags, NULL, arena);
    if (closeit)
        fclose(fp);
    if (mod == NULL) {
        goto exit;
    }
    ret = run_mod(mod, filename, globals, locals, flags, arena);

exit:
    Py_XDECREF(filename);
    if (arena != NULL)
        PyArena_Free(arena);
    return ret;
}
开发者ID:tiran,项目名称:cpython,代码行数:32,代码来源:pythonrun.c


示例14: psutil_get_cmdline

// returns the command line as a python list object
PyObject *
psutil_get_cmdline(long pid) {
    static char **argv;
    char **p;
    PyObject *py_arg = NULL;
    PyObject *py_retlist = Py_BuildValue("[]");

    if (!py_retlist)
        return NULL;
    if (pid < 0)
        return py_retlist;

    if ((argv = _psutil_get_argv(pid)) == NULL)
        goto error;

    for (p = argv; *p != NULL; p++) {
#if PY_MAJOR_VERSION >= 3
        py_arg = PyUnicode_DecodeFSDefault(*p);
#else
        py_arg = Py_BuildValue("s", *p);
#endif
        if (!py_arg)
            goto error;
        if (PyList_Append(py_retlist, py_arg))
            goto error;
        Py_DECREF(py_arg);
    }
    return py_retlist;

error:
    Py_XDECREF(py_arg);
    Py_DECREF(py_retlist);
    return NULL;
}
开发者ID:Zyalia,项目名称:psutil,代码行数:35,代码来源:openbsd.c


示例15: set_main_loader

static int
set_main_loader(PyObject *d, const char *filename, const char *loader_name)
{
    PyObject *filename_obj, *bootstrap, *loader_type = NULL, *loader;
    int result = 0;

    filename_obj = PyUnicode_DecodeFSDefault(filename);
    if (filename_obj == NULL)
        return -1;
    PyInterpreterState *interp = _PyInterpreterState_Get();
    bootstrap = PyObject_GetAttrString(interp->importlib,
                                       "_bootstrap_external");
    if (bootstrap != NULL) {
        loader_type = PyObject_GetAttrString(bootstrap, loader_name);
        Py_DECREF(bootstrap);
    }
    if (loader_type == NULL) {
        Py_DECREF(filename_obj);
        return -1;
    }
    loader = PyObject_CallFunction(loader_type, "sN", "__main__", filename_obj);
    Py_DECREF(loader_type);
    if (loader == NULL) {
        return -1;
    }
    if (PyDict_SetItemString(d, "__loader__", loader) < 0) {
        result = -1;
    }
    Py_DECREF(loader);
    return result;
}
开发者ID:tiran,项目名称:cpython,代码行数:31,代码来源:pythonrun.c


示例16: psutil_proc_cwd

PyObject *
psutil_proc_cwd(PyObject *self, PyObject *args) {
    // Reference:
    // http://anoncvs.spacehopper.org/openbsd-src/tree/bin/ps/print.c#n179
    long pid;
    struct kinfo_proc kp;
    char path[MAXPATHLEN];
    size_t pathlen = sizeof path;

    if (! PyArg_ParseTuple(args, "l", &pid))
        return NULL;
    if (psutil_kinfo_proc(pid, &kp) == -1)
        return NULL;

    int name[] = { CTL_KERN, KERN_PROC_CWD, pid };
    if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0) {
        PyErr_SetFromErrno(PyExc_OSError);
        return NULL;
    }
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_DecodeFSDefault(path);
#else
    return Py_BuildValue("s", path);
#endif
}
开发者ID:Zyalia,项目名称:psutil,代码行数:25,代码来源:openbsd.c


示例17: PyErr_SetFromErrnoWithFilename

PyObject *
PyErr_SetFromErrnoWithFilename(PyObject *exc, const char *filename)
{
    PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
    PyObject *result = PyErr_SetFromErrnoWithFilenameObjects(exc, name, NULL);
    Py_XDECREF(name);
    return result;
}
开发者ID:cpcloud,项目名称:cpython,代码行数:8,代码来源:errors.c


示例18: jieba_init

void jieba_init(void)
{
	void *res;
	Py_Initialize();

	if (!Py_IsInitialized()) {
		printf("Py_Initialize() fails.\n");
		assert(0);
	}

	PyRun_SimpleString("import sys");
	PyRun_SimpleString("sys.path.append('./')");

	/* Decode a string using Py_FileSystemDefaultEncoding */
	jieba_wrap_nm = PyUnicode_DecodeFSDefault(JIEBA_WRAP_NAME);

	jieba_module = PyImport_Import(jieba_wrap_nm); /* new ref */
	if (jieba_module == NULL) {
		printf("PyImport_Import() fails.\n");
		goto free;
	}

	jieba_init_func = PyObject_GetAttrString(jieba_module,
			JIEBA_WRAP_INIT_FUN); /* new ref */
	if (jieba_init_func == NULL) {
		printf("PyObject_GetAttrString() fails.\n");

		jieba_release();
		jieba_module = NULL;
	}

	assert(1 == PyCallable_Check(jieba_init_func));

	/* call jieba_init_func in Python */
	res = PyObject_CallObject(jieba_init_func, NULL); /* new ref */
	Py_DECREF(res);
	Py_DECREF(jieba_init_func);

free:
	/* should free obj returned by PyUnicode_DecodeFSDefault(), see #1.3:
	 * http://python.readthedocs.org/en/latest/extending/embedding.html */
	Py_DECREF(jieba_wrap_nm);

	assert(jieba_module != NULL);

	goto invoke_lazy_dict_load; /* uncomment if you do not want this */
	return;

invoke_lazy_dict_load:
	res = jieba_cut("初始化test", strlen("初始化test"));
	if (res) {
		foreach_tok(res, &token_donothing, NULL);

		// PRINT_REF_CNT(res);
		Py_DECREF(res);
	}
}
开发者ID:tkhost,项目名称:the-day-after-tomorrow,代码行数:57,代码来源:jieba-wrap.c


示例19: _ctypes_add_traceback

/* after code that pyrex generates */
void _ctypes_add_traceback(char *funcname, char *filename, int lineno)
{
	PyObject *py_srcfile = 0;
	PyObject *py_funcname = 0;
	PyObject *py_globals = 0;
	PyObject *empty_tuple = 0;
	PyObject *empty_string = 0;
	PyCodeObject *py_code = 0;
	PyFrameObject *py_frame = 0;
    
	py_srcfile = PyUnicode_DecodeFSDefault(filename);
	if (!py_srcfile) goto bad;
	py_funcname = PyUnicode_FromString(funcname);
	if (!py_funcname) goto bad;
	py_globals = PyDict_New();
	if (!py_globals) goto bad;
	empty_tuple = PyTuple_New(0);
	if (!empty_tuple) goto bad;
	empty_string = PyBytes_FromString("");
	if (!empty_string) goto bad;
	py_code = PyCode_New(
		0,            /*int argcount,*/
		0,            /*int kwonlyargcount,*/
		0,            /*int nlocals,*/
		0,            /*int stacksize,*/
		0,            /*int flags,*/
		empty_string, /*PyObject *code,*/
		empty_tuple,  /*PyObject *consts,*/
		empty_tuple,  /*PyObject *names,*/
		empty_tuple,  /*PyObject *varnames,*/
		empty_tuple,  /*PyObject *freevars,*/
		empty_tuple,  /*PyObject *cellvars,*/
		py_srcfile,   /*PyObject *filename,*/
		py_funcname,  /*PyObject *name,*/
		lineno,   /*int firstlineno,*/
		empty_string  /*PyObject *lnotab*/
		);
	if (!py_code) goto bad;
	py_frame = PyFrame_New(
		PyThreadState_Get(), /*PyThreadState *tstate,*/
		py_code,             /*PyCodeObject *code,*/
		py_globals,          /*PyObject *globals,*/
		0                    /*PyObject *locals*/
		);
	if (!py_frame) goto bad;
	py_frame->f_lineno = lineno;
	PyTraceBack_Here(py_frame);
  bad:
	Py_XDECREF(py_globals);
	Py_XDECREF(py_srcfile);
	Py_XDECREF(py_funcname);
	Py_XDECREF(empty_tuple);
	Py_XDECREF(empty_string);
	Py_XDECREF(py_code);
	Py_XDECREF(py_frame);
}
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:57,代码来源:callbacks.c


示例20: sets

static void
sets(PyObject *v, int i, const char* val)
{
  if (val) {
      PyObject *o = PyUnicode_DecodeFSDefault(val);
      PyStructSequence_SET_ITEM(v, i, o);
  } else {
      PyStructSequence_SET_ITEM(v, i, Py_None);
      Py_INCREF(Py_None);
  }
}
开发者ID:Orav,项目名称:kbengine,代码行数:11,代码来源:spwdmodule.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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