summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/c-api/bytearray.rst6
-rw-r--r--Doc/c-api/type.rst9
-rw-r--r--Doc/library/codecs.rst3
-rw-r--r--Doc/library/http.cookies.rst6
-rw-r--r--Doc/library/os.rst2
-rw-r--r--Doc/tutorial/controlflow.rst4
-rw-r--r--Doc/tutorial/interpreter.rst4
-rw-r--r--Include/object.h1
-rw-r--r--Lib/collections.py5
-rw-r--r--Lib/distutils/command/bdist_wininst.py6
-rw-r--r--Lib/locale.py179
-rw-r--r--Lib/subprocess.py2
-rw-r--r--Lib/tarfile.py1
-rw-r--r--Lib/test/pydoc_mod.py27
-rw-r--r--Lib/test/test_subprocess.py18
-rw-r--r--Lib/test/test_tarfile.py16
-rw-r--r--Lib/xmlrpc/client.py1
-rw-r--r--Objects/setobject.c4
-rw-r--r--Objects/typeobject.c19
-rw-r--r--Objects/unicodeobject.c6
-rw-r--r--Python/bltinmodule.c4
21 files changed, 247 insertions, 76 deletions
diff --git a/Doc/c-api/bytearray.rst b/Doc/c-api/bytearray.rst
index 1b0f377..b90b3ff 100644
--- a/Doc/c-api/bytearray.rst
+++ b/Doc/c-api/bytearray.rst
@@ -10,7 +10,7 @@ Byte Array Objects
.. ctype:: PyByteArrayObject
- This subtype of :ctype:`PyObject` represents a Python string object.
+ This subtype of :ctype:`PyObject` represents a Python bytearray object.
.. cvar:: PyTypeObject PyByteArray_Type
@@ -36,10 +36,12 @@ Byte Array Objects
Return a new bytearray object from any object, *o*, that implements the
buffer protocol.
+ .. XXX expand about the buffer protocol, at least somewhere
+
.. cfunction:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
- Create a new bytearray object from *string* and it's length, *len*. On
+ Create a new bytearray object from *string* and its length, *len*. On
failure, *NULL* is returned.
diff --git a/Doc/c-api/type.rst b/Doc/c-api/type.rst
index bc0eeef..07f82c9 100644
--- a/Doc/c-api/type.rst
+++ b/Doc/c-api/type.rst
@@ -35,7 +35,14 @@ Type Objects
.. cfunction:: unsigned int PyType_ClearCache(void)
- Clears the internal lookup cache. Return the current version tag.
+ Clear the internal lookup cache. Return the current version tag.
+
+
+.. cfunction:: void PyType_Modified(PyTypeObject *type)
+
+ Invalidate the internal lookup cache for the type and all of its
+ subtypes. This function must be called after any manual
+ modification of the attributes or base classes of the type.
.. cfunction:: int PyType_HasFeature(PyObject *o, int feature)
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst
index 42273051..29f0350 100644
--- a/Doc/library/codecs.rst
+++ b/Doc/library/codecs.rst
@@ -285,7 +285,8 @@ Codec Base Classes
------------------
The :mod:`codecs` module defines a set of base classes which define the
-interface and can also be used to easily write you own codecs for use in Python.
+interface and can also be used to easily write your own codecs for use in
+Python.
Each codec has to define four interfaces to make it usable as codec in Python:
stateless encoder, stateless decoder, stream reader and stream writer. The
diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst
index 533e963..9bffa40 100644
--- a/Doc/library/http.cookies.rst
+++ b/Doc/library/http.cookies.rst
@@ -17,6 +17,12 @@ The module formerly strictly applied the parsing rules described in the
MSIE 3.0x doesn't follow the character rules outlined in those specs. As a
result, the parsing rules used are a bit less strict.
+.. note::
+
+ On encountering an invalid cookie, :exc:`CookieError` is raised, so if your
+ cookie data comes from a browser you should always prepare for invalid data
+ and catch :exc:`CookieError` on parsing.
+
.. exception:: CookieError
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 844f488..33d42da 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1748,7 +1748,7 @@ Miscellaneous System Information
Return the number of processes in the system run queue averaged over the last
1, 5, and 15 minutes or raises :exc:`OSError` if the load average was
- unobtainable.
+ unobtainable. Availability: Unix.
.. function:: sysconf(name)
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 280c028..c21e531 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -475,8 +475,8 @@ called with an arbitrary number of arguments. These arguments will be wrapped
up in a tuple. Before the variable number of arguments, zero or more normal
arguments may occur. ::
- def fprintf(file, template, *args):
- file.write(template.format(args))
+ def write_multiple_items(file, separator, *args):
+ file.write(separator.join(args))
Normally, these ``variadic`` arguments will be last in the list of formal
diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst
index 42fc6e1..27a91d0 100644
--- a/Doc/tutorial/interpreter.rst
+++ b/Doc/tutorial/interpreter.rst
@@ -51,8 +51,8 @@ and executes a *script* from that file.
A second way of starting the interpreter is ``python -c command [arg] ...``,
which executes the statement(s) in *command*, analogous to the shell's
:option:`-c` option. Since Python statements often contain spaces or other
-characters that are special to the shell, it is best to quote *command* in its
-entirety with double quotes.
+characters that are special to the shell, it is usually advised to quote
+*command* in its entirety with single quotes.
Some Python modules are also useful as scripts. These can be invoked using
``python -m module [arg] ...``, which executes the source file for *module* as
diff --git a/Include/object.h b/Include/object.h
index e924131..92388cf 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -417,6 +417,7 @@ PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
PyAPI_FUNC(unsigned int) PyType_ClearCache(void);
+PyAPI_FUNC(void) PyType_Modified(PyTypeObject *);
/* Generic operations on objects */
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
diff --git a/Lib/collections.py b/Lib/collections.py
index f746145..73fc150 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -93,8 +93,9 @@ def namedtuple(typename, field_names, verbose=False):
if verbose:
print(template)
- # Execute the template string in a temporary namespace
- namespace = dict(itemgetter=_itemgetter)
+ # Execute the template string in a temporary namespace and
+ # support tracing utilities by setting a value for frame.f_globals['__name__']
+ namespace = dict(itemgetter=_itemgetter, __name__='namedtuple_%s' % typename)
try:
exec(template, namespace)
except SyntaxError as e:
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index 3f0e09b..ae7d4fd 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -75,6 +75,12 @@ class bdist_wininst(Command):
def finalize_options(self):
if self.bdist_dir is None:
+ if self.skip_build and self.plat_name:
+ # If build is skipped and plat_name is overridden, bdist will
+ # not see the correct 'plat_name' - so set that up manually.
+ bdist = self.distribution.get_command_obj('bdist')
+ bdist.plat_name = self.plat_name
+ # next the command will be initialized using that name
bdist_base = self.get_finalized_command('bdist').bdist_base
self.bdist_dir = os.path.join(bdist_base, 'wininst')
if not self.target_version:
diff --git a/Lib/locale.py b/Lib/locale.py
index eb8b33d..2f8cd85 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -626,6 +626,33 @@ locale_encoding_alias = {
# updated 'zh_cn.big5' -> 'zh_TW.eucTW' to 'zh_TW.big5'
# updated 'zh_tw' -> 'zh_TW.eucTW' to 'zh_TW.big5'
#
+# MAL 2008-05-30:
+# Updated alias mapping to most recent locale.alias file
+# from X.org distribution using makelocalealias.py.
+#
+# These are the differences compared to the old mapping (Python 2.5
+# and older):
+#
+# updated 'cs_cs.iso88592' -> 'cs_CZ.ISO8859-2' to 'cs_CS.ISO8859-2'
+# updated 'serbocroatian' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
+# updated 'sh' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
+# updated 'sh_hr.iso88592' -> 'sh_HR.ISO8859-2' to 'hr_HR.ISO8859-2'
+# updated 'sh_sp' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
+# updated 'sh_yu' -> 'sh_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
+# updated 'sp' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+# updated 'sp_yu' -> 'sp_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+# updated 'sr' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+# updated 'sr@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+# updated 'sr_sp' -> 'sr_SP.ISO8859-2' to 'sr_CS.ISO8859-2'
+# updated 'sr_yu' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+# updated 'sr_yu.cp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
+# updated 'sr_yu.iso88592' -> 'sr_YU.ISO8859-2' to 'sr_CS.ISO8859-2'
+# updated 'sr_yu.iso88595' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+# updated 'sr_yu.iso88595@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+# updated 'sr_yu.microsoftcp1251@cyrillic' -> 'sr_YU.CP1251' to 'sr_CS.CP1251'
+# updated 'sr_yu.utf8@cyrillic' -> 'sr_YU.UTF-8' to 'sr_CS.UTF-8'
+# updated 'sr_yu@cyrillic' -> 'sr_YU.ISO8859-5' to 'sr_CS.ISO8859-5'
+
locale_alias = {
'a3': 'a3_AZ.KOI8-C',
'a3_az': 'a3_AZ.KOI8-C',
@@ -634,30 +661,46 @@ locale_alias = {
'af_za': 'af_ZA.ISO8859-1',
'af_za.iso88591': 'af_ZA.ISO8859-1',
'am': 'am_ET.UTF-8',
+ 'am_et': 'am_ET.UTF-8',
'american': 'en_US.ISO8859-1',
'american.iso88591': 'en_US.ISO8859-1',
'ar': 'ar_AA.ISO8859-6',
'ar_aa': 'ar_AA.ISO8859-6',
'ar_aa.iso88596': 'ar_AA.ISO8859-6',
'ar_ae': 'ar_AE.ISO8859-6',
+ 'ar_ae.iso88596': 'ar_AE.ISO8859-6',
'ar_bh': 'ar_BH.ISO8859-6',
+ 'ar_bh.iso88596': 'ar_BH.ISO8859-6',
'ar_dz': 'ar_DZ.ISO8859-6',
+ 'ar_dz.iso88596': 'ar_DZ.ISO8859-6',
'ar_eg': 'ar_EG.ISO8859-6',
'ar_eg.iso88596': 'ar_EG.ISO8859-6',
'ar_iq': 'ar_IQ.ISO8859-6',
+ 'ar_iq.iso88596': 'ar_IQ.ISO8859-6',
'ar_jo': 'ar_JO.ISO8859-6',
+ 'ar_jo.iso88596': 'ar_JO.ISO8859-6',
'ar_kw': 'ar_KW.ISO8859-6',
+ 'ar_kw.iso88596': 'ar_KW.ISO8859-6',
'ar_lb': 'ar_LB.ISO8859-6',
+ 'ar_lb.iso88596': 'ar_LB.ISO8859-6',
'ar_ly': 'ar_LY.ISO8859-6',
+ 'ar_ly.iso88596': 'ar_LY.ISO8859-6',
'ar_ma': 'ar_MA.ISO8859-6',
+ 'ar_ma.iso88596': 'ar_MA.ISO8859-6',
'ar_om': 'ar_OM.ISO8859-6',
+ 'ar_om.iso88596': 'ar_OM.ISO8859-6',
'ar_qa': 'ar_QA.ISO8859-6',
+ 'ar_qa.iso88596': 'ar_QA.ISO8859-6',
'ar_sa': 'ar_SA.ISO8859-6',
'ar_sa.iso88596': 'ar_SA.ISO8859-6',
'ar_sd': 'ar_SD.ISO8859-6',
+ 'ar_sd.iso88596': 'ar_SD.ISO8859-6',
'ar_sy': 'ar_SY.ISO8859-6',
+ 'ar_sy.iso88596': 'ar_SY.ISO8859-6',
'ar_tn': 'ar_TN.ISO8859-6',
+ 'ar_tn.iso88596': 'ar_TN.ISO8859-6',
'ar_ye': 'ar_YE.ISO8859-6',
+ 'ar_ye.iso88596': 'ar_YE.ISO8859-6',
'arabic': 'ar_AA.ISO8859-6',
'arabic.iso88596': 'ar_AA.ISO8859-6',
'az': 'az_AZ.ISO8859-9E',
@@ -673,6 +716,7 @@ locale_alias = {
'bg_bg.iso88595': 'bg_BG.ISO8859-5',
'bg_bg.koi8r': 'bg_BG.KOI8-R',
'bg_bg.microsoftcp1251': 'bg_BG.CP1251',
+ 'bn_in': 'bn_IN.UTF-8',
'bokmal': 'nb_NO.ISO8859-1',
'bokm\xe5l': 'nb_NO.ISO8859-1',
'br': 'br_FR.ISO8859-1',
@@ -680,7 +724,12 @@ locale_alias = {
'br_fr.iso88591': 'br_FR.ISO8859-1',
'br_fr.iso885914': 'br_FR.ISO8859-14',
'br_fr.iso885915': 'br_FR.ISO8859-15',
+ 'br_fr.iso885915@euro': 'br_FR.ISO8859-15',
+ 'br_fr.utf8@euro': 'br_FR.UTF-8',
'br_fr@euro': 'br_FR.ISO8859-15',
+ 'bs': 'bs_BA.ISO8859-2',
+ 'bs_ba': 'bs_BA.ISO8859-2',
+ 'bs_ba.iso88592': 'bs_BA.ISO8859-2',
'bulgarian': 'bg_BG.CP1251',
'c': 'C',
'c-french': 'fr_CA.ISO8859-1',
@@ -693,6 +742,8 @@ locale_alias = {
'ca_es': 'ca_ES.ISO8859-1',
'ca_es.iso88591': 'ca_ES.ISO8859-1',
'ca_es.iso885915': 'ca_ES.ISO8859-15',
+ 'ca_es.iso885915@euro': 'ca_ES.ISO8859-15',
+ 'ca_es.utf8@euro': 'ca_ES.UTF-8',
'ca_es@euro': 'ca_ES.ISO8859-15',
'catalan': 'ca_ES.ISO8859-1',
'cextend': 'en_US.ISO8859-1',
@@ -702,7 +753,7 @@ locale_alias = {
'croatian': 'hr_HR.ISO8859-2',
'cs': 'cs_CZ.ISO8859-2',
'cs_cs': 'cs_CZ.ISO8859-2',
- 'cs_cs.iso88592': 'cs_CZ.ISO8859-2',
+ 'cs_cs.iso88592': 'cs_CS.ISO8859-2',
'cs_cz': 'cs_CZ.ISO8859-2',
'cs_cz.iso88592': 'cs_CZ.ISO8859-2',
'cy': 'cy_GB.ISO8859-1',
@@ -728,10 +779,14 @@ locale_alias = {
'de_at': 'de_AT.ISO8859-1',
'de_at.iso88591': 'de_AT.ISO8859-1',
'de_at.iso885915': 'de_AT.ISO8859-15',
+ 'de_at.iso885915@euro': 'de_AT.ISO8859-15',
+ 'de_at.utf8@euro': 'de_AT.UTF-8',
'de_at@euro': 'de_AT.ISO8859-15',
'de_be': 'de_BE.ISO8859-1',
'de_be.iso88591': 'de_BE.ISO8859-1',
'de_be.iso885915': 'de_BE.ISO8859-15',
+ 'de_be.iso885915@euro': 'de_BE.ISO8859-15',
+ 'de_be.utf8@euro': 'de_BE.UTF-8',
'de_be@euro': 'de_BE.ISO8859-15',
'de_ch': 'de_CH.ISO8859-1',
'de_ch.iso88591': 'de_CH.ISO8859-1',
@@ -743,10 +798,14 @@ locale_alias = {
'de_de.885915@euro': 'de_DE.ISO8859-15',
'de_de.iso88591': 'de_DE.ISO8859-1',
'de_de.iso885915': 'de_DE.ISO8859-15',
+ 'de_de.iso885915@euro': 'de_DE.ISO8859-15',
+ 'de_de.utf8@euro': 'de_DE.UTF-8',
'de_de@euro': 'de_DE.ISO8859-15',
'de_lu': 'de_LU.ISO8859-1',
'de_lu.iso88591': 'de_LU.ISO8859-1',
'de_lu.iso885915': 'de_LU.ISO8859-15',
+ 'de_lu.iso885915@euro': 'de_LU.ISO8859-15',
+ 'de_lu.utf8@euro': 'de_LU.UTF-8',
'de_lu@euro': 'de_LU.ISO8859-15',
'deutsch': 'de_DE.ISO8859-1',
'dutch': 'nl_NL.ISO8859-1',
@@ -766,6 +825,7 @@ locale_alias = {
'en_be': 'en_BE.ISO8859-1',
'en_be@euro': 'en_BE.ISO8859-15',
'en_bw': 'en_BW.ISO8859-1',
+ 'en_bw.iso88591': 'en_BW.ISO8859-1',
'en_ca': 'en_CA.ISO8859-1',
'en_ca.iso88591': 'en_CA.ISO8859-1',
'en_gb': 'en_GB.ISO8859-1',
@@ -774,15 +834,20 @@ locale_alias = {
'en_gb.iso885915': 'en_GB.ISO8859-15',
'en_gb@euro': 'en_GB.ISO8859-15',
'en_hk': 'en_HK.ISO8859-1',
+ 'en_hk.iso88591': 'en_HK.ISO8859-1',
'en_ie': 'en_IE.ISO8859-1',
'en_ie.iso88591': 'en_IE.ISO8859-1',
'en_ie.iso885915': 'en_IE.ISO8859-15',
+ 'en_ie.iso885915@euro': 'en_IE.ISO8859-15',
+ 'en_ie.utf8@euro': 'en_IE.UTF-8',
'en_ie@euro': 'en_IE.ISO8859-15',
'en_in': 'en_IN.ISO8859-1',
'en_nz': 'en_NZ.ISO8859-1',
'en_nz.iso88591': 'en_NZ.ISO8859-1',
'en_ph': 'en_PH.ISO8859-1',
+ 'en_ph.iso88591': 'en_PH.ISO8859-1',
'en_sg': 'en_SG.ISO8859-1',
+ 'en_sg.iso88591': 'en_SG.ISO8859-1',
'en_uk': 'en_GB.ISO8859-1',
'en_us': 'en_US.ISO8859-1',
'en_us.88591': 'en_US.ISO8859-1',
@@ -798,6 +863,7 @@ locale_alias = {
'en_za.iso885915': 'en_ZA.ISO8859-15',
'en_za@euro': 'en_ZA.ISO8859-15',
'en_zw': 'en_ZW.ISO8859-1',
+ 'en_zw.iso88591': 'en_ZW.ISO8859-1',
'eng_gb': 'en_GB.ISO8859-1',
'eng_gb.8859': 'en_GB.ISO8859-1',
'english': 'en_EN.ISO8859-1',
@@ -833,6 +899,8 @@ locale_alias = {
'es_es.88591': 'es_ES.ISO8859-1',
'es_es.iso88591': 'es_ES.ISO8859-1',
'es_es.iso885915': 'es_ES.ISO8859-15',
+ 'es_es.iso885915@euro': 'es_ES.ISO8859-15',
+ 'es_es.utf8@euro': 'es_ES.UTF-8',
'es_es@euro': 'es_ES.ISO8859-15',
'es_gt': 'es_GT.ISO8859-1',
'es_gt.iso88591': 'es_GT.ISO8859-1',
@@ -861,6 +929,7 @@ locale_alias = {
'es_sv.iso885915': 'es_SV.ISO8859-15',
'es_sv@euro': 'es_SV.ISO8859-15',
'es_us': 'es_US.ISO8859-1',
+ 'es_us.iso88591': 'es_US.ISO8859-1',
'es_uy': 'es_UY.ISO8859-1',
'es_uy.iso88591': 'es_UY.ISO8859-1',
'es_uy.iso885915': 'es_UY.ISO8859-15',
@@ -881,6 +950,8 @@ locale_alias = {
'eu_es': 'eu_ES.ISO8859-1',
'eu_es.iso88591': 'eu_ES.ISO8859-1',
'eu_es.iso885915': 'eu_ES.ISO8859-15',
+ 'eu_es.iso885915@euro': 'eu_ES.ISO8859-15',
+ 'eu_es.utf8@euro': 'eu_ES.UTF-8',
'eu_es@euro': 'eu_ES.ISO8859-15',
'fa': 'fa_IR.UTF-8',
'fa_ir': 'fa_IR.UTF-8',
@@ -890,6 +961,7 @@ locale_alias = {
'fi_fi.88591': 'fi_FI.ISO8859-1',
'fi_fi.iso88591': 'fi_FI.ISO8859-1',
'fi_fi.iso885915': 'fi_FI.ISO8859-15',
+ 'fi_fi.iso885915@euro': 'fi_FI.ISO8859-15',
'fi_fi.utf8@euro': 'fi_FI.UTF-8',
'fi_fi@euro': 'fi_FI.ISO8859-15',
'finnish': 'fi_FI.ISO8859-1',
@@ -904,6 +976,8 @@ locale_alias = {
'fr_be.88591': 'fr_BE.ISO8859-1',
'fr_be.iso88591': 'fr_BE.ISO8859-1',
'fr_be.iso885915': 'fr_BE.ISO8859-15',
+ 'fr_be.iso885915@euro': 'fr_BE.ISO8859-15',
+ 'fr_be.utf8@euro': 'fr_BE.UTF-8',
'fr_be@euro': 'fr_BE.ISO8859-15',
'fr_ca': 'fr_CA.ISO8859-1',
'fr_ca.88591': 'fr_CA.ISO8859-1',
@@ -919,11 +993,15 @@ locale_alias = {
'fr_fr.88591': 'fr_FR.ISO8859-1',
'fr_fr.iso88591': 'fr_FR.ISO8859-1',
'fr_fr.iso885915': 'fr_FR.ISO8859-15',
+ 'fr_fr.iso885915@euro': 'fr_FR.ISO8859-15',
+ 'fr_fr.utf8@euro': 'fr_FR.UTF-8',
'fr_fr@euro': 'fr_FR.ISO8859-15',
'fr_lu': 'fr_LU.ISO8859-1',
'fr_lu.88591': 'fr_LU.ISO8859-1',
'fr_lu.iso88591': 'fr_LU.ISO8859-1',
'fr_lu.iso885915': 'fr_LU.ISO8859-15',
+ 'fr_lu.iso885915@euro': 'fr_LU.ISO8859-15',
+ 'fr_lu.utf8@euro': 'fr_LU.UTF-8',
'fr_lu@euro': 'fr_LU.ISO8859-15',
'fran\xe7ais': 'fr_FR.ISO8859-1',
'fre_fr': 'fr_FR.ISO8859-1',
@@ -937,6 +1015,8 @@ locale_alias = {
'ga_ie.iso88591': 'ga_IE.ISO8859-1',
'ga_ie.iso885914': 'ga_IE.ISO8859-14',
'ga_ie.iso885915': 'ga_IE.ISO8859-15',
+ 'ga_ie.iso885915@euro': 'ga_IE.ISO8859-15',
+ 'ga_ie.utf8@euro': 'ga_IE.UTF-8',
'ga_ie@euro': 'ga_IE.ISO8859-15',
'galego': 'gl_ES.ISO8859-1',
'galician': 'gl_ES.ISO8859-1',
@@ -956,9 +1036,12 @@ locale_alias = {
'gl_es': 'gl_ES.ISO8859-1',
'gl_es.iso88591': 'gl_ES.ISO8859-1',
'gl_es.iso885915': 'gl_ES.ISO8859-15',
+ 'gl_es.iso885915@euro': 'gl_ES.ISO8859-15',
+ 'gl_es.utf8@euro': 'gl_ES.UTF-8',
'gl_es@euro': 'gl_ES.ISO8859-15',
'greek': 'el_GR.ISO8859-7',
'greek.iso88597': 'el_GR.ISO8859-7',
+ 'gu_in': 'gu_IN.UTF-8',
'gv': 'gv_GB.ISO8859-1',
'gv_gb': 'gv_GB.ISO8859-1',
'gv_gb.iso88591': 'gv_GB.ISO8859-1',
@@ -1009,6 +1092,8 @@ locale_alias = {
'it_it.88591': 'it_IT.ISO8859-1',
'it_it.iso88591': 'it_IT.ISO8859-1',
'it_it.iso885915': 'it_IT.ISO8859-15',
+ 'it_it.iso885915@euro': 'it_IT.ISO8859-15',
+ 'it_it.utf8@euro': 'it_IT.UTF-8',
'it_it@euro': 'it_IT.ISO8859-15',
'italian': 'it_IT.ISO8859-1',
'italian.iso88591': 'it_IT.ISO8859-1',
@@ -1048,6 +1133,8 @@ locale_alias = {
'kl_gl.iso88591': 'kl_GL.ISO8859-1',
'kl_gl.iso885915': 'kl_GL.ISO8859-15',
'kl_gl@euro': 'kl_GL.ISO8859-15',
+ 'km_kh': 'km_KH.UTF-8',
+ 'kn_in': 'kn_IN.UTF-8',
'ko': 'ko_KR.eucKR',
'ko_kr': 'ko_KR.eucKR',
'ko_kr.euc': 'ko_KR.eucKR',
@@ -1060,6 +1147,8 @@ locale_alias = {
'kw_gb.iso885914': 'kw_GB.ISO8859-14',
'kw_gb.iso885915': 'kw_GB.ISO8859-15',
'kw_gb@euro': 'kw_GB.ISO8859-15',
+ 'ky': 'ky_KG.UTF-8',
+ 'ky_kg': 'ky_KG.UTF-8',
'lithuanian': 'lt_LT.ISO8859-13',
'lo': 'lo_LA.MULELAO-1',
'lo_la': 'lo_LA.MULELAO-1',
@@ -1082,6 +1171,7 @@ locale_alias = {
'mk_mk.cp1251': 'mk_MK.CP1251',
'mk_mk.iso88595': 'mk_MK.ISO8859-5',
'mk_mk.microsoftcp1251': 'mk_MK.CP1251',
+ 'mr_in': 'mr_IN.UTF-8',
'ms': 'ms_MY.ISO8859-1',
'ms_my': 'ms_MY.ISO8859-1',
'ms_my.iso88591': 'ms_MY.ISO8859-1',
@@ -1099,11 +1189,15 @@ locale_alias = {
'nl_be.88591': 'nl_BE.ISO8859-1',
'nl_be.iso88591': 'nl_BE.ISO8859-1',
'nl_be.iso885915': 'nl_BE.ISO8859-15',
+ 'nl_be.iso885915@euro': 'nl_BE.ISO8859-15',
+ 'nl_be.utf8@euro': 'nl_BE.UTF-8',
'nl_be@euro': 'nl_BE.ISO8859-15',
'nl_nl': 'nl_NL.ISO8859-1',
'nl_nl.88591': 'nl_NL.ISO8859-1',
'nl_nl.iso88591': 'nl_NL.ISO8859-1',
'nl_nl.iso885915': 'nl_NL.ISO8859-15',
+ 'nl_nl.iso885915@euro': 'nl_NL.ISO8859-15',
+ 'nl_nl.utf8@euro': 'nl_NL.UTF-8',
'nl_nl@euro': 'nl_NL.ISO8859-15',
'nn': 'nn_NO.ISO8859-1',
'nn_no': 'nn_NO.ISO8859-1',
@@ -1120,6 +1214,12 @@ locale_alias = {
'no_no@euro': 'no_NO.ISO8859-15',
'norwegian': 'no_NO.ISO8859-1',
'norwegian.iso88591': 'no_NO.ISO8859-1',
+ 'nr': 'nr_ZA.ISO8859-1',
+ 'nr_za': 'nr_ZA.ISO8859-1',
+ 'nr_za.iso88591': 'nr_ZA.ISO8859-1',
+ 'nso': 'nso_ZA.ISO8859-15',
+ 'nso_za': 'nso_ZA.ISO8859-15',
+ 'nso_za.iso885915': 'nso_ZA.ISO8859-15',
'ny': 'ny_NO.ISO8859-1',
'ny_no': 'ny_NO.ISO8859-1',
'ny_no.88591': 'ny_NO.ISO8859-1',
@@ -1132,6 +1232,7 @@ locale_alias = {
'oc_fr.iso88591': 'oc_FR.ISO8859-1',
'oc_fr.iso885915': 'oc_FR.ISO8859-15',
'oc_fr@euro': 'oc_FR.ISO8859-15',
+ 'pa_in': 'pa_IN.UTF-8',
'pd': 'pd_US.ISO8859-1',
'pd_de': 'pd_DE.ISO8859-1',
'pd_de.iso88591': 'pd_DE.ISO8859-1',
@@ -1167,6 +1268,7 @@ locale_alias = {
'pt_pt.88591': 'pt_PT.ISO8859-1',
'pt_pt.iso88591': 'pt_PT.ISO8859-1',
'pt_pt.iso885915': 'pt_PT.ISO8859-15',
+ 'pt_pt.iso885915@euro': 'pt_PT.ISO8859-15',
'pt_pt.utf8@euro': 'pt_PT.UTF-8',
'pt_pt@euro': 'pt_PT.ISO8859-15',
'ro': 'ro_RO.ISO8859-2',
@@ -1185,13 +1287,19 @@ locale_alias = {
'ru_ua.microsoftcp1251': 'ru_UA.CP1251',
'rumanian': 'ro_RO.ISO8859-2',
'russian': 'ru_RU.ISO8859-5',
+ 'rw': 'rw_RW.ISO8859-1',
+ 'rw_rw': 'rw_RW.ISO8859-1',
+ 'rw_rw.iso88591': 'rw_RW.ISO8859-1',
'se_no': 'se_NO.UTF-8',
- 'serbocroatian': 'sh_YU.ISO8859-2',
- 'sh': 'sh_YU.ISO8859-2',
+ 'serbocroatian': 'sr_CS.ISO8859-2',
+ 'sh': 'sr_CS.ISO8859-2',
'sh_hr': 'sh_HR.ISO8859-2',
- 'sh_hr.iso88592': 'sh_HR.ISO8859-2',
- 'sh_sp': 'sh_YU.ISO8859-2',
- 'sh_yu': 'sh_YU.ISO8859-2',
+ 'sh_hr.iso88592': 'hr_HR.ISO8859-2',
+ 'sh_sp': 'sr_CS.ISO8859-2',
+ 'sh_yu': 'sr_CS.ISO8859-2',
+ 'si': 'si_LK.UTF-8',
+ 'si_lk': 'si_LK.UTF-8',
+ 'sinhala': 'si_LK.UTF-8',
'sk': 'sk_SK.ISO8859-2',
'sk_sk': 'sk_SK.ISO8859-2',
'sk_sk.iso88592': 'sk_SK.ISO8859-2',
@@ -1202,8 +1310,8 @@ locale_alias = {
'slovak': 'sk_SK.ISO8859-2',
'slovene': 'sl_SI.ISO8859-2',
'slovenian': 'sl_SI.ISO8859-2',
- 'sp': 'sp_YU.ISO8859-5',
- 'sp_yu': 'sp_YU.ISO8859-5',
+ 'sp': 'sr_CS.ISO8859-5',
+ 'sp_yu': 'sr_CS.ISO8859-5',
'spanish': 'es_ES.ISO8859-1',
'spanish.iso88591': 'es_ES.ISO8859-1',
'spanish_spain': 'es_ES.ISO8859-1',
@@ -1211,21 +1319,35 @@ locale_alias = {
'sq': 'sq_AL.ISO8859-2',
'sq_al': 'sq_AL.ISO8859-2',
'sq_al.iso88592': 'sq_AL.ISO8859-2',
- 'sr': 'sr_YU.ISO8859-5',
- 'sr@cyrillic': 'sr_YU.ISO8859-5',
- 'sr_sp': 'sr_SP.ISO8859-2',
- 'sr_yu': 'sr_YU.ISO8859-5',
- 'sr_yu.cp1251@cyrillic': 'sr_YU.CP1251',
- 'sr_yu.iso88592': 'sr_YU.ISO8859-2',
- 'sr_yu.iso88595': 'sr_YU.ISO8859-5',
- 'sr_yu.iso88595@cyrillic': 'sr_YU.ISO8859-5',
- 'sr_yu.microsoftcp1251@cyrillic': 'sr_YU.CP1251',
- 'sr_yu.utf8@cyrillic': 'sr_YU.UTF-8',
- 'sr_yu@cyrillic': 'sr_YU.ISO8859-5',
+ 'sr': 'sr_CS.ISO8859-5',
+ 'sr@cyrillic': 'sr_CS.ISO8859-5',
+ 'sr@latn': 'sr_CS.ISO8859-2',
+ 'sr_cs.iso88592': 'sr_CS.ISO8859-2',
+ 'sr_cs.iso88592@latn': 'sr_CS.ISO8859-2',
+ 'sr_cs.iso88595': 'sr_CS.ISO8859-5',
+ 'sr_cs.utf8@latn': 'sr_CS.UTF-8',
+ 'sr_cs@latn': 'sr_CS.ISO8859-2',
+ 'sr_sp': 'sr_CS.ISO8859-2',
+ 'sr_yu': 'sr_CS.ISO8859-5',
+ 'sr_yu.cp1251@cyrillic': 'sr_CS.CP1251',
+ 'sr_yu.iso88592': 'sr_CS.ISO8859-2',
+ 'sr_yu.iso88595': 'sr_CS.ISO8859-5',
+ 'sr_yu.iso88595@cyrillic': 'sr_CS.ISO8859-5',
+ 'sr_yu.microsoftcp1251@cyrillic': 'sr_CS.CP1251',
+ 'sr_yu.utf8@cyrillic': 'sr_CS.UTF-8',
+ 'sr_yu@cyrillic': 'sr_CS.ISO8859-5',
+ 'ss': 'ss_ZA.ISO8859-1',
+ 'ss_za': 'ss_ZA.ISO8859-1',
+ 'ss_za.iso88591': 'ss_ZA.ISO8859-1',
+ 'st': 'st_ZA.ISO8859-1',
+ 'st_za': 'st_ZA.ISO8859-1',
+ 'st_za.iso88591': 'st_ZA.ISO8859-1',
'sv': 'sv_SE.ISO8859-1',
'sv_fi': 'sv_FI.ISO8859-1',
'sv_fi.iso88591': 'sv_FI.ISO8859-1',
'sv_fi.iso885915': 'sv_FI.ISO8859-15',
+ 'sv_fi.iso885915@euro': 'sv_FI.ISO8859-15',
+ 'sv_fi.utf8@euro': 'sv_FI.UTF-8',
'sv_fi@euro': 'sv_FI.ISO8859-15',
'sv_se': 'sv_SE.ISO8859-1',
'sv_se.88591': 'sv_SE.ISO8859-1',
@@ -1250,9 +1372,15 @@ locale_alias = {
'tl': 'tl_PH.ISO8859-1',
'tl_ph': 'tl_PH.ISO8859-1',
'tl_ph.iso88591': 'tl_PH.ISO8859-1',
+ 'tn': 'tn_ZA.ISO8859-15',
+ 'tn_za': 'tn_ZA.ISO8859-15',
+ 'tn_za.iso885915': 'tn_ZA.ISO8859-15',
'tr': 'tr_TR.ISO8859-9',
'tr_tr': 'tr_TR.ISO8859-9',
'tr_tr.iso88599': 'tr_TR.ISO8859-9',
+ 'ts': 'ts_ZA.ISO8859-1',
+ 'ts_za': 'ts_ZA.ISO8859-1',
+ 'ts_za.iso88591': 'ts_ZA.ISO8859-1',
'tt': 'tt_RU.TATAR-CYR',
'tt_ru': 'tt_RU.TATAR-CYR',
'tt_ru.koi8c': 'tt_RU.KOI8-C',
@@ -1274,6 +1402,11 @@ locale_alias = {
'ur_pk.microsoftcp1256': 'ur_PK.CP1256',
'uz': 'uz_UZ.UTF-8',
'uz_uz': 'uz_UZ.UTF-8',
+ 'uz_uz.iso88591': 'uz_UZ.ISO8859-1',
+ 'uz_uz.utf8@cyrillic': 'uz_UZ.UTF-8',
+ 'uz_uz@cyrillic': 'uz_UZ.UTF-8',
+ 've': 've_ZA.UTF-8',
+ 've_za': 've_ZA.UTF-8',
'vi': 'vi_VN.TCVN',
'vi_vn': 'vi_VN.TCVN',
'vi_vn.tcvn': 'vi_VN.TCVN',
@@ -1284,7 +1417,11 @@ locale_alias = {
'wa_be': 'wa_BE.ISO8859-1',
'wa_be.iso88591': 'wa_BE.ISO8859-1',
'wa_be.iso885915': 'wa_BE.ISO8859-15',
+ 'wa_be.iso885915@euro': 'wa_BE.ISO8859-15',
'wa_be@euro': 'wa_BE.ISO8859-15',
+ 'xh': 'xh_ZA.ISO8859-1',
+ 'xh_za': 'xh_ZA.ISO8859-1',
+ 'xh_za.iso88591': 'xh_ZA.ISO8859-1',
'yi': 'yi_US.CP1255',
'yi_us': 'yi_US.CP1255',
'yi_us.cp1255': 'yi_US.CP1255',
@@ -1302,6 +1439,10 @@ locale_alias = {
'zh_tw': 'zh_TW.big5',
'zh_tw.big5': 'zh_TW.big5',
'zh_tw.euc': 'zh_TW.eucTW',
+ 'zh_tw.euctw': 'zh_TW.eucTW',
+ 'zu': 'zu_ZA.ISO8859-1',
+ 'zu_za': 'zu_ZA.ISO8859-1',
+ 'zu_za.iso88591': 'zu_ZA.ISO8859-1',
}
#
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index ba4fac0..b239c48 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -661,8 +661,10 @@ class Popen(object):
self.stdin.close()
elif self.stdout:
stdout = self.stdout.read()
+ self.stdout.close()
elif self.stderr:
stderr = self.stderr.read()
+ self.stderr.close()
self.wait()
return (stdout, stderr)
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index c744951..a79e35c 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -669,7 +669,6 @@ class _BZ2Proxy(object):
if self.mode == "w":
raw = self.bz2obj.flush()
self.fileobj.write(raw)
- self.fileobj.close()
# class _BZ2Proxy
#------------------------
diff --git a/Lib/test/pydoc_mod.py b/Lib/test/pydoc_mod.py
index 8601e3f..9c53324 100644
--- a/Lib/test/pydoc_mod.py
+++ b/Lib/test/pydoc_mod.py
@@ -25,30 +25,3 @@ def doc_func():
def nodoc_func():
pass
-"""This is a test module for test_pydoc"""
-
-__author__ = "Benjamin Peterson"
-__credits__ = "Nobody"
-__version__ = "1.2.3.4"
-
-
-class A:
- """Hello and goodbye"""
- def __init__():
- """Wow, I have no function!"""
- pass
-
-class B(object):
- NO_MEANING = "eggs"
- pass
-
-def doc_func():
- """
- This function solves all of the world's problems:
- hunger
- lack of Python
- war
- """
-
-def nodoc_func():
- pass
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index c9a3e1b..71ae0db 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -292,7 +292,7 @@ class ProcessTestCase(unittest.TestCase):
self.assertEqual(stdout, None)
# When running with a pydebug build, the # of references is outputted
# to stderr, so just check if stderr at least started with "pinapple"
- self.assert_(stderr.startswith(b"pineapple"))
+ self.assertEqual(remove_stderr_debug_decorations(stderr), b"pineapple")
def test_communicate(self):
p = subprocess.Popen([sys.executable, "-c",
@@ -307,6 +307,22 @@ class ProcessTestCase(unittest.TestCase):
self.assertEqual(remove_stderr_debug_decorations(stderr),
b"pineapple")
+ # This test is Linux specific for simplicity to at least have
+ # some coverage. It is not a platform specific bug.
+ if os.path.isdir('/proc/%d/fd' % os.getpid()):
+ # Test for the fd leak reported in http://bugs.python.org/issue2791.
+ def test_communicate_pipe_fd_leak(self):
+ fd_directory = '/proc/%d/fd' % os.getpid()
+ num_fds_before_popen = len(os.listdir(fd_directory))
+ p = subprocess.Popen([sys.executable, '-c', 'print()'],
+ stdout=subprocess.PIPE)
+ p.communicate()
+ num_fds_after_communicate = len(os.listdir(fd_directory))
+ del p
+ num_fds_after_destruction = len(os.listdir(fd_directory))
+ self.assertEqual(num_fds_before_popen, num_fds_after_destruction)
+ self.assertEqual(num_fds_before_popen, num_fds_after_communicate)
+
def test_communicate_returns(self):
# communicate() should return None if no redirection is active
p = subprocess.Popen([sys.executable, "-c",
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 9fde707..7e039a6 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -528,7 +528,19 @@ class PaxReadTest(LongnameTest):
self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
-class WriteTest(unittest.TestCase):
+class WriteTestBase(unittest.TestCase):
+ # Put all write tests in here that are supposed to be tested
+ # in all possible mode combinations.
+
+ def test_fileobj_no_close(self):
+ fobj = io.BytesIO()
+ tar = tarfile.open(fileobj=fobj, mode=self.mode)
+ tar.addfile(tarfile.TarInfo("foo"))
+ tar.close()
+ self.assert_(fobj.closed is False, "external fileobjs must never closed")
+
+
+class WriteTest(WriteTestBase):
mode = "w:"
@@ -651,7 +663,7 @@ class WriteTest(unittest.TestCase):
shutil.rmtree(tempdir)
-class StreamWriteTest(unittest.TestCase):
+class StreamWriteTest(WriteTestBase):
mode = "w|"
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index 43e7a6c..6868d3b 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -800,6 +800,7 @@ class Unmarshaller:
self.append(int(data))
self._value = 0
dispatch["i4"] = end_int
+ dispatch["i8"] = end_int
dispatch["int"] = end_int
def end_double(self, data):
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 2fd03af..f760b6a 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -96,7 +96,9 @@ set_lookkey(PySetObject *so, PyObject *key, register long hash)
else {
if (entry->hash == hash) {
startkey = entry->key;
+ Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
+ Py_DECREF(startkey);
if (cmp < 0)
return NULL;
if (table == so->table && entry->key == startkey) {
@@ -127,7 +129,9 @@ set_lookkey(PySetObject *so, PyObject *key, register long hash)
break;
if (entry->hash == hash && entry->key != dummy) {
startkey = entry->key;
+ Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
+ Py_DECREF(startkey);
if (cmp < 0)
return NULL;
if (table == so->table && entry->key == startkey) {
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 6e4ac7a..c139fbc 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -33,7 +33,6 @@ struct method_cache_entry {
static struct method_cache_entry method_cache[1 << MCACHE_SIZE_EXP];
static unsigned int next_version_tag = 0;
-static void type_modified(PyTypeObject *);
unsigned int
PyType_ClearCache(void)
@@ -48,12 +47,12 @@ PyType_ClearCache(void)
}
next_version_tag = 0;
/* mark all version tags as invalid */
- type_modified(&PyBaseObject_Type);
+ PyType_Modified(&PyBaseObject_Type);
return cur_version_tag;
}
-static void
-type_modified(PyTypeObject *type)
+void
+PyType_Modified(PyTypeObject *type)
{
/* Invalidate any cached data for the specified type and all
subclasses. This function is called after the base
@@ -87,7 +86,7 @@ type_modified(PyTypeObject *type)
ref = PyList_GET_ITEM(raw, i);
ref = PyWeakref_GET_OBJECT(ref);
if (ref != Py_None) {
- type_modified((PyTypeObject *)ref);
+ PyType_Modified((PyTypeObject *)ref);
}
}
}
@@ -173,7 +172,7 @@ assign_version_tag(PyTypeObject *type)
Py_INCREF(Py_None);
}
/* mark all version tags as invalid */
- type_modified(&PyBaseObject_Type);
+ PyType_Modified(&PyBaseObject_Type);
return 1;
}
bases = type->tp_bases;
@@ -313,7 +312,7 @@ type_set_module(PyTypeObject *type, PyObject *value, void *context)
return -1;
}
- type_modified(type);
+ PyType_Modified(type);
return PyDict_SetItemString(type->tp_dict, "__module__", value);
}
@@ -341,7 +340,7 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
int res = PyDict_SetItemString(type->tp_dict,
"__abstractmethods__", value);
if (res == 0) {
- type_modified(type);
+ PyType_Modified(type);
if (value && PyObject_IsTrue(value)) {
type->tp_flags |= Py_TPFLAGS_IS_ABSTRACT;
}
@@ -1520,7 +1519,7 @@ mro_internal(PyTypeObject *type)
from the custom MRO */
type_mro_modified(type, type->tp_bases);
- type_modified(type);
+ PyType_Modified(type);
return 0;
}
@@ -5750,7 +5749,7 @@ update_slot(PyTypeObject *type, PyObject *name)
update_subclasses() recursion below, but carefully:
they each have their own conditions on which to stop
recursing into subclasses. */
- type_modified(type);
+ PyType_Modified(type);
init_slotdefs();
pp = ptrs;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index fc8c8a9..5cd9eb9 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7524,11 +7524,11 @@ PyObject *PyUnicode_Replace(PyObject *obj,
}
PyDoc_STRVAR(replace__doc__,
-"S.replace (old, new[, maxsplit]) -> str\n\
+"S.replace (old, new[, count]) -> str\n\
\n\
Return a copy of S with all occurrences of substring\n\
-old replaced by new. If the optional argument maxsplit is\n\
-given, only the first maxsplit occurrences are replaced.");
+old replaced by new. If the optional argument count is\n\
+given, only the first count occurrences are replaced.");
static PyObject*
unicode_replace(PyUnicodeObject *self, PyObject *args)
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 3dc6a00..6ad8d66 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1889,7 +1889,7 @@ builtin_sum(PyObject *self, PyObject *args)
return PyFloat_FromDouble(f_result);
}
if (PyFloat_CheckExact(item)) {
- PyFPE_START_PROTECT("add", return 0)
+ PyFPE_START_PROTECT("add", Py_DECREF(item); Py_DECREF(iter); return 0)
f_result += PyFloat_AS_DOUBLE(item);
PyFPE_END_PROTECT(f_result)
Py_DECREF(item);
@@ -1900,7 +1900,7 @@ builtin_sum(PyObject *self, PyObject *args)
int overflow;
value = PyLong_AsLongAndOverflow(item, &overflow);
if (!overflow) {
- PyFPE_START_PROTECT("add", return 0)
+ PyFPE_START_PROTECT("add", Py_DECREF(item); Py_DECREF(iter); return 0)
f_result += (double)value;
PyFPE_END_PROTECT(f_result)
Py_DECREF(item);