# HG changeset patch # User Benjamin Peterson # Date 1265164545 0 # Node ID 993f703a61bae08e910ca7a7b86a520188d08d44 # Parent ef8178477567f7c04a9cb27cf7c6ab04e7b46213 Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines Update PyEval_EvalFrame to PyEval_EvalFrameEx. This looks to have been done partially before. Also add a comment describing how this might have to work with different versions of the interpreter. ........ r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line Fixed typo ........ r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line #7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such. ........ r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line Add note about usage of STRINGLIB_EMPTY. ........ r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line Fix internal reference. ........ r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines data descriptors do not override the class dictionary if __get__ is not defined Adjust documentation and add a test to verify this behavior. See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for discussion. ........ r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines Do not compile stubs for the sha2 series hashes in the openssl hashlib module when the openssl version is too old to support them. That leads both compiled code bloat and to unittests attempting to test implementations that don't exist for comparison purposes on such platforms. ........ r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line Add two more test_strtod test values. ........ r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line #7762: fix refcount annotation of PyUnicode_Tailmatch(). ........ r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line #7725: fix referencing issue. ........ r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line mention from_float() in error message ........ r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line #7802: fix invalid example (heh). ........ r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines Fix-up ftplib documentation: move exception descriptions to toplevel, not inside a class remove attribution in "versionadded" spell and grammar check docstring of FTP_TLS ........ r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line Minor modification to unittest documentation. ........ diff -r ef8178477567 -r 993f703a61ba Doc/data/refcounts.dat --- a/Doc/data/refcounts.dat Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/data/refcounts.dat Wed Feb 03 02:35:45 2010 +0000 @@ -1637,7 +1637,7 @@ PyUnicode_Join:PyObject*:separator:0: PyUnicode_Join:PyObject*:seq:0: -PyUnicode_Tailmatch:PyObject*::+1: +PyUnicode_Tailmatch:int::: PyUnicode_Tailmatch:PyObject*:str:0: PyUnicode_Tailmatch:PyObject*:substr:0: PyUnicode_Tailmatch:int:start:: diff -r ef8178477567 -r 993f703a61ba Doc/distutils/examples.rst --- a/Doc/distutils/examples.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/distutils/examples.rst Wed Feb 03 02:35:45 2010 +0000 @@ -285,8 +285,11 @@ warning: check: Title underline too short. (line 2) warning: check: Could not finish the parsing. + +.. _reading-metadata: + Reading the metadata -===================== +==================== The :func:`distutils.core.setup` function provides a command-line interface that allows you to query the metadata fields of a project through the diff -r ef8178477567 -r 993f703a61ba Doc/library/datetime.rst --- a/Doc/library/datetime.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/library/datetime.rst Wed Feb 03 02:35:45 2010 +0000 @@ -36,7 +36,6 @@ The :mod:`datetime` module exports the following constants: - .. data:: MINYEAR The smallest year number allowed in a :class:`date` or :class:`datetime` object. @@ -61,7 +60,6 @@ Available Types --------------- - .. class:: date :noindex: @@ -131,7 +129,6 @@ A :class:`timedelta` object represents a duration, the difference between two dates or times. - .. class:: timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0) All arguments are optional and default to ``0``. Arguments may be integers @@ -168,9 +165,9 @@ >>> (d.days, d.seconds, d.microseconds) (-1, 86399, 999999) + Class attributes are: - .. attribute:: timedelta.min The most negative :class:`timedelta` object, ``timedelta(-999999999)``. @@ -326,16 +323,16 @@ If an argument outside those ranges is given, :exc:`ValueError` is raised. + Other constructors, all class methods: - -.. method:: date.today() +.. classmethod:: date.today() Return the current local date. This is equivalent to ``date.fromtimestamp(time.time())``. -.. method:: date.fromtimestamp(timestamp) +.. classmethod:: date.fromtimestamp(timestamp) Return the local date corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. This may raise :exc:`ValueError`, if the timestamp is out @@ -345,16 +342,16 @@ timestamp, leap seconds are ignored by :meth:`fromtimestamp`. -.. method:: date.fromordinal(ordinal) +.. classmethod:: date.fromordinal(ordinal) Return the date corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 <= ordinal <= date.max.toordinal()``. For any date *d*, ``date.fromordinal(d.toordinal()) == d``. + Class attributes: - .. attribute:: date.min The earliest representable date, ``date(MINYEAR, 1, 1)``. @@ -370,9 +367,9 @@ The smallest possible difference between non-equal date objects, ``timedelta(days=1)``. + Instance attributes (read-only): - .. attribute:: date.year Between :const:`MINYEAR` and :const:`MAXYEAR` inclusive. @@ -387,6 +384,7 @@ Between 1 and the number of days in the given month of the given year. + Supported operations: +-------------------------------+----------------------------------------------+ @@ -439,7 +437,6 @@ Instance methods: - .. method:: date.replace(year, month, day) Return a date with the same value, except for those members given new values by @@ -519,7 +516,8 @@ Return a string representing the date, controlled by an explicit format string. Format codes referring to hours, minutes or seconds will see 0 values. See - section :ref:`strftime-behavior`. + section :ref:`strftime-strptime-behavior`. + Example of counting days to an event:: @@ -586,7 +584,6 @@ Constructor: - .. class:: datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None) The year, month and day arguments are required. *tzinfo* may be ``None``, or an @@ -605,15 +602,14 @@ Other constructors, all class methods: - -.. method:: datetime.today() +.. classmethod:: datetime.today() Return the current local datetime, with :attr:`tzinfo` ``None``. This is equivalent to ``datetime.fromtimestamp(time.time())``. See also :meth:`now`, :meth:`fromtimestamp`. -.. method:: datetime.now(tz=None) +.. classmethod:: datetime.now(tz=None) Return the current local date and time. If optional argument *tz* is ``None`` or not specified, this is like :meth:`today`, but, if possible, supplies more @@ -627,14 +623,14 @@ See also :meth:`today`, :meth:`utcnow`. -.. method:: datetime.utcnow() +.. classmethod:: datetime.utcnow() Return the current UTC date and time, with :attr:`tzinfo` ``None``. This is like :meth:`now`, but returns the current UTC date and time, as a naive :class:`datetime` object. See also :meth:`now`. -.. method:: datetime.fromtimestamp(timestamp, tz=None) +.. classmethod:: datetime.fromtimestamp(timestamp, tz=None) Return the local date and time corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. If optional argument *tz* is ``None`` or not @@ -655,7 +651,7 @@ identical :class:`datetime` objects. See also :meth:`utcfromtimestamp`. -.. method:: datetime.utcfromtimestamp(timestamp) +.. classmethod:: datetime.utcfromtimestamp(timestamp) Return the UTC :class:`datetime` corresponding to the POSIX timestamp, with :attr:`tzinfo` ``None``. This may raise :exc:`ValueError`, if the timestamp is @@ -664,7 +660,7 @@ :meth:`fromtimestamp`. -.. method:: datetime.fromordinal(ordinal) +.. classmethod:: datetime.fromordinal(ordinal) Return the :class:`datetime` corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 @@ -672,7 +668,7 @@ microsecond of the result are all 0, and :attr:`tzinfo` is ``None``. -.. method:: datetime.combine(date, time) +.. classmethod:: datetime.combine(date, time) Return a new :class:`datetime` object whose date members are equal to the given :class:`date` object's, and whose time and :attr:`tzinfo` members are equal to @@ -681,18 +677,18 @@ object, its time and :attr:`tzinfo` members are ignored. -.. method:: datetime.strptime(date_string, format) +.. classmethod:: datetime.strptime(date_string, format) Return a :class:`datetime` corresponding to *date_string*, parsed according to *format*. This is equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. :exc:`ValueError` is raised if the date_string and format can't be parsed by :func:`time.strptime` or if it returns a value which isn't a - time tuple. + time tuple. See section :ref:`strftime-strptime-behavior`. + Class attributes: - .. attribute:: datetime.min The earliest representable :class:`datetime`, ``datetime(MINYEAR, 1, 1, @@ -710,9 +706,9 @@ The smallest possible difference between non-equal :class:`datetime` objects, ``timedelta(microseconds=1)``. + Instance attributes (read-only): - .. attribute:: datetime.year Between :const:`MINYEAR` and :const:`MAXYEAR` inclusive. @@ -753,6 +749,7 @@ The object passed as the *tzinfo* argument to the :class:`datetime` constructor, or ``None`` if none was passed. + Supported operations: +---------------------------------------+-------------------------------+ @@ -826,7 +823,6 @@ Instance methods: - .. method:: datetime.date() Return :class:`date` object with same year, month and day. @@ -1004,7 +1000,8 @@ .. method:: datetime.strftime(format) Return a string representing the date and time, controlled by an explicit format - string. See section :ref:`strftime-behavior`. + string. See section :ref:`strftime-strptime-behavior`. + Examples of working with datetime objects: @@ -1117,7 +1114,6 @@ A time object represents a (local) time of day, independent of any particular day, and subject to adjustment via a :class:`tzinfo` object. - .. class:: time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None) All arguments are optional. *tzinfo* may be ``None``, or an instance of a @@ -1151,9 +1147,9 @@ ``timedelta(microseconds=1)``, although note that arithmetic on :class:`time` objects is not supported. + Instance attributes (read-only): - .. attribute:: time.hour In ``range(24)``. @@ -1179,6 +1175,7 @@ The object passed as the tzinfo argument to the :class:`time` constructor, or ``None`` if none was passed. + Supported operations: * comparison of :class:`time` to :class:`time`, where *a* is considered less @@ -1201,9 +1198,9 @@ only if, after converting it to minutes and subtracting :meth:`utcoffset` (or ``0`` if that's ``None``), the result is non-zero. + Instance methods: - .. method:: time.replace([hour[, minute[, second[, microsecond[, tzinfo]]]]]) Return a :class:`time` with the same value, except for those members given new @@ -1228,7 +1225,7 @@ .. method:: time.strftime(format) Return a string representing the time, controlled by an explicit format string. - See section :ref:`strftime-behavior`. + See section :ref:`strftime-strptime-behavior`. .. method:: time.utcoffset() @@ -1253,6 +1250,7 @@ ``self.tzinfo.tzname(None)``, or raises an exception if the latter doesn't return ``None`` or a string object. + Example: >>> from datetime import time, tzinfo @@ -1389,6 +1387,7 @@ The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`. + These methods are called by a :class:`datetime` or :class:`time` object, in response to their methods of the same names. A :class:`datetime` object passes itself as the argument, and a :class:`time` object passes ``None`` as the @@ -1492,10 +1491,10 @@ EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). -.. _strftime-behavior: +.. _strftime-strptime-behavior: -:meth:`strftime` Behavior -------------------------- +:meth:`strftime` and :meth:`strptime` Behavior +---------------------------------------------- :class:`date`, :class:`datetime`, and :class:`time` objects all support a ``strftime(format)`` method, to create a string representing the time under the @@ -1503,9 +1502,14 @@ acts like the :mod:`time` module's ``time.strftime(fmt, d.timetuple())`` although not all objects support a :meth:`timetuple` method. +Conversely, the :meth:`datetime.strptime` class method creates a +:class:`datetime` object from a string representing a date and time and a +corresponding format string. ``datetime.strptime(date_string, format)`` is +equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. + For :class:`time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900`` -is substituted for the year, and ``0`` for the month and day. +is substituted for the year, and ``1`` for the month and day. For :class:`date` objects, the format codes for hours, minutes, seconds, and microseconds should not be used, as :class:`date` objects have no such @@ -1627,14 +1631,14 @@ Notes: (1) - When used with the :func:`strptime` function, the ``%f`` directive + When used with the :meth:`strptime` method, the ``%f`` directive accepts from one to six digits and zero pads on the right. ``%f`` is an extension to the set of format characters in the C standard (but implemented separately in datetime objects, and therefore always available). (2) - When used with the :func:`strptime` function, the ``%p`` directive only affects + When used with the :meth:`strptime` method, the ``%p`` directive only affects the output hour field if the ``%I`` directive is used to parse the hour. (3) @@ -1642,11 +1646,11 @@ accounts for leap seconds and the (very rare) double leap seconds. The :mod:`time` module may produce and does accept leap seconds since it is based on the Posix standard, but the :mod:`datetime` module - does not accept leap seconds in :func:`strptime` input nor will it + does not accept leap seconds in :meth:`strptime` input nor will it produce them in :func:`strftime` output. (4) - When used with the :func:`strptime` function, ``%U`` and ``%W`` are only used in + When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used in calculations when the day of the week and the year are specified. (5) diff -r ef8178477567 -r 993f703a61ba Doc/library/ftplib.rst --- a/Doc/library/ftplib.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/library/ftplib.rst Wed Feb 03 02:35:45 2010 +0000 @@ -33,9 +33,9 @@ '226 Transfer complete.' >>> ftp.quit() + The module defines the following items: - .. class:: FTP(host='', user='', passwd='', acct=''[, timeout]) Return a new instance of the :class:`FTP` class. When *host* is given, the @@ -51,21 +51,20 @@ A :class:`FTP` subclass which adds TLS support to FTP as described in :rfc:`4217`. Connect as usual to port 21 implicitly securing the FTP control connection - before authenticating. Securing the data connection requires user to - explicitly ask for it by calling :exc:`prot_p()` method. - *keyfile* and *certfile* are optional - they can contain a PEM formatted - private key and certificate chain file for the SSL connection. + before authenticating. Securing the data connection requires the user to + explicitly ask for it by calling the :meth:`prot_p` method. + *keyfile* and *certfile* are optional -- they can contain a PEM formatted + private key and certificate chain file name for the SSL connection. - .. versionadded:: 3.2 Contributed by Giampaolo Rodola' + .. versionadded:: 3.2 - - Here's a sample session using :class:`FTP_TLS` class: + Here's a sample session using the :class:`FTP_TLS` class: >>> from ftplib import FTP_TLS >>> ftps = FTP_TLS('ftp.python.org') - >>> ftps.login() # login anonimously previously securing control channel - >>> ftps.prot_p() # switch to secure data connection - >>> ftps.retrlines('LIST') # list directory content securely + >>> ftps.login() # login anonymously before securing control channel + >>> ftps.prot_p() # switch to secure data connection + >>> ftps.retrlines('LIST') # list directory content securely total 9 drwxr-xr-x 8 root wheel 1024 Jan 3 1994 . drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .. @@ -81,16 +80,6 @@ >>> - - .. attribute:: all_errors - - The set of all exceptions (as a tuple) that methods of :class:`FTP` - instances may raise as a result of problems with the FTP connection (as - opposed to programming errors made by the caller). This set includes the - four exceptions listed below as well as :exc:`socket.error` and - :exc:`IOError`. - - .. exception:: error_reply Exception raised when an unexpected reply is received from the server. @@ -98,19 +87,24 @@ .. exception:: error_temp - Exception raised when an error code in the range 400--499 is received. - + Exception raised when an unexpected reply is received from the server. .. exception:: error_perm Exception raised when an error code in the range 500--599 is received. - .. exception:: error_proto - Exception raised when a reply is received from the server that does not begin - with a digit in the range 1--5. + Exception raised when a reply is received from the server that does not + begin with a digit in the range 1--5. + +.. data:: all_errors + The set of all exceptions (as a tuple) that methods of :class:`FTP` + instances may raise as a result of problems with the FTP connection (as + opposed to programming errors made by the caller). This set includes the + four exceptions listed below as well as :exc:`socket.error` and + :exc:`IOError`. .. seealso:: diff -r ef8178477567 -r 993f703a61ba Doc/library/profile.rst --- a/Doc/library/profile.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/library/profile.rst Wed Feb 03 02:35:45 2010 +0000 @@ -107,7 +107,7 @@ cProfile.py [-o output_file] [-s sort_order] -:option:`-s` only applies to standard output (:option:`-o` is not supplied). +``-s`` only applies to standard output (``-o`` is not supplied). Look in the :class:`Stats` documentation for valid sort values. When you wish to review the profile, you should use the methods in the diff -r ef8178477567 -r 993f703a61ba Doc/library/unittest.rst --- a/Doc/library/unittest.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/library/unittest.rst Wed Feb 03 02:35:45 2010 +0000 @@ -803,9 +803,9 @@ .. method:: assertSameElements(expected, actual, msg=None) - Test that sequence *expected* contains the same elements as *actual*. - When they don't an error message listing the differences between the - sequences will be generated. + Test that sequence *expected* contains the same elements as *actual*, + regardless of their order. When they don't, an error message listing + the differences between the sequences will be generated. If specified *msg* will be used as the error message on failure. diff -r ef8178477567 -r 993f703a61ba Doc/library/xmlrpc.client.rst --- a/Doc/library/xmlrpc.client.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/library/xmlrpc.client.rst Wed Feb 03 02:35:45 2010 +0000 @@ -383,8 +383,8 @@ import xmlrpc.client - # create a ServerProxy with an invalid URI - proxy = xmlrpc.client.ServerProxy("http://invalidaddress/") + # create a ServerProxy with an URI that doesn't respond to XMLRPC requests + proxy = xmlrpc.client.ServerProxy("http://google.com/") try: proxy.some_method() diff -r ef8178477567 -r 993f703a61ba Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/reference/datamodel.rst Wed Feb 03 02:35:45 2010 +0000 @@ -1413,11 +1413,17 @@ ``A.__dict__['m'].__get__(obj, A)``. For instance bindings, the precedence of descriptor invocation depends on the -which descriptor methods are defined. Normally, data descriptors define both -:meth:`__get__` and :meth:`__set__`, while non-data descriptors have just the -:meth:`__get__` method. Data descriptors always override a redefinition in an +which descriptor methods are defined. A descriptor can define any combination +of :meth:`__get__`, :meth:`__set__` and :meth:`__delete__`. If it does not +define :meth:`__get__`, then accessing the attribute will return the descriptor +object itself unless there is a value in the object's instance dictionary. If +the descriptor defines :meth:`__set__` and/or :meth:`__delete__`, it is a data +descriptor; if it defines neither, it is a non-data descriptor. Normally, data +descriptors define both :meth:`__get__` and :meth:`__set__`, while non-data +descriptors have just the :meth:`__get__` method. Data descriptors with +:meth:`__set__` and :meth:`__get__` defined always override a redefinition in an instance dictionary. In contrast, non-data descriptors can be overridden by -instances. [#]_ +instances. Python methods (including :func:`staticmethod` and :func:`classmethod`) are implemented as non-data descriptors. Accordingly, instances can redefine and @@ -2006,13 +2012,6 @@ controlled conditions. It generally isn't a good idea though, since it can lead to some very strange behaviour if it is handled incorrectly. -.. [#] A descriptor can define any combination of :meth:`__get__`, - :meth:`__set__` and :meth:`__delete__`. If it does not define :meth:`__get__`, - then accessing the attribute even on an instance will return the descriptor - object itself. If the descriptor defines :meth:`__set__` and/or - :meth:`__delete__`, it is a data descriptor; if it defines neither, it is a - non-data descriptor. - .. [#] For operands of the same type, it is assumed that if the non-reflected method (such as :meth:`__add__`) fails the operation is not supported, which is why the reflected method is not called. diff -r ef8178477567 -r 993f703a61ba Doc/whatsnew/2.7.rst --- a/Doc/whatsnew/2.7.rst Wed Feb 03 01:57:04 2010 +0000 +++ b/Doc/whatsnew/2.7.rst Wed Feb 03 02:35:45 2010 +0000 @@ -612,8 +612,8 @@ The :class:`distutils.dist.DistributionMetadata` class' :meth:`read_pkg_file` method will read the contents of a package's - :file:`PKG-INFO` metadata file. For an example of its use, - XXX link to file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata + :file:`PKG-INFO` metadata file. For an example of its use, see + :ref:`reading-metadata`. (Contributed by Tarek Ziade; :issue:`7457`.) :file:`setup.py` files will now accept a :option:`--no-user-cfg` switch diff -r ef8178477567 -r 993f703a61ba Lib/decimal.py --- a/Lib/decimal.py Wed Feb 03 01:57:04 2010 +0000 +++ b/Lib/decimal.py Wed Feb 03 02:35:45 2010 +0000 @@ -648,8 +648,8 @@ return self if isinstance(value, float): - raise TypeError("Cannot convert float to Decimal. " + - "First convert the float to a string") + raise TypeError("Cannot convert float in Decimal constructor. " + "Use from_float class method.") raise TypeError("Cannot convert %r to Decimal" % value) diff -r ef8178477567 -r 993f703a61ba Lib/test/test_descr.py --- a/Lib/test/test_descr.py Wed Feb 03 01:57:04 2010 +0000 +++ b/Lib/test/test_descr.py Wed Feb 03 02:35:45 2010 +0000 @@ -4147,6 +4147,26 @@ c[1:2] = 3 self.assertEqual(c.value, 3) + def test_set_and_no_get(self): + # See + # http://mail.python.org/pipermail/python-dev/2010-January/095637.html + class Descr(object): + + def __init__(self, name): + self.name = name + + def __set__(self, obj, value): + obj.__dict__[self.name] = value + descr = Descr("a") + + class X(object): + a = descr + + x = X() + self.assertIs(x.a, descr) + x.a = 42 + self.assertEqual(x.a, 42) + def test_getattr_hooks(self): # issue 4230 diff -r ef8178477567 -r 993f703a61ba Lib/test/test_strtod.py --- a/Lib/test/test_strtod.py Wed Feb 03 01:57:04 2010 +0000 +++ b/Lib/test/test_strtod.py Wed Feb 03 02:35:45 2010 +0000 @@ -313,6 +313,42 @@ '4106250198039490000000000000000000000000000000000000000e-38', # issue 7632 bug 8: the following produced 10.0 '10.900000000000000012345678912345678912345', + + # two humongous values from issue 7743 + '116512874940594195638617907092569881519034793229385' #... + '228569165191541890846564669771714896916084883987920' #... + '473321268100296857636200926065340769682863349205363' #... + '349247637660671783209907949273683040397979984107806' #... + '461822693332712828397617946036239581632976585100633' #... + '520260770761060725403904123144384571612073732754774' #... + '588211944406465572591022081973828448927338602556287' #... + '851831745419397433012491884869454462440536895047499' #... + '436551974649731917170099387762871020403582994193439' #... + '761933412166821484015883631622539314203799034497982' #... + '130038741741727907429575673302461380386596501187482' #... + '006257527709842179336488381672818798450229339123527' #... + '858844448336815912020452294624916993546388956561522' #... + '161875352572590420823607478788399460162228308693742' #... + '05287663441403533948204085390898399055004119873046875e-1075', + + '525440653352955266109661060358202819561258984964913' #... + '892256527849758956045218257059713765874251436193619' #... + '443248205998870001633865657517447355992225852945912' #... + '016668660000210283807209850662224417504752264995360' #... + '631512007753855801075373057632157738752800840302596' #... + '237050247910530538250008682272783660778181628040733' #... + '653121492436408812668023478001208529190359254322340' #... + '397575185248844788515410722958784640926528544043090' #... + '115352513640884988017342469275006999104519620946430' #... + '818767147966495485406577703972687838176778993472989' #... + '561959000047036638938396333146685137903018376496408' #... + '319705333868476925297317136513970189073693314710318' #... + '991252811050501448326875232850600451776091303043715' #... + '157191292827614046876950225714743118291034780466325' #... + '085141343734564915193426994587206432697337118211527' #... + '278968731294639353354774788602467795167875117481660' #... + '4738791256853675690543663283782215866825e-1180', + # exercise exit conditions in bigcomp comparison loop '2602129298404963083833853479113577253105939995688e2', '260212929840496308383385347911357725310593999568896e0', diff -r ef8178477567 -r 993f703a61ba Modules/_hashopenssl.c --- a/Modules/_hashopenssl.c Wed Feb 03 01:57:04 2010 +0000 +++ b/Modules/_hashopenssl.c Wed Feb 03 02:35:45 2010 +0000 @@ -49,6 +49,10 @@ #define HASH_OBJ_CONSTRUCTOR 0 #endif +/* Minimum OpenSSL version needed to support sha224 and higher. */ +#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x00908000) +#define _OPENSSL_SUPPORTS_SHA2 +#endif typedef struct { PyObject_HEAD @@ -70,10 +74,12 @@ DEFINE_CONSTS_FOR_NEW(md5) DEFINE_CONSTS_FOR_NEW(sha1) +#ifdef _OPENSSL_SUPPORTS_SHA2 DEFINE_CONSTS_FOR_NEW(sha224) DEFINE_CONSTS_FOR_NEW(sha256) DEFINE_CONSTS_FOR_NEW(sha384) DEFINE_CONSTS_FOR_NEW(sha512) +#endif static EVPobject * @@ -537,10 +543,12 @@ GEN_CONSTRUCTOR(md5) GEN_CONSTRUCTOR(sha1) +#ifdef _OPENSSL_SUPPORTS_SHA2 GEN_CONSTRUCTOR(sha224) GEN_CONSTRUCTOR(sha256) GEN_CONSTRUCTOR(sha384) GEN_CONSTRUCTOR(sha512) +#endif /* List of functions exported by this module */ @@ -548,11 +556,13 @@ {"new", (PyCFunction)EVP_new, METH_VARARGS|METH_KEYWORDS, EVP_new__doc__}, CONSTRUCTOR_METH_DEF(md5), CONSTRUCTOR_METH_DEF(sha1), +#ifdef _OPENSSL_SUPPORTS_SHA2 CONSTRUCTOR_METH_DEF(sha224), CONSTRUCTOR_METH_DEF(sha256), CONSTRUCTOR_METH_DEF(sha384), CONSTRUCTOR_METH_DEF(sha512), - {NULL, NULL} /* Sentinel */ +#endif + {NULL, NULL} /* Sentinel */ }; @@ -599,9 +609,11 @@ /* these constants are used by the convenience constructors */ INIT_CONSTRUCTOR_CONSTANTS(md5); INIT_CONSTRUCTOR_CONSTANTS(sha1); +#ifdef _OPENSSL_SUPPORTS_SHA2 INIT_CONSTRUCTOR_CONSTANTS(sha224); INIT_CONSTRUCTOR_CONSTANTS(sha256); INIT_CONSTRUCTOR_CONSTANTS(sha384); INIT_CONSTRUCTOR_CONSTANTS(sha512); +#endif return m; } diff -r ef8178477567 -r 993f703a61ba Objects/stringlib/README.txt --- a/Objects/stringlib/README.txt Wed Feb 03 01:57:04 2010 +0000 +++ b/Objects/stringlib/README.txt Wed Feb 03 02:35:45 2010 +0000 @@ -13,7 +13,8 @@ STRINGLIB_EMPTY - a PyObject representing the empty string + a PyObject representing the empty string, only to be used if + STRINGLIB_MUTABLE is 0 Py_ssize_t STRINGLIB_LEN(PyObject*) @@ -31,9 +32,9 @@ int STRINGLIB_CHECK_EXACT(PyObject *) - returns true if the object is an instance of our type, not a subclass. + returns true if the object is an instance of our type, not a subclass STRINGLIB_MUTABLE - Must be 0 or 1 to tell the cpp macros in stringlib code if the object - being operated on is mutable or not. + must be 0 or 1 to tell the cpp macros in stringlib code if the object + being operated on is mutable or not