Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c877a7c2
Kaydet (Commit)
c877a7c2
authored
Kas 26, 2010
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use PyLong_FromLong where appropriate.
üst
84499323
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
8 deletions
+5
-8
embedding.rst
Doc/extending/embedding.rst
+1
-1
extending.rst
Doc/extending/extending.rst
+4
-7
No files found.
Doc/extending/embedding.rst
Dosyayı görüntüle @
c877a7c2
...
@@ -209,7 +209,7 @@ Python extension. For example::
...
@@ -209,7 +209,7 @@ Python extension. For example::
{
{
if(!PyArg_ParseTuple(args, ":numargs"))
if(!PyArg_ParseTuple(args, ":numargs"))
return NULL;
return NULL;
return Py
_BuildValue("i",
numargs);
return Py
Long_FromLong(
numargs);
}
}
static PyMethodDef EmbMethods[] = {
static PyMethodDef EmbMethods[] = {
...
...
Doc/extending/extending.rst
Dosyayı görüntüle @
c877a7c2
...
@@ -81,7 +81,7 @@ shortly how it ends up being called)::
...
@@ -81,7 +81,7 @@ shortly how it ends up being called)::
if (!PyArg_ParseTuple(args, "s", &command))
if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
return NULL;
sts = system(command);
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
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`::
...
@@ -274,12 +274,9 @@ the string we just got from :c:func:`PyArg_ParseTuple`::
sts = system(command);
sts = system(command);
Our :func:`spam.system` function must return the value of :c:data:`sts` as a
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
Python object. This is done using the function :c:func:`PyLong_FromLong`. ::
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. ::
return Py
_BuildValue("i",
sts);
return Py
Long_FromLong(
sts);
In this case, it will return an integer object. (Yes, even integers are objects
In this case, it will return an integer object. (Yes, even integers are objects
on the heap in Python!)
on the heap in Python!)
...
@@ -1195,7 +1192,7 @@ The function :c:func:`spam_system` is modified in a trivial way::
...
@@ -1195,7 +1192,7 @@ The function :c:func:`spam_system` is modified in a trivial way::
if (!PyArg_ParseTuple(args, "s", &command))
if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
return NULL;
sts = PySpam_System(command);
sts = PySpam_System(command);
return Py
_BuildValue("i",
sts);
return Py
Long_FromLong(
sts);
}
}
In the beginning of the module, right after the line ::
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