summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-09-03 22:22:18 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-09-03 22:22:18 (GMT)
commitdcc1e117604cc64dfa03a703391fbaeba654181a (patch)
treef708dbb01a7da17982a2df4eac69e07d1f390ee5
parenta64072f994d8ddc748948e0b8376e69881cf26ac (diff)
downloadcpython-dcc1e117604cc64dfa03a703391fbaeba654181a.zip
cpython-dcc1e117604cc64dfa03a703391fbaeba654181a.tar.gz
cpython-dcc1e117604cc64dfa03a703391fbaeba654181a.tar.bz2
Merged revisions 66134,66136,66143,66154-66155,66190 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66134 | andrew.kuchling | 2008-09-01 20:13:42 -0500 (Mon, 01 Sep 2008) | 1 line Describe the __hash__ changes ........ r66136 | andrew.kuchling | 2008-09-01 20:39:18 -0500 (Mon, 01 Sep 2008) | 1 line typo fix ........ r66143 | mark.summerfield | 2008-09-02 02:23:16 -0500 (Tue, 02 Sep 2008) | 3 lines a typo ........ r66154 | andrew.kuchling | 2008-09-02 08:06:00 -0500 (Tue, 02 Sep 2008) | 1 line Clarify example; add imports ........ r66155 | andrew.kuchling | 2008-09-02 08:08:11 -0500 (Tue, 02 Sep 2008) | 1 line Add e-mail address ........ r66190 | benjamin.peterson | 2008-09-03 16:48:20 -0500 (Wed, 03 Sep 2008) | 1 line 3.0 still has the old threading names ........
-rw-r--r--Doc/library/warnings.rst2
-rw-r--r--Doc/whatsnew/2.6.rst58
2 files changed, 45 insertions, 15 deletions
diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst
index ccd7b44..e3d3b5b 100644
--- a/Doc/library/warnings.rst
+++ b/Doc/library/warnings.rst
@@ -253,7 +253,7 @@ Available Classes
.. class:: catch_warnings([\*, record=False, module=None])
- A context manager that guards the warnings filter from being permanentally
+ A context manager that guards the warnings filter from being permanently
mutated. The manager returns an instance of :class:`WarningsRecorder`. The
*record* argument specifies whether warnings that would typically be
handled by :func:`showwarning` should instead be recorded by the
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst
index 961d637..883eb90 100644
--- a/Doc/whatsnew/2.6.rst
+++ b/Doc/whatsnew/2.6.rst
@@ -4,7 +4,7 @@
.. XXX add trademark info for Apple, Microsoft, SourceForge.
-:Author: A.M. Kuchling
+:Author: A.M. Kuchling (amk at amk.ca)
:Release: |release|
:Date: |today|
@@ -203,7 +203,7 @@ The Python documentation was written using LaTeX since the project
started around 1989. In the 1980s and early 1990s, most documentation
was printed out for later study, not viewed online. LaTeX was widely
used because it provided attractive printed output while remaining
-straightforward to write once the basic rules of the markup werw
+straightforward to write once the basic rules of the markup were
learned.
Today LaTeX is still used for writing publications destined for
@@ -1224,7 +1224,7 @@ do it where it's absolutely necessary.
You can write your own ABCs by using ``abc.ABCMeta`` as the
metaclass in a class definition::
- from abc import ABCMeta
+ from abc import ABCMeta, abstractmethod
class Drawable():
__metaclass__ = ABCMeta
@@ -1256,15 +1256,21 @@ exception for classes that don't define the method.
Note that the exception is only raised when you actually
try to create an instance of a subclass lacking the method::
- >>> s=Square()
+ >>> class Circle(Drawable):
+ ... pass
+ ...
+ >>> c=Circle()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
- TypeError: Can't instantiate abstract class Square with abstract methods draw
+ TypeError: Can't instantiate abstract class Circle with abstract methods draw
>>>
Abstract data attributes can be declared using the
``@abstractproperty`` decorator::
+ from abc import abstractproperty
+ ...
+
@abstractproperty
def readonly(self):
return self._x
@@ -1595,6 +1601,22 @@ Some smaller changes made to the core Python language are:
:func:`complex` constructor will now preserve the sign
of the zero. (Fixed by Mark T. Dickinson; :issue:`1507`.)
+* Classes that inherit a :meth:`__hash__` method from a parent class
+ can set ``__hash__ = None`` to indicate that the class isn't
+ hashable. This will make ``hash(obj)`` raise a :exc:`TypeError`
+ and the class will not be indicated as implementing the
+ :class:`Hashable` ABC.
+
+ You should do this when you've defined a :meth:`__cmp__` or
+ :meth:`__eq__` method that compares objects by their value rather
+ than by identity. All objects have a default hash method that uses
+ ``id(obj)`` as the hash value. There's no tidy way to remove the
+ :meth:`__hash__` method inherited from a parent class, so
+ assigning ``None`` was implemented as an override. At the
+ C level, extensions can set ``tp_hash`` to
+ :cfunc:`PyObject_HashNotImplemented`.
+ (Fixed by Nick Coghlan and Amaury Forgeot d'Arc; :issue:`2235`.)
+
* Changes to the :class:`Exception` interface
as dictated by :pep:`352` continue to be made. For 2.6,
the :attr:`message` attribute is being deprecated in favor of the
@@ -2501,14 +2523,14 @@ changes, or look through the Subversion logs for all the details.
(Contributed by Dwayne Bailey; :issue:`1581073`.)
-* The :mod:`threading` module API is being changed in Python 3.0 to
- use properties such as :attr:`daemon` instead of :meth:`setDaemon`
- and :meth:`isDaemon` methods, and some methods have been renamed to
- use underscores instead of camel-case; for example, the
- :meth:`activeCount` method is renamed to :meth:`active_count`. The
- 2.6 version of the module supports the same properties and renamed
- methods, but doesn't remove the old methods. (Carried out by
- several people, most notably Benjamin Peterson.)
+* The :mod:`threading` module API is being changed to use properties such as
+ :attr:`daemon` instead of :meth:`setDaemon` and :meth:`isDaemon` methods, and
+ some methods have been renamed to use underscores instead of camel-case; for
+ example, the :meth:`activeCount` method is renamed to :meth:`active_count`.
+ The 2.6 version of the module supports the same properties and renamed
+ methods, but doesn't remove the old methods. 3.0 also fully supports both
+ APIs, and a date for the deprecation of the old APIs has not been set yet.
+ (Carried out by several people, most notably Benjamin Peterson.)
The :mod:`threading` module's :class:`Thread` objects
gained an :attr:`ident` property that returns the thread's
@@ -3125,6 +3147,10 @@ Porting to Python 2.6
This section lists previously described changes and other bugfixes
that may require changes to your code:
+* Classes that aren't supposed to be hashable should
+ set ``__hash__ = None`` in their definitions to indicate
+ the fact.
+
* The :meth:`__init__` method of :class:`collections.deque`
now clears any existing contents of the deque
before adding elements from the iterable. This change makes the
@@ -3147,6 +3173,10 @@ that may require changes to your code:
functions now default to absolute imports, not relative imports.
This will affect C extensions that import other modules.
+* C API: extension data types that shouldn't be hashable
+ should define their ``tp_hash`` slot to
+ :cfunc:`PyObject_HashNotImplemented`.
+
* The :mod:`socket` module exception :exc:`socket.error` now inherits
from :exc:`IOError`. Previously it wasn't a subclass of
:exc:`StandardError` but now it is, through :exc:`IOError`.
@@ -3182,5 +3212,5 @@ Acknowledgements
The author would like to thank the following people for offering suggestions,
corrections and assistance with various drafts of this article:
-Georg Brandl, Jim Jewett, Antoine Pitrou.
+Georg Brandl, Steve Brown, Nick Coghlan, Jim Jewett, Antoine Pitrou.