Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23b9ef7

Browse files
committed
Merged revisions 77937 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ................ r77937 | benjamin.peterson | 2010-02-02 20:35:45 -0600 (Tue, 02 Feb 2010) | 75 lines Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from svn+ssh://[email protected]/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. ........ ................
1 parent 93fc46f commit 23b9ef7

11 files changed

Lines changed: 136 additions & 64 deletions

File tree

Doc/data/refcounts.dat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ PyUnicode_Join:PyObject*::+1:
16311631
PyUnicode_Join:PyObject*:separator:0:
16321632
PyUnicode_Join:PyObject*:seq:0:
16331633

1634-
PyUnicode_Tailmatch:PyObject*::+1:
1634+
PyUnicode_Tailmatch:int:::
16351635
PyUnicode_Tailmatch:PyObject*:str:0:
16361636
PyUnicode_Tailmatch:PyObject*:substr:0:
16371637
PyUnicode_Tailmatch:int:start::

Doc/library/datetime.rst

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ than rational, and there is no standard suitable for every application.
3636

3737
The :mod:`datetime` module exports the following constants:
3838

39-
4039
.. data:: MINYEAR
4140

4241
The smallest year number allowed in a :class:`date` or :class:`datetime` object.
@@ -61,7 +60,6 @@ The :mod:`datetime` module exports the following constants:
6160
Available Types
6261
---------------
6362

64-
6563
.. class:: date
6664
:noindex:
6765

@@ -131,7 +129,6 @@ Subclass relationships::
131129
A :class:`timedelta` object represents a duration, the difference between two
132130
dates or times.
133131

134-
135132
.. class:: timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
136133

137134
All arguments are optional and default to ``0``. Arguments may be integers
@@ -168,8 +165,8 @@ dates or times.
168165
>>> (d.days, d.seconds, d.microseconds)
169166
(-1, 86399, 999999)
170167

171-
Class attributes are:
172168

169+
Class attributes are:
173170

174171
.. attribute:: timedelta.min
175172

@@ -314,16 +311,16 @@ systems.
314311

315312
If an argument outside those ranges is given, :exc:`ValueError` is raised.
316313

317-
Other constructors, all class methods:
318314

315+
Other constructors, all class methods:
319316

320-
.. method:: date.today()
317+
.. classmethod:: date.today()
321318

322319
Return the current local date. This is equivalent to
323320
``date.fromtimestamp(time.time())``.
324321

325322

326-
.. method:: date.fromtimestamp(timestamp)
323+
.. classmethod:: date.fromtimestamp(timestamp)
327324

328325
Return the local date corresponding to the POSIX timestamp, such as is returned
329326
by :func:`time.time`. This may raise :exc:`ValueError`, if the timestamp is out
@@ -333,15 +330,15 @@ Other constructors, all class methods:
333330
timestamp, leap seconds are ignored by :meth:`fromtimestamp`.
334331

335332

336-
.. method:: date.fromordinal(ordinal)
333+
.. classmethod:: date.fromordinal(ordinal)
337334

338335
Return the date corresponding to the proleptic Gregorian ordinal, where January
339336
1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 <= ordinal <=
340337
date.max.toordinal()``. For any date *d*, ``date.fromordinal(d.toordinal()) ==
341338
d``.
342339

343-
Class attributes:
344340

341+
Class attributes:
345342

346343
.. attribute:: date.min
347344

@@ -358,8 +355,8 @@ Class attributes:
358355
The smallest possible difference between non-equal date objects,
359356
``timedelta(days=1)``.
360357

361-
Instance attributes (read-only):
362358

359+
Instance attributes (read-only):
363360

364361
.. attribute:: date.year
365362

@@ -375,6 +372,7 @@ Instance attributes (read-only):
375372

376373
Between 1 and the number of days in the given month of the given year.
377374

375+
378376
Supported operations:
379377

380378
+-------------------------------+----------------------------------------------+
@@ -427,7 +425,6 @@ objects are considered to be true.
427425

428426
Instance methods:
429427

430-
431428
.. method:: date.replace(year, month, day)
432429

433430
Return a date with the same value, except for those members given new values by
@@ -507,7 +504,8 @@ Instance methods:
507504

508505
Return a string representing the date, controlled by an explicit format string.
509506
Format codes referring to hours, minutes or seconds will see 0 values. See
510-
section :ref:`strftime-behavior`.
507+
section :ref:`strftime-strptime-behavior`.
508+
511509

512510
Example of counting days to an event::
513511

@@ -574,7 +572,6 @@ both directions; like a time object, :class:`datetime` assumes there are exactly
574572

575573
Constructor:
576574

577-
578575
.. class:: datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None)
579576

580577
The year, month and day arguments are required. *tzinfo* may be ``None``, or an
@@ -593,15 +590,14 @@ Constructor:
593590

594591
Other constructors, all class methods:
595592

596-
597-
.. method:: datetime.today()
593+
.. classmethod:: datetime.today()
598594

599595
Return the current local datetime, with :attr:`tzinfo` ``None``. This is
600596
equivalent to ``datetime.fromtimestamp(time.time())``. See also :meth:`now`,
601597
:meth:`fromtimestamp`.
602598

603599

604-
.. method:: datetime.now(tz=None)
600+
.. classmethod:: datetime.now(tz=None)
605601

606602
Return the current local date and time. If optional argument *tz* is ``None``
607603
or not specified, this is like :meth:`today`, but, if possible, supplies more
@@ -615,14 +611,14 @@ Other constructors, all class methods:
615611
See also :meth:`today`, :meth:`utcnow`.
616612

617613

618-
.. method:: datetime.utcnow()
614+
.. classmethod:: datetime.utcnow()
619615

620616
Return the current UTC date and time, with :attr:`tzinfo` ``None``. This is like
621617
:meth:`now`, but returns the current UTC date and time, as a naive
622618
:class:`datetime` object. See also :meth:`now`.
623619

624620

625-
.. method:: datetime.fromtimestamp(timestamp, tz=None)
621+
.. classmethod:: datetime.fromtimestamp(timestamp, tz=None)
626622

627623
Return the local date and time corresponding to the POSIX timestamp, such as is
628624
returned by :func:`time.time`. If optional argument *tz* is ``None`` or not
@@ -643,7 +639,7 @@ Other constructors, all class methods:
643639
identical :class:`datetime` objects. See also :meth:`utcfromtimestamp`.
644640

645641

646-
.. method:: datetime.utcfromtimestamp(timestamp)
642+
.. classmethod:: datetime.utcfromtimestamp(timestamp)
647643

648644
Return the UTC :class:`datetime` corresponding to the POSIX timestamp, with
649645
:attr:`tzinfo` ``None``. This may raise :exc:`ValueError`, if the timestamp is
@@ -652,15 +648,15 @@ Other constructors, all class methods:
652648
:meth:`fromtimestamp`.
653649

654650

655-
.. method:: datetime.fromordinal(ordinal)
651+
.. classmethod:: datetime.fromordinal(ordinal)
656652

657653
Return the :class:`datetime` corresponding to the proleptic Gregorian ordinal,
658654
where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1
659655
<= ordinal <= datetime.max.toordinal()``. The hour, minute, second and
660656
microsecond of the result are all 0, and :attr:`tzinfo` is ``None``.
661657

662658

663-
.. method:: datetime.combine(date, time)
659+
.. classmethod:: datetime.combine(date, time)
664660

665661
Return a new :class:`datetime` object whose date members are equal to the given
666662
:class:`date` object's, and whose time and :attr:`tzinfo` members are equal to
@@ -669,17 +665,17 @@ Other constructors, all class methods:
669665
object, its time and :attr:`tzinfo` members are ignored.
670666

671667

672-
.. method:: datetime.strptime(date_string, format)
668+
.. classmethod:: datetime.strptime(date_string, format)
673669

674670
Return a :class:`datetime` corresponding to *date_string*, parsed according to
675671
*format*. This is equivalent to ``datetime(*(time.strptime(date_string,
676672
format)[0:6]))``. :exc:`ValueError` is raised if the date_string and format
677673
can't be parsed by :func:`time.strptime` or if it returns a value which isn't a
678-
time tuple.
674+
time tuple. See section :ref:`strftime-strptime-behavior`.
679675

680676

681-
Class attributes:
682677

678+
Class attributes:
683679

684680
.. attribute:: datetime.min
685681

@@ -698,8 +694,8 @@ Class attributes:
698694
The smallest possible difference between non-equal :class:`datetime` objects,
699695
``timedelta(microseconds=1)``.
700696

701-
Instance attributes (read-only):
702697

698+
Instance attributes (read-only):
703699

704700
.. attribute:: datetime.year
705701

@@ -741,6 +737,7 @@ Instance attributes (read-only):
741737
The object passed as the *tzinfo* argument to the :class:`datetime` constructor,
742738
or ``None`` if none was passed.
743739

740+
744741
Supported operations:
745742

746743
+---------------------------------------+-------------------------------+
@@ -814,7 +811,6 @@ all :class:`datetime` objects are considered to be true.
814811

815812
Instance methods:
816813

817-
818814
.. method:: datetime.date()
819815

820816
Return :class:`date` object with same year, month and day.
@@ -992,7 +988,8 @@ Instance methods:
992988
.. method:: datetime.strftime(format)
993989

994990
Return a string representing the date and time, controlled by an explicit format
995-
string. See section :ref:`strftime-behavior`.
991+
string. See section :ref:`strftime-strptime-behavior`.
992+
996993

997994
Examples of working with datetime objects:
998995

@@ -1105,7 +1102,6 @@ Using datetime with tzinfo:
11051102
A time object represents a (local) time of day, independent of any particular
11061103
day, and subject to adjustment via a :class:`tzinfo` object.
11071104

1108-
11091105
.. class:: time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None)
11101106

11111107
All arguments are optional. *tzinfo* may be ``None``, or an instance of a
@@ -1139,8 +1135,8 @@ Class attributes:
11391135
``timedelta(microseconds=1)``, although note that arithmetic on :class:`time`
11401136
objects is not supported.
11411137

1142-
Instance attributes (read-only):
11431138

1139+
Instance attributes (read-only):
11441140

11451141
.. attribute:: time.hour
11461142

@@ -1167,6 +1163,7 @@ Instance attributes (read-only):
11671163
The object passed as the tzinfo argument to the :class:`time` constructor, or
11681164
``None`` if none was passed.
11691165

1166+
11701167
Supported operations:
11711168

11721169
* comparison of :class:`time` to :class:`time`, where *a* is considered less
@@ -1189,8 +1186,8 @@ Supported operations:
11891186
only if, after converting it to minutes and subtracting :meth:`utcoffset` (or
11901187
``0`` if that's ``None``), the result is non-zero.
11911188

1192-
Instance methods:
11931189

1190+
Instance methods:
11941191

11951192
.. method:: time.replace([hour[, minute[, second[, microsecond[, tzinfo]]]]])
11961193

@@ -1216,7 +1213,7 @@ Instance methods:
12161213
.. method:: time.strftime(format)
12171214

12181215
Return a string representing the time, controlled by an explicit format string.
1219-
See section :ref:`strftime-behavior`.
1216+
See section :ref:`strftime-strptime-behavior`.
12201217

12211218

12221219
.. method:: time.utcoffset()
@@ -1241,6 +1238,7 @@ Instance methods:
12411238
``self.tzinfo.tzname(None)``, or raises an exception if the latter doesn't
12421239
return ``None`` or a string object.
12431240

1241+
12441242
Example:
12451243

12461244
>>> from datetime import time, tzinfo
@@ -1377,6 +1375,7 @@ methods. Exactly which methods are needed depends on the uses made of aware
13771375

13781376
The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`.
13791377

1378+
13801379
These methods are called by a :class:`datetime` or :class:`time` object, in
13811380
response to their methods of the same names. A :class:`datetime` object passes
13821381
itself as the argument, and a :class:`time` object passes ``None`` as the
@@ -1480,20 +1479,25 @@ other fixed-offset :class:`tzinfo` subclass (such as a class representing only
14801479
EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
14811480

14821481

1483-
.. _strftime-behavior:
1482+
.. _strftime-strptime-behavior:
14841483

1485-
:meth:`strftime` Behavior
1486-
-------------------------
1484+
:meth:`strftime` and :meth:`strptime` Behavior
1485+
----------------------------------------------
14871486

14881487
:class:`date`, :class:`datetime`, and :class:`time` objects all support a
14891488
``strftime(format)`` method, to create a string representing the time under the
14901489
control of an explicit format string. Broadly speaking, ``d.strftime(fmt)``
14911490
acts like the :mod:`time` module's ``time.strftime(fmt, d.timetuple())``
14921491
although not all objects support a :meth:`timetuple` method.
14931492

1493+
Conversely, the :meth:`datetime.strptime` class method creates a
1494+
:class:`datetime` object from a string representing a date and time and a
1495+
corresponding format string. ``datetime.strptime(date_string, format)`` is
1496+
equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``.
1497+
14941498
For :class:`time` objects, the format codes for year, month, and day should not
14951499
be used, as time objects have no such values. If they're used anyway, ``1900``
1496-
is substituted for the year, and ``0`` for the month and day.
1500+
is substituted for the year, and ``1`` for the month and day.
14971501

14981502
For :class:`date` objects, the format codes for hours, minutes, seconds, and
14991503
microseconds should not be used, as :class:`date` objects have no such
@@ -1615,26 +1619,26 @@ platforms. Regardless of platform, years before 1900 cannot be used.
16151619
Notes:
16161620

16171621
(1)
1618-
When used with the :func:`strptime` function, the ``%f`` directive
1622+
When used with the :meth:`strptime` method, the ``%f`` directive
16191623
accepts from one to six digits and zero pads on the right. ``%f`` is
16201624
an extension to the set of format characters in the C standard (but
16211625
implemented separately in datetime objects, and therefore always
16221626
available).
16231627

16241628
(2)
1625-
When used with the :func:`strptime` function, the ``%p`` directive only affects
1629+
When used with the :meth:`strptime` method, the ``%p`` directive only affects
16261630
the output hour field if the ``%I`` directive is used to parse the hour.
16271631

16281632
(3)
16291633
The range really is ``0`` to ``61``; according to the Posix standard this
16301634
accounts for leap seconds and the (very rare) double leap seconds.
16311635
The :mod:`time` module may produce and does accept leap seconds since
16321636
it is based on the Posix standard, but the :mod:`datetime` module
1633-
does not accept leap seconds in :func:`strptime` input nor will it
1637+
does not accept leap seconds in :meth:`strptime` input nor will it
16341638
produce them in :func:`strftime` output.
16351639

16361640
(4)
1637-
When used with the :func:`strptime` function, ``%U`` and ``%W`` are only used in
1641+
When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used in
16381642
calculations when the day of the week and the year are specified.
16391643

16401644
(5)

Doc/library/profile.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ script. For example::
108108

109109
cProfile.py [-o output_file] [-s sort_order]
110110

111-
:option:`-s` only applies to standard output (:option:`-o` is not supplied).
111+
``-s`` only applies to standard output (``-o`` is not supplied).
112112
Look in the :class:`Stats` documentation for valid sort values.
113113

114114
When you wish to review the profile, you should use the methods in the

Doc/library/unittest.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,9 @@ Test cases
731731

732732
.. method:: assertSameElements(expected, actual, msg=None)
733733

734-
Test that sequence *expected* contains the same elements as *actual*.
735-
When they don't an error message listing the differences between the
736-
sequences will be generated.
734+
Test that sequence *expected* contains the same elements as *actual*,
735+
regardless of their order. When they don't, an error message listing
736+
the differences between the sequences will be generated.
737737

738738
If specified *msg* will be used as the error message on failure.
739739

Doc/library/xmlrpc.client.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ by providing an invalid URI::
383383

384384
import xmlrpc.client
385385

386-
# create a ServerProxy with an invalid URI
387-
proxy = xmlrpc.client.ServerProxy("http://invalidaddress/")
386+
# create a ServerProxy with an URI that doesn't respond to XMLRPC requests
387+
proxy = xmlrpc.client.ServerProxy("http://google.com/")
388388

389389
try:
390390
proxy.some_method()

0 commit comments

Comments
 (0)