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
0d231eda
Kaydet (Commit)
0d231eda
authored
Agu 06, 2001
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
A totally new way to do the __new__ wrapper. This should address the
problem brought up in SF bug #444229.
üst
45900492
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
34 deletions
+45
-34
typeobject.c
Objects/typeobject.c
+45
-34
No files found.
Objects/typeobject.c
Dosyayı görüntüle @
0d231eda
...
@@ -938,31 +938,6 @@ add_wrappers(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
...
@@ -938,31 +938,6 @@ add_wrappers(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
return
0
;
return
0
;
}
}
static
int
add_staticmethodwrappers
(
PyTypeObject
*
type
,
struct
wrapperbase
*
base
,
void
*
wrapped
)
{
PyObject
*
dict
=
type
->
tp_defined
;
PyObject
*
sm
;
for
(;
base
->
name
!=
NULL
;
base
++
)
{
PyObject
*
descr
;
if
(
PyDict_GetItemString
(
dict
,
base
->
name
))
continue
;
descr
=
PyDescr_NewWrapper
(
type
->
ob_type
,
base
,
wrapped
);
if
(
descr
==
NULL
)
return
-
1
;
sm
=
PyStaticMethod_New
(
descr
);
Py_DECREF
(
descr
);
if
(
sm
==
NULL
)
return
-
1
;
if
(
PyDict_SetItemString
(
dict
,
base
->
name
,
sm
)
<
0
)
return
-
1
;
Py_DECREF
(
sm
);
}
return
0
;
}
static
int
static
int
add_members
(
PyTypeObject
*
type
,
struct
memberlist
*
memb
)
add_members
(
PyTypeObject
*
type
,
struct
memberlist
*
memb
)
{
{
...
@@ -1197,7 +1172,7 @@ PyType_InitDict(PyTypeObject *type)
...
@@ -1197,7 +1172,7 @@ PyType_InitDict(PyTypeObject *type)
}
}
/* Initialize the base class */
/* Initialize the base class */
if
(
base
)
{
if
(
base
&&
base
->
tp_dict
==
NULL
)
{
if
(
PyType_InitDict
(
base
)
<
0
)
if
(
PyType_InitDict
(
base
)
<
0
)
return
-
1
;
return
-
1
;
}
}
...
@@ -1853,18 +1828,55 @@ static struct wrapperbase tab_init[] = {
...
@@ -1853,18 +1828,55 @@ static struct wrapperbase tab_init[] = {
};
};
static
PyObject
*
static
PyObject
*
wrap_new
(
PyObject
*
type
,
PyObject
*
args
,
void
*
wrapped
)
tp_new_wrapper
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
{
newfunc
new
=
(
newfunc
)
wrapped
;
PyTypeObject
*
type
,
*
subtype
;
return
new
((
PyTypeObject
*
)
type
,
args
,
NULL
);
PyObject
*
arg0
,
*
res
;
if
(
self
==
NULL
||
!
PyType_Check
(
self
))
Py_FatalError
(
"__new__() called with non-type 'self'"
);
type
=
(
PyTypeObject
*
)
self
;
if
(
!
PyTuple_Check
(
args
)
||
PyTuple_GET_SIZE
(
args
)
<
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"T.__new__(): not enough arguments"
);
return
NULL
;
}
arg0
=
PyTuple_GET_ITEM
(
args
,
0
);
if
(
!
PyType_Check
(
arg0
))
{
PyErr_SetString
(
PyExc_TypeError
,
"T.__new__(S): S is not a type object"
);
return
NULL
;
}
subtype
=
(
PyTypeObject
*
)
arg0
;
if
(
!
PyType_IsSubtype
(
subtype
,
type
))
{
PyErr_SetString
(
PyExc_TypeError
,
"T.__new__(S): S is not a subtype of T"
);
return
NULL
;
}
args
=
PyTuple_GetSlice
(
args
,
1
,
PyTuple_GET_SIZE
(
args
));
if
(
args
==
NULL
)
return
NULL
;
res
=
type
->
tp_new
(
subtype
,
args
,
kwds
);
Py_DECREF
(
args
);
return
res
;
}
}
static
struct
wrapperbase
tab_new
[]
=
{
static
struct
PyMethodDef
tp_new_methoddef
[]
=
{
{
"__new__"
,
(
wrapperfunc
)
wrap_new
,
{
"__new__"
,
(
PyCFunction
)
tp_new_wrapper
,
METH_KEYWORDS
,
"T.__new__(
) -> an object with type
T"
},
"T.__new__(
S, ...) -> a new object with type S, a subtype of
T"
},
{
0
}
{
0
}
};
};
static
int
add_tp_new_wrapper
(
PyTypeObject
*
type
)
{
PyObject
*
func
=
PyCFunction_New
(
tp_new_methoddef
,
(
PyObject
*
)
type
);
if
(
func
==
NULL
)
return
-
1
;
return
PyDict_SetItemString
(
type
->
tp_defined
,
"__new__"
,
func
);
}
static
int
static
int
add_operators
(
PyTypeObject
*
type
)
add_operators
(
PyTypeObject
*
type
)
{
{
...
@@ -1955,8 +1967,7 @@ add_operators(PyTypeObject *type)
...
@@ -1955,8 +1967,7 @@ add_operators(PyTypeObject *type)
ADD
(
type
->
tp_init
,
tab_init
);
ADD
(
type
->
tp_init
,
tab_init
);
if
(
type
->
tp_new
!=
NULL
)
if
(
type
->
tp_new
!=
NULL
)
add_staticmethodwrappers
(
type
,
tab_new
,
add_tp_new_wrapper
(
type
);
(
void
*
)(
type
->
tp_new
));
return
0
;
return
0
;
}
}
...
...
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