Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c877a7c2
Commit
c877a7c2
authored
Nov 26, 2010
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use PyLong_FromLong where appropriate.
parent
84499323
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
8 deletions
+5
-8
Doc/extending/embedding.rst
Doc/extending/embedding.rst
+1
-1
Doc/extending/extending.rst
Doc/extending/extending.rst
+4
-7
No files found.
Doc/extending/embedding.rst
View file @
c877a7c2
...
...
@@ -209,7 +209,7 @@ Python extension. For example::
{
if(!PyArg_ParseTuple(args, ":numargs"))
return NULL;
return Py
_BuildValue("i",
numargs);
return Py
Long_FromLong(
numargs);
}
static PyMethodDef EmbMethods[] = {
...
...
Doc/extending/extending.rst
View file @
c877a7c2
...
...
@@ -81,7 +81,7 @@ shortly how it ends up being called)::
if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
sts = system(command);
return Py
_BuildValue("i",
sts);
return Py
Long_FromLong(
sts);
}
There is a straightforward translation from the argument list in Python (for
...
...
@@ -274,12 +274,9 @@ the string we just got from :c:func:`PyArg_ParseTuple`::
sts = system(command);
Our :func:`spam.system` function must return the value of :c:data:`sts` as a
Python object. This is done using the function :c:func:`Py_BuildValue`, which is
something like the inverse of :c:func:`PyArg_ParseTuple`: it takes a format
string and an arbitrary number of C values, and returns a new Python object.
More info on :c:func:`Py_BuildValue` is given later. ::
Python object. This is done using the function :c:func:`PyLong_FromLong`. ::
return Py
_BuildValue("i",
sts);
return Py
Long_FromLong(
sts);
In this case, it will return an integer object. (Yes, even integers are objects
on the heap in Python!)
...
...
@@ -1195,7 +1192,7 @@ The function :c:func:`spam_system` is modified in a trivial way::
if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
sts = PySpam_System(command);
return Py
_BuildValue("i",
sts);
return Py
Long_FromLong(
sts);
}
In the beginning of the module, right after the line ::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment