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
47fe5c0d
Kaydet (Commit)
47fe5c0d
authored
Agu 12, 2011
tarafından
Eli Bendersky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #12672: fix code samples in extending/newtypes.html for PEP-7 compliance
üst
ff3d3e4c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
93 deletions
+85
-93
newtypes.rst
Doc/extending/newtypes.rst
+4
-6
noddy2.c
Doc/includes/noddy2.c
+16
-18
noddy3.c
Doc/includes/noddy3.c
+50
-52
noddy4.c
Doc/includes/noddy4.c
+15
-17
No files found.
Doc/extending/newtypes.rst
Dosyayı görüntüle @
47fe5c0d
...
...
@@ -289,18 +289,16 @@ strings, so we provide a new method::
self = (Noddy *)type->tp_alloc(type, 0);
if (self != NULL) {
self->first = PyString_FromString("");
if (self->first == NULL)
{
if (self->first == NULL) {
Py_DECREF(self);
return NULL;
}
}
self->last = PyString_FromString("");
if (self->last == NULL)
{
if (self->last == NULL) {
Py_DECREF(self);
return NULL;
}
}
self->number = 0;
}
...
...
Doc/includes/noddy2.c
Dosyayı görüntüle @
47fe5c0d
...
...
@@ -24,18 +24,16 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self
=
(
Noddy
*
)
type
->
tp_alloc
(
type
,
0
);
if
(
self
!=
NULL
)
{
self
->
first
=
PyUnicode_FromString
(
""
);
if
(
self
->
first
==
NULL
)
{
if
(
self
->
first
==
NULL
)
{
Py_DECREF
(
self
);
return
NULL
;
}
}
self
->
last
=
PyUnicode_FromString
(
""
);
if
(
self
->
last
==
NULL
)
{
if
(
self
->
last
==
NULL
)
{
Py_DECREF
(
self
);
return
NULL
;
}
}
self
->
number
=
0
;
}
...
...
@@ -50,10 +48,10 @@ Noddy_init(Noddy *self, PyObject *args, PyObject *kwds)
static
char
*
kwlist
[]
=
{
"first"
,
"last"
,
"number"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OOi"
,
kwlist
,
&
first
,
&
last
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OOi"
,
kwlist
,
&
first
,
&
last
,
&
self
->
number
))
return
-
1
;
return
-
1
;
if
(
first
)
{
tmp
=
self
->
first
;
...
...
@@ -111,7 +109,7 @@ Noddy_name(Noddy* self)
result
=
PyUnicode_Format
(
format
,
args
);
Py_DECREF
(
args
);
return
result
;
}
...
...
@@ -145,12 +143,12 @@ static PyTypeObject NoddyType = {
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
"Noddy objects"
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
Noddy_methods
,
/* tp_methods */
Noddy_members
,
/* tp_members */
0
,
/* tp_getset */
...
...
@@ -173,7 +171,7 @@ static PyModuleDef noddy2module = {
};
PyMODINIT_FUNC
PyInit_noddy2
(
void
)
PyInit_noddy2
(
void
)
{
PyObject
*
m
;
...
...
Doc/includes/noddy3.c
Dosyayı görüntüle @
47fe5c0d
...
...
@@ -24,18 +24,16 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self
=
(
Noddy
*
)
type
->
tp_alloc
(
type
,
0
);
if
(
self
!=
NULL
)
{
self
->
first
=
PyUnicode_FromString
(
""
);
if
(
self
->
first
==
NULL
)
{
if
(
self
->
first
==
NULL
)
{
Py_DECREF
(
self
);
return
NULL
;
}
}
self
->
last
=
PyUnicode_FromString
(
""
);
if
(
self
->
last
==
NULL
)
{
if
(
self
->
last
==
NULL
)
{
Py_DECREF
(
self
);
return
NULL
;
}
}
self
->
number
=
0
;
}
...
...
@@ -50,10 +48,10 @@ Noddy_init(Noddy *self, PyObject *args, PyObject *kwds)
static
char
*
kwlist
[]
=
{
"first"
,
"last"
,
"number"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|SSi"
,
kwlist
,
&
first
,
&
last
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|SSi"
,
kwlist
,
&
first
,
&
last
,
&
self
->
number
))
return
-
1
;
return
-
1
;
if
(
first
)
{
tmp
=
self
->
first
;
...
...
@@ -88,22 +86,22 @@ Noddy_getfirst(Noddy *self, void *closure)
static
int
Noddy_setfirst
(
Noddy
*
self
,
PyObject
*
value
,
void
*
closure
)
{
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"Cannot delete the first attribute"
);
return
-
1
;
}
if
(
!
PyUnicode_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"The first attribute value must be a string"
);
return
-
1
;
}
Py_DECREF
(
self
->
first
);
Py_INCREF
(
value
);
self
->
first
=
value
;
return
0
;
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"Cannot delete the first attribute"
);
return
-
1
;
}
if
(
!
PyUnicode_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"The first attribute value must be a string"
);
return
-
1
;
}
Py_DECREF
(
self
->
first
);
Py_INCREF
(
value
);
self
->
first
=
value
;
return
0
;
}
static
PyObject
*
...
...
@@ -116,30 +114,30 @@ Noddy_getlast(Noddy *self, void *closure)
static
int
Noddy_setlast
(
Noddy
*
self
,
PyObject
*
value
,
void
*
closure
)
{
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"Cannot delete the last attribute"
);
return
-
1
;
}
if
(
!
PyUnicode_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"The last attribute value must be a string"
);
return
-
1
;
}
Py_DECREF
(
self
->
last
);
Py_INCREF
(
value
);
self
->
last
=
value
;
return
0
;
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"Cannot delete the last attribute"
);
return
-
1
;
}
if
(
!
PyUnicode_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"The last attribute value must be a string"
);
return
-
1
;
}
Py_DECREF
(
self
->
last
);
Py_INCREF
(
value
);
self
->
last
=
value
;
return
0
;
}
static
PyGetSetDef
Noddy_getseters
[]
=
{
{
"first"
,
{
"first"
,
(
getter
)
Noddy_getfirst
,
(
setter
)
Noddy_setfirst
,
"first name"
,
NULL
},
{
"last"
,
{
"last"
,
(
getter
)
Noddy_getlast
,
(
setter
)
Noddy_setlast
,
"last name"
,
NULL
},
...
...
@@ -164,7 +162,7 @@ Noddy_name(Noddy* self)
result
=
PyUnicode_Format
(
format
,
args
);
Py_DECREF
(
args
);
return
result
;
}
...
...
@@ -198,12 +196,12 @@ static PyTypeObject NoddyType = {
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
"Noddy objects"
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
Noddy_methods
,
/* tp_methods */
Noddy_members
,
/* tp_members */
Noddy_getseters
,
/* tp_getset */
...
...
@@ -226,7 +224,7 @@ static PyModuleDef noddy3module = {
};
PyMODINIT_FUNC
PyInit_noddy3
(
void
)
PyInit_noddy3
(
void
)
{
PyObject
*
m
;
...
...
Doc/includes/noddy4.c
Dosyayı görüntüle @
47fe5c0d
...
...
@@ -27,7 +27,7 @@ Noddy_traverse(Noddy *self, visitproc visit, void *arg)
return
0
;
}
static
int
static
int
Noddy_clear
(
Noddy
*
self
)
{
PyObject
*
tmp
;
...
...
@@ -58,18 +58,16 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self
=
(
Noddy
*
)
type
->
tp_alloc
(
type
,
0
);
if
(
self
!=
NULL
)
{
self
->
first
=
PyUnicode_FromString
(
""
);
if
(
self
->
first
==
NULL
)
{
if
(
self
->
first
==
NULL
)
{
Py_DECREF
(
self
);
return
NULL
;
}
}
self
->
last
=
PyUnicode_FromString
(
""
);
if
(
self
->
last
==
NULL
)
{
if
(
self
->
last
==
NULL
)
{
Py_DECREF
(
self
);
return
NULL
;
}
}
self
->
number
=
0
;
}
...
...
@@ -84,10 +82,10 @@ Noddy_init(Noddy *self, PyObject *args, PyObject *kwds)
static
char
*
kwlist
[]
=
{
"first"
,
"last"
,
"number"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OOi"
,
kwlist
,
&
first
,
&
last
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OOi"
,
kwlist
,
&
first
,
&
last
,
&
self
->
number
))
return
-
1
;
return
-
1
;
if
(
first
)
{
tmp
=
self
->
first
;
...
...
@@ -145,7 +143,7 @@ Noddy_name(Noddy* self)
result
=
PyUnicode_Format
(
format
,
args
);
Py_DECREF
(
args
);
return
result
;
}
...
...
@@ -182,10 +180,10 @@ static PyTypeObject NoddyType = {
"Noddy objects"
,
/* tp_doc */
(
traverseproc
)
Noddy_traverse
,
/* tp_traverse */
(
inquiry
)
Noddy_clear
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
Noddy_methods
,
/* tp_methods */
Noddy_members
,
/* tp_members */
0
,
/* tp_getset */
...
...
@@ -208,7 +206,7 @@ static PyModuleDef noddy4module = {
};
PyMODINIT_FUNC
PyInit_noddy4
(
void
)
PyInit_noddy4
(
void
)
{
PyObject
*
m
;
...
...
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