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
bcd2aa6d
Kaydet (Commit)
bcd2aa6d
authored
Mar 22, 2013
tarafından
Gregory P. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
cleanup references to PyString_ APIs from 2.x in the 3.3 docs.
üst
340a4bb2
4b52ae8f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
18 deletions
+19
-18
intro.rst
Doc/c-api/intro.rst
+1
-1
memory.rst
Doc/c-api/memory.rst
+3
-3
newtypes.rst
Doc/extending/newtypes.rst
+7
-8
extending.rst
Doc/faq/extending.rst
+8
-6
No files found.
Doc/c-api/intro.rst
Dosyayı görüntüle @
bcd2aa6d
...
@@ -210,7 +210,7 @@ error handling for the moment; a better way to code this is shown below)::
...
@@ -210,7 +210,7 @@ error handling for the moment; a better way to code this is shown below)::
t = PyTuple_New(3);
t = PyTuple_New(3);
PyTuple_SetItem(t, 0, PyLong_FromLong(1L));
PyTuple_SetItem(t, 0, PyLong_FromLong(1L));
PyTuple_SetItem(t, 1, PyLong_FromLong(2L));
PyTuple_SetItem(t, 1, PyLong_FromLong(2L));
PyTuple_SetItem(t, 2, Py
String
_FromString("three"));
PyTuple_SetItem(t, 2, Py
Unicode
_FromString("three"));
Here, :c:func:`PyLong_FromLong` returns a new reference which is immediately
Here, :c:func:`PyLong_FromLong` returns a new reference which is immediately
stolen by :c:func:`PyTuple_SetItem`. When you want to keep using an object
stolen by :c:func:`PyTuple_SetItem`. When you want to keep using an object
...
...
Doc/c-api/memory.rst
Dosyayı görüntüle @
bcd2aa6d
...
@@ -61,7 +61,7 @@ example::
...
@@ -61,7 +61,7 @@ example::
if (buf == NULL)
if (buf == NULL)
return PyErr_NoMemory();
return PyErr_NoMemory();
...Do some I/O operation involving buf...
...Do some I/O operation involving buf...
res = Py
String
_FromString(buf);
res = Py
Bytes
_FromString(buf);
free(buf); /* malloc'ed */
free(buf); /* malloc'ed */
return res;
return res;
...
@@ -169,7 +169,7 @@ I/O buffer is allocated from the Python heap by using the first function set::
...
@@ -169,7 +169,7 @@ I/O buffer is allocated from the Python heap by using the first function set::
if (buf == NULL)
if (buf == NULL)
return PyErr_NoMemory();
return PyErr_NoMemory();
/* ...Do some I/O operation involving buf... */
/* ...Do some I/O operation involving buf... */
res = Py
String
_FromString(buf);
res = Py
Bytes
_FromString(buf);
PyMem_Free(buf); /* allocated with PyMem_Malloc */
PyMem_Free(buf); /* allocated with PyMem_Malloc */
return res;
return res;
...
@@ -181,7 +181,7 @@ The same code using the type-oriented function set::
...
@@ -181,7 +181,7 @@ The same code using the type-oriented function set::
if (buf == NULL)
if (buf == NULL)
return PyErr_NoMemory();
return PyErr_NoMemory();
/* ...Do some I/O operation involving buf... */
/* ...Do some I/O operation involving buf... */
res = Py
String
_FromString(buf);
res = Py
Bytes
_FromString(buf);
PyMem_Del(buf); /* allocated with PyMem_New */
PyMem_Del(buf); /* allocated with PyMem_New */
return res;
return res;
...
...
Doc/extending/newtypes.rst
Dosyayı görüntüle @
bcd2aa6d
...
@@ -288,13 +288,13 @@ strings, so we provide a new method::
...
@@ -288,13 +288,13 @@ strings, so we provide a new method::
self = (Noddy *)type->tp_alloc(type, 0);
self = (Noddy *)type->tp_alloc(type, 0);
if (self != NULL) {
if (self != NULL) {
self->first = Py
String
_FromString("");
self->first = Py
Unicode
_FromString("");
if (self->first == NULL) {
if (self->first == NULL) {
Py_DECREF(self);
Py_DECREF(self);
return NULL;
return NULL;
}
}
self->last = Py
String
_FromString("");
self->last = Py
Unicode
_FromString("");
if (self->last == NULL) {
if (self->last == NULL) {
Py_DECREF(self);
Py_DECREF(self);
return NULL;
return NULL;
...
@@ -540,9 +540,9 @@ getting and setting the :attr:`first` attribute::
...
@@ -540,9 +540,9 @@ getting and setting the :attr:`first` attribute::
return -1;
return -1;
}
}
if (! Py
String
_Check(value)) {
if (! Py
Unicode
_Check(value)) {
PyErr_SetString(PyExc_TypeError,
PyErr_SetString(PyExc_TypeError,
"The first attribute value must be a str
ing
");
"The first attribute value must be a str");
return -1;
return -1;
}
}
...
@@ -1005,7 +1005,7 @@ example::
...
@@ -1005,7 +1005,7 @@ example::
static PyObject *
static PyObject *
newdatatype_repr(newdatatypeobject * obj)
newdatatype_repr(newdatatypeobject * obj)
{
{
return Py
String
_FromFormat("Repr-ified_newdatatype{{size:\%d}}",
return Py
Unicode
_FromFormat("Repr-ified_newdatatype{{size:\%d}}",
obj->obj_UnderlyingDatatypePtr->size);
obj->obj_UnderlyingDatatypePtr->size);
}
}
...
@@ -1025,7 +1025,7 @@ Here is a simple example::
...
@@ -1025,7 +1025,7 @@ Here is a simple example::
static PyObject *
static PyObject *
newdatatype_str(newdatatypeobject * obj)
newdatatype_str(newdatatypeobject * obj)
{
{
return Py
String
_FromFormat("Stringified_newdatatype{{size:\%d}}",
return Py
Unicode
_FromFormat("Stringified_newdatatype{{size:\%d}}",
obj->obj_UnderlyingDatatypePtr->size);
obj->obj_UnderlyingDatatypePtr->size);
}
}
...
@@ -1342,11 +1342,10 @@ Here is a desultory example of the implementation of the call function. ::
...
@@ -1342,11 +1342,10 @@ Here is a desultory example of the implementation of the call function. ::
if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
return NULL;
return NULL;
}
}
result = Py
String
_FromFormat(
result = Py
Unicode
_FromFormat(
"Returning -- value: [\%d] arg1: [\%s] arg2: [\%s] arg3: [\%s]\n",
"Returning -- value: [\%d] arg1: [\%s] arg2: [\%s] arg3: [\%s]\n",
obj->obj_UnderlyingDatatypePtr->size,
obj->obj_UnderlyingDatatypePtr->size,
arg1, arg2, arg3);
arg1, arg2, arg3);
printf("\%s", PyString_AS_STRING(result));
return result;
return result;
}
}
...
...
Doc/faq/extending.rst
Dosyayı görüntüle @
bcd2aa6d
...
@@ -82,18 +82,20 @@ returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
...
@@ -82,18 +82,20 @@ returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
index. Lists have similar functions, :c:func:`PyListSize` and
index. Lists have similar functions, :c:func:`PyListSize` and
:c:func:`PyList_GetItem`.
:c:func:`PyList_GetItem`.
For strings, :c:func:`PyString_Size` returns its length and
For bytes, :c:func:`PyBytes_Size` returns its length and
:c:func:`PyString_AsString` a pointer to its value. Note that Python strings may
:c:func:`PyBytes_AsStringAndSize` provides a pointer to its value and its
contain null bytes so C's :c:func:`strlen` should not be used.
length. Note that Python bytes objects may contain null bytes so C's
:c:func:`strlen` should not be used.
To test the type of an object, first make sure it isn't *NULL*, and then use
To test the type of an object, first make sure it isn't *NULL*, and then use
:c:func:`Py
String
_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
:c:func:`Py
Bytes
_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
There is also a high-level API to Python objects which is provided by the
There is also a high-level API to Python objects which is provided by the
so-called 'abstract' interface -- read ``Include/abstract.h`` for further
so-called 'abstract' interface -- read ``Include/abstract.h`` for further
details. It allows interfacing with any kind of Python sequence using calls
details. It allows interfacing with any kind of Python sequence using calls
like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc.) as well as
like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc.) as well
many other useful protocols.
as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et.
al.) and mappings in the PyMapping APIs.
How do I use Py_BuildValue() to create a tuple of arbitrary length?
How do I use Py_BuildValue() to create a tuple of arbitrary length?
...
...
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