Merge 3.2.1 release clone into main repo.
diff --git a/Doc/ACKS.txt b/Doc/ACKS.txt
index 7f67d36..1ad18f1 100644
--- a/Doc/ACKS.txt
+++ b/Doc/ACKS.txt
@@ -105,6 +105,7 @@
* Robert Kern
* Jim Kerr
* Jan Kim
+ * Kamil Kisiel
* Greg Kochanski
* Guido Kollerie
* Peter A. Koren
@@ -142,7 +143,7 @@
* Ross Moore
* Sjoerd Mullender
* Dale Nagata
- * Michal Nowikowski
+ * Michal Nowikowski
* Ng Pheng Siong
* Koray Oner
* Tomas Oppelstrup
diff --git a/Doc/library/cmd.rst b/Doc/library/cmd.rst
index 464764d..e9a049f 100644
--- a/Doc/library/cmd.rst
+++ b/Doc/library/cmd.rst
@@ -50,7 +50,7 @@
the line as argument.
The optional argument is a banner or intro string to be issued before the first
- prompt (this overrides the :attr:`intro` class member).
+ prompt (this overrides the :attr:`intro` class attribute).
If the :mod:`readline` module is loaded, input will automatically inherit
:program:`bash`\ -like history-list editing (e.g. :kbd:`Control-P` scrolls back
diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst
index b7039de..16b7681 100644
--- a/Doc/library/curses.rst
+++ b/Doc/library/curses.rst
@@ -1639,7 +1639,7 @@
each keystroke entered with the keystroke as a parameter; command dispatch
is done on the result. This method returns the window contents as a
string; whether blanks in the window are included is affected by the
- :attr:`stripspaces` member.
+ :attr:`stripspaces` attribute.
.. method:: do_command(ch)
@@ -1711,7 +1711,7 @@
.. attribute:: stripspaces
- This data member is a flag which controls the interpretation of blanks in
+ This attribute is a flag which controls the interpretation of blanks in
the window. When it is on, trailing blanks on each line are ignored; any
cursor motion that would land the cursor on a trailing blank goes to the
end of that line instead, and trailing blanks are stripped when the window
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index de9ad44..56fa698 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -11,7 +11,7 @@
The :mod:`datetime` module supplies classes for manipulating dates and times in
both simple and complex ways. While date and time arithmetic is supported, the
-focus of the implementation is on efficient member extraction for output
+focus of the implementation is on efficient attribute extraction for output
formatting and manipulation. For related
functionality, see also the :mod:`time` and :mod:`calendar` modules.
@@ -25,7 +25,7 @@
work with, at the cost of ignoring some aspects of reality.
For applications requiring more, :class:`datetime` and :class:`time` objects
-have an optional time zone information member, :attr:`tzinfo`, that can contain
+have an optional time zone information attribute, :attr:`tzinfo`, that can contain
an instance of a subclass of the abstract :class:`tzinfo` class. These
:class:`tzinfo` objects capture information about the offset from UTC time, the
time zone name, and whether Daylight Saving Time is in effect. Note that only
@@ -499,9 +499,9 @@
.. method:: date.replace(year, month, day)
- Return a date with the same value, except for those members given new values by
- whichever keyword arguments are specified. For example, if ``d == date(2002,
- 12, 31)``, then ``d.replace(day=26) == date(2002, 12, 26)``.
+ Return a date with the same value, except for those parameters given new
+ values by whichever keyword arguments are specified. For example, if ``d ==
+ date(2002, 12, 31)``, then ``d.replace(day=26) == date(2002, 12, 26)``.
.. method:: date.timetuple()
@@ -732,11 +732,11 @@
.. 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
- the given :class:`time` object's. For any :class:`datetime` object *d*, ``d ==
- datetime.combine(d.date(), d.timetz())``. If date is a :class:`datetime`
- object, its time and :attr:`tzinfo` members are ignored.
+ Return a new :class:`datetime` object whose date attributes are equal to the
+ given :class:`date` object's, and whose time and :attr:`tzinfo` attributes are
+ equal to the given :class:`time` object's. For any :class:`datetime` object
+ *d*, ``d == datetime.combine(d.date(), d.timetz())``. If date is a
+ :class:`datetime` object, its time and :attr:`tzinfo` attributes are ignored.
.. classmethod:: datetime.strptime(date_string, format)
@@ -830,43 +830,44 @@
(1)
datetime2 is a duration of timedelta removed from datetime1, moving forward in
time if ``timedelta.days`` > 0, or backward if ``timedelta.days`` < 0. The
- result has the same :attr:`tzinfo` member as the input datetime, and datetime2 -
- datetime1 == timedelta after. :exc:`OverflowError` is raised if datetime2.year
- would be smaller than :const:`MINYEAR` or larger than :const:`MAXYEAR`. Note
- that no time zone adjustments are done even if the input is an aware object.
+ result has the same :attr:`tzinfo` attribute as the input datetime, and
+ datetime2 - datetime1 == timedelta after. :exc:`OverflowError` is raised if
+ datetime2.year would be smaller than :const:`MINYEAR` or larger than
+ :const:`MAXYEAR`. Note that no time zone adjustments are done even if the
+ input is an aware object.
(2)
Computes the datetime2 such that datetime2 + timedelta == datetime1. As for
- addition, the result has the same :attr:`tzinfo` member as the input datetime,
- and no time zone adjustments are done even if the input is aware. This isn't
- quite equivalent to datetime1 + (-timedelta), because -timedelta in isolation
- can overflow in cases where datetime1 - timedelta does not.
+ addition, the result has the same :attr:`tzinfo` attribute as the input
+ datetime, and no time zone adjustments are done even if the input is aware.
+ This isn't quite equivalent to datetime1 + (-timedelta), because -timedelta
+ in isolation can overflow in cases where datetime1 - timedelta does not.
(3)
Subtraction of a :class:`datetime` from a :class:`datetime` is defined only if
both operands are naive, or if both are aware. If one is aware and the other is
naive, :exc:`TypeError` is raised.
- If both are naive, or both are aware and have the same :attr:`tzinfo` member,
- the :attr:`tzinfo` members are ignored, and the result is a :class:`timedelta`
+ If both are naive, or both are aware and have the same :attr:`tzinfo` attribute,
+ the :attr:`tzinfo` attributes are ignored, and the result is a :class:`timedelta`
object *t* such that ``datetime2 + t == datetime1``. No time zone adjustments
are done in this case.
- If both are aware and have different :attr:`tzinfo` members, ``a-b`` acts as if
- *a* and *b* were first converted to naive UTC datetimes first. The result is
- ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None) -
- b.utcoffset())`` except that the implementation never overflows.
+ If both are aware and have different :attr:`tzinfo` attributes, ``a-b`` acts
+ as if *a* and *b* were first converted to naive UTC datetimes first. The
+ result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None)
+ - b.utcoffset())`` except that the implementation never overflows.
(4)
*datetime1* is considered less than *datetime2* when *datetime1* precedes
*datetime2* in time.
If one comparand is naive and the other is aware, :exc:`TypeError` is raised.
- If both comparands are aware, and have the same :attr:`tzinfo` member, the
- common :attr:`tzinfo` member is ignored and the base datetimes are compared. If
- both comparands are aware and have different :attr:`tzinfo` members, the
- comparands are first adjusted by subtracting their UTC offsets (obtained from
- ``self.utcoffset()``).
+ If both comparands are aware, and have the same :attr:`tzinfo` attribute, the
+ common :attr:`tzinfo` attribute is ignored and the base datetimes are
+ compared. If both comparands are aware and have different :attr:`tzinfo`
+ attributes, the comparands are first adjusted by subtracting their UTC
+ offsets (obtained from ``self.utcoffset()``).
.. note::
@@ -899,22 +900,22 @@
.. method:: datetime.timetz()
Return :class:`time` object with same hour, minute, second, microsecond, and
- tzinfo members. See also method :meth:`time`.
+ tzinfo attributes. See also method :meth:`time`.
.. method:: datetime.replace([year[, month[, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]]]])
- Return a datetime with the same members, except for those members given new
- values by whichever keyword arguments are specified. Note that ``tzinfo=None``
- can be specified to create a naive datetime from an aware datetime with no
- conversion of date and time members.
+ Return a datetime with the same attributes, except for those attributes given
+ new values by whichever keyword arguments are specified. Note that
+ ``tzinfo=None`` can be specified to create a naive datetime from an aware
+ datetime with no conversion of date and time attributes.
.. method:: datetime.astimezone(tz)
- Return a :class:`datetime` object with new :attr:`tzinfo` member *tz*, adjusting
- the date and time members so the result is the same UTC time as *self*, but in
- *tz*'s local time.
+ Return a :class:`datetime` object with new :attr:`tzinfo` attribute *tz*,
+ adjusting the date and time attributes so the result is the same UTC time as
+ *self*, but in *tz*'s local time.
*tz* must be an instance of a :class:`tzinfo` subclass, and its
:meth:`utcoffset` and :meth:`dst` methods must not return ``None``. *self* must
@@ -922,18 +923,18 @@
not return ``None``).
If ``self.tzinfo`` is *tz*, ``self.astimezone(tz)`` is equal to *self*: no
- adjustment of date or time members is performed. Else the result is local time
- in time zone *tz*, representing the same UTC time as *self*: after ``astz =
- dt.astimezone(tz)``, ``astz - astz.utcoffset()`` will usually have the same date
- and time members as ``dt - dt.utcoffset()``. The discussion of class
- :class:`tzinfo` explains the cases at Daylight Saving Time transition boundaries
- where this cannot be achieved (an issue only if *tz* models both standard and
- daylight time).
+ adjustment of date or time attributes is performed. Else the result is local
+ time in time zone *tz*, representing the same UTC time as *self*: after
+ ``astz = dt.astimezone(tz)``, ``astz - astz.utcoffset()`` will usually have
+ the same date and time attributes as ``dt - dt.utcoffset()``. The discussion
+ of class :class:`tzinfo` explains the cases at Daylight Saving Time transition
+ boundaries where this cannot be achieved (an issue only if *tz* models both
+ standard and daylight time).
If you merely want to attach a time zone object *tz* to a datetime *dt* without
- adjustment of date and time members, use ``dt.replace(tzinfo=tz)``. If you
+ adjustment of date and time attributes, use ``dt.replace(tzinfo=tz)``. If you
merely want to remove the time zone object from an aware datetime *dt* without
- conversion of date and time members, use ``dt.replace(tzinfo=None)``.
+ conversion of date and time attributes, use ``dt.replace(tzinfo=None)``.
Note that the default :meth:`tzinfo.fromutc` method can be overridden in a
:class:`tzinfo` subclass to affect the result returned by :meth:`astimezone`.
@@ -1244,14 +1245,14 @@
* comparison of :class:`time` to :class:`time`, where *a* is considered less
than *b* when *a* precedes *b* in time. If one comparand is naive and the other
is aware, :exc:`TypeError` is raised. If both comparands are aware, and have
- the same :attr:`tzinfo` member, the common :attr:`tzinfo` member is ignored and
- the base times are compared. If both comparands are aware and have different
- :attr:`tzinfo` members, the comparands are first adjusted by subtracting their
- UTC offsets (obtained from ``self.utcoffset()``). In order to stop mixed-type
- comparisons from falling back to the default comparison by object address, when
- a :class:`time` object is compared to an object of a different type,
- :exc:`TypeError` is raised unless the comparison is ``==`` or ``!=``. The
- latter cases return :const:`False` or :const:`True`, respectively.
+ the same :attr:`tzinfo` attribute, the common :attr:`tzinfo` attribute is
+ ignored and the base times are compared. If both comparands are aware and
+ have different :attr:`tzinfo` attributes, the comparands are first adjusted by
+ subtracting their UTC offsets (obtained from ``self.utcoffset()``). In order
+ to stop mixed-type comparisons from falling back to the default comparison by
+ object address, when a :class:`time` object is compared to an object of a
+ different type, :exc:`TypeError` is raised unless the comparison is ``==`` or
+ ``!=``. The latter cases return :const:`False` or :const:`True`, respectively.
* hash, use as dict key
@@ -1266,10 +1267,10 @@
.. method:: time.replace([hour[, minute[, second[, microsecond[, tzinfo]]]]])
- Return a :class:`time` with the same value, except for those members given new
- values by whichever keyword arguments are specified. Note that ``tzinfo=None``
- can be specified to create a naive :class:`time` from an aware :class:`time`,
- without conversion of the time members.
+ Return a :class:`time` with the same value, except for those attributes given
+ new values by whichever keyword arguments are specified. Note that
+ ``tzinfo=None`` can be specified to create a naive :class:`time` from an
+ aware :class:`time`, without conversion of the time attributes.
.. method:: time.isoformat()
@@ -1354,7 +1355,7 @@
An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the
constructors for :class:`datetime` and :class:`time` objects. The latter objects
-view their members as being in local time, and the :class:`tzinfo` object
+view their attributes as being in local time, and the :class:`tzinfo` object
supports methods revealing offset of local time from UTC, the name of the time
zone, and DST offset, all relative to a date or time object passed to them.
@@ -1399,9 +1400,9 @@
already been added to the UTC offset returned by :meth:`utcoffset`, so there's
no need to consult :meth:`dst` unless you're interested in obtaining DST info
separately. For example, :meth:`datetime.timetuple` calls its :attr:`tzinfo`
- member's :meth:`dst` method to determine how the :attr:`tm_isdst` flag should be
- set, and :meth:`tzinfo.fromutc` calls :meth:`dst` to account for DST changes
- when crossing time zones.
+ attribute's :meth:`dst` method to determine how the :attr:`tm_isdst` flag
+ should be set, and :meth:`tzinfo.fromutc` calls :meth:`dst` to account for
+ DST changes when crossing time zones.
An instance *tz* of a :class:`tzinfo` subclass that models both standard and
daylight times must be consistent in this sense:
@@ -1477,10 +1478,10 @@
.. method:: tzinfo.fromutc(dt)
This is called from the default :class:`datetime.astimezone()` implementation.
- When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time members
- are to be viewed as expressing a UTC time. The purpose of :meth:`fromutc` is to
- adjust the date and time members, returning an equivalent datetime in *self*'s
- local time.
+ When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time
+ attributes are to be viewed as expressing a UTC time. The purpose of
+ :meth:`fromutc` is to adjust the date and time attributes, returning an
+ equivalent datetime in *self*'s local time.
Most :class:`tzinfo` subclasses should be able to inherit the default
:meth:`fromutc` implementation without problems. It's strong enough to handle
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
index 9d5b32f..d6cd504 100644
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -654,7 +654,7 @@
Normalize the number by stripping the rightmost trailing zeros and
converting any result equal to :const:`Decimal('0')` to
- :const:`Decimal('0e0')`. Used for producing canonical values for members
+ :const:`Decimal('0e0')`. Used for producing canonical values for attributes
of an equivalence class. For example, ``Decimal('32.100')`` and
``Decimal('0.321000e+2')`` both normalize to the equivalent value
``Decimal('32.1')``.
diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst
index 29fbd64..cdd6c26 100644
--- a/Doc/library/doctest.rst
+++ b/Doc/library/doctest.rst
@@ -1127,11 +1127,10 @@
.. class:: DocTest(examples, globs, name, filename, lineno, docstring)
A collection of doctest examples that should be run in a single namespace. The
- constructor arguments are used to initialize the member variables of the same
- names.
+ constructor arguments are used to initialize the attributes of the same names.
- :class:`DocTest` defines the following member variables. They are initialized by
+ :class:`DocTest` defines the following attributes. They are initialized by
the constructor, and should not be modified directly.
@@ -1184,11 +1183,11 @@
.. class:: Example(source, want, exc_msg=None, lineno=0, indent=0, options=None)
A single interactive example, consisting of a Python statement and its expected
- output. The constructor arguments are used to initialize the member variables
- of the same names.
+ output. The constructor arguments are used to initialize the attributes of
+ the same names.
- :class:`Example` defines the following member variables. They are initialized by
+ :class:`Example` defines the following attributes. They are initialized by
the constructor, and should not be modified directly.
@@ -1675,9 +1674,9 @@
An exception raised by :class:`DocTestRunner` to signal that a doctest example's
actual output did not match its expected output. The constructor arguments are
- used to initialize the member variables of the same names.
+ used to initialize the attributes of the same names.
-:exc:`DocTestFailure` defines the following member variables:
+:exc:`DocTestFailure` defines the following attributes:
.. attribute:: DocTestFailure.test
@@ -1699,9 +1698,9 @@
An exception raised by :class:`DocTestRunner` to signal that a doctest
example raised an unexpected exception. The constructor arguments are used
- to initialize the member variables of the same names.
+ to initialize the attributes of the same names.
-:exc:`UnexpectedException` defines the following member variables:
+:exc:`UnexpectedException` defines the following attributes:
.. attribute:: UnexpectedException.test
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst
index 659a027..48a8694 100644
--- a/Doc/library/gzip.rst
+++ b/Doc/library/gzip.rst
@@ -61,7 +61,7 @@
time is used. This module ignores the timestamp when decompressing;
however, some programs, such as :program:`gunzip`\ , make use of it.
The format of the timestamp is the same as that of the return value of
- ``time.time()`` and of the ``st_mtime`` member of the object returned
+ ``time.time()`` and of the ``st_mtime`` attribute of the object returned
by ``os.stat()``.
Calling a :class:`GzipFile` object's :meth:`close` method does not close
diff --git a/Doc/library/html.entities.rst b/Doc/library/html.entities.rst
index 239ae50..b8b4aa8 100644
--- a/Doc/library/html.entities.rst
+++ b/Doc/library/html.entities.rst
@@ -11,7 +11,7 @@
This module defines three dictionaries, ``name2codepoint``, ``codepoint2name``,
and ``entitydefs``. ``entitydefs`` is used to provide the :attr:`entitydefs`
-member of the :class:`html.parser.HTMLParser` class. The definition provided
+attribute of the :class:`html.parser.HTMLParser` class. The definition provided
here contains all the entities defined by XHTML 1.0 that can be handled using
simple textual substitution in the Latin-1 character set (ISO-8859-1).
diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst
index d8a437b..6baf28e 100644
--- a/Doc/library/http.cookies.rst
+++ b/Doc/library/http.cookies.rst
@@ -152,7 +152,7 @@
.. method:: Morsel.set(key, value, coded_value)
- Set the *key*, *value* and *coded_value* members.
+ Set the *key*, *value* and *coded_value* attributes.
.. method:: Morsel.isReservedKey(K)
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index 0584b70..0d87305 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -391,8 +391,8 @@
:class:`RawIOBase` implementation, but wrap one, like
:class:`BufferedWriter` and :class:`BufferedReader` do.
- :class:`BufferedIOBase` provides or overrides these members in addition to
- those from :class:`IOBase`:
+ :class:`BufferedIOBase` provides or overrides these methods and attribute in
+ addition to those from :class:`IOBase`:
.. attribute:: raw
diff --git a/Doc/library/nntplib.rst b/Doc/library/nntplib.rst
index 164f149..ef507e1 100644
--- a/Doc/library/nntplib.rst
+++ b/Doc/library/nntplib.rst
@@ -394,7 +394,7 @@
Send an ``ARTICLE`` command, where *message_spec* has the same meaning as
for :meth:`stat`. Return a tuple ``(response, info)`` where *info*
- is a :class:`~collections.namedtuple` with three members *number*,
+ is a :class:`~collections.namedtuple` with three attributes *number*,
*message_id* and *lines* (in that order). *number* is the article number
in the group (or 0 if the information is not available), *message_id* the
message id as a string, and *lines* a list of lines (without terminating
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 3d370a0..c412ee1 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1339,11 +1339,12 @@
.. note::
- The exact meaning and resolution of the :attr:`st_atime`, :attr:`st_mtime`, and
- :attr:`st_ctime` members depends on the operating system and the file system.
- For example, on Windows systems using the FAT or FAT32 file systems,
- :attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
- resolution. See your operating system documentation for details.
+ The exact meaning and resolution of the :attr:`st_atime`,
+ :attr:`st_mtime`, and :attr:`st_ctime` attributes depend on the operating
+ system and the file system. For example, on Windows systems using the FAT
+ or FAT32 file systems, :attr:`st_mtime` has 2-second resolution, and
+ :attr:`st_atime` has only 1-day resolution. See your operating system
+ documentation for details.
For backward compatibility, the return value of :func:`~os.stat` is also accessible
as a tuple of at least 10 integers giving the most important (and portable)
@@ -1581,8 +1582,9 @@
Generate a :const:`SIGABRT` signal to the current process. On Unix, the default
behavior is to produce a core dump; on Windows, the process immediately returns
- an exit code of ``3``. Be aware that programs which use :func:`signal.signal`
- to register a handler for :const:`SIGABRT` will behave differently.
+ an exit code of ``3``. Be aware that calling this function will not call the
+ Python signal handler registered for :const:`SIGABRT` with
+ :func:`signal.signal`.
Availability: Unix, Windows.
diff --git a/Doc/library/pyclbr.rst b/Doc/library/pyclbr.rst
index d4a76a6..13eaabf 100644
--- a/Doc/library/pyclbr.rst
+++ b/Doc/library/pyclbr.rst
@@ -45,7 +45,7 @@
The :class:`Class` objects used as values in the dictionary returned by
:func:`readmodule` and :func:`readmodule_ex` provide the following data
-members:
+attributes:
.. attribute:: Class.module
@@ -89,7 +89,7 @@
----------------
The :class:`Function` objects used as values in the dictionary returned by
-:func:`readmodule_ex` provide the following data members:
+:func:`readmodule_ex` provide the following attributes:
.. attribute:: Function.module
diff --git a/Doc/library/reprlib.rst b/Doc/library/reprlib.rst
index 0e870da..24a8e52 100644
--- a/Doc/library/reprlib.rst
+++ b/Doc/library/reprlib.rst
@@ -66,7 +66,7 @@
Repr Objects
------------
-:class:`Repr` instances provide several members which can be used to provide
+:class:`Repr` instances provide several attributes which can be used to provide
size limits for the representations of different object types, and methods
which format specific object types.
diff --git a/Doc/library/shlex.rst b/Doc/library/shlex.rst
index 03c9f98..0113fb7 100644
--- a/Doc/library/shlex.rst
+++ b/Doc/library/shlex.rst
@@ -24,8 +24,8 @@
Split the string *s* using shell-like syntax. If *comments* is :const:`False`
(the default), the parsing of comments in the given string will be disabled
- (setting the :attr:`commenters` member of the :class:`shlex` instance to the
- empty string). This function operates in POSIX mode by default, but uses
+ (setting the :attr:`commenters` attribute of the :class:`shlex` instance to
+ the empty string). This function operates in POSIX mode by default, but uses
non-POSIX mode if the *posix* argument is false.
.. note::
@@ -44,7 +44,7 @@
from. It must be a file-/stream-like object with :meth:`read` and
:meth:`readline` methods, or a string. If no argument is given, input will
be taken from ``sys.stdin``. The second optional argument is a filename
- string, which sets the initial value of the :attr:`infile` member. If the
+ string, which sets the initial value of the :attr:`infile` attribute. If the
*instream* argument is omitted or equal to ``sys.stdin``, this second
argument defaults to "stdin". The *posix* argument defines the operational
mode: when *posix* is not true (default), the :class:`shlex` instance will
@@ -202,8 +202,8 @@
.. attribute:: shlex.source
- This member is ``None`` by default. If you assign a string to it, that string
- will be recognized as a lexical-level inclusion request similar to the
+ This attribute is ``None`` by default. If you assign a string to it, that
+ string will be recognized as a lexical-level inclusion request similar to the
``source`` keyword in various shells. That is, the immediately following token
will opened as a filename and input taken from that stream until EOF, at which
point the :meth:`close` method of that stream will be called and the input
@@ -213,7 +213,7 @@
.. attribute:: shlex.debug
- If this member is numeric and ``1`` or more, a :class:`shlex` instance will
+ If this attribute is numeric and ``1`` or more, a :class:`shlex` instance will
print verbose progress output on its behavior. If you need to use this, you can
read the module source code to learn the details.
diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst
index ed547f5e..1d151a7 100644
--- a/Doc/library/socketserver.rst
+++ b/Doc/library/socketserver.rst
@@ -81,7 +81,7 @@
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
The mix-in class must come first, since it overrides a method defined in
-:class:`UDPServer`. Setting the various member variables also changes the
+:class:`UDPServer`. Setting the various attributes also change the
behavior of the underlying server mechanism.
To implement a service, you must derive a class from :class:`BaseRequestHandler`
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 7367674..32ae724 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -599,43 +599,43 @@
Let's assume we initialize a table as in the example given above::
- conn = sqlite3.connect(":memory:")
- c = conn.cursor()
- c.execute('''create table stocks
- (date text, trans text, symbol text,
- qty real, price real)''')
- c.execute("""insert into stocks
- values ('2006-01-05','BUY','RHAT',100,35.14)""")
- conn.commit()
- c.close()
+ conn = sqlite3.connect(":memory:")
+ c = conn.cursor()
+ c.execute('''create table stocks
+ (date text, trans text, symbol text,
+ qty real, price real)''')
+ c.execute("""insert into stocks
+ values ('2006-01-05','BUY','RHAT',100,35.14)""")
+ conn.commit()
+ c.close()
Now we plug :class:`Row` in::
- >>> conn.row_factory = sqlite3.Row
- >>> c = conn.cursor()
- >>> c.execute('select * from stocks')
- <sqlite3.Cursor object at 0x7f4e7dd8fa80>
- >>> r = c.fetchone()
- >>> type(r)
- <class 'sqlite3.Row'>
- >>> tuple(r)
- ('2006-01-05', 'BUY', 'RHAT', 100.0, 35.14)
- >>> len(r)
- 5
- >>> r[2]
- 'RHAT'
- >>> r.keys()
- ['date', 'trans', 'symbol', 'qty', 'price']
- >>> r['qty']
- 100.0
- >>> for member in r:
- ... print(member)
- ...
- 2006-01-05
- BUY
- RHAT
- 100.0
- 35.14
+ >>> conn.row_factory = sqlite3.Row
+ >>> c = conn.cursor()
+ >>> c.execute('select * from stocks')
+ <sqlite3.Cursor object at 0x7f4e7dd8fa80>
+ >>> r = c.fetchone()
+ >>> type(r)
+ <class 'sqlite3.Row'>
+ >>> tuple(r)
+ ('2006-01-05', 'BUY', 'RHAT', 100.0, 35.14)
+ >>> len(r)
+ 5
+ >>> r[2]
+ 'RHAT'
+ >>> r.keys()
+ ['date', 'trans', 'symbol', 'qty', 'price']
+ >>> r['qty']
+ 100.0
+ >>> for member in r:
+ ... print(member)
+ ...
+ 2006-01-05
+ BUY
+ RHAT
+ 100.0
+ 35.14
.. _sqlite3-types:
@@ -886,6 +886,7 @@
.. rubric:: Footnotes
.. [#f1] The sqlite3 module is not built with loadable extension support by
- default, because some platforms (notably Mac OS X) have SQLite libraries which
- are compiled without this feature. To get loadable extension support, you must
- pass --enable-loadable-sqlite-extensions to configure.
+ default, because some platforms (notably Mac OS X) have SQLite
+ libraries which are compiled without this feature. To get loadable
+ extension support, you must pass --enable-loadable-sqlite-extensions to
+ configure.
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index e24c450..f0933a5 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -2567,7 +2567,7 @@
foo`` does not require a module object named *foo* to exist, rather it requires
an (external) *definition* for a module named *foo* somewhere.)
-A special member of every module is :attr:`__dict__`. This is the dictionary
+A special attribute of every module is :attr:`__dict__`. This is the dictionary
containing the module's symbol table. Modifying this dictionary will actually
change the module's symbol table, but direct assignment to the :attr:`__dict__`
attribute is not possible (you can write ``m.__dict__['a'] = 1``, which defines
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 4c0edb3..16c2605 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -497,38 +497,39 @@
.. attribute:: dwFlags
- A bit field that determines whether certain :class:`STARTUPINFO` members
- are used when the process creates a window. ::
+ A bit field that determines whether certain :class:`STARTUPINFO`
+ attributes are used when the process creates a window. ::
si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
.. attribute:: hStdInput
- If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this member is
- the standard input handle for the process. If :data:`STARTF_USESTDHANDLES`
- is not specified, the default for standard input is the keyboard buffer.
+ If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute
+ is the standard input handle for the process. If
+ :data:`STARTF_USESTDHANDLES` is not specified, the default for standard
+ input is the keyboard buffer.
.. attribute:: hStdOutput
- If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this member is
- the standard output handle for the process. Otherwise, this member is
- ignored and the default for standard output is the console window's
+ If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute
+ is the standard output handle for the process. Otherwise, this attribute
+ is ignored and the default for standard output is the console window's
buffer.
.. attribute:: hStdError
- If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this member is
- the standard error handle for the process. Otherwise, this member is
+ If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute
+ is the standard error handle for the process. Otherwise, this attribute is
ignored and the default for standard error is the console window's buffer.
.. attribute:: wShowWindow
- If :attr:`dwFlags` specifies :data:`STARTF_USESHOWWINDOW`, this member
+ If :attr:`dwFlags` specifies :data:`STARTF_USESHOWWINDOW`, this attribute
can be any of the values that can be specified in the ``nCmdShow``
parameter for the
`ShowWindow <http://msdn.microsoft.com/en-us/library/ms633548(v=vs.85).aspx>`__
- function, except for ``SW_SHOWDEFAULT``. Otherwise, this member is
+ function, except for ``SW_SHOWDEFAULT``. Otherwise, this attribute is
ignored.
:data:`SW_HIDE` is provided for this attribute. It is used when
@@ -562,12 +563,12 @@
.. data:: STARTF_USESTDHANDLES
Specifies that the :attr:`STARTUPINFO.hStdInput`,
- :attr:`STARTUPINFO.hStdOutput`, and :attr:`STARTUPINFO.hStdError` members
+ :attr:`STARTUPINFO.hStdOutput`, and :attr:`STARTUPINFO.hStdError` attributes
contain additional information.
.. data:: STARTF_USESHOWWINDOW
- Specifies that the :attr:`STARTUPINFO.wShowWindow` member contains
+ Specifies that the :attr:`STARTUPINFO.wShowWindow` attribute contains
additional information.
.. data:: CREATE_NEW_CONSOLE
diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst
index 01092fc..fff6c4e 100644
--- a/Doc/library/tempfile.rst
+++ b/Doc/library/tempfile.rst
@@ -60,7 +60,7 @@
This function operates exactly as :func:`TemporaryFile` does, except that
the file is guaranteed to have a visible name in the file system (on
Unix, the directory entry is not unlinked). That name can be retrieved
- from the :attr:`name` member of the file object. Whether the name can be
+ from the :attr:`name` attribute of the file object. Whether the name can be
used to open the file a second time, while the named temporary file is
still open, varies across platforms (it can be so used on Unix; it cannot
on Windows NT or later). If *delete* is true (the default), the file is
@@ -96,7 +96,7 @@
of the temporary directory object), the newly created temporary directory
and all its contents are removed from the filesystem.
- The directory name can be retrieved from the :attr:`name` member
+ The directory name can be retrieved from the :attr:`name` attribute
of the returned object.
The directory can be explicitly cleaned up by calling the
diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst
index 3e24956..2cd0620 100644
--- a/Doc/library/urllib.request.rst
+++ b/Doc/library/urllib.request.rst
@@ -105,7 +105,7 @@
can be imported), :class:`HTTPSHandler` will also be added.
A :class:`BaseHandler` subclass may also change its :attr:`handler_order`
- member variable to modify its position in the handlers list.
+ attribute to modify its position in the handlers list.
.. function:: pathname2url(path)
@@ -536,7 +536,7 @@
Remove any parents.
-The following members and methods should only be used by classes derived from
+The following attribute and methods should only be used by classes derived from
:class:`BaseHandler`.
.. note::
diff --git a/Doc/library/xdrlib.rst b/Doc/library/xdrlib.rst
index 1d3da0a..5c7dfa4 100644
--- a/Doc/library/xdrlib.rst
+++ b/Doc/library/xdrlib.rst
@@ -260,7 +260,7 @@
.. exception:: Error
- The base exception class. :exc:`Error` has a single public data member
+ The base exception class. :exc:`Error` has a single public attribute
:attr:`msg` containing the description of the error.
diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst
index a62021d..bb058df 100644
--- a/Doc/library/xmlrpc.client.rst
+++ b/Doc/library/xmlrpc.client.rst
@@ -136,7 +136,7 @@
:class:`Fault` or :class:`ProtocolError` object indicating an error.
Servers that support the XML introspection API support some common methods
-grouped under the reserved :attr:`system` member:
+grouped under the reserved :attr:`system` attribute:
.. method:: ServerProxy.system.listMethods()
@@ -310,7 +310,7 @@
-------------
A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault
-objects have the following members:
+objects have the following attributes:
.. attribute:: Fault.faultCode
@@ -359,7 +359,7 @@
A :class:`ProtocolError` object describes a protocol error in the underlying
transport layer (such as a 404 'not found' error if the server named by the URI
-does not exist). It has the following members:
+does not exist). It has the following attributes:
.. attribute:: ProtocolError.url
diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst
index 79d8ad2..ff599c8 100644
--- a/Doc/whatsnew/2.5.rst
+++ b/Doc/whatsnew/2.5.rst
@@ -1459,7 +1459,7 @@
On FreeBSD, the :func:`os.stat` function now returns times with nanosecond
resolution, and the returned object now has :attr:`st_gen` and
- :attr:`st_birthtime`. The :attr:`st_flags` member is also available, if the
+ :attr:`st_birthtime`. The :attr:`st_flags` attribute is also available, if the
platform supports it. (Contributed by Antti Louko and Diego Pettenò.)
.. (Patch 1180695, 1212117)
diff --git a/Lib/glob.py b/Lib/glob.py
index c5f5f69..36d493d 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -1,6 +1,5 @@
"""Filename globbing utility."""
-import sys
import os
import re
import fnmatch
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 1619446..aa4b6d5 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -256,20 +256,18 @@
def importfile(path):
"""Import a Python source file or compiled file given its path."""
magic = imp.get_magic()
- file = open(path, 'r')
- if file.read(len(magic)) == magic:
- kind = imp.PY_COMPILED
- else:
- kind = imp.PY_SOURCE
- file.close()
- filename = os.path.basename(path)
- name, ext = os.path.splitext(filename)
- file = open(path, 'r')
- try:
- module = imp.load_module(name, file, path, (ext, 'r', kind))
- except:
- raise ErrorDuringImport(path, sys.exc_info())
- file.close()
+ with open(path, 'rb') as file:
+ if file.read(len(magic)) == magic:
+ kind = imp.PY_COMPILED
+ else:
+ kind = imp.PY_SOURCE
+ file.seek(0)
+ filename = os.path.basename(path)
+ name, ext = os.path.splitext(filename)
+ try:
+ module = imp.load_module(name, file, path, (ext, 'r', kind))
+ except:
+ raise ErrorDuringImport(path, sys.exc_info())
return module
def safeimport(path, forceload=0, cache={}):
@@ -2582,7 +2580,7 @@
def html_getfile(path):
"""Get and display a source file listing safely."""
path = path.replace('%20', ' ')
- with open(path, 'r') as fp:
+ with tokenize.open(path) as fp:
lines = html.escape(fp.read())
body = '<pre>%s</pre>' % lines
heading = html.heading(
diff --git a/Lib/runpy.py b/Lib/runpy.py
index 4738df3..31e5e55 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -226,7 +226,7 @@
code = read_code(f)
if code is None:
# That didn't work, so try it as normal source code
- with open(fname, "rU") as f:
+ with open(fname, "rb") as f:
code = compile(f.read(), fname, 'exec')
return code
diff --git a/Lib/ssl.py b/Lib/ssl.py
index e9e9aa8..ce9ebdf 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -77,6 +77,8 @@
)
from _ssl import HAS_SNI
from _ssl import PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
+from _ssl import _OPENSSL_API_VERSION
+
_PROTOCOL_NAMES = {
PROTOCOL_TLSv1: "TLSv1",
PROTOCOL_SSLv23: "SSLv23",
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 06285e9..0523219 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -450,7 +450,7 @@
while True:
try:
return func(*args)
- except OSError as e:
+ except (OSError, IOError) as e:
if e.errno == errno.EINTR:
continue
raise
@@ -804,10 +804,10 @@
raise
self.stdin.close()
elif self.stdout:
- stdout = self.stdout.read()
+ stdout = _eintr_retry_call(self.stdout.read)
self.stdout.close()
elif self.stderr:
- stderr = self.stderr.read()
+ stderr = _eintr_retry_call(self.stderr.read)
self.stderr.close()
self.wait()
return (stdout, stderr)
diff --git a/Lib/test/data/README b/Lib/test/data/README
index 8bf8c9b..bd05984 100644
--- a/Lib/test/data/README
+++ b/Lib/test/data/README
@@ -1,2 +1,2 @@
This empty directory serves as destination for temporary files
-created by some tests.
+created by some tests, in particular, the test_codecmaps_* tests.
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 76f4249..46ddc82 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -566,6 +566,33 @@
del g
self.assertEqual(sys.exc_info()[0], TypeError)
+ def test_generator_leaking2(self):
+ # See issue 12475.
+ def g():
+ yield
+ try:
+ raise RuntimeError
+ except RuntimeError:
+ it = g()
+ next(it)
+ try:
+ next(it)
+ except StopIteration:
+ pass
+ self.assertEqual(sys.exc_info(), (None, None, None))
+
+ def test_generator_doesnt_retain_old_exc(self):
+ def g():
+ self.assertIsInstance(sys.exc_info()[1], RuntimeError)
+ yield
+ self.assertEqual(sys.exc_info(), (None, None, None))
+ it = g()
+ try:
+ raise RuntimeError
+ except RuntimeError:
+ next(it)
+ self.assertRaises(StopIteration, next, it)
+
def test_generator_finalizing_and_exc_info(self):
# See #7173
def simple_gen():
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index 2a6d047..178761d 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -1,7 +1,8 @@
import io
import unittest
import urllib.robotparser
-from urllib.error import URLError
+from urllib.error import URLError, HTTPError
+from urllib.request import urlopen
from test import support
class RobotTestCase(unittest.TestCase):
@@ -237,13 +238,27 @@
support.requires('network')
with support.transient_internet('mueblesmoraleda.com'):
url = 'http://mueblesmoraleda.com'
+ robots_url = url + "/robots.txt"
+ # First check the URL is usable for our purposes, since the
+ # test site is a bit flaky.
+ try:
+ urlopen(robots_url)
+ except HTTPError as e:
+ if e.code not in {401, 403}:
+ self.skipTest(
+ "%r should return a 401 or 403 HTTP error, not %r"
+ % (robots_url, e.code))
+ else:
+ self.skipTest(
+ "%r should return a 401 or 403 HTTP error, not succeed"
+ % (robots_url))
parser = urllib.robotparser.RobotFileParser()
parser.set_url(url)
try:
parser.read()
except URLError:
self.skipTest('%s is unavailable' % url)
- self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
+ self.assertEqual(parser.can_fetch("*", robots_url), False)
def testPythonOrg(self):
support.requires('network')
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index ad3ab39..7ffb6af 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -405,6 +405,16 @@
msg = "recursion depth exceeded"
self.assertRaisesRegex(RuntimeError, msg, run_path, zip_name)
+ def test_encoding(self):
+ with temp_dir() as script_dir:
+ filename = os.path.join(script_dir, 'script.py')
+ with open(filename, 'w', encoding='latin1') as f:
+ f.write("""
+#coding:latin1
+"non-ASCII: h\xe9"
+""")
+ result = run_path(filename)
+ self.assertEqual(result['__doc__'], "non-ASCII: h\xe9")
def test_main():
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index ede6545..8df1bf0 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -11,7 +11,7 @@
import unittest
from test import support
from contextlib import closing
-from test.script_helper import spawn_python
+from test.script_helper import assert_python_ok, spawn_python
if sys.platform in ('os2', 'riscos'):
raise unittest.SkipTest("Can't test signal on %s" % sys.platform)
@@ -233,49 +233,80 @@
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
class WakeupSignalTests(unittest.TestCase):
- TIMEOUT_FULL = 10
- TIMEOUT_HALF = 5
+ def check_wakeup(self, test_body):
+ # use a subprocess to have only one thread and to not change signal
+ # handling of the parent process
+ code = """if 1:
+ import fcntl
+ import os
+ import signal
+
+ def handler(signum, frame):
+ pass
+
+ {}
+
+ signal.signal(signal.SIGALRM, handler)
+ read, write = os.pipe()
+ flags = fcntl.fcntl(write, fcntl.F_GETFL, 0)
+ flags = flags | os.O_NONBLOCK
+ fcntl.fcntl(write, fcntl.F_SETFL, flags)
+ signal.set_wakeup_fd(write)
+
+ test()
+
+ os.close(read)
+ os.close(write)
+ """.format(test_body)
+
+ assert_python_ok('-c', code)
def test_wakeup_fd_early(self):
- import select
+ self.check_wakeup("""def test():
+ import select
+ import time
- signal.alarm(1)
- before_time = time.time()
- # We attempt to get a signal during the sleep,
- # before select is called
- time.sleep(self.TIMEOUT_FULL)
- mid_time = time.time()
- self.assertTrue(mid_time - before_time < self.TIMEOUT_HALF)
- select.select([self.read], [], [], self.TIMEOUT_FULL)
- after_time = time.time()
- self.assertTrue(after_time - mid_time < self.TIMEOUT_HALF)
+ TIMEOUT_FULL = 10
+ TIMEOUT_HALF = 5
+
+ signal.alarm(1)
+ before_time = time.time()
+ # We attempt to get a signal during the sleep,
+ # before select is called
+ time.sleep(TIMEOUT_FULL)
+ mid_time = time.time()
+ dt = mid_time - before_time
+ if dt >= TIMEOUT_HALF:
+ raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
+ select.select([read], [], [], TIMEOUT_FULL)
+ after_time = time.time()
+ dt = after_time - mid_time
+ if dt >= TIMEOUT_HALF:
+ raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
+ """)
def test_wakeup_fd_during(self):
- import select
+ self.check_wakeup("""def test():
+ import select
+ import time
- signal.alarm(1)
- before_time = time.time()
- # We attempt to get a signal during the select call
- self.assertRaises(select.error, select.select,
- [self.read], [], [], self.TIMEOUT_FULL)
- after_time = time.time()
- self.assertTrue(after_time - before_time < self.TIMEOUT_HALF)
+ TIMEOUT_FULL = 10
+ TIMEOUT_HALF = 5
- def setUp(self):
- import fcntl
-
- self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None)
- self.read, self.write = os.pipe()
- flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0)
- flags = flags | os.O_NONBLOCK
- fcntl.fcntl(self.write, fcntl.F_SETFL, flags)
- self.old_wakeup = signal.set_wakeup_fd(self.write)
-
- def tearDown(self):
- signal.set_wakeup_fd(self.old_wakeup)
- os.close(self.read)
- os.close(self.write)
- signal.signal(signal.SIGALRM, self.alrm)
+ signal.alarm(1)
+ before_time = time.time()
+ # We attempt to get a signal during the select call
+ try:
+ select.select([read], [], [], TIMEOUT_FULL)
+ except select.error:
+ pass
+ else:
+ raise Exception("select.error not raised")
+ after_time = time.time()
+ dt = after_time - before_time
+ if dt >= TIMEOUT_HALF:
+ raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
+ """)
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
class SiginterruptTest(unittest.TestCase):
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 7edf5b2..869381a 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -60,7 +60,7 @@
def can_clear_options():
# 0.9.8m or higher
- return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 13, 15)
+ return ssl._OPENSSL_API_VERSION >= (0, 9, 8, 13, 15)
def no_sslv2_implies_sslv3_hello():
# 0.9.7h or higher
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 4a563b9..08f0ecf 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -675,6 +675,24 @@
time.sleep(2)
p.communicate(b"x" * 2**20)
+ @unittest.skipUnless(hasattr(signal, 'SIGALRM'),
+ "Requires signal.SIGALRM")
+ def test_communicate_eintr(self):
+ # Issue #12493: communicate() should handle EINTR
+ def handler(signum, frame):
+ pass
+ old_handler = signal.signal(signal.SIGALRM, handler)
+ self.addCleanup(signal.signal, signal.SIGALRM, old_handler)
+
+ # the process is running for 2 seconds
+ args = [sys.executable, "-c", 'import time; time.sleep(2)']
+ for stream in ('stdout', 'stderr'):
+ kw = {stream: subprocess.PIPE}
+ with subprocess.Popen(args, **kw) as process:
+ signal.alarm(1)
+ # communicate() will be interrupted by SIGALRM
+ process.communicate()
+
# context manager
class _SuppressCoreFiles(object):
diff --git a/Lib/test/test_tk.py b/Lib/test/test_tk.py
index ab979fa..f993c53 100644
--- a/Lib/test/test_tk.py
+++ b/Lib/test/test_tk.py
@@ -2,15 +2,11 @@
# Skip test if _tkinter wasn't built.
support.import_module('_tkinter')
-import tkinter
-from tkinter.test import runtktests
-import unittest
+# Skip test if tk cannot be initialized.
+from tkinter.test.support import check_tk_availability
+check_tk_availability()
-try:
- tkinter.Button()
-except tkinter.TclError as msg:
- # assuming tk is not available
- raise unittest.SkipTest("tk not available: %s" % msg)
+from tkinter.test import runtktests
def test_main(enable_gui=False):
if enable_gui:
diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py
index bff4fc1..b8c1a4c 100644
--- a/Lib/test/test_ttk_guionly.py
+++ b/Lib/test/test_ttk_guionly.py
@@ -5,6 +5,10 @@
# Skip this test if _tkinter wasn't built.
support.import_module('_tkinter')
+# Skip test if tk cannot be initialized.
+from tkinter.test.support import check_tk_availability
+check_tk_availability()
+
from _tkinter import TclError
from tkinter import ttk
from tkinter.test import runtktests
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 97be587..885e740 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -788,6 +788,7 @@
self.assertEqual('%c' % '\U00021483', '\U00021483')
self.assertRaises(TypeError, "%c".__mod__, "aa")
self.assertRaises(ValueError, "%.1\u1032f".__mod__, (1.0/3))
+ self.assertRaises(TypeError, "%i".__mod__, "aa")
# formatting jobs delegated from the string implementation:
self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
diff --git a/Lib/tkinter/test/support.py b/Lib/tkinter/test/support.py
index 97212fb..6dd6d4a 100644
--- a/Lib/tkinter/test/support.py
+++ b/Lib/tkinter/test/support.py
@@ -1,6 +1,52 @@
+import sys
import tkinter
+import unittest
+
+_tk_unavailable = None
+
+def check_tk_availability():
+ """Check that Tk is installed and available."""
+ global _tk_unavailable
+
+ if _tk_unavailable is None:
+ _tk_unavailable = False
+ if sys.platform == 'darwin':
+ # The Aqua Tk implementations on OS X can abort the process if
+ # being called in an environment where a window server connection
+ # cannot be made, for instance when invoked by a buildbot or ssh
+ # process not running under the same user id as the current console
+ # user. To avoid that, raise an exception if the window manager
+ # connection is not available.
+ from ctypes import cdll, c_int, pointer, Structure
+ from ctypes.util import find_library
+
+ app_services = cdll.LoadLibrary(find_library("ApplicationServices"))
+
+ if app_services.CGMainDisplayID() == 0:
+ _tk_unavailable = "cannot run without OS X window manager"
+ else:
+ class ProcessSerialNumber(Structure):
+ _fields_ = [("highLongOfPSN", c_int),
+ ("lowLongOfPSN", c_int)]
+ psn = ProcessSerialNumber()
+ psn_p = pointer(psn)
+ if ( (app_services.GetCurrentProcess(psn_p) < 0) or
+ (app_services.SetFrontProcess(psn_p) < 0) ):
+ _tk_unavailable = "cannot run without OS X gui process"
+ else: # not OS X
+ import tkinter
+ try:
+ tkinter.Button()
+ except tkinter.TclError as msg:
+ # assuming tk is not available
+ _tk_unavailable = "tk not available: %s" % msg
+
+ if _tk_unavailable:
+ raise unittest.SkipTest(_tk_unavailable)
+ return
def get_tk_root():
+ check_tk_availability() # raise exception if tk unavailable
try:
root = tkinter._default_root
except AttributeError:
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py
index 81a36b0..d5ac8b2 100644
--- a/Lib/xml/dom/pulldom.py
+++ b/Lib/xml/dom/pulldom.py
@@ -326,7 +326,7 @@
if bufsize is None:
bufsize = default_bufsize
if isinstance(stream_or_string, str):
- stream = open(stream_or_string)
+ stream = open(stream_or_string, 'rb')
else:
stream = stream_or_string
if not parser:
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 694faad..dfa7219 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -910,6 +910,7 @@
XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
tkinter/test/test_ttk site-packages test \
+ test/capath test/data \
test/cjkencodings test/decimaltestdata test/xmltestdata test/subprocessdata \
test/tracedmodules test/encoded_modules \
concurrent concurrent/futures encodings \
diff --git a/Misc/NEWS b/Misc/NEWS
index cd4fac9..9a46b72 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -5,14 +5,67 @@
What's New in Python 3.2.2?
===========================
-*Release date: XXXX-XX-XX*
+*Release date: XX-XXX-2011*
Core and Builtins
-----------------
+- Issue #9611, #9015: FileIO.read() clamps the length to INT_MAX on Windows.
+
+- When a generator yields, do not retain the caller's exception state on the
+ generator.
+
+- Issue #12475: Prevent generators from leaking their exception state into the
+ caller's frame as they return for the last time.
+
Library
-------
+- Issue #12493: subprocess: Popen.communicate() now also handles EINTR errors
+ if the process has only one pipe.
+
+- Issue #12451: pydoc: html_getfile() now uses tokenize.open() to support
+ Python scripts using a encoding different than UTF-8 (read the coding cookie
+ of the script).
+
+- Issue #12451: pydoc: importfile() now opens the Python script in binary mode,
+ instead of text mode using the locale encoding, to avoid encoding issues.
+
+- Issue #12451: runpy: run_path() now opens the Python script in binary mode,
+ instead of text mode using the locale encoding, to support other encodings
+ than UTF-8 (scripts using the coding cookie).
+
+- Issue #12451: xml.dom.pulldom: parse() now opens files in binary mode instead
+ of the text mode (using the locale encoding) to avoid encoding issues.
+
+C-API
+-----
+
+Tests
+-----
+
+- Avoid failing in test_robotparser when mueblesmoraleda.com is flaky and
+ an overzealous DNS service (e.g. OpenDNS) redirects to a placeholder
+ Web site.
+
+- Issue #12440: When testing whether some bits in SSLContext.options can be
+ reset, check the version of the OpenSSL headers Python was compiled against,
+ rather than the runtime version of the OpenSSL library.
+
+- Issue #12497: Install test/data to prevent failures of the various codecmaps
+ tests.
+
+- Issue #12496: Install test/capath directory to prevent test_connect_capath
+ testcase failure in test_ssl.
+
+- Issue #12469: Run "wakeup" signal tests in subprocess to run the test in a
+ fresh process with only one thread and to not change signal handling of the
+ parent process.
+
+- Issue #8716: Avoid crashes caused by Aqua Tk on OSX when attempting to run
+ test_tk or test_ttk_guionly under a username that is not currently logged
+ in to the console windowserver (as may be the case under buildbot or ssh).
+
What's New in Python 3.2.1?
===========================
@@ -876,7 +929,7 @@
(length bigger than 2^31-1 bytes).
- Issue #9015, #9611: FileIO.readinto(), FileIO.write(), os.write() and
- stdprinter.write() clamp the length to 2^31-1 on Windows.
+ stdprinter.write() clamp the length to INT_MAX on Windows.
- Issue #8278: On Windows and with a NTFS filesystem, os.stat() and os.utime()
can now handle dates after 2038.
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 141b6de..b1d492b 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -664,6 +664,10 @@
return fileio_readall(self);
}
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ if (size > INT_MAX)
+ size = INT_MAX;
+#endif
bytes = PyBytes_FromStringAndSize(NULL, size);
if (bytes == NULL)
return NULL;
@@ -672,7 +676,11 @@
if (_PyVerify_fd(self->fd)) {
Py_BEGIN_ALLOW_THREADS
errno = 0;
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ n = read(self->fd, ptr, (int)size);
+#else
n = read(self->fd, ptr, size);
+#endif
Py_END_ALLOW_THREADS
} else
n = -1;
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index a813d5f..27dcdbc 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -2037,6 +2037,24 @@
NULL
};
+
+static void
+parse_openssl_version(unsigned long libver,
+ unsigned int *major, unsigned int *minor,
+ unsigned int *fix, unsigned int *patch,
+ unsigned int *status)
+{
+ *status = libver & 0xF;
+ libver >>= 4;
+ *patch = libver & 0xFF;
+ libver >>= 8;
+ *fix = libver & 0xFF;
+ libver >>= 8;
+ *minor = libver & 0xFF;
+ libver >>= 8;
+ *major = libver & 0xFF;
+}
+
PyMODINIT_FUNC
PyInit__ssl(void)
{
@@ -2149,15 +2167,7 @@
return NULL;
if (PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r))
return NULL;
- status = libver & 0xF;
- libver >>= 4;
- patch = libver & 0xFF;
- libver >>= 8;
- fix = libver & 0xFF;
- libver >>= 8;
- minor = libver & 0xFF;
- libver >>= 8;
- major = libver & 0xFF;
+ parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r))
return NULL;
@@ -2165,5 +2175,11 @@
if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r))
return NULL;
+ libver = OPENSSL_VERSION_NUMBER;
+ parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
+ r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
+ if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r))
+ return NULL;
+
return m;
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7a70a5e..03807a4 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9689,8 +9689,6 @@
case 'o':
case 'x':
case 'X':
- if (c == 'i')
- c = 'd';
isnumok = 0;
if (PyNumber_Check(v)) {
PyObject *iobj=NULL;
@@ -9705,7 +9703,7 @@
if (iobj!=NULL) {
if (PyLong_Check(iobj)) {
isnumok = 1;
- temp = formatlong(iobj, flags, prec, c);
+ temp = formatlong(iobj, flags, prec, (c == 'i'? 'd': c));
Py_DECREF(iobj);
if (!temp)
goto onError;
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 07fd683..615a2d3 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -517,6 +517,7 @@
}
else {
const char *module_str = _PyUnicode_AsString(*module);
+ *filename = NULL;
if (module_str == NULL)
goto handle_error;
if (strcmp(module_str, "__main__") == 0) {
diff --git a/Python/ceval.c b/Python/ceval.c
index 705ed41..5c3bb83 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1145,6 +1145,23 @@
f->f_exc_traceback = tmp; \
}
+#define RESTORE_AND_CLEAR_EXC_STATE() \
+ { \
+ PyObject *type, *value, *tb; \
+ type = tstate->exc_type; \
+ value = tstate->exc_value; \
+ tb = tstate->exc_traceback; \
+ tstate->exc_type = f->f_exc_type; \
+ tstate->exc_value = f->f_exc_value; \
+ tstate->exc_traceback = f->f_exc_traceback; \
+ f->f_exc_type = NULL; \
+ f->f_exc_value = NULL; \
+ f->f_exc_traceback = NULL; \
+ Py_XDECREF(type); \
+ Py_XDECREF(value); \
+ Py_XDECREF(tb); \
+ }
+
/* Start of code */
if (f == NULL)
@@ -1881,10 +1898,6 @@
retval = POP();
f->f_stacktop = stack_pointer;
why = WHY_YIELD;
- /* Put aside the current exception state and restore
- that of the calling frame. This only serves when
- "yield" is used inside an except handler. */
- SWAP_EXC_STATE();
goto fast_yield;
TARGET(POP_EXCEPT)
@@ -3021,6 +3034,26 @@
retval = NULL;
fast_yield:
+ if (co->co_flags & CO_GENERATOR && (why == WHY_YIELD || why == WHY_RETURN)) {
+ /* The purpose of this block is to put aside the generator's exception
+ state and restore that of the calling frame. If the current
+ exception state is from the caller, we clear the exception values
+ on the generator frame, so they are not swapped back in latter. The
+ origin of the current exception state is determined by checking for
+ except handler blocks, which we must be in iff a new exception
+ state came into existence in this frame. (An uncaught exception
+ would have why == WHY_EXCEPTION, and we wouldn't be here). */
+ int i;
+ for (i = 0; i < f->f_iblock; i++)
+ if (f->f_blockstack[i].b_type == EXCEPT_HANDLER)
+ break;
+ if (i == f->f_iblock)
+ /* We did not create this exception. */
+ RESTORE_AND_CLEAR_EXC_STATE()
+ else
+ SWAP_EXC_STATE()
+ }
+
if (tstate->use_tracing) {
if (tstate->c_tracefunc) {
if (why == WHY_RETURN || why == WHY_YIELD) {