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
6e8fef07
Kaydet (Commit)
6e8fef07
authored
Agu 18, 2008
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 2235: document PyObject_HashNotImplemented
üst
f70385a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
object.rst
Doc/c-api/object.rst
+10
-0
typeobj.rst
Doc/c-api/typeobj.rst
+8
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/c-api/object.rst
Dosyayı görüntüle @
6e8fef07
...
...
@@ -269,6 +269,16 @@ is considered sufficient for this determination.
This is the equivalent of the Python expression ``hash(o)``.
.. cfunction:: long PyObject_HashNotImplemented(PyObject *o)
Set a TypeError indicating that ``type(o)`` is not hashable and return ``-1``.
This function receives special treatment when stored in a ``tp_hash`` slot,
allowing a type to explicit indicate to the interpreter that it is not
hashable.
.. versionadded:: 2.6
.. cfunction:: int PyObject_IsTrue(PyObject *o)
Returns ``1`` if the object *o* is considered to be true, and ``0`` otherwise.
...
...
Doc/c-api/typeobj.rst
Dosyayı görüntüle @
6e8fef07
...
...
@@ -324,6 +324,14 @@ type objects) *must* have the :attr:`ob_size` field.
error occurs during the computation of the hash value, the function should set
an exception and return ``-1``.
This field can be set explicitly to :cfunc:`PyObject_HashNotImplemented` to
block inheritance of the hash method from a parent type. This is interpreted
as the equivalent of ``__hash__ = None`` at the Python level, causing
``isinstance(o, collections.Hashable)`` to correctly return ``False``. Note
that the converse is also true - setting ``__hash__ = None`` on a class at
the Python level will result in the ``tp_hash`` slot being set to
:cfunc:`PyObject_HashNotImplemented`.
When this field is not set, two possibilities exist: if the :attr:`tp_compare`
and :attr:`tp_richcompare` fields are both *NULL*, a default hash value based on
the object's address is returned; otherwise, a :exc:`TypeError` is raised.
...
...
Misc/NEWS
Dosyayı görüntüle @
6e8fef07
...
...
@@ -166,6 +166,9 @@ Build
Documentation
-------------
- Issue #2235: the C API function PyObject_HashNotImplemented and its
interaction with the tp_hash slot (added in 2.6b2) are now documented
- Issue #643841: The language reference now provides more detailed
coverage of the lookup process for special methods. The disclaimers
regarding lack of coverage of new-style classes have also been
...
...
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