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
66d2be89
Kaydet (Commit)
66d2be89
authored
Tem 28, 2011
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 12647: Add __bool__() method to the None object.
üst
a2250e61
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
5 deletions
+48
-5
test_descr.py
Lib/test/test_descr.py
+0
-3
NEWS
Misc/NEWS
+4
-0
object.c
Objects/object.c
+44
-2
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
66d2be89
...
...
@@ -2068,9 +2068,6 @@ order (MRO) for bases """
# Two essentially featureless objects, just inheriting stuff from
# object.
self
.
assertEqual
(
dir
(
NotImplemented
),
dir
(
Ellipsis
))
if
support
.
check_impl_detail
():
# None differs in PyPy: it has a __nonzero__
self
.
assertEqual
(
dir
(
None
),
dir
(
Ellipsis
))
# Nasty test case for proxied objects
class
Wrapper
(
object
):
...
...
Misc/NEWS
Dosyayı görüntüle @
66d2be89
...
...
@@ -13,6 +13,10 @@ Core and Builtins
- Verify the types of AST strings and identifiers provided by the user before
compiling them.
- Issue #12647: The None object now has a __bool__() method that returns False.
Formerly, bool(None) returned False only because of special case logic
in PyObject_IsTrue().
- Issue #12579: str.format_map() now raises a ValueError if used on a
format string that contains positional fields. Initial patch by
Julian Berman.
...
...
Objects/object.c
Dosyayı görüntüle @
66d2be89
...
...
@@ -1255,7 +1255,7 @@ PyObject_Dir(PyObject *obj)
}
/*
None is a
s a
non-NULL undefined value.
None is a non-NULL undefined value.
There is (and should be!) no way to create other objects of this type,
so there is exactly one (which is indestructible, by the way).
*/
...
...
@@ -1277,6 +1277,48 @@ none_dealloc(PyObject* ignore)
Py_FatalError
(
"deallocating None"
);
}
static
int
none_bool
(
PyObject
*
v
)
{
return
0
;
}
static
PyNumberMethods
none_as_number
=
{
0
,
/* nb_add */
0
,
/* nb_subtract */
0
,
/* nb_multiply */
0
,
/* nb_remainder */
0
,
/* nb_divmod */
0
,
/* nb_power */
0
,
/* nb_negative */
0
,
/* nb_positive */
0
,
/* nb_absolute */
(
inquiry
)
none_bool
,
/* nb_bool */
0
,
/* nb_invert */
0
,
/* nb_lshift */
0
,
/* nb_rshift */
0
,
/* nb_and */
0
,
/* nb_xor */
0
,
/* nb_or */
0
,
/* nb_int */
0
,
/* nb_reserved */
0
,
/* nb_float */
0
,
/* nb_inplace_add */
0
,
/* nb_inplace_subtract */
0
,
/* nb_inplace_multiply */
0
,
/* nb_inplace_remainder */
0
,
/* nb_inplace_power */
0
,
/* nb_inplace_lshift */
0
,
/* nb_inplace_rshift */
0
,
/* nb_inplace_and */
0
,
/* nb_inplace_xor */
0
,
/* nb_inplace_or */
0
,
/* nb_floor_divide */
0
,
/* nb_true_divide */
0
,
/* nb_inplace_floor_divide */
0
,
/* nb_inplace_true_divide */
0
,
/* nb_index */
};
static
PyTypeObject
PyNone_Type
=
{
PyVarObject_HEAD_INIT
(
&
PyType_Type
,
0
)
...
...
@@ -1289,7 +1331,7 @@ static PyTypeObject PyNone_Type = {
0
,
/*tp_setattr*/
0
,
/*tp_reserved*/
none_repr
,
/*tp_repr*/
0
,
/*tp_as_number*/
&
none_as_number
,
/*tp_as_number*/
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
0
,
/*tp_hash */
...
...
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