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
b6bb0c79
Kaydet (Commit)
b6bb0c79
authored
Agu 24, 2006
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Implement == and != comparisons for code objects by value.
This makes test_codeop and test_marshal pass.
üst
8f78fe9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
39 deletions
+55
-39
codeobject.c
Objects/codeobject.c
+55
-39
No files found.
Objects/codeobject.c
Dosyayı görüntüle @
b6bb0c79
...
...
@@ -294,44 +294,60 @@ code_repr(PyCodeObject *co)
static
PyObject
*
code_richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op
)
{
/* Temporarily make this unsupported */
_Py_Break
();
Py_INCREF
(
Py_NotImplemented
);
return
Py_NotImplemented
;
#if 0
int cmp;
cmp = PyObject_Compare(co->co_name, cp->co_name);
if (cmp) return cmp;
cmp = co->co_argcount - cp->co_argcount;
if (cmp) goto normalize;
cmp = co->co_nlocals - cp->co_nlocals;
if (cmp) goto normalize;
cmp = co->co_flags - cp->co_flags;
if (cmp) goto normalize;
cmp = co->co_firstlineno - cp->co_firstlineno;
if (cmp) goto normalize;
cmp = PyObject_Compare(co->co_code, cp->co_code);
if (cmp) return cmp;
cmp = PyObject_Compare(co->co_consts, cp->co_consts);
if (cmp) return cmp;
cmp = PyObject_Compare(co->co_names, cp->co_names);
if (cmp) return cmp;
cmp = PyObject_Compare(co->co_varnames, cp->co_varnames);
if (cmp) return cmp;
cmp = PyObject_Compare(co->co_freevars, cp->co_freevars);
if (cmp) return cmp;
cmp = PyObject_Compare(co->co_cellvars, cp->co_cellvars);
return cmp;
normalize:
if (cmp > 0)
return 1;
else if (cmp < 0)
return -1;
PyCodeObject
*
co
,
*
cp
;
int
eq
;
PyObject
*
res
;
if
((
op
!=
Py_EQ
&&
op
!=
Py_NE
)
||
!
PyCode_Check
(
self
)
||
!
PyCode_Check
(
other
))
{
Py_INCREF
(
Py_NotImplemented
);
return
Py_NotImplemented
;
}
co
=
(
PyCodeObject
*
)
self
;
cp
=
(
PyCodeObject
*
)
other
;
eq
=
PyObject_RichCompare
(
co
->
co_name
,
cp
->
co_name
,
Py_EQ
);
if
(
eq
<=
0
)
goto
unequal
;
eq
=
co
->
co_argcount
==
cp
->
co_argcount
;
if
(
!
eq
)
goto
unequal
;
eq
=
co
->
co_nlocals
==
cp
->
co_nlocals
;
if
(
!
eq
)
goto
unequal
;
eq
=
co
->
co_flags
==
cp
->
co_flags
;
if
(
!
eq
)
goto
unequal
;
eq
=
co
->
co_firstlineno
==
cp
->
co_firstlineno
;
if
(
!
eq
)
goto
unequal
;
eq
=
PyObject_RichCompare
(
co
->
co_code
,
cp
->
co_code
,
Py_EQ
);
if
(
eq
<=
0
)
goto
unequal
;
eq
=
PyObject_RichCompare
(
co
->
co_consts
,
cp
->
co_consts
,
Py_EQ
);
if
(
eq
<=
0
)
goto
unequal
;
eq
=
PyObject_RichCompare
(
co
->
co_names
,
cp
->
co_names
,
Py_EQ
);
if
(
eq
<=
0
)
goto
unequal
;
eq
=
PyObject_RichCompare
(
co
->
co_varnames
,
cp
->
co_varnames
,
Py_EQ
);
if
(
eq
<=
0
)
goto
unequal
;
eq
=
PyObject_RichCompare
(
co
->
co_freevars
,
cp
->
co_freevars
,
Py_EQ
);
if
(
eq
<=
0
)
goto
unequal
;
eq
=
PyObject_RichCompare
(
co
->
co_cellvars
,
cp
->
co_cellvars
,
Py_EQ
);
if
(
eq
<=
0
)
goto
unequal
;
if
(
op
==
Py_EQ
)
res
=
Py_True
;
else
res
=
Py_False
;
goto
done
;
unequal:
if
(
eq
<
0
)
return
NULL
;
if
(
op
==
Py_NE
)
res
=
Py_True
;
else
return 0;
#endif
res
=
Py_False
;
done:
Py_INCREF
(
res
);
return
res
;
}
static
long
...
...
@@ -375,7 +391,7 @@ PyTypeObject PyCode_Type = {
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
0
,
/* tp_hash */
(
hashfunc
)
code_hash
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_str */
PyObject_GenericGetAttr
,
/* tp_getattro */
...
...
@@ -385,7 +401,7 @@ PyTypeObject PyCode_Type = {
code_doc
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
code_richcompare
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
...
...
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