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
d019fe29
Commit
d019fe29
authored
Dec 08, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace all remaining occurrences of PyInt_.
parent
0aa93cda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
21 deletions
+15
-21
Doc/c-api/concrete.rst
Doc/c-api/concrete.rst
+5
-11
Doc/c-api/intro.rst
Doc/c-api/intro.rst
+10
-10
No files found.
Doc/c-api/concrete.rst
View file @
d019fe29
...
@@ -374,15 +374,6 @@ All integers are implemented as "long" integer objects of arbitrary size.
...
@@ -374,15 +374,6 @@ All integers are implemented as "long" integer objects of arbitrary size.
:cfunc:`PyLong_FromVoidPtr`.
:cfunc:`PyLong_FromVoidPtr`.
.. XXX name?
.. cfunction:: long PyInt_GetMax()
.. index:: single: LONG_MAX
Return the system's idea of the largest integer it can handle
(:const:`LONG_MAX`, as defined in the system header files).
.. _floatobjects:
.. _floatobjects:
Floating Point Objects
Floating Point Objects
...
@@ -2275,8 +2266,11 @@ Dictionary Objects
...
@@ -2275,8 +2266,11 @@ Dictionary Objects
Py_ssize_t pos = 0;
Py_ssize_t pos = 0;
while (PyDict_Next(self->dict, &pos, &key, &value)) {
while (PyDict_Next(self->dict, &pos, &key, &value)) {
int i = PyInt_AS_LONG(value) + 1;
long i = PyLong_AsLong(value);
PyObject *o = PyInt_FromLong(i);
if (i == -1 && PyErr_Occurred()) {
return -1;
}
PyObject *o = PyLong_FromLong(i + 1);
if (o == NULL)
if (o == NULL)
return -1;
return -1;
if (PyDict_SetItem(self->dict, key, o) < 0) {
if (PyDict_SetItem(self->dict, key, o) < 0) {
...
...
Doc/c-api/intro.rst
View file @
d019fe29
...
@@ -208,11 +208,11 @@ error handling for the moment; a better way to code this is shown below)::
...
@@ -208,11 +208,11 @@ error handling for the moment; a better way to code this is shown below)::
PyObject *t;
PyObject *t;
t = PyTuple_New(3);
t = PyTuple_New(3);
PyTuple_SetItem(t, 0, Py
Int
_FromLong(1L));
PyTuple_SetItem(t, 0, Py
Long
_FromLong(1L));
PyTuple_SetItem(t, 1, Py
Int
_FromLong(2L));
PyTuple_SetItem(t, 1, Py
Long
_FromLong(2L));
PyTuple_SetItem(t, 2, PyString_FromString("three"));
PyTuple_SetItem(t, 2, PyString_FromString("three"));
Here, :cfunc:`Py
Int
_FromLong` returns a new reference which is immediately
Here, :cfunc:`Py
Long
_FromLong` returns a new reference which is immediately
stolen by :cfunc:`PyTuple_SetItem`. When you want to keep using an object
stolen by :cfunc:`PyTuple_SetItem`. When you want to keep using an object
although the reference to it will be stolen, use :cfunc:`Py_INCREF` to grab
although the reference to it will be stolen, use :cfunc:`Py_INCREF` to grab
another reference before calling the reference-stealing function.
another reference before calling the reference-stealing function.
...
@@ -252,7 +252,7 @@ sets all items of a list (actually, any mutable sequence) to a given item::
...
@@ -252,7 +252,7 @@ sets all items of a list (actually, any mutable sequence) to a given item::
if (n < 0)
if (n < 0)
return -1;
return -1;
for (i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
PyObject *index = Py
Int
_FromLong(i);
PyObject *index = Py
Long
_FromLong(i);
if (!index)
if (!index)
return -1;
return -1;
if (PyObject_SetItem(target, index, item) < 0)
if (PyObject_SetItem(target, index, item) < 0)
...
@@ -301,8 +301,8 @@ using :cfunc:`PySequence_GetItem`. ::
...
@@ -301,8 +301,8 @@ using :cfunc:`PySequence_GetItem`. ::
return -1; /* Not a list */
return -1; /* Not a list */
for (i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
item = PyList_GetItem(list, i); /* Can't fail */
item = PyList_GetItem(list, i); /* Can't fail */
if (!Py
Int
_Check(item)) continue; /* Skip non-integers */
if (!Py
Long
_Check(item)) continue; /* Skip non-integers */
total += Py
Int
_AsLong(item);
total += Py
Long
_AsLong(item);
}
}
return total;
return total;
}
}
...
@@ -324,8 +324,8 @@ using :cfunc:`PySequence_GetItem`. ::
...
@@ -324,8 +324,8 @@ using :cfunc:`PySequence_GetItem`. ::
item = PySequence_GetItem(sequence, i);
item = PySequence_GetItem(sequence, i);
if (item == NULL)
if (item == NULL)
return -1; /* Not a sequence, or other failure */
return -1; /* Not a sequence, or other failure */
if (Py
Int
_Check(item))
if (Py
Long
_Check(item))
total += Py
Int
_AsLong(item);
total += Py
Long
_AsLong(item);
Py_DECREF(item); /* Discard reference ownership */
Py_DECREF(item); /* Discard reference ownership */
}
}
return total;
return total;
...
@@ -449,11 +449,11 @@ Here is the corresponding C code, in all its glory::
...
@@ -449,11 +449,11 @@ Here is the corresponding C code, in all its glory::
/* Clear the error and use zero: */
/* Clear the error and use zero: */
PyErr_Clear();
PyErr_Clear();
item = Py
Int
_FromLong(0L);
item = Py
Long
_FromLong(0L);
if (item == NULL)
if (item == NULL)
goto error;
goto error;
}
}
const_one = Py
Int
_FromLong(1L);
const_one = Py
Long
_FromLong(1L);
if (const_one == NULL)
if (const_one == NULL)
goto error;
goto error;
...
...
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