From python-checkins at python.org Tue Jan 1 00:07:55 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 1 Jan 2013 00:07:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE0OTU4?= =?utf-8?q?=3A_backport_to_2=2E7=2Ex_from_3=2E3_=28patch_by_Roger_Serwy=29?= Message-ID: <3YZvLz59rVzS5H@mail.python.org> http://hg.python.org/cpython/rev/0dbdb85fd141 changeset: 81177:0dbdb85fd141 branch: 2.7 parent: 81175:c5c27b84d7af user: Ned Deily date: Mon Dec 31 15:06:38 2012 -0800 summary: Issue #14958: backport to 2.7.x from 3.3 (patch by Roger Serwy) files: Lib/idlelib/ColorDelegator.py | 9 +++++---- Misc/NEWS | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -20,10 +20,11 @@ # 1st 'file' colorized normal, 2nd as builtin, 3rd as string builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) - sqstring = r"(\b[rRuU])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" - dqstring = r'(\b[rRuU])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' - sq3string = r"(\b[rRuU])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" - dq3string = r'(\b[rRuU])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' + stringprefix = r"(\br|u|ur|R|U|UR|Ur|uR|b|B|br|Br|bR|BR)?" + sqstring = stringprefix + r"'[^'\\\n]*(\\.[^'\\\n]*)*'?" + dqstring = stringprefix + r'"[^"\\\n]*(\\.[^"\\\n]*)*"?' + sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" + dq3string = stringprefix + r'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) return kw + "|" + builtin + "|" + comment + "|" + string +\ "|" + any("SYNC", [r"\n"]) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -430,6 +430,9 @@ - Issue #12157: Make pool.map() empty iterables correctly. Initial patch by mouad. +- Issue #14958: Change IDLE systax highlighting to recognize all string and byte + literals currently supported in Python 2.7. + - Issue #14962: Update text coloring in IDLE shell window after changing options. Patch by Roger Serwy. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 00:34:56 2013 From: python-checkins at python.org (eli.bendersky) Date: Tue, 1 Jan 2013 00:34:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Make_indentati?= =?utf-8?q?on_consistent_and_remove_dead_commented-out_code=2E?= Message-ID: <3YZvy86wmSzSDl@mail.python.org> http://hg.python.org/cpython/rev/3ca72d4e9762 changeset: 81178:3ca72d4e9762 branch: 3.3 parent: 81173:d89891f3f769 user: Eli Bendersky date: Mon Dec 31 15:34:20 2012 -0800 summary: Make indentation consistent and remove dead commented-out code. files: Modules/arraymodule.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2114,7 +2114,7 @@ static PyMethodDef array_methods[] = { {"append", (PyCFunction)array_append, METH_O, append_doc}, - {"buffer_info", (PyCFunction)array_buffer_info, METH_NOARGS, + {"buffer_info", (PyCFunction)array_buffer_info, METH_NOARGS, buffer_info_doc}, {"byteswap", (PyCFunction)array_byteswap, METH_NOARGS, byteswap_doc}, @@ -2122,9 +2122,9 @@ copy_doc}, {"count", (PyCFunction)array_count, METH_O, count_doc}, - {"__deepcopy__",(PyCFunction)array_copy, METH_O, + {"__deepcopy__", (PyCFunction)array_copy, METH_O, copy_doc}, - {"extend", (PyCFunction)array_extend, METH_O, + {"extend", (PyCFunction)array_extend, METH_O, extend_doc}, {"fromfile", (PyCFunction)array_fromfile, METH_VARARGS, fromfile_doc}, @@ -2142,14 +2142,12 @@ insert_doc}, {"pop", (PyCFunction)array_pop, METH_VARARGS, pop_doc}, - {"__reduce_ex__", (PyCFunction)array_reduce_ex, METH_O, + {"__reduce_ex__", (PyCFunction)array_reduce_ex, METH_O, reduce_doc}, {"remove", (PyCFunction)array_remove, METH_O, remove_doc}, {"reverse", (PyCFunction)array_reverse, METH_NOARGS, reverse_doc}, -/* {"sort", (PyCFunction)array_sort, METH_VARARGS, - sort_doc},*/ {"tofile", (PyCFunction)array_tofile, METH_O, tofile_doc}, {"tolist", (PyCFunction)array_tolist, METH_NOARGS, @@ -2158,7 +2156,7 @@ tostring_doc}, {"tobytes", (PyCFunction)array_tobytes, METH_NOARGS, tobytes_doc}, - {"tounicode", (PyCFunction)array_tounicode, METH_NOARGS, + {"tounicode", (PyCFunction)array_tounicode, METH_NOARGS, tounicode_doc}, {"__sizeof__", (PyCFunction)array_sizeof, METH_NOARGS, sizeof_doc}, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 00:34:58 2013 From: python-checkins at python.org (eli.bendersky) Date: Tue, 1 Jan 2013 00:34:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Make_indentation_consistent_and_remove_dead_commented-ou?= =?utf-8?q?t_code=2E?= Message-ID: <3YZvyB2cBLzSDq@mail.python.org> http://hg.python.org/cpython/rev/0a095821c74e changeset: 81179:0a095821c74e parent: 81176:3738d270c54a parent: 81178:3ca72d4e9762 user: Eli Bendersky date: Mon Dec 31 15:34:43 2012 -0800 summary: Make indentation consistent and remove dead commented-out code. files: Modules/arraymodule.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2111,7 +2111,7 @@ static PyMethodDef array_methods[] = { {"append", (PyCFunction)array_append, METH_O, append_doc}, - {"buffer_info", (PyCFunction)array_buffer_info, METH_NOARGS, + {"buffer_info", (PyCFunction)array_buffer_info, METH_NOARGS, buffer_info_doc}, {"byteswap", (PyCFunction)array_byteswap, METH_NOARGS, byteswap_doc}, @@ -2119,9 +2119,9 @@ copy_doc}, {"count", (PyCFunction)array_count, METH_O, count_doc}, - {"__deepcopy__",(PyCFunction)array_copy, METH_O, + {"__deepcopy__", (PyCFunction)array_copy, METH_O, copy_doc}, - {"extend", (PyCFunction)array_extend, METH_O, + {"extend", (PyCFunction)array_extend, METH_O, extend_doc}, {"fromfile", (PyCFunction)array_fromfile, METH_VARARGS, fromfile_doc}, @@ -2139,14 +2139,12 @@ insert_doc}, {"pop", (PyCFunction)array_pop, METH_VARARGS, pop_doc}, - {"__reduce_ex__", (PyCFunction)array_reduce_ex, METH_O, + {"__reduce_ex__", (PyCFunction)array_reduce_ex, METH_O, reduce_doc}, {"remove", (PyCFunction)array_remove, METH_O, remove_doc}, {"reverse", (PyCFunction)array_reverse, METH_NOARGS, reverse_doc}, -/* {"sort", (PyCFunction)array_sort, METH_VARARGS, - sort_doc},*/ {"tofile", (PyCFunction)array_tofile, METH_O, tofile_doc}, {"tolist", (PyCFunction)array_tolist, METH_NOARGS, @@ -2155,7 +2153,7 @@ tostring_doc}, {"tobytes", (PyCFunction)array_tobytes, METH_NOARGS, tobytes_doc}, - {"tounicode", (PyCFunction)array_tounicode, METH_NOARGS, + {"tounicode", (PyCFunction)array_tounicode, METH_NOARGS, tounicode_doc}, {"__sizeof__", (PyCFunction)array_sizeof, METH_NOARGS, sizeof_doc}, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 04:41:01 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 1 Jan 2013 04:41:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_bring_Python_i?= =?utf-8?q?nto_2013?= Message-ID: <3Yb1Q54ztFzSBB@mail.python.org> http://hg.python.org/cpython/rev/24d6e8ca27d2 changeset: 81180:24d6e8ca27d2 branch: 3.3 parent: 81178:3ca72d4e9762 user: Benjamin Peterson date: Mon Dec 31 21:37:21 2012 -0600 summary: bring Python into 2013 files: Doc/copyright.rst | 2 +- Doc/license.rst | 2 +- LICENSE | 4 ++-- Python/getcopyright.c | 2 +- README | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/copyright.rst b/Doc/copyright.rst --- a/Doc/copyright.rst +++ b/Doc/copyright.rst @@ -4,7 +4,7 @@ Python and this documentation is: -Copyright ? 2001-2012 Python Software Foundation. All rights reserved. +Copyright ? 2001-2013 Python Software Foundation. All rights reserved. Copyright ? 2000 BeOpen.com. All rights reserved. diff --git a/Doc/license.rst b/Doc/license.rst --- a/Doc/license.rst +++ b/Doc/license.rst @@ -150,7 +150,7 @@ analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python |release| alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of - copyright, i.e., "Copyright ? 2001-2012 Python Software Foundation; All Rights + copyright, i.e., "Copyright ? 2001-2013 Python Software Foundation; All Rights Reserved" are retained in Python |release| alone or in any derivative version prepared by Licensee. diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -110,8 +110,8 @@ distribute, and otherwise use Python alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -2011, 2012 Python Software Foundation; All Rights Reserved" are retained in Python -alone or in any derivative version prepared by Licensee. +2011, 2012, 2013 Python Software Foundation; All Rights Reserved" are retained +in Python alone or in any derivative version prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and wants to make diff --git a/Python/getcopyright.c b/Python/getcopyright.c --- a/Python/getcopyright.c +++ b/Python/getcopyright.c @@ -4,7 +4,7 @@ static char cprt[] = "\ -Copyright (c) 2001-2012 Python Software Foundation.\n\ +Copyright (c) 2001-2013 Python Software Foundation.\n\ All Rights Reserved.\n\ \n\ Copyright (c) 2000 BeOpen.com.\n\ diff --git a/README b/README --- a/README +++ b/README @@ -2,7 +2,7 @@ ============================ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -2012 Python Software Foundation. All rights reserved. +2012, 2013 Python Software Foundation. All rights reserved. Python 3.x is a new version of the language, which is incompatible with the 2.x line of releases. The language is mostly the same, but many details, especially -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 04:41:03 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 1 Jan 2013 04:41:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3Yb1Q70Gs2zSBB@mail.python.org> http://hg.python.org/cpython/rev/4e4c102a018a changeset: 81181:4e4c102a018a parent: 81179:0a095821c74e parent: 81180:24d6e8ca27d2 user: Benjamin Peterson date: Mon Dec 31 21:37:30 2012 -0600 summary: merge 3.3 files: Doc/copyright.rst | 2 +- Doc/license.rst | 2 +- LICENSE | 4 ++-- Python/getcopyright.c | 2 +- README | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/copyright.rst b/Doc/copyright.rst --- a/Doc/copyright.rst +++ b/Doc/copyright.rst @@ -4,7 +4,7 @@ Python and this documentation is: -Copyright ? 2001-2012 Python Software Foundation. All rights reserved. +Copyright ? 2001-2013 Python Software Foundation. All rights reserved. Copyright ? 2000 BeOpen.com. All rights reserved. diff --git a/Doc/license.rst b/Doc/license.rst --- a/Doc/license.rst +++ b/Doc/license.rst @@ -152,7 +152,7 @@ analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python |release| alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of - copyright, i.e., "Copyright ? 2001-2012 Python Software Foundation; All Rights + copyright, i.e., "Copyright ? 2001-2013 Python Software Foundation; All Rights Reserved" are retained in Python |release| alone or in any derivative version prepared by Licensee. diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -111,8 +111,8 @@ distribute, and otherwise use Python alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -2011, 2012 Python Software Foundation; All Rights Reserved" are retained in Python -alone or in any derivative version prepared by Licensee. +2011, 2012, 2013 Python Software Foundation; All Rights Reserved" are retained +in Python alone or in any derivative version prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and wants to make diff --git a/Python/getcopyright.c b/Python/getcopyright.c --- a/Python/getcopyright.c +++ b/Python/getcopyright.c @@ -4,7 +4,7 @@ static char cprt[] = "\ -Copyright (c) 2001-2012 Python Software Foundation.\n\ +Copyright (c) 2001-2013 Python Software Foundation.\n\ All Rights Reserved.\n\ \n\ Copyright (c) 2000 BeOpen.com.\n\ diff --git a/README b/README --- a/README +++ b/README @@ -2,7 +2,7 @@ ======================================= Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -2012 Python Software Foundation. All rights reserved. +2012, 2013 Python Software Foundation. All rights reserved. Python 3.x is a new version of the language, which is incompatible with the 2.x line of releases. The language is mostly the same, but many details, especially -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 04:41:04 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 1 Jan 2013 04:41:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_bring_Python_i?= =?utf-8?q?nto_2013?= Message-ID: <3Yb1Q82qVpzSC7@mail.python.org> http://hg.python.org/cpython/rev/4f35d9dc8a8e changeset: 81182:4f35d9dc8a8e branch: 2.7 parent: 80962:39803c20c9bf user: Benjamin Peterson date: Mon Dec 31 21:37:21 2012 -0600 summary: bring Python into 2013 files: Doc/copyright.rst | 2 +- Doc/license.rst | 2 +- LICENSE | 4 ++-- Python/getcopyright.c | 2 +- README | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/copyright.rst b/Doc/copyright.rst --- a/Doc/copyright.rst +++ b/Doc/copyright.rst @@ -4,7 +4,7 @@ Python and this documentation is: -Copyright ? 2001-2012 Python Software Foundation. All rights reserved. +Copyright ? 2001-2013 Python Software Foundation. All rights reserved. Copyright ? 2000 BeOpen.com. All rights reserved. diff --git a/Doc/license.rst b/Doc/license.rst --- a/Doc/license.rst +++ b/Doc/license.rst @@ -132,7 +132,7 @@ analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python |release| alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of - copyright, i.e., "Copyright ? 2001-2012 Python Software Foundation; All Rights + copyright, i.e., "Copyright ? 2001-2013 Python Software Foundation; All Rights Reserved" are retained in Python |release| alone or in any derivative version prepared by Licensee. diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -99,8 +99,8 @@ distribute, and otherwise use Python alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -2011, 2012 Python Software Foundation; All Rights Reserved" are retained in Python -alone or in any derivative version prepared by Licensee. +2011, 2012, 2013 Python Software Foundation; All Rights Reserved" are retained +in Python alone or in any derivative version prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and wants to make diff --git a/Python/getcopyright.c b/Python/getcopyright.c --- a/Python/getcopyright.c +++ b/Python/getcopyright.c @@ -4,7 +4,7 @@ static char cprt[] = "\ -Copyright (c) 2001-2012 Python Software Foundation.\n\ +Copyright (c) 2001-2013 Python Software Foundation.\n\ All Rights Reserved.\n\ \n\ Copyright (c) 2000 BeOpen.com.\n\ diff --git a/README b/README --- a/README +++ b/README @@ -2,7 +2,7 @@ ============================ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -2012 Python Software Foundation. All rights reserved. +2012, 2013 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. All rights reserved. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 04:41:06 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 1 Jan 2013 04:41:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_merge_heads?= Message-ID: <3Yb1QB4F3JzSBS@mail.python.org> http://hg.python.org/cpython/rev/77507e14db81 changeset: 81183:77507e14db81 branch: 2.7 parent: 81182:4f35d9dc8a8e parent: 81177:0dbdb85fd141 user: Benjamin Peterson date: Mon Dec 31 21:40:42 2012 -0600 summary: merge heads files: Doc/faq/programming.rst | 4 + Doc/glossary.rst | 5 +- Doc/howto/regex.rst | 49 ++++---- Doc/library/argparse.rst | 2 +- Doc/library/ftplib.rst | 8 +- Doc/library/imp.rst | 16 +- Doc/library/itertools.rst | 3 +- Doc/library/poplib.rst | 2 +- Doc/library/smtplib.rst | 3 +- Doc/library/socket.rst | 12 +- Doc/library/socketserver.rst | 4 +- Doc/reference/compound_stmts.rst | 16 ++- Doc/reference/expressions.rst | 28 +++-- Doc/using/windows.rst | 2 + Lib/SocketServer.py | 7 +- Lib/aifc.py | 38 ++++--- Lib/cgi.py | 1 - Lib/ctypes/test/test_bitfields.py | 8 +- Lib/curses/__init__.py | 2 +- Lib/idlelib/ColorDelegator.py | 9 +- Lib/idlelib/EditorWindow.py | 12 +- Lib/idlelib/FormatParagraph.py | 3 +- Lib/idlelib/configDialog.py | 11 +- Lib/idlelib/configHandler.py | 51 ++++++--- Lib/multiprocessing/connection.py | 21 ++++ Lib/socket.py | 4 +- Lib/ssl.py | 20 ++- Lib/subprocess.py | 4 +- Lib/test/regrtest.py | 4 +- Lib/test/test_aifc.py | 7 + Lib/test/test_builtin.py | 2 + Lib/test/test_calendar.py | 2 +- Lib/test/test_glob.py | 99 ++++++++++++++---- Lib/test/test_import.py | 41 +++++++ Lib/test/test_int.py | 63 +++++++++++- Lib/test/test_long.py | 6 +- Lib/test/test_multiprocessing.py | 1 + Lib/test/test_mutex.py | 2 +- Lib/test/test_socket.py | 60 +++++++++++- Lib/test/test_ssl.py | 28 +++++ Lib/test/test_tarfile.py | 29 ++--- Lib/test/test_urllib2.py | 34 ++++- Lib/test/test_urllib2_localnet.py | 8 + Lib/test/test_urlparse.py | 33 ++++++ Lib/test/test_winreg.py | 29 +++++ Lib/urllib2.py | 3 + Lib/urlparse.py | 2 +- Misc/ACKS | 1 + Misc/NEWS | 44 ++++++++ Modules/_ctypes/callproc.c | 2 +- Modules/_sre.c | 60 +++++++++- Objects/intobject.c | 8 +- Objects/longobject.c | 8 +- PC/_winreg.c | 15 +- Python/import.c | 52 ++++++++- 55 files changed, 768 insertions(+), 220 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -469,6 +469,10 @@ apply(g, (x,)+args, kwargs) +.. index:: + single: argument; difference from parameter + single: parameter; difference from argument + .. _faq-argument-vs-parameter: What is the difference between arguments and parameters? diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -245,8 +245,9 @@ function A series of statements which returns some value to a caller. It can also - be passed zero or more arguments which may be used in the execution of - the body. See also :term:`argument` and :term:`method`. + be passed zero or more :term:`arguments ` which may be used in + the execution of the body. See also :term:`parameter`, :term:`method`, + and the :ref:`function` section. __future__ A pseudo-module which programmers can use to enable new language features diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -359,9 +359,9 @@ +------------------+-----------------------------------------------+ :meth:`match` and :meth:`search` return ``None`` if no match can be found. If -they're successful, a ``MatchObject`` instance is returned, containing -information about the match: where it starts and ends, the substring it matched, -and more. +they're successful, a :ref:`match object ` instance is returned, +containing information about the match: where it starts and ends, the substring +it matched, and more. You can learn about this by interactively experimenting with the :mod:`re` module. If you have Tkinter available, you may also want to look at @@ -392,16 +392,16 @@ None Now, let's try it on a string that it should match, such as ``tempo``. In this -case, :meth:`match` will return a :class:`MatchObject`, so you should store the -result in a variable for later use. :: +case, :meth:`match` will return a :ref:`match object `, so you +should store the result in a variable for later use. :: >>> m = p.match('tempo') >>> m #doctest: +ELLIPSIS <_sre.SRE_Match object at 0x...> -Now you can query the :class:`MatchObject` for information about the matching -string. :class:`MatchObject` instances also have several methods and -attributes; the most important ones are: +Now you can query the :ref:`match object ` for information +about the matching string. :ref:`match object ` instances +also have several methods and attributes; the most important ones are: +------------------+--------------------------------------------+ | Method/Attribute | Purpose | @@ -442,8 +442,9 @@ >>> m.span() (4, 11) -In actual programs, the most common style is to store the :class:`MatchObject` -in a variable, and then check if it was ``None``. This usually looks like:: +In actual programs, the most common style is to store the +:ref:`match object ` in a variable, and then check if it was +``None``. This usually looks like:: p = re.compile( ... ) m = p.match( 'string goes here' ) @@ -460,8 +461,8 @@ ['12', '11', '10'] :meth:`findall` has to create the entire list before it can be returned as the -result. The :meth:`finditer` method returns a sequence of :class:`MatchObject` -instances as an :term:`iterator`. [#]_ :: +result. The :meth:`finditer` method returns a sequence of +:ref:`match object ` instances as an :term:`iterator`. [#]_ :: >>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...') >>> iterator #doctest: +ELLIPSIS @@ -482,7 +483,7 @@ :func:`search`, :func:`findall`, :func:`sub`, and so forth. These functions take the same arguments as the corresponding pattern method, with the RE string added as the first argument, and still return either ``None`` or a -:class:`MatchObject` instance. :: +:ref:`match object ` instance. :: >>> print re.match(r'From\s+', 'Fromage amk') None @@ -791,9 +792,9 @@ index of the text that they match; this can be retrieved by passing an argument to :meth:`group`, :meth:`start`, :meth:`end`, and :meth:`span`. Groups are numbered starting with 0. Group 0 is always present; it's the whole RE, so -:class:`MatchObject` methods all have group 0 as their default argument. Later -we'll see how to express groups that don't capture the span of text that they -match. :: +:ref:`match object ` methods all have group 0 as their default +argument. Later we'll see how to express groups that don't capture the span +of text that they match. :: >>> p = re.compile('(a)b') >>> m = p.match('ab') @@ -913,10 +914,10 @@ The syntax for a named group is one of the Python-specific extensions: ``(?P...)``. *name* is, obviously, the name of the group. Named groups also behave exactly like capturing groups, and additionally associate a name -with a group. The :class:`MatchObject` methods that deal with capturing groups -all accept either integers that refer to the group by number or strings that -contain the desired group's name. Named groups are still given numbers, so you -can retrieve information about a group in two ways:: +with a group. The :ref:`match object ` methods that deal with +capturing groups all accept either integers that refer to the group by number +or strings that contain the desired group's name. Named groups are still +given numbers, so you can retrieve information about a group in two ways:: >>> p = re.compile(r'(?P\b\w+\b)') >>> m = p.search( '(((( Lots of punctuation )))' ) @@ -1180,11 +1181,11 @@ *replacement* can also be a function, which gives you even more control. If *replacement* is a function, the function is called for every non-overlapping -occurrence of *pattern*. On each call, the function is passed a -:class:`MatchObject` argument for the match and can use this information to -compute the desired replacement string and return it. +occurrence of *pattern*. On each call, the function is passed a +:ref:`match object ` argument for the match and can use this +information to compute the desired replacement string and return it. -In the following example, the replacement function translates decimals into +In the following example, the replacement function translates decimals into hexadecimal:: >>> def hexrepl(match): diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1439,7 +1439,7 @@ different functions which require different kinds of command-line arguments. :class:`ArgumentParser` supports the creation of such sub-commands with the :meth:`add_subparsers` method. The :meth:`add_subparsers` method is normally - called with no arguments and returns an special action object. This object + called with no arguments and returns a special action object. This object has a single method, :meth:`~ArgumentParser.add_parser`, which takes a command name and any :class:`ArgumentParser` constructor arguments, and returns an :class:`ArgumentParser` object that can be modified as usual. diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -370,10 +370,10 @@ .. method:: FTP.close() Close the connection unilaterally. This should not be applied to an already - closed connection such as after a successful call to :meth:`quit`. After this - call the :class:`FTP` instance should not be used any more (after a call to - :meth:`close` or :meth:`quit` you cannot reopen the connection by issuing - another :meth:`login` method). + closed connection such as after a successful call to :meth:`~FTP.quit`. + After this call the :class:`FTP` instance should not be used any more (after + a call to :meth:`close` or :meth:`~FTP.quit` you cannot reopen the + connection by issuing another :meth:`login` method). FTP_TLS Objects diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst --- a/Doc/library/imp.rst +++ b/Doc/library/imp.rst @@ -239,14 +239,14 @@ .. impl-detail:: - The import internals identify extension modules by filename, so doing - ``foo = load_dynamic("foo", "mod.so")`` and - ``bar = load_dynamic("bar", "mod.so")`` will result in both foo and bar - referring to the same module, regardless of whether or not - ``mod.so`` exports an ``initbar`` function. On systems which - support them, symlinks can be used to import multiple modules from - the same shared library, as each reference to the module will use - a different file name. + The import internals identify extension modules by filename, so doing + ``foo = load_dynamic("foo", "mod.so")`` and + ``bar = load_dynamic("bar", "mod.so")`` will result in both foo and bar + referring to the same module, regardless of whether or not + ``mod.so`` exports an ``initbar`` function. On systems which + support them, symlinks can be used to import multiple modules from + the same shared library, as each reference to the module will use + a different file name. .. function:: load_source(name, pathname[, file]) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -106,9 +106,8 @@ .. classmethod:: chain.from_iterable(iterable) Alternate constructor for :func:`chain`. Gets chained inputs from a - single iterable argument that is evaluated lazily. Equivalent to:: + single iterable argument that is evaluated lazily. Roughly equivalent to:: - @classmethod def from_iterable(iterables): # chain.from_iterable(['ABC', 'DEF']) --> A B C D E F for it in iterables: diff --git a/Doc/library/poplib.rst b/Doc/library/poplib.rst --- a/Doc/library/poplib.rst +++ b/Doc/library/poplib.rst @@ -102,7 +102,7 @@ .. method:: POP3.pass_(password) Send password, response includes message count and mailbox size. Note: the - mailbox on the server is locked until :meth:`quit` is called. + mailbox on the server is locked until :meth:`~poplib.quit` is called. .. method:: POP3.apop(user, secret) diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -32,7 +32,8 @@ setting will be used). For normal use, you should only require the initialization/connect, - :meth:`sendmail`, and :meth:`quit` methods. An example is included below. + :meth:`sendmail`, and :meth:`~smtplib.quit` methods. + An example is included below. .. versionchanged:: 2.6 *timeout* was added. diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -230,7 +230,7 @@ *source_address* was added. -.. function:: getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0) +.. function:: getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]]) Translate the *host*/*port* argument into a sequence of 5-tuples that contain all the necessary arguments for creating a socket connected to that service. @@ -240,12 +240,12 @@ and *port*, you can pass ``NULL`` to the underlying C API. The *family*, *socktype* and *proto* arguments can be optionally specified - in order to narrow the list of addresses returned. Passing zero as a - value for each of these arguments selects the full range of results. + in order to narrow the list of addresses returned. By default, their value + is ``0``, meaning that the full range of results is selected. The *flags* argument can be one or several of the ``AI_*`` constants, - and will influence how results are computed and returned. - For example, :const:`AI_NUMERICHOST` will disable domain name resolution - and will raise an error if *host* is a domain name. + and will influence how results are computed and returned. Its default value + is ``0``. For example, :const:`AI_NUMERICHOST` will disable domain name + resolution and will raise an error if *host* is a domain name. The function returns a list of 5-tuples with the following structure: diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -306,8 +306,8 @@ .. method:: RequestHandler.finish() Called after the :meth:`handle` method to perform any clean-up actions - required. The default implementation does nothing. If :meth:`setup` or - :meth:`handle` raise an exception, this function will not be called. + required. The default implementation does nothing. If :meth:`setup` + raises an exception, this function will not be called. .. method:: RequestHandler.handle() diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -407,6 +407,9 @@ statement. +.. index:: + single: parameter; function definition + .. _function: .. _def: @@ -467,12 +470,15 @@ def func(): pass func = f1(arg)(f2(func)) -.. index:: triple: default; parameter; value +.. index:: + triple: default; parameter; value + single: argument; function definition -When one or more top-level parameters have the form *parameter* ``=`` -*expression*, the function is said to have "default parameter values." For a -parameter with a default value, the corresponding argument may be omitted from a -call, in which case the parameter's default value is substituted. If a +When one or more top-level :term:`parameters ` have the form +*parameter* ``=`` *expression*, the function is said to have "default parameter +values." For a parameter with a default value, the corresponding +:term:`argument` may be omitted from a call, in which +case the parameter's default value is substituted. If a parameter has a default value, all following parameters must also have a default value --- this is a syntactic restriction that is not expressed by the grammar. diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -667,17 +667,18 @@ expressions. +.. index:: + object: callable + single: call + single: argument; call semantics + .. _calls: Calls ----- -.. index:: single: call - -.. index:: object: callable - -A call calls a callable object (e.g., a function) with a possibly empty series -of arguments: +A call calls a callable object (e.g., a :term:`function`) with a possibly empty +series of :term:`arguments `: .. productionlist:: call: `primary` "(" [`argument_list` [","] @@ -696,12 +697,15 @@ A trailing comma may be present after the positional and keyword arguments but does not affect the semantics. +.. index:: + single: parameter; call semantics + The primary must evaluate to a callable object (user-defined functions, built-in functions, methods of built-in objects, class objects, methods of class instances, and certain class instances themselves are callable; extensions may define additional callable object types). All argument expressions are evaluated before the call is attempted. Please refer to section :ref:`function` -for the syntax of formal parameter lists. +for the syntax of formal :term:`parameter` lists. If keyword arguments are present, they are first converted to positional arguments, as follows. First, a list of unfilled slots is created for the @@ -1339,8 +1343,8 @@ .. _operator-summary: -Summary -======= +Operator precedence +=================== .. index:: pair: operator; precedence @@ -1363,9 +1367,9 @@ +-----------------------------------------------+-------------------------------------+ | :keyword:`and` | Boolean AND | +-----------------------------------------------+-------------------------------------+ -| :keyword:`not` *x* | Boolean NOT | +| :keyword:`not` ``x`` | Boolean NOT | +-----------------------------------------------+-------------------------------------+ -| :keyword:`in`, :keyword:`not` :keyword:`in`, | Comparisons, including membership | +| :keyword:`in`, :keyword:`not in`, | Comparisons, including membership | | :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests, | | ``<=``, ``>``, ``>=``, ``<>``, ``!=``, ``==`` | | +-----------------------------------------------+-------------------------------------+ @@ -1391,7 +1395,7 @@ +-----------------------------------------------+-------------------------------------+ | ``(expressions...)``, | Binding or tuple display, | | ``[expressions...]``, | list display, | -| ``{key:datum...}``, | dictionary display, | +| ``{key: value...}``, | dictionary display, | | ```expressions...``` | string conversion | +-----------------------------------------------+-------------------------------------+ diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -84,6 +84,8 @@ settings in Windows. +.. _setting-envvars: + Excursus: Setting environment variables --------------------------------------- diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -701,7 +701,12 @@ def finish(self): if not self.wfile.closed: - self.wfile.flush() + try: + self.wfile.flush() + except socket.error: + # An final socket error may have occurred here, such as + # the local error ECONNABORTED. + pass self.wfile.close() self.rfile.close() diff --git a/Lib/aifc.py b/Lib/aifc.py --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -732,22 +732,28 @@ self._patchheader() def close(self): - self._ensure_header_written(0) - if self._datawritten & 1: - # quick pad to even size - self._file.write(chr(0)) - self._datawritten = self._datawritten + 1 - self._writemarkers() - if self._nframeswritten != self._nframes or \ - self._datalength != self._datawritten or \ - self._marklength: - self._patchheader() - if self._comp: - self._comp.CloseCompressor() - self._comp = None - # Prevent ref cycles - self._convert = None - self._file.close() + if self._file is None: + return + try: + self._ensure_header_written(0) + if self._datawritten & 1: + # quick pad to even size + self._file.write(chr(0)) + self._datawritten = self._datawritten + 1 + self._writemarkers() + if self._nframeswritten != self._nframes or \ + self._datalength != self._datawritten or \ + self._marklength: + self._patchheader() + if self._comp: + self._comp.CloseCompressor() + self._comp = None + finally: + # Prevent ref cycles + self._convert = None + f = self._file + self._file = None + f.close() # # Internal methods. diff --git a/Lib/cgi.py b/Lib/cgi.py --- a/Lib/cgi.py +++ b/Lib/cgi.py @@ -37,7 +37,6 @@ from operator import attrgetter import sys import os -import urllib import UserDict import urlparse diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py --- a/Lib/ctypes/test/test_bitfields.py +++ b/Lib/ctypes/test/test_bitfields.py @@ -246,9 +246,9 @@ _fields_ = [("a", c_uint32, 32)] x = X() x.a = 10 - self.assertEquals(x.a, 10) + self.assertEqual(x.a, 10) x.a = 0xFDCBA987 - self.assertEquals(x.a, 0xFDCBA987) + self.assertEqual(x.a, 0xFDCBA987) @unittest.skipUnless(hasattr(ctypes, "c_uint64"), "c_int64 is required") def test_uint64(self): @@ -256,9 +256,9 @@ _fields_ = [("a", c_uint64, 64)] x = X() x.a = 10 - self.assertEquals(x.a, 10) + self.assertEqual(x.a, 10) x.a = 0xFEDCBA9876543211 - self.assertEquals(x.a, 0xFEDCBA9876543211) + self.assertEqual(x.a, 0xFEDCBA9876543211) if __name__ == "__main__": unittest.main() diff --git a/Lib/curses/__init__.py b/Lib/curses/__init__.py --- a/Lib/curses/__init__.py +++ b/Lib/curses/__init__.py @@ -5,7 +5,7 @@ import curses from curses import textpad - curses.initwin() + curses.initscr() ... """ diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -20,10 +20,11 @@ # 1st 'file' colorized normal, 2nd as builtin, 3rd as string builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) - sqstring = r"(\b[rRuU])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" - dqstring = r'(\b[rRuU])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' - sq3string = r"(\b[rRuU])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" - dq3string = r'(\b[rRuU])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' + stringprefix = r"(\br|u|ur|R|U|UR|Ur|uR|b|B|br|Br|bR|BR)?" + sqstring = stringprefix + r"'[^'\\\n]*(\\.[^'\\\n]*)*'?" + dqstring = stringprefix + r'"[^"\\\n]*(\\.[^"\\\n]*)*"?' + sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" + dq3string = stringprefix + r'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) return kw + "|" + builtin + "|" + comment + "|" + string +\ "|" + any("SYNC", [r"\n"]) diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -172,13 +172,13 @@ 'recent-files.lst') self.text_frame = text_frame = Frame(top) self.vbar = vbar = Scrollbar(text_frame, name='vbar') - self.width = idleConf.GetOption('main','EditorWindow','width') + self.width = idleConf.GetOption('main','EditorWindow','width', type='int') text_options = { 'name': 'text', 'padx': 5, 'wrap': 'none', 'width': self.width, - 'height': idleConf.GetOption('main', 'EditorWindow', 'height')} + 'height': idleConf.GetOption('main', 'EditorWindow', 'height', type='int')} if TkVersion >= 8.5: # Starting with tk 8.5 we have to set the new tabstyle option # to 'wordprocessor' to achieve the same display of tabs as in @@ -255,7 +255,8 @@ if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'): fontWeight='bold' text.config(font=(idleConf.GetOption('main', 'EditorWindow', 'font'), - idleConf.GetOption('main', 'EditorWindow', 'font-size'), + idleConf.GetOption('main', 'EditorWindow', + 'font-size', type='int'), fontWeight)) text_frame.pack(side=LEFT, fill=BOTH, expand=1) text.pack(side=TOP, fill=BOTH, expand=1) @@ -763,7 +764,8 @@ if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'): fontWeight='bold' self.text.config(font=(idleConf.GetOption('main','EditorWindow','font'), - idleConf.GetOption('main','EditorWindow','font-size'), + idleConf.GetOption('main','EditorWindow','font-size', + type='int'), fontWeight)) def RemoveKeybindings(self): @@ -1609,7 +1611,7 @@ try: try: _tokenize.tokenize(self.readline, self.tokeneater) - except _tokenize.TokenError: + except (_tokenize.TokenError, SyntaxError): # since we cut off the tokenizer early, we can trigger # spurious errors pass diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py --- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/FormatParagraph.py @@ -32,7 +32,8 @@ self.editwin = None def format_paragraph_event(self, event): - maxformatwidth = int(idleConf.GetOption('main','FormatParagraph','paragraph')) + maxformatwidth = int(idleConf.GetOption('main','FormatParagraph', + 'paragraph', type='int')) text = self.editwin.text first, last = self.editwin.get_selection_indices() if first and last: diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -947,7 +947,7 @@ self.listFontName.select_anchor(currentFontIndex) ##font size dropdown fontSize=idleConf.GetOption('main','EditorWindow','font-size', - default='10') + type='int', default='10') self.optMenuFontSize.SetMenu(('7','8','9','10','11','12','13','14', '16','18','20','22'),fontSize ) ##fontWeight @@ -1033,10 +1033,13 @@ self.autoSave.set(idleConf.GetOption('main', 'General', 'autosave', default=0, type='bool')) #initial window size - self.winWidth.set(idleConf.GetOption('main','EditorWindow','width')) - self.winHeight.set(idleConf.GetOption('main','EditorWindow','height')) + self.winWidth.set(idleConf.GetOption('main','EditorWindow','width', + type='int')) + self.winHeight.set(idleConf.GetOption('main','EditorWindow','height', + type='int')) #initial paragraph reformat size - self.paraWidth.set(idleConf.GetOption('main','FormatParagraph','paragraph')) + self.paraWidth.set(idleConf.GetOption('main','FormatParagraph','paragraph', + type='int')) # default source encoding self.encoding.set(idleConf.GetOption('main', 'EditorWindow', 'encoding', default='none')) diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -237,24 +237,39 @@ printed to stderr. """ - if self.userCfg[configType].has_option(section,option): - return self.userCfg[configType].Get(section, option, - type=type, raw=raw) - elif self.defaultCfg[configType].has_option(section,option): - return self.defaultCfg[configType].Get(section, option, - type=type, raw=raw) - else: #returning default, print warning - if warn_on_default: - warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' - ' problem retrieving configuration option %r\n' - ' from section %r.\n' - ' returning default value: %r\n' % - (option, section, default)) - try: - sys.stderr.write(warning) - except IOError: - pass - return default + try: + if self.userCfg[configType].has_option(section,option): + return self.userCfg[configType].Get(section, option, + type=type, raw=raw) + except ValueError: + warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' + ' invalid %r value for configuration option %r\n' + ' from section %r: %r\n' % + (type, option, section, + self.userCfg[configType].Get(section, option, + raw=raw))) + try: + sys.stderr.write(warning) + except IOError: + pass + try: + if self.defaultCfg[configType].has_option(section,option): + return self.defaultCfg[configType].Get(section, option, + type=type, raw=raw) + except ValueError: + pass + #returning default, print warning + if warn_on_default: + warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' + ' problem retrieving configuration option %r\n' + ' from section %r.\n' + ' returning default value: %r\n' % + (option, section, default)) + try: + sys.stderr.write(warning) + except IOError: + pass + return default def SetOption(self, configType, section, option, value): """In user's config file, set section's option to value. diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -200,6 +200,27 @@ return c1, c2 else: + if hasattr(select, 'poll'): + def _poll(fds, timeout): + if timeout is not None: + timeout = int(timeout) * 1000 # timeout is in milliseconds + fd_map = {} + pollster = select.poll() + for fd in fds: + pollster.register(fd, select.POLLIN) + if hasattr(fd, 'fileno'): + fd_map[fd.fileno()] = fd + else: + fd_map[fd] = fd + ls = [] + for fd, event in pollster.poll(timeout): + if event & select.POLLNVAL: + raise ValueError('invalid file descriptor %i' % fd) + ls.append(fd_map[fd]) + return ls + else: + def _poll(fds, timeout): + return select.select(fds, [], [], timeout)[0] from _multiprocessing import win32 diff --git a/Lib/socket.py b/Lib/socket.py --- a/Lib/socket.py +++ b/Lib/socket.py @@ -319,8 +319,8 @@ self._wbuf.append(data) self._wbuf_len += len(data) if (self._wbufsize == 0 or - self._wbufsize == 1 and '\n' in data or - self._wbuf_len >= self._wbufsize): + (self._wbufsize == 1 and '\n' in data) or + (self._wbufsize > 1 and self._wbuf_len >= self._wbufsize)): self.flush() def writelines(self, list): diff --git a/Lib/ssl.py b/Lib/ssl.py --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -313,17 +313,19 @@ self.cert_reqs, self.ssl_version, self.ca_certs, self.ciphers) try: - socket.connect(self, addr) - if self.do_handshake_on_connect: - self.do_handshake() - except socket_error as e: if return_errno: - return e.errno + rc = socket.connect_ex(self, addr) else: - self._sslobj = None - raise e - self._connected = True - return 0 + rc = None + socket.connect(self, addr) + if not rc: + if self.do_handshake_on_connect: + self.do_handshake() + self._connected = True + return rc + except socket_error: + self._sslobj = None + raise def connect(self, addr): """Connects to remote ADDR, and then wraps the connection in diff --git a/Lib/subprocess.py b/Lib/subprocess.py --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1292,7 +1292,7 @@ def _internal_poll(self, _deadstate=None, _waitpid=os.waitpid, - _WNOHANG=os.WNOHANG, _os_error=os.error): + _WNOHANG=os.WNOHANG, _os_error=os.error, _ECHILD=errno.ECHILD): """Check if child process has terminated. Returns returncode attribute. @@ -1308,7 +1308,7 @@ except _os_error as e: if _deadstate is not None: self.returncode = _deadstate - if e.errno == errno.ECHILD: + if e.errno == _ECHILD: # This happens if SIGCLD is set to be ignored or # waiting for child processes has otherwise been # disabled for our process. This child is dead, we diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -32,7 +32,7 @@ Selecting tests --r/--random -- randomize test execution order (see below) +-r/--randomize -- randomize test execution order (see below) --randseed -- pass a random seed to reproduce a previous random run -f/--fromfile -- read names of tests to run from a file (see below) -x/--exclude -- arguments are tests to *exclude* @@ -258,7 +258,7 @@ try: opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:j:', ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', - 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks', + 'exclude', 'single', 'slow', 'randomize', 'fromfile=', 'findleaks', 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir', 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=', 'multiprocess=', 'slaveargs=', 'forever', 'header']) diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py --- a/Lib/test/test_aifc.py +++ b/Lib/test/test_aifc.py @@ -106,6 +106,13 @@ self.assertEqual(testfile.closed, False) f.close() self.assertEqual(testfile.closed, True) + testfile = open(TESTFN, 'wb') + fout = aifc.open(testfile, 'wb') + self.assertFalse(testfile.closed) + with self.assertRaises(aifc.Error): + fout.close() + self.assertTrue(testfile.closed) + fout.close() # do nothing class AIFCLowLevelTest(unittest.TestCase): diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -680,6 +680,8 @@ # Test input() later, together with raw_input + # test_int(): see test_int.py for int() tests. + def test_intern(self): self.assertRaises(TypeError, intern) # This fails if the test is run twice with a constant string, diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -261,7 +261,7 @@ return calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10) new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) - self.assertEquals(old_october, new_october) + self.assertEqual(old_october, new_october) def test_itermonthdates(self): # ensure itermonthdates doesn't overflow after datetime.MAXYEAR diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -1,9 +1,14 @@ -import unittest -from test.test_support import run_unittest, TESTFN import glob import os import shutil import sys +import unittest + +from test.test_support import run_unittest, TESTFN + + +def fsdecode(s): + return unicode(s, sys.getfilesystemencoding()) class GlobTests(unittest.TestCase): @@ -31,7 +36,8 @@ self.mktemp('a', 'bcd', 'efg', 'ha') if hasattr(os, 'symlink'): os.symlink(self.norm('broken'), self.norm('sym1')) - os.symlink(self.norm('broken'), self.norm('sym2')) + os.symlink('broken', self.norm('sym2')) + os.symlink(os.path.join('a', 'bcd'), self.norm('sym3')) def tearDown(self): shutil.rmtree(self.tempdir) @@ -44,10 +50,16 @@ p = os.path.join(self.tempdir, pattern) res = glob.glob(p) self.assertEqual(list(glob.iglob(p)), res) + ures = [fsdecode(x) for x in res] + self.assertEqual(glob.glob(fsdecode(p)), ures) + self.assertEqual(list(glob.iglob(fsdecode(p))), ures) return res def assertSequencesEqual_noorder(self, l1, l2): + l1 = list(l1) + l2 = list(l2) self.assertEqual(set(l1), set(l2)) + self.assertEqual(sorted(l1), sorted(l2)) def test_glob_literal(self): eq = self.assertSequencesEqual_noorder @@ -56,15 +68,19 @@ eq(self.glob('aab'), [self.norm('aab')]) eq(self.glob('zymurgy'), []) + res = glob.glob('*') + self.assertEqual({type(r) for r in res}, {str}) + res = glob.glob(os.path.join(os.curdir, '*')) + self.assertEqual({type(r) for r in res}, {str}) + # test return types are unicode, but only if os.listdir # returns unicode filenames - uniset = set([unicode]) - tmp = os.listdir(u'.') - if set(type(x) for x in tmp) == uniset: - u1 = glob.glob(u'*') - u2 = glob.glob(u'./*') - self.assertEqual(set(type(r) for r in u1), uniset) - self.assertEqual(set(type(r) for r in u2), uniset) + tmp = os.listdir(fsdecode(os.curdir)) + if {type(x) for x in tmp} == {unicode}: + res = glob.glob(u'*') + self.assertEqual({type(r) for r in res}, {unicode}) + res = glob.glob(os.path.join(fsdecode(os.curdir), u'*')) + self.assertEqual({type(r) for r in res}, {unicode}) def test_glob_one_directory(self): eq = self.assertSequencesEqual_noorder @@ -93,23 +109,60 @@ eq(self.glob('*', '*a'), []) eq(self.glob('a', '*', '*', '*a'), [self.norm('a', 'bcd', 'efg', 'ha')]) - eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'), - os.path.join('aab', 'F')])) + eq(self.glob('?a?', '*F'), [self.norm('aaa', 'zzzF'), + self.norm('aab', 'F')]) def test_glob_directory_with_trailing_slash(self): - # We are verifying that when there is wildcard pattern which - # ends with os.sep doesn't blow up. - res = glob.glob(self.tempdir + '*' + os.sep) - self.assertEqual(len(res), 1) - # either of these results are reasonable - self.assertIn(res[0], [self.tempdir, self.tempdir + os.sep]) + # Patterns ending with a slash shouldn't match non-dirs + res = glob.glob(self.norm('Z*Z') + os.sep) + self.assertEqual(res, []) + res = glob.glob(self.norm('ZZZ') + os.sep) + self.assertEqual(res, []) + # When there is a wildcard pattern which ends with os.sep, glob() + # doesn't blow up. + res = glob.glob(self.norm('aa*') + os.sep) + self.assertEqual(len(res), 2) + # either of these results is reasonable + self.assertIn(set(res), [ + {self.norm('aaa'), self.norm('aab')}, + {self.norm('aaa') + os.sep, self.norm('aab') + os.sep}, + ]) + def test_glob_unicode_directory_with_trailing_slash(self): + # Same as test_glob_directory_with_trailing_slash, but with an + # unicode argument. + res = glob.glob(fsdecode(self.norm('Z*Z') + os.sep)) + self.assertEqual(res, []) + res = glob.glob(fsdecode(self.norm('ZZZ') + os.sep)) + self.assertEqual(res, []) + res = glob.glob(fsdecode(self.norm('aa*') + os.sep)) + self.assertEqual(len(res), 2) + # either of these results is reasonable + self.assertIn(set(res), [ + {fsdecode(self.norm('aaa')), fsdecode(self.norm('aab'))}, + {fsdecode(self.norm('aaa') + os.sep), + fsdecode(self.norm('aab') + os.sep)}, + ]) + + @unittest.skipUnless(hasattr(os, 'symlink'), "Requires symlink support") + def test_glob_symlinks(self): + eq = self.assertSequencesEqual_noorder + eq(self.glob('sym3'), [self.norm('sym3')]) + eq(self.glob('sym3', '*'), [self.norm('sym3', 'EF'), + self.norm('sym3', 'efg')]) + self.assertIn(self.glob('sym3' + os.sep), + [[self.norm('sym3')], [self.norm('sym3') + os.sep]]) + eq(self.glob('*', '*F'), + [self.norm('aaa', 'zzzF'), self.norm('aab', 'F'), + self.norm('sym3', 'EF')]) + + @unittest.skipUnless(hasattr(os, 'symlink'), "Requires symlink support") def test_glob_broken_symlinks(self): - if hasattr(os, 'symlink'): - eq = self.assertSequencesEqual_noorder - eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2')]) - eq(self.glob('sym1'), [self.norm('sym1')]) - eq(self.glob('sym2'), [self.norm('sym2')]) + eq = self.assertSequencesEqual_noorder + eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2'), + self.norm('sym3')]) + eq(self.glob('sym1'), [self.norm('sym1')]) + eq(self.glob('sym2'), [self.norm('sym2')]) @unittest.skipUnless(sys.platform == "win32", "Win32 specific test") def test_glob_magic_in_drive(self): diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -5,6 +5,7 @@ import py_compile import random import stat +import struct import sys import unittest import textwrap @@ -350,6 +351,46 @@ del sys.path[0] remove_files(TESTFN) + def test_pyc_mtime(self): + # Test for issue #13863: .pyc timestamp sometimes incorrect on Windows. + sys.path.insert(0, os.curdir) + try: + # Jan 1, 2012; Jul 1, 2012. + mtimes = 1325376000, 1341100800 + + # Different names to avoid running into import caching. + tails = "spam", "eggs" + for mtime, tail in zip(mtimes, tails): + module = TESTFN + tail + source = module + ".py" + compiled = source + ('c' if __debug__ else 'o') + + # Create a new Python file with the given mtime. + with open(source, 'w') as f: + f.write("# Just testing\nx=1, 2, 3\n") + os.utime(source, (mtime, mtime)) + + # Generate the .pyc/o file; if it couldn't be created + # for some reason, skip the test. + m = __import__(module) + if not os.path.exists(compiled): + unlink(source) + self.skipTest("Couldn't create .pyc/.pyo file.") + + # Actual modification time of .py file. + mtime1 = int(os.stat(source).st_mtime) & 0xffffffff + + # mtime that was encoded in the .pyc file. + with open(compiled, 'rb') as f: + mtime2 = struct.unpack('> self.serv_file, msg, + print >> self.serv_file, msg + + # second line: + print >> self.serv_file, msg, + print >> self.serv_file, msg, + print >> self.serv_file, msg + + # third line + print >> self.serv_file, '' + + self.serv_file.flush() + + msg1 = "%s %s\n"%(msg, msg) + msg2 = "%s %s %s\n"%(msg, msg, msg) + msg3 = "\n" + self.assertEqual(self.serv_file._sock.getsent(), [msg1, msg2, msg3]) + + def _testLinebufferedWrite(self): + msg = MSG.strip() + msg1 = "%s %s\n"%(msg, msg) + msg2 = "%s %s %s\n"%(msg, msg, msg) + msg3 = "\n" + l1 = self.cli_file.readline() + self.assertEqual(l1, msg1) + l2 = self.cli_file.readline() + self.assertEqual(l2, msg2) + l3 = self.cli_file.readline() + self.assertEqual(l3, msg3) + class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -280,6 +280,34 @@ finally: s.close() + def test_timeout_connect_ex(self): + # Issue #12065: on a timeout, connect_ex() should return the original + # errno (mimicking the behaviour of non-SSL sockets). + with test_support.transient_internet("svn.python.org"): + s = ssl.wrap_socket(socket.socket(socket.AF_INET), + cert_reqs=ssl.CERT_REQUIRED, + ca_certs=SVN_PYTHON_ORG_ROOT_CERT, + do_handshake_on_connect=False) + try: + s.settimeout(0.0000001) + rc = s.connect_ex(('svn.python.org', 443)) + if rc == 0: + self.skipTest("svn.python.org responded too quickly") + self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK)) + finally: + s.close() + + def test_connect_ex_error(self): + with test_support.transient_internet("svn.python.org"): + s = ssl.wrap_socket(socket.socket(socket.AF_INET), + cert_reqs=ssl.CERT_REQUIRED, + ca_certs=SVN_PYTHON_ORG_ROOT_CERT) + try: + self.assertEqual(errno.ECONNREFUSED, + s.connect_ex(("svn.python.org", 444))) + finally: + s.close() + @unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows") def test_makefile_close(self): # Issue #5238: creating a file-like object with makefile() shouldn't diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -297,26 +297,21 @@ def test_extract_hardlink(self): # Test hardlink extraction (e.g. bug #857297). - tar = tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") + with tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") as tar: + tar.extract("ustar/regtype", TEMPDIR) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/regtype")) - tar.extract("ustar/regtype", TEMPDIR) - try: tar.extract("ustar/lnktype", TEMPDIR) - except EnvironmentError, e: - if e.errno == errno.ENOENT: - self.fail("hardlink not extracted properly") + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/lnktype")) + with open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb") as f: + data = f.read() + self.assertEqual(md5sum(data), md5_regtype) - data = open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb").read() - self.assertEqual(md5sum(data), md5_regtype) - - try: tar.extract("ustar/symtype", TEMPDIR) - except EnvironmentError, e: - if e.errno == errno.ENOENT: - self.fail("symlink not extracted properly") - - data = open(os.path.join(TEMPDIR, "ustar/symtype"), "rb").read() - self.assertEqual(md5sum(data), md5_regtype) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/symtype")) + with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f: + data = f.read() + self.assertEqual(md5sum(data), md5_regtype) def test_extractall(self): # Test if extractall() correctly restores directory permissions @@ -858,7 +853,7 @@ tar = tarfile.open(tmpname, "r") for t in tar: - self.assert_(t.name == "." or t.name.startswith("./")) + self.assertTrue(t.name == "." or t.name.startswith("./")) tar.close() finally: os.chdir(cwd) diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1336,16 +1336,32 @@ req = Request(url) self.assertEqual(req.get_full_url(), url) -def test_HTTPError_interface(): - """ - Issue 13211 reveals that HTTPError didn't implement the URLError - interface even though HTTPError is a subclass of URLError. + def test_HTTPError_interface(self): + """ + Issue 13211 reveals that HTTPError didn't implement the URLError + interface even though HTTPError is a subclass of URLError. - >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) - >>> assert hasattr(err, 'reason') - >>> err.reason - 'something bad happened' - """ + >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) + >>> assert hasattr(err, 'reason') + >>> err.reason + 'something bad happened' + """ + + def test_HTTPError_interface_call(self): + """ + Issue 15701= - HTTPError interface has info method available from URLError. + """ + err = urllib2.HTTPError(msg='something bad happened', url=None, + code=None, hdrs='Content-Length:42', fp=None) + self.assertTrue(hasattr(err, 'reason')) + assert hasattr(err, 'reason') + assert hasattr(err, 'info') + assert callable(err.info) + try: + err.info() + except AttributeError: + self.fail("err.info() failed") + self.assertEqual(err.info(), "Content-Length:42") def test_main(verbose=None): from test import test_urllib2 diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -5,7 +5,9 @@ import BaseHTTPServer import unittest import hashlib + from test import test_support + mimetools = test_support.import_module('mimetools', deprecated=True) threading = test_support.import_module('threading') @@ -346,6 +348,12 @@ for transparent redirection have been written. """ + def setUp(self): + proxy_handler = urllib2.ProxyHandler({}) + opener = urllib2.build_opener(proxy_handler) + urllib2.install_opener(opener) + super(TestUrlopen, self).setUp() + def start_server(self, responses): handler = GetRequestHandler(responses) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -446,10 +446,43 @@ p1 = urlparse.urlsplit('tel:+31-641044153') self.assertEqual(p1.scheme, 'tel') self.assertEqual(p1.path, '+31-641044153') + p2 = urlparse.urlsplit('tel:+31641044153') self.assertEqual(p2.scheme, 'tel') self.assertEqual(p2.path, '+31641044153') + # Assert for urlparse + p1 = urlparse.urlparse('tel:+31-641044153') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+31-641044153') + + p2 = urlparse.urlparse('tel:+31641044153') + self.assertEqual(p2.scheme, 'tel') + self.assertEqual(p2.path, '+31641044153') + + + def test_telurl_params(self): + p1 = urlparse.urlparse('tel:123-4;phone-context=+1-650-516') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '123-4') + self.assertEqual(p1.params, 'phone-context=+1-650-516') + + p1 = urlparse.urlparse('tel:+1-201-555-0123') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+1-201-555-0123') + self.assertEqual(p1.params, '') + + p1 = urlparse.urlparse('tel:7042;phone-context=example.com') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '7042') + self.assertEqual(p1.params, 'phone-context=example.com') + + p1 = urlparse.urlparse('tel:863-1234;phone-context=+1-914-555') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '863-1234') + self.assertEqual(p1.params, 'phone-context=+1-914-555') + + def test_attributes_bad_port(self): """Check handling of non-integer ports.""" p = urlparse.urlsplit("http://www.example.net:foo") diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -314,6 +314,35 @@ finally: DeleteKey(HKEY_CURRENT_USER, test_key_name) + def test_setvalueex_value_range(self): + # Test for Issue #14420, accept proper ranges for SetValueEx. + # Py2Reg, which gets called by SetValueEx, was using PyLong_AsLong, + # thus raising OverflowError. The implementation now uses + # PyLong_AsUnsignedLong to match DWORD's size. + try: + with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: + self.assertNotEqual(ck.handle, 0) + SetValueEx(ck, "test_name", None, REG_DWORD, 0x80000000) + finally: + DeleteKey(HKEY_CURRENT_USER, test_key_name) + + def test_queryvalueex_return_value(self): + # Test for Issue #16759, return unsigned int from QueryValueEx. + # Reg2Py, which gets called by QueryValueEx, was returning a value + # generated by PyLong_FromLong. The implmentation now uses + # PyLong_FromUnsignedLong to match DWORD's size. + try: + with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: + self.assertNotEqual(ck.handle, 0) + test_val = 0x80000000 + SetValueEx(ck, "test_name", None, REG_DWORD, test_val) + ret_val, ret_type = QueryValueEx(ck, "test_name") + self.assertEqual(ret_type, REG_DWORD) + self.assertEqual(ret_val, test_val) + finally: + DeleteKey(HKEY_CURRENT_USER, test_key_name) + + @unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests") class RemoteWinregTests(BaseWinregTests): diff --git a/Lib/urllib2.py b/Lib/urllib2.py --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -173,6 +173,9 @@ def reason(self): return self.msg + def info(self): + return self.hdrs + # copied from cookielib.py _cut_port_re = re.compile(r":\d+$") def request_host(request): diff --git a/Lib/urlparse.py b/Lib/urlparse.py --- a/Lib/urlparse.py +++ b/Lib/urlparse.py @@ -42,7 +42,7 @@ 'svn', 'svn+ssh', 'sftp','nfs','git', 'git+ssh'] uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', - 'mms', '', 'sftp'] + 'mms', '', 'sftp', 'tel'] # These are not actually used anymore, but should stay for backwards # compatibility. (They are undocumented, but have a public-looking name.) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -499,6 +499,7 @@ Peter van Kampen Jacob Kaplan-Moss Piotr Kasprzyk +Anton Kasyanov Lou Kates Hiroaki Kawai Sebastien Keim diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,21 @@ Core and Builtins ----------------- +- Issue #16761: Calling ``int()`` and ``long()`` with *base* argument only + now raises TypeError. + +- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py + when retreiving a REG_DWORD value. This corrects functions like + winreg.QueryValueEx that may have been returning truncated values. + +- Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg + when passed a REG_DWORD value. Fixes ValueError in winreg.SetValueEx when + given a long. + +- Issue #13863: Work around buggy 'fstat' implementation on Windows / NTFS that + lead to incorrect timestamps (off by one hour) being stored in .pyc files on + some systems. + - Issue #16602: When a weakref's target was part of a long deallocation chain, the object could remain reachable through its weakref even though its refcount had dropped to zero. @@ -160,11 +175,32 @@ Library ------- +- Issue 10527: make multiprocessing use poll() instead of select() if available. + +- Issue #16485: Fix file descriptor not being closed if file header patching + fails on closing of aifc file. + +- Issue #12065: connect_ex() on an SSL socket now returns the original errno + when the socket's timeout expires (it used to return None). + +- Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by + Roger Serwy. + +- Issue #16702: test_urllib2_localnet tests now correctly ignores proxies for + localhost tests. + +- Issue #16713: Fix the parsing of tel url with params using urlparse module. + +- Issue #16443: Add docstrings to regular expression match objects. + Patch by Anton Kasyanov. + - Issue #8853: Allow port to be of type long for socket.getaddrinfo(). - Issue #16597: In buffered and text IO, call close() on the underlying stream if invoking flush() fails. +- Issue #15701: Fix HTTPError info method call to return the headers information. + - Issue #16646: ftplib.FTP.makeport() might lose socket error details. (patch by Serhiy Storchaka) @@ -394,6 +430,9 @@ - Issue #12157: Make pool.map() empty iterables correctly. Initial patch by mouad. +- Issue #14958: Change IDLE systax highlighting to recognize all string and byte + literals currently supported in Python 2.7. + - Issue #14962: Update text coloring in IDLE shell window after changing options. Patch by Roger Serwy. @@ -560,6 +599,11 @@ Tests ----- +- Issue #15324: Fix regrtest parsing of --fromfile and --randomize options. + +- Issue #16618: Add more regression tests for glob. + Patch by Serhiy Storchaka. + - Issue #16664: Add regression tests for glob's behaviour concerning entries starting with a ".". Patch by Sebastian Kreft. diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -844,11 +844,11 @@ space[0] = errno; errno = temp; } - Py_XDECREF(error_object); #ifdef WITH_THREAD if ((flags & FUNCFLAG_PYTHONAPI) == 0) Py_BLOCK_THREADS #endif + Py_XDECREF(error_object); #ifdef MS_WIN32 #ifndef DONT_USE_SEH if (dwExceptionCode) { diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2546,7 +2546,7 @@ PyDoc_STRVAR(pattern_search_doc, "search(string[, pos[, endpos]]) --> match object or None.\n\ Scan through string looking for a match, and return a corresponding\n\ - MatchObject instance. Return None if no position in the string matches."); + match object instance. Return None if no position in the string matches."); PyDoc_STRVAR(pattern_split_doc, "split(string[, maxsplit = 0]) --> list.\n\ @@ -3545,14 +3545,54 @@ #endif } -static struct PyMethodDef match_methods[] = { - {"group", (PyCFunction) match_group, METH_VARARGS}, - {"start", (PyCFunction) match_start, METH_VARARGS}, - {"end", (PyCFunction) match_end, METH_VARARGS}, - {"span", (PyCFunction) match_span, METH_VARARGS}, - {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS}, - {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS}, - {"expand", (PyCFunction) match_expand, METH_O}, +PyDoc_STRVAR(match_doc, +"The result of re.match() and re.search().\n\ +Match objects always have a boolean value of True."); + +PyDoc_STRVAR(match_group_doc, +"group([group1, ...]) -> str or tuple.\n\ + Return subgroup(s) of the match by indices or names.\n\ + For 0 returns the entire match."); + +PyDoc_STRVAR(match_start_doc, +"start([group=0]) -> int.\n\ + Return index of the start of the substring matched by group."); + +PyDoc_STRVAR(match_end_doc, +"end([group=0]) -> int.\n\ + Return index of the end of the substring matched by group."); + +PyDoc_STRVAR(match_span_doc, +"span([group]) -> tuple.\n\ + For MatchObject m, return the 2-tuple (m.start(group), m.end(group))."); + +PyDoc_STRVAR(match_groups_doc, +"groups([default=None]) -> tuple.\n\ + Return a tuple containing all the subgroups of the match, from 1.\n\ + The default argument is used for groups\n\ + that did not participate in the match"); + +PyDoc_STRVAR(match_groupdict_doc, +"groupdict([default=None]) -> dict.\n\ + Return a dictionary containing all the named subgroups of the match,\n\ + keyed by the subgroup name. The default argument is used for groups\n\ + that did not participate in the match"); + +PyDoc_STRVAR(match_expand_doc, +"expand(template) -> str.\n\ + Return the string obtained by doing backslash substitution\n\ + on the string template, as done by the sub() method."); + +static PyMethodDef match_methods[] = { + {"group", (PyCFunction) match_group, METH_VARARGS, match_group_doc}, + {"start", (PyCFunction) match_start, METH_VARARGS, match_start_doc}, + {"end", (PyCFunction) match_end, METH_VARARGS, match_end_doc}, + {"span", (PyCFunction) match_span, METH_VARARGS, match_span_doc}, + {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS, + match_groups_doc}, + {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS, + match_groupdict_doc}, + {"expand", (PyCFunction) match_expand, METH_O, match_expand_doc}, {"__copy__", (PyCFunction) match_copy, METH_NOARGS}, {"__deepcopy__", (PyCFunction) match_deepcopy, METH_O}, {NULL, NULL} @@ -3632,7 +3672,7 @@ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, - 0, /* tp_doc */ + match_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/Objects/intobject.c b/Objects/intobject.c --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -1059,8 +1059,14 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:int", kwlist, &x, &base)) return NULL; - if (x == NULL) + if (x == NULL) { + if (base != -909) { + PyErr_SetString(PyExc_TypeError, + "int() missing string argument"); + return NULL; + } return PyInt_FromLong(0L); + } if (base == -909) return PyNumber_Int(x); if (PyString_Check(x)) { diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -3987,8 +3987,14 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:long", kwlist, &x, &base)) return NULL; - if (x == NULL) + if (x == NULL) { + if (base != -909) { + PyErr_SetString(PyExc_TypeError, + "long() missing string argument"); + return NULL; + } return PyLong_FromLong(0L); + } if (base == -909) return PyNumber_Long(x); else if (PyString_Check(x)) { diff --git a/PC/_winreg.c b/PC/_winreg.c --- a/PC/_winreg.c +++ b/PC/_winreg.c @@ -753,7 +753,8 @@ Py_ssize_t i,j; switch (typ) { case REG_DWORD: - if (value != Py_None && !PyInt_Check(value)) + if (value != Py_None && + !(PyInt_Check(value) || PyLong_Check(value))) return FALSE; *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); if (*retDataBuf==NULL){ @@ -765,10 +766,10 @@ DWORD zero = 0; memcpy(*retDataBuf, &zero, sizeof(DWORD)); } - else - memcpy(*retDataBuf, - &PyInt_AS_LONG((PyIntObject *)value), - sizeof(DWORD)); + else { + DWORD d = PyLong_AsUnsignedLong(value); + memcpy(*retDataBuf, &d, sizeof(DWORD)); + } break; case REG_SZ: case REG_EXPAND_SZ: @@ -917,9 +918,9 @@ switch (typ) { case REG_DWORD: if (retDataSize == 0) - obData = Py_BuildValue("i", 0); + obData = Py_BuildValue("k", 0); else - obData = Py_BuildValue("i", + obData = Py_BuildValue("k", *(int *)retDataBuf); break; case REG_SZ: diff --git a/Python/import.c b/Python/import.c --- a/Python/import.c +++ b/Python/import.c @@ -904,10 +904,9 @@ remove the file. */ static void -write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat) +write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, time_t mtime) { FILE *fp; - time_t mtime = srcstat->st_mtime; #ifdef MS_WINDOWS /* since Windows uses different permissions */ mode_t mode = srcstat->st_mode & ~S_IEXEC; /* Issue #6074: We ensure user write access, so we can delete it later @@ -993,6 +992,38 @@ return 1; } +#ifdef MS_WINDOWS + +/* Seconds between 1.1.1601 and 1.1.1970 */ +static __int64 secs_between_epochs = 11644473600; + +/* Get mtime from file pointer. */ + +static time_t +win32_mtime(FILE *fp, char *pathname) +{ + __int64 filetime; + HANDLE fh; + BY_HANDLE_FILE_INFORMATION file_information; + + fh = (HANDLE)_get_osfhandle(fileno(fp)); + if (fh == INVALID_HANDLE_VALUE || + !GetFileInformationByHandle(fh, &file_information)) { + PyErr_Format(PyExc_RuntimeError, + "unable to get file status from '%s'", + pathname); + return -1; + } + /* filetime represents the number of 100ns intervals since + 1.1.1601 (UTC). Convert to seconds since 1.1.1970 (UTC). */ + filetime = (__int64)file_information.ftLastWriteTime.dwHighDateTime << 32 | + file_information.ftLastWriteTime.dwLowDateTime; + return filetime / 10000000 - secs_between_epochs; +} + +#endif /* #ifdef MS_WINDOWS */ + + /* Load a source module from a given file and return its module object WITH INCREMENTED REFERENCE COUNT. If there's a matching byte-compiled file, use that instead. */ @@ -1006,6 +1037,7 @@ char *cpathname; PyCodeObject *co = NULL; PyObject *m; + time_t mtime; if (fstat(fileno(fp), &st) != 0) { PyErr_Format(PyExc_RuntimeError, @@ -1013,13 +1045,21 @@ pathname); return NULL; } - if (sizeof st.st_mtime > 4) { + +#ifdef MS_WINDOWS + mtime = win32_mtime(fp, pathname); + if (mtime == (time_t)-1 && PyErr_Occurred()) + return NULL; +#else + mtime = st.st_mtime; +#endif + if (sizeof mtime > 4) { /* Python's .pyc timestamp handling presumes that the timestamp fits in 4 bytes. Since the code only does an equality comparison, ordering is not important and we can safely ignore the higher bits (collisions are extremely unlikely). */ - st.st_mtime &= 0xFFFFFFFF; + mtime &= 0xFFFFFFFF; } buf = PyMem_MALLOC(MAXPATHLEN+1); if (buf == NULL) { @@ -1028,7 +1068,7 @@ cpathname = make_compiled_pathname(pathname, buf, (size_t)MAXPATHLEN + 1); if (cpathname != NULL && - (fpc = check_compiled_module(pathname, st.st_mtime, cpathname))) { + (fpc = check_compiled_module(pathname, mtime, cpathname))) { co = read_compiled_module(cpathname, fpc); fclose(fpc); if (co == NULL) @@ -1053,7 +1093,7 @@ if (b < 0) goto error_exit; if (!b) - write_compiled_module(co, cpathname, &st); + write_compiled_module(co, cpathname, &st, mtime); } } m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 04:44:32 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 1 Jan 2013 04:44:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_update_another?= =?utf-8?q?_year?= Message-ID: <3Yb1V81VmZzSBD@mail.python.org> http://hg.python.org/cpython/rev/eb7c5a36bd2c changeset: 81184:eb7c5a36bd2c branch: 3.3 parent: 81180:24d6e8ca27d2 user: Benjamin Peterson date: Mon Dec 31 21:44:00 2012 -0600 summary: update another year files: Doc/README.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/README.txt b/Doc/README.txt --- a/Doc/README.txt +++ b/Doc/README.txt @@ -135,7 +135,7 @@ as long as you don't change or remove the copyright notice: ---------------------------------------------------------------------- -Copyright (c) 2000-2012 Python Software Foundation. +Copyright (c) 2000-2013 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 04:44:33 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 1 Jan 2013 04:44:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3Yb1V95TjwzSBJ@mail.python.org> http://hg.python.org/cpython/rev/47d2664b1da4 changeset: 81185:47d2664b1da4 parent: 81181:4e4c102a018a parent: 81184:eb7c5a36bd2c user: Benjamin Peterson date: Mon Dec 31 21:44:06 2012 -0600 summary: merge 3.3 files: Doc/README.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/README.txt b/Doc/README.txt --- a/Doc/README.txt +++ b/Doc/README.txt @@ -135,7 +135,7 @@ as long as you don't change or remove the copyright notice: ---------------------------------------------------------------------- -Copyright (c) 2000-2012 Python Software Foundation. +Copyright (c) 2000-2013 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 04:44:35 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 1 Jan 2013 04:44:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_update_another?= =?utf-8?q?_year?= Message-ID: <3Yb1VC0jLhzSCh@mail.python.org> http://hg.python.org/cpython/rev/e36513032265 changeset: 81186:e36513032265 branch: 2.7 parent: 81183:77507e14db81 user: Benjamin Peterson date: Mon Dec 31 21:44:00 2012 -0600 summary: update another year files: Doc/README.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/README.txt b/Doc/README.txt --- a/Doc/README.txt +++ b/Doc/README.txt @@ -127,7 +127,7 @@ as long as you don't change or remove the copyright notice: ---------------------------------------------------------------------- -Copyright (c) 2000-2012 Python Software Foundation. +Copyright (c) 2000-2013 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Tue Jan 1 05:54:15 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 01 Jan 2013 05:54:15 +0100 Subject: [Python-checkins] Daily reference leaks (0a095821c74e): sum=0 Message-ID: results for 0a095821c74e on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogYkTXoL', '-x'] From python-checkins at python.org Tue Jan 1 15:28:49 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 1 Jan 2013 15:28:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_overlooked_licence_tex?= =?utf-8?q?t=2E?= Message-ID: <3YbHnY12rJzSBX@mail.python.org> http://hg.python.org/cpython/rev/eaba31b32efd changeset: 81187:eaba31b32efd parent: 81185:47d2664b1da4 user: Richard Oudkerk date: Tue Jan 01 14:25:59 2013 +0000 summary: Fix overlooked licence text. files: Lib/multiprocessing/__init__.py | 6 -- Lib/multiprocessing/dummy/__init__.py | 27 +------------ Lib/multiprocessing/dummy/connection.py | 27 +------------ 3 files changed, 2 insertions(+), 58 deletions(-) diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py --- a/Lib/multiprocessing/__init__.py +++ b/Lib/multiprocessing/__init__.py @@ -8,10 +8,6 @@ # subpackage 'multiprocessing.dummy' has the same API but is a simple # wrapper for 'threading'. # -# Try calling `multiprocessing.doc.main()` to read the html -# documentation in a webbrowser. -# -# # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # @@ -27,8 +23,6 @@ 'Value', 'Array', 'RawValue', 'RawArray', 'SUBDEBUG', 'SUBWARNING', ] -__author__ = 'R. Oudkerk (r.m.oudkerk at gmail.com)' - # # Imports # diff --git a/Lib/multiprocessing/dummy/__init__.py b/Lib/multiprocessing/dummy/__init__.py --- a/Lib/multiprocessing/dummy/__init__.py +++ b/Lib/multiprocessing/dummy/__init__.py @@ -4,32 +4,7 @@ # multiprocessing/dummy/__init__.py # # Copyright (c) 2006-2008, R Oudkerk -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of author nor the names of any contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# Licensed to PSF under a Contributor Agreement. # __all__ = [ diff --git a/Lib/multiprocessing/dummy/connection.py b/Lib/multiprocessing/dummy/connection.py --- a/Lib/multiprocessing/dummy/connection.py +++ b/Lib/multiprocessing/dummy/connection.py @@ -4,32 +4,7 @@ # multiprocessing/dummy/connection.py # # Copyright (c) 2006-2008, R Oudkerk -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of author nor the names of any contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# Licensed to PSF under a Contributor Agreement. # __all__ = [ 'Client', 'Listener', 'Pipe' ] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 16:33:36 2013 From: python-checkins at python.org (charles-francois.natali) Date: Tue, 1 Jan 2013 16:33:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316787=3A_Increase?= =?utf-8?q?_asyncore_and_asynchat_default_output_buffers_size=2C_to?= Message-ID: <3YbKDJ6Cq9zSHy@mail.python.org> http://hg.python.org/cpython/rev/2eddf7c2efe6 changeset: 81188:2eddf7c2efe6 user: Charles-Fran?ois Natali date: Tue Jan 01 16:31:54 2013 +0100 summary: Issue #16787: Increase asyncore and asynchat default output buffers size, to decrease CPU usage and increase throughput. files: Lib/asynchat.py | 4 ++-- Lib/asyncore.py | 2 +- Misc/NEWS | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/asynchat.py b/Lib/asynchat.py --- a/Lib/asynchat.py +++ b/Lib/asynchat.py @@ -56,8 +56,8 @@ # these are overridable defaults - ac_in_buffer_size = 4096 - ac_out_buffer_size = 4096 + ac_in_buffer_size = 65536 + ac_out_buffer_size = 65536 # we don't want to enable the use of encoding by default, because that is a # sign of an application bug that we don't want to pass silently diff --git a/Lib/asyncore.py b/Lib/asyncore.py --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -532,7 +532,7 @@ def initiate_send(self): num_sent = 0 - num_sent = dispatcher.send(self, self.out_buffer[:512]) + num_sent = dispatcher.send(self, self.out_buffer[:65536]) self.out_buffer = self.out_buffer[num_sent:] def handle_write(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,7 +200,10 @@ Library ------- -- Issue 10527: make multiprocessing use poll() instead of select() if available. +- Issue #16787: Increase asyncore and asynchat default output buffers size, to + decrease CPU usage and increase throughput. + +- Issue #10527: make multiprocessing use poll() instead of select() if available. - Issue #16688: Fix backreferences did make case-insensitive regex fail on non-ASCII strings. Patch by Matthew Barnett. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 16:42:21 2013 From: python-checkins at python.org (eli.bendersky) Date: Tue, 1 Jan 2013 16:42:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Make_indentati?= =?utf-8?q?on_consistent?= Message-ID: <3YbKQP1ZkjzSJD@mail.python.org> http://hg.python.org/cpython/rev/3ff3f3ab5e5b changeset: 81189:3ff3f3ab5e5b branch: 3.3 parent: 81184:eb7c5a36bd2c user: Eli Bendersky date: Tue Jan 01 07:41:51 2013 -0800 summary: Make indentation consistent files: Modules/xxmodule.c | 56 +++++++++++++++++----------------- 1 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -102,42 +102,42 @@ sizeof(XxoObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ - (destructor)Xxo_dealloc, /*tp_dealloc*/ + (destructor)Xxo_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)Xxo_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)Xxo_setattr, /*tp_setattr*/ 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ + 0, /*tp_call*/ + 0, /*tp_str*/ (getattrofunc)Xxo_getattro, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - Xxo_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + Xxo_methods, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ }; /* --------------------------------------------------------------------- */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 16:42:22 2013 From: python-checkins at python.org (eli.bendersky) Date: Tue, 1 Jan 2013 16:42:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Make_indentation_consistent?= Message-ID: <3YbKQQ4DmbzSJS@mail.python.org> http://hg.python.org/cpython/rev/6e10b04caeb6 changeset: 81190:6e10b04caeb6 parent: 81188:2eddf7c2efe6 parent: 81189:3ff3f3ab5e5b user: Eli Bendersky date: Tue Jan 01 07:42:06 2013 -0800 summary: Make indentation consistent files: Modules/xxmodule.c | 56 +++++++++++++++++----------------- 1 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -102,42 +102,42 @@ sizeof(XxoObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ - (destructor)Xxo_dealloc, /*tp_dealloc*/ + (destructor)Xxo_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)Xxo_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)Xxo_setattr, /*tp_setattr*/ 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ + 0, /*tp_call*/ + 0, /*tp_str*/ (getattrofunc)Xxo_getattro, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - Xxo_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + Xxo_methods, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ }; /* --------------------------------------------------------------------- */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 18:54:15 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 1 Jan 2013 18:54:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzk1ODY6?= =?utf-8?q?_Redefine_SEM=5FFAILED_on_MacOSX_to_keep_compiler_happy=2E?= Message-ID: <3YbNLb6YWkzS3D@mail.python.org> http://hg.python.org/cpython/rev/a5b49db3383d changeset: 81191:a5b49db3383d branch: 3.2 parent: 81172:5530251d9cac user: Richard Oudkerk date: Tue Jan 01 17:29:44 2013 +0000 summary: Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. files: Misc/NEWS | 2 ++ Modules/_multiprocessing/semaphore.c | 7 +++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,8 @@ Library ------- +- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. + - Issue 10527: make multiprocessing use poll() instead of select() if available. - Issue #16485: Fix file descriptor not being closed if file header patching diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -197,6 +197,13 @@ #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) +/* OS X 10.4 defines SEM_FAILED as -1 instead of (sem_t *)-1; this gives + compiler warnings, and (potentially) undefined behaviour. */ +#ifdef __APPLE__ +# undef SEM_FAILED +# define SEM_FAILED ((sem_t *)-1) +#endif + #ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 18:54:17 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 1 Jan 2013 18:54:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=239586=3A_Merge?= Message-ID: <3YbNLd23YfzS5f@mail.python.org> http://hg.python.org/cpython/rev/a70db584e897 changeset: 81192:a70db584e897 branch: 3.3 parent: 81189:3ff3f3ab5e5b parent: 81191:a5b49db3383d user: Richard Oudkerk date: Tue Jan 01 17:36:53 2013 +0000 summary: Issue #9586: Merge files: Misc/NEWS | 2 ++ Modules/_multiprocessing/semaphore.c | 7 +++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,8 @@ Library ------- +- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. + - Issue 10527: make multiprocessing use poll() instead of select() if available. - Issue #16688: Fix backreferences did make case-insensitive regex fail on diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -186,6 +186,13 @@ #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) +/* OS X 10.4 defines SEM_FAILED as -1 instead of (sem_t *)-1; this gives + compiler warnings, and (potentially) undefined behaviour. */ +#ifdef __APPLE__ +# undef SEM_FAILED +# define SEM_FAILED ((sem_t *)-1) +#endif + #ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 18:54:18 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 1 Jan 2013 18:54:18 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=239586=3A_Merge=2E?= Message-ID: <3YbNLf4P0PzS5v@mail.python.org> http://hg.python.org/cpython/rev/92990dd91b07 changeset: 81193:92990dd91b07 parent: 81190:6e10b04caeb6 parent: 81192:a70db584e897 user: Richard Oudkerk date: Tue Jan 01 17:40:58 2013 +0000 summary: Issue #9586: Merge. files: Misc/NEWS | 2 ++ Modules/_multiprocessing/semaphore.c | 7 +++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,8 @@ Library ------- +- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. + - Issue #16787: Increase asyncore and asynchat default output buffers size, to decrease CPU usage and increase throughput. diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -186,6 +186,13 @@ #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) +/* OS X 10.4 defines SEM_FAILED as -1 instead of (sem_t *)-1; this gives + compiler warnings, and (potentially) undefined behaviour. */ +#ifdef __APPLE__ +# undef SEM_FAILED +# define SEM_FAILED ((sem_t *)-1) +#endif + #ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 18:54:19 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 1 Jan 2013 18:54:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzk1ODY6?= =?utf-8?q?_Redefine_SEM=5FFAILED_on_MacOSX_to_keep_compiler_happy=2E?= Message-ID: <3YbNLg72ldzS3D@mail.python.org> http://hg.python.org/cpython/rev/395976a1f26f changeset: 81194:395976a1f26f branch: 2.7 parent: 81186:e36513032265 user: Richard Oudkerk date: Tue Jan 01 17:25:09 2013 +0000 summary: Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. files: Misc/NEWS | 2 ++ Modules/_multiprocessing/semaphore.c | 7 +++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -175,6 +175,8 @@ Library ------- +- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. + - Issue 10527: make multiprocessing use poll() instead of select() if available. - Issue #16485: Fix file descriptor not being closed if file header patching diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -197,6 +197,13 @@ #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) +/* OS X 10.4 defines SEM_FAILED as -1 instead of (sem_t *)-1; this gives + compiler warnings, and (potentially) undefined behaviour. */ +#ifdef __APPLE__ +# undef SEM_FAILED +# define SEM_FAILED ((sem_t *)-1) +#endif + #ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 19:21:53 2013 From: python-checkins at python.org (brian.curtin) Date: Tue, 1 Jan 2013 19:21:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Set_st=5Fdev_on_Windows_as?= =?utf-8?q?_unsigned_long_to_match_its_DWORD_type=2C_related_to_the?= Message-ID: <3YbNyT6DkXzP21@mail.python.org> http://hg.python.org/cpython/rev/61bada808b34 changeset: 81195:61bada808b34 parent: 81193:92990dd91b07 user: Brian Curtin date: Tue Jan 01 12:21:35 2013 -0600 summary: Set st_dev on Windows as unsigned long to match its DWORD type, related to the change to fix #11939. files: Modules/posixmodule.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1955,7 +1955,8 @@ PyStructSequence_SET_ITEM(v, 2, PyLong_FromLongLong((PY_LONG_LONG)st->st_dev)); #else - PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long)st->st_dev)); + PyStructSequence_SET_ITEM(v, 2, + PyLong_FromUnsignedLong(st->st_dev)); #endif PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long)st->st_nlink)); PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long)st->st_uid)); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 19:31:56 2013 From: python-checkins at python.org (brian.curtin) Date: Tue, 1 Jan 2013 19:31:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Backed_out_changeset_61bad?= =?utf-8?q?a808b34?= Message-ID: <3YbPB42GYJzS6T@mail.python.org> http://hg.python.org/cpython/rev/8fac1a749a1b changeset: 81196:8fac1a749a1b user: Brian Curtin date: Tue Jan 01 12:31:06 2013 -0600 summary: Backed out changeset 61bada808b34 files: Modules/posixmodule.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1955,8 +1955,7 @@ PyStructSequence_SET_ITEM(v, 2, PyLong_FromLongLong((PY_LONG_LONG)st->st_dev)); #else - PyStructSequence_SET_ITEM(v, 2, - PyLong_FromUnsignedLong(st->st_dev)); + PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long)st->st_dev)); #endif PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long)st->st_nlink)); PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long)st->st_uid)); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:09:53 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 1 Jan 2013 21:09:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Update_copyrig?= =?utf-8?q?ht_dates_in_Mac_plists=2E?= Message-ID: <3YbRM50K85zS4F@mail.python.org> http://hg.python.org/cpython/rev/737eb611aaa8 changeset: 81197:737eb611aaa8 branch: 2.7 parent: 81194:395976a1f26f user: Ned Deily date: Tue Jan 01 12:06:15 2013 -0800 summary: Update copyright dates in Mac plists. files: Mac/IDLE/Info.plist.in | 2 +- Mac/PythonLauncher/Info.plist.in | 2 +- Mac/Resources/app/Info.plist.in | 6 +++--- Mac/Resources/framework/Info.plist.in | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Mac/IDLE/Info.plist.in b/Mac/IDLE/Info.plist.in --- a/Mac/IDLE/Info.plist.in +++ b/Mac/IDLE/Info.plist.in @@ -36,7 +36,7 @@ CFBundleExecutable IDLE CFBundleGetInfoString - %VERSION%, ? 2001-2012 Python Software Foundation + %VERSION%, ? 2001-2013 Python Software Foundation CFBundleIconFile IDLE.icns CFBundleIdentifier diff --git a/Mac/PythonLauncher/Info.plist.in b/Mac/PythonLauncher/Info.plist.in --- a/Mac/PythonLauncher/Info.plist.in +++ b/Mac/PythonLauncher/Info.plist.in @@ -40,7 +40,7 @@ CFBundleExecutable PythonLauncher CFBundleGetInfoString - %VERSION%, ? 2001-2012 Python Software Foundation + %VERSION%, ? 2001-2013 Python Software Foundation CFBundleIconFile PythonLauncher.icns CFBundleIdentifier diff --git a/Mac/Resources/app/Info.plist.in b/Mac/Resources/app/Info.plist.in --- a/Mac/Resources/app/Info.plist.in +++ b/Mac/Resources/app/Info.plist.in @@ -20,7 +20,7 @@ CFBundleExecutable Python CFBundleGetInfoString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleHelpBookFolder Documentation @@ -37,7 +37,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleName Python CFBundlePackageType @@ -55,6 +55,6 @@ NSAppleScriptEnabled NSHumanReadableCopyright - (c) 2012 Python Software Foundation. + (c) 2013 Python Software Foundation. diff --git a/Mac/Resources/framework/Info.plist.in b/Mac/Resources/framework/Info.plist.in --- a/Mac/Resources/framework/Info.plist.in +++ b/Mac/Resources/framework/Info.plist.in @@ -17,9 +17,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleLongVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleSignature ???? CFBundleVersion -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:09:54 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 1 Jan 2013 21:09:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Update_copyrig?= =?utf-8?q?ht_dates_in_Mac_plists=2E?= Message-ID: <3YbRM62wd0zS4Q@mail.python.org> http://hg.python.org/cpython/rev/c9f846c9e73a changeset: 81198:c9f846c9e73a branch: 3.2 parent: 81191:a5b49db3383d user: Ned Deily date: Tue Jan 01 12:07:15 2013 -0800 summary: Update copyright dates in Mac plists. files: Mac/IDLE/IDLE.app/Contents/Info.plist | 2 +- Mac/PythonLauncher/Info.plist.in | 2 +- Mac/Resources/app/Info.plist.in | 6 +++--- Mac/Resources/framework/Info.plist.in | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Mac/IDLE/IDLE.app/Contents/Info.plist b/Mac/IDLE/IDLE.app/Contents/Info.plist --- a/Mac/IDLE/IDLE.app/Contents/Info.plist +++ b/Mac/IDLE/IDLE.app/Contents/Info.plist @@ -36,7 +36,7 @@ CFBundleExecutable IDLE CFBundleGetInfoString - %version%, ? 2001-2012 Python Software Foundation + %version%, ? 2001-2013 Python Software Foundation CFBundleIconFile IDLE.icns CFBundleIdentifier diff --git a/Mac/PythonLauncher/Info.plist.in b/Mac/PythonLauncher/Info.plist.in --- a/Mac/PythonLauncher/Info.plist.in +++ b/Mac/PythonLauncher/Info.plist.in @@ -40,7 +40,7 @@ CFBundleExecutable PythonLauncher CFBundleGetInfoString - %VERSION%, ? 2001-2012 Python Software Foundation + %VERSION%, ? 2001-2013 Python Software Foundation CFBundleIconFile PythonLauncher.icns CFBundleIdentifier diff --git a/Mac/Resources/app/Info.plist.in b/Mac/Resources/app/Info.plist.in --- a/Mac/Resources/app/Info.plist.in +++ b/Mac/Resources/app/Info.plist.in @@ -20,7 +20,7 @@ CFBundleExecutable Python CFBundleGetInfoString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleHelpBookFolder Documentation @@ -37,7 +37,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleName Python CFBundlePackageType @@ -55,6 +55,6 @@ NSAppleScriptEnabled NSHumanReadableCopyright - (c) 2012 Python Software Foundation. + (c) 2013 Python Software Foundation. diff --git a/Mac/Resources/framework/Info.plist.in b/Mac/Resources/framework/Info.plist.in --- a/Mac/Resources/framework/Info.plist.in +++ b/Mac/Resources/framework/Info.plist.in @@ -17,9 +17,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleLongVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleSignature ???? CFBundleVersion -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:09:55 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 1 Jan 2013 21:09:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Update_copyright_dates_in_Mac_plists=2E?= Message-ID: <3YbRM75bKczS4m@mail.python.org> http://hg.python.org/cpython/rev/f7cad712669a changeset: 81199:f7cad712669a branch: 3.3 parent: 81192:a70db584e897 parent: 81198:c9f846c9e73a user: Ned Deily date: Tue Jan 01 12:08:39 2013 -0800 summary: Update copyright dates in Mac plists. files: Mac/IDLE/IDLE.app/Contents/Info.plist | 2 +- Mac/PythonLauncher/Info.plist.in | 2 +- Mac/Resources/app/Info.plist.in | 6 +++--- Mac/Resources/framework/Info.plist.in | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Mac/IDLE/IDLE.app/Contents/Info.plist b/Mac/IDLE/IDLE.app/Contents/Info.plist --- a/Mac/IDLE/IDLE.app/Contents/Info.plist +++ b/Mac/IDLE/IDLE.app/Contents/Info.plist @@ -36,7 +36,7 @@ CFBundleExecutable IDLE CFBundleGetInfoString - %version%, ? 2001-2012 Python Software Foundation + %version%, ? 2001-2013 Python Software Foundation CFBundleIconFile IDLE.icns CFBundleIdentifier diff --git a/Mac/PythonLauncher/Info.plist.in b/Mac/PythonLauncher/Info.plist.in --- a/Mac/PythonLauncher/Info.plist.in +++ b/Mac/PythonLauncher/Info.plist.in @@ -40,7 +40,7 @@ CFBundleExecutable PythonLauncher CFBundleGetInfoString - %VERSION%, ? 2001-2012 Python Software Foundation + %VERSION%, ? 2001-2013 Python Software Foundation CFBundleIconFile PythonLauncher.icns CFBundleIdentifier diff --git a/Mac/Resources/app/Info.plist.in b/Mac/Resources/app/Info.plist.in --- a/Mac/Resources/app/Info.plist.in +++ b/Mac/Resources/app/Info.plist.in @@ -20,7 +20,7 @@ CFBundleExecutable Python CFBundleGetInfoString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleHelpBookFolder Documentation @@ -37,7 +37,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleName Python CFBundlePackageType @@ -55,6 +55,6 @@ NSAppleScriptEnabled NSHumanReadableCopyright - (c) 2012 Python Software Foundation. + (c) 2013 Python Software Foundation. diff --git a/Mac/Resources/framework/Info.plist.in b/Mac/Resources/framework/Info.plist.in --- a/Mac/Resources/framework/Info.plist.in +++ b/Mac/Resources/framework/Info.plist.in @@ -17,9 +17,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleLongVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleSignature ???? CFBundleVersion -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:09:57 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 1 Jan 2013 21:09:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Update_copyright_dates_in_Mac_plists=2E?= Message-ID: <3YbRM90qKszS50@mail.python.org> http://hg.python.org/cpython/rev/cce65c5324fb changeset: 81200:cce65c5324fb parent: 81196:8fac1a749a1b parent: 81199:f7cad712669a user: Ned Deily date: Tue Jan 01 12:09:23 2013 -0800 summary: Update copyright dates in Mac plists. files: Mac/IDLE/IDLE.app/Contents/Info.plist | 2 +- Mac/PythonLauncher/Info.plist.in | 2 +- Mac/Resources/app/Info.plist.in | 6 +++--- Mac/Resources/framework/Info.plist.in | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Mac/IDLE/IDLE.app/Contents/Info.plist b/Mac/IDLE/IDLE.app/Contents/Info.plist --- a/Mac/IDLE/IDLE.app/Contents/Info.plist +++ b/Mac/IDLE/IDLE.app/Contents/Info.plist @@ -36,7 +36,7 @@ CFBundleExecutable IDLE CFBundleGetInfoString - %version%, ? 2001-2012 Python Software Foundation + %version%, ? 2001-2013 Python Software Foundation CFBundleIconFile IDLE.icns CFBundleIdentifier diff --git a/Mac/PythonLauncher/Info.plist.in b/Mac/PythonLauncher/Info.plist.in --- a/Mac/PythonLauncher/Info.plist.in +++ b/Mac/PythonLauncher/Info.plist.in @@ -40,7 +40,7 @@ CFBundleExecutable PythonLauncher CFBundleGetInfoString - %VERSION%, ? 2001-2012 Python Software Foundation + %VERSION%, ? 2001-2013 Python Software Foundation CFBundleIconFile PythonLauncher.icns CFBundleIdentifier diff --git a/Mac/Resources/app/Info.plist.in b/Mac/Resources/app/Info.plist.in --- a/Mac/Resources/app/Info.plist.in +++ b/Mac/Resources/app/Info.plist.in @@ -20,7 +20,7 @@ CFBundleExecutable Python CFBundleGetInfoString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleHelpBookFolder Documentation @@ -37,7 +37,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleName Python CFBundlePackageType @@ -55,6 +55,6 @@ NSAppleScriptEnabled NSHumanReadableCopyright - (c) 2012 Python Software Foundation. + (c) 2013 Python Software Foundation. diff --git a/Mac/Resources/framework/Info.plist.in b/Mac/Resources/framework/Info.plist.in --- a/Mac/Resources/framework/Info.plist.in +++ b/Mac/Resources/framework/Info.plist.in @@ -17,9 +17,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleLongVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleSignature ???? CFBundleVersion -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:36:39 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 1 Jan 2013 21:36:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2ODE5?= =?utf-8?q?=3A_IDLE_method_completion_now_correctly_works_for_unicode_lite?= =?utf-8?q?rals=2E?= Message-ID: <3YbRxz2TwszS5T@mail.python.org> http://hg.python.org/cpython/rev/de82da4b04cd changeset: 81201:de82da4b04cd branch: 2.7 parent: 81197:737eb611aaa8 user: Serhiy Storchaka date: Tue Jan 01 22:27:45 2013 +0200 summary: Issue #16819: IDLE method completion now correctly works for unicode literals. files: Lib/idlelib/HyperParser.py | 5 +++++ Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/HyperParser.py @@ -232,6 +232,11 @@ pass else: # We can't continue after other types of brackets + if rawtext[pos] in "'\"": + # Scan a string prefix + while pos > 0 and rawtext[pos - 1] in "rRbBuU": + pos -= 1 + last_identifier_pos = pos break else: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -175,6 +175,8 @@ Library ------- +- Issue #16819: IDLE method completion now correctly works for unicode literals. + - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. - Issue 10527: make multiprocessing use poll() instead of select() if available. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:36:40 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 1 Jan 2013 21:36:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2ODE5?= =?utf-8?q?=3A_IDLE_method_completion_now_correctly_works_for_bytes_litera?= =?utf-8?b?bHMu?= Message-ID: <3YbRy05Cn3zS6G@mail.python.org> http://hg.python.org/cpython/rev/99a06886b258 changeset: 81202:99a06886b258 branch: 3.2 parent: 81198:c9f846c9e73a user: Serhiy Storchaka date: Tue Jan 01 22:25:59 2013 +0200 summary: Issue #16819: IDLE method completion now correctly works for bytes literals. files: Lib/idlelib/HyperParser.py | 5 +++++ Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/HyperParser.py @@ -232,6 +232,11 @@ pass else: # We can't continue after other types of brackets + if rawtext[pos] in "'\"": + # Scan a string prefix + while pos > 0 and rawtext[pos - 1] in "rRbB": + pos -= 1 + last_identifier_pos = pos break else: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,8 @@ Library ------- +- Issue #16819: IDLE method completion now correctly works for bytes literals. + - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. - Issue 10527: make multiprocessing use poll() instead of select() if available. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:36:42 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 1 Jan 2013 21:36:42 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316819=3A_IDLE_method_completion_now_correctly_works_f?= =?utf-8?q?or_bytes_literals=2E?= Message-ID: <3YbRy20Z4kzS5d@mail.python.org> http://hg.python.org/cpython/rev/b8b5303ac96f changeset: 81203:b8b5303ac96f branch: 3.3 parent: 81199:f7cad712669a parent: 81202:99a06886b258 user: Serhiy Storchaka date: Tue Jan 01 22:32:42 2013 +0200 summary: Issue #16819: IDLE method completion now correctly works for bytes literals. files: Lib/idlelib/HyperParser.py | 5 +++++ Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/HyperParser.py @@ -232,6 +232,11 @@ pass else: # We can't continue after other types of brackets + if rawtext[pos] in "'\"": + # Scan a string prefix + while pos > 0 and rawtext[pos - 1] in "rRbBuU": + pos -= 1 + last_identifier_pos = pos break else: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,8 @@ Library ------- +- Issue #16819: IDLE method completion now correctly works for bytes literals. + - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. - Issue 10527: make multiprocessing use poll() instead of select() if available. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 21:36:43 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 1 Jan 2013 21:36:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316819=3A_IDLE_method_completion_now_correctly_w?= =?utf-8?q?orks_for_bytes_literals=2E?= Message-ID: <3YbRy32zMYzS6b@mail.python.org> http://hg.python.org/cpython/rev/00cbbcd8af31 changeset: 81204:00cbbcd8af31 parent: 81200:cce65c5324fb parent: 81203:b8b5303ac96f user: Serhiy Storchaka date: Tue Jan 01 22:33:19 2013 +0200 summary: Issue #16819: IDLE method completion now correctly works for bytes literals. files: Lib/idlelib/HyperParser.py | 5 +++++ Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/HyperParser.py @@ -232,6 +232,11 @@ pass else: # We can't continue after other types of brackets + if rawtext[pos] in "'\"": + # Scan a string prefix + while pos > 0 and rawtext[pos - 1] in "rRbBuU": + pos -= 1 + last_identifier_pos = pos break else: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,8 @@ Library ------- +- Issue #16819: IDLE method completion now correctly works for bytes literals. + - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. - Issue #16787: Increase asyncore and asynchat default output buffers size, to -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 22:37:56 2013 From: python-checkins at python.org (lukasz.langa) Date: Tue, 1 Jan 2013 22:37:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_configparser?= =?utf-8?q?=3A_preserve_section_order_when_using_=60=5F=5Fsetitem=5F=5F=60?= =?utf-8?b?IChpc3N1ZSAjMTY4MjAp?= Message-ID: <3YbTJh5XGTzS3t@mail.python.org> http://hg.python.org/cpython/rev/f580342b63d8 changeset: 81205:f580342b63d8 branch: 3.3 parent: 81203:b8b5303ac96f user: ?ukasz Langa date: Tue Jan 01 22:33:19 2013 +0100 summary: configparser: preserve section order when using `__setitem__` (issue #16820) files: Lib/configparser.py | 4 ++-- Lib/test/test_configparser.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/configparser.py b/Lib/configparser.py --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -962,8 +962,8 @@ # no update method in configparser is atomic in this implementation. if key == self.default_section: self._defaults.clear() - else: - self.remove_section(key) + elif key in self._sections: + self._sections[key].clear() self.read_dict({key: value}) def __delitem__(self, key): diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -812,18 +812,22 @@ self.assertEqual(cf['section1']['name1'], 'value1') self.assertEqual(cf['section2']['name2'], 'value2') self.assertEqual(cf['section3']['name3'], 'value3') + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) cf['section2'] = {'name22': 'value22'} self.assertEqual(set(cf['section2'].keys()), {'name22', 'named'}) self.assertEqual(cf['section2']['name22'], 'value22') self.assertNotIn('name2', cf['section2']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) cf['section3'] = {} self.assertEqual(set(cf['section3'].keys()), {'named'}) self.assertNotIn('name3', cf['section3']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) cf[self.default_section] = {} self.assertEqual(set(cf[self.default_section].keys()), set()) self.assertEqual(set(cf['section1'].keys()), {'name1'}) self.assertEqual(set(cf['section2'].keys()), {'name22'}) self.assertEqual(set(cf['section3'].keys()), set()) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) class StrictTestCase(BasicTestCase): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 22:37:58 2013 From: python-checkins at python.org (lukasz.langa) Date: Tue, 1 Jan 2013 22:37:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merged_section_order_preservation_fix_when_using_=60=5F?= =?utf-8?b?X3NldGl0ZW1fX2AgKGlzc3VlICMxNjgyMCk=?= Message-ID: <3YbTJk1BffzS40@mail.python.org> http://hg.python.org/cpython/rev/a758f561a280 changeset: 81206:a758f561a280 parent: 81204:00cbbcd8af31 parent: 81205:f580342b63d8 user: ?ukasz Langa date: Tue Jan 01 22:36:33 2013 +0100 summary: Merged section order preservation fix when using `__setitem__` (issue #16820) files: Lib/configparser.py | 4 ++-- Lib/test/test_configparser.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/configparser.py b/Lib/configparser.py --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -962,8 +962,8 @@ # no update method in configparser is atomic in this implementation. if key == self.default_section: self._defaults.clear() - else: - self.remove_section(key) + elif key in self._sections: + self._sections[key].clear() self.read_dict({key: value}) def __delitem__(self, key): diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -812,18 +812,22 @@ self.assertEqual(cf['section1']['name1'], 'value1') self.assertEqual(cf['section2']['name2'], 'value2') self.assertEqual(cf['section3']['name3'], 'value3') + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) cf['section2'] = {'name22': 'value22'} self.assertEqual(set(cf['section2'].keys()), {'name22', 'named'}) self.assertEqual(cf['section2']['name22'], 'value22') self.assertNotIn('name2', cf['section2']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) cf['section3'] = {} self.assertEqual(set(cf['section3'].keys()), {'named'}) self.assertNotIn('name3', cf['section3']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) cf[self.default_section] = {} self.assertEqual(set(cf[self.default_section].keys()), set()) self.assertEqual(set(cf['section1'].keys()), {'name1'}) self.assertEqual(set(cf['section2'].keys()), {'name22'}) self.assertEqual(set(cf['section3'].keys()), set()) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) class StrictTestCase(BasicTestCase): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 23:13:17 2013 From: python-checkins at python.org (victor.stinner) Date: Tue, 1 Jan 2013 23:13:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzk2NDQ6?= =?utf-8?q?_Fix_the_encoding_used_by_os=2Estatvfs=28=29=3A_use_the_filesys?= =?utf-8?q?tem_encoding?= Message-ID: <3YbV5T5TLbzS0R@mail.python.org> http://hg.python.org/cpython/rev/479fca0adbf6 changeset: 81207:479fca0adbf6 branch: 3.2 parent: 81202:99a06886b258 user: Victor Stinner date: Tue Jan 01 23:05:55 2013 +0100 summary: Issue #9644: Fix the encoding used by os.statvfs(): use the filesystem encoding with the surrogateescape error handler, instead of UTF-8 in strict mode. files: Lib/test/test_os.py | 9 +++++++++ Misc/NEWS | 4 ++++ Modules/posixmodule.c | 14 +++++++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1057,6 +1057,15 @@ f = open(os.path.join(self.dir, fn), 'rb') f.close() + @unittest.skipUnless(hasattr(os, 'statvfs'), + "need os.statvfs()") + def test_statvfs(self): + # issue #9645 + for fn in self.unicodefn: + # should not fail with file not found error + fullname = os.path.join(self.dir, fn) + os.statvfs(fullname) + def test_stat(self): for fn in self.unicodefn: os.stat(os.path.join(self.dir, fn)) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,10 @@ Library ------- +- Issue #9644: Fix the encoding used by os.statvfs(): use the filesystem + encoding with the surrogateescape error handler, instead of UTF-8 in strict + mode. + - Issue #16819: IDLE method completion now correctly works for bytes literals. - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6463,18 +6463,22 @@ static PyObject * posix_statvfs(PyObject *self, PyObject *args) { + PyObject *opath, *result = NULL; char *path; int res; struct statvfs st; - if (!PyArg_ParseTuple(args, "s:statvfs", &path)) - return NULL; + if (!PyArg_ParseTuple(args, "O&:statvfs", PyUnicode_FSConverter, &opath)) + return NULL; + path = PyBytes_AS_STRING(opath); Py_BEGIN_ALLOW_THREADS res = statvfs(path, &st); Py_END_ALLOW_THREADS if (res != 0) - return posix_error_with_filename(path); - - return _pystatvfs_fromstructstatvfs(st); + return posix_error_with_allocated_filename(opath); + + result = _pystatvfs_fromstructstatvfs(st); + Py_DECREF(opath); + return result; } #endif /* HAVE_STATVFS */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 23:13:19 2013 From: python-checkins at python.org (victor.stinner) Date: Tue, 1 Jan 2013 23:13:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=239644=3A_Add_a_test_on_os=2Estatvfs=28=29_for_the_PEP_?= =?utf-8?q?383?= Message-ID: <3YbV5W111LzS15@mail.python.org> http://hg.python.org/cpython/rev/b0cc0b9e2472 changeset: 81208:b0cc0b9e2472 branch: 3.3 parent: 81205:f580342b63d8 parent: 81207:479fca0adbf6 user: Victor Stinner date: Tue Jan 01 23:11:21 2013 +0100 summary: Issue #9644: Add a test on os.statvfs() for the PEP 383 files: Lib/test/test_os.py | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1342,6 +1342,15 @@ f = open(os.path.join(self.dir, fn), 'rb') f.close() + @unittest.skipUnless(hasattr(os, 'statvfs'), + "need os.statvfs()") + def test_statvfs(self): + # issue #9645 + for fn in self.unicodefn: + # should not fail with file not found error + fullname = os.path.join(self.dir, fn) + os.statvfs(fullname) + def test_stat(self): for fn in self.unicodefn: os.stat(os.path.join(self.dir, fn)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 23:18:09 2013 From: python-checkins at python.org (victor.stinner) Date: Tue, 1 Jan 2013 23:18:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_=28Merge_3=2E3=29_Issue_=239644=3A_Add_a_test_on_os=2Est?= =?utf-8?q?atvfs=28=29_for_the_PEP_383?= Message-ID: <3YbVC54lVGzS0j@mail.python.org> http://hg.python.org/cpython/rev/dbe607fdc271 changeset: 81209:dbe607fdc271 parent: 81206:a758f561a280 parent: 81208:b0cc0b9e2472 user: Victor Stinner date: Tue Jan 01 23:17:22 2013 +0100 summary: (Merge 3.3) Issue #9644: Add a test on os.statvfs() for the PEP 383 files: Lib/test/test_os.py | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1342,6 +1342,15 @@ f = open(os.path.join(self.dir, fn), 'rb') f.close() + @unittest.skipUnless(hasattr(os, 'statvfs'), + "need os.statvfs()") + def test_statvfs(self): + # issue #9645 + for fn in self.unicodefn: + # should not fail with file not found error + fullname = os.path.join(self.dir, fn) + os.statvfs(fullname) + def test_stat(self): for fn in self.unicodefn: os.stat(os.path.join(self.dir, fn)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 23:51:24 2013 From: python-checkins at python.org (lukasz.langa) Date: Tue, 1 Jan 2013 23:51:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_configparser?= =?utf-8?q?=3A_preserve_section_order_when_using_=60=5F=5Fsetitem=5F=5F=60?= =?utf-8?b?IChpc3N1ZSAjMTY4MjAp?= Message-ID: <3YbVxS15WGzS3Z@mail.python.org> http://hg.python.org/cpython/rev/6f0cee62f0c6 changeset: 81210:6f0cee62f0c6 branch: 3.2 parent: 81207:479fca0adbf6 user: ?ukasz Langa date: Tue Jan 01 23:45:33 2013 +0100 summary: configparser: preserve section order when using `__setitem__` (issue #16820) files: Lib/configparser.py | 3 ++- Lib/test/test_cfgparser.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-) diff --git a/Lib/configparser.py b/Lib/configparser.py --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -959,7 +959,8 @@ # XXX this is not atomic if read_dict fails at any point. Then again, # no update method in configparser is atomic in this implementation. - self.remove_section(key) + if key in self._sections: + self._sections[key].clear() self.read_dict({key: value}) def __delitem__(self, key): diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -797,6 +797,32 @@ self.assertEqual(set(cf.sections()), set()) self.assertEqual(set(cf[self.default_section].keys()), {'foo'}) + def test_setitem(self): + cf = self.fromstring(""" + [section1] + name1 {0[0]} value1 + [section2] + name2 {0[0]} value2 + [section3] + name3 {0[0]} value3 + """.format(self.delimiters), defaults={"nameD": "valueD"}) + self.assertEqual(set(cf['section1'].keys()), {'name1', 'named'}) + self.assertEqual(set(cf['section2'].keys()), {'name2', 'named'}) + self.assertEqual(set(cf['section3'].keys()), {'name3', 'named'}) + self.assertEqual(cf['section1']['name1'], 'value1') + self.assertEqual(cf['section2']['name2'], 'value2') + self.assertEqual(cf['section3']['name3'], 'value3') + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) + cf['section2'] = {'name22': 'value22'} + self.assertEqual(set(cf['section2'].keys()), {'name22', 'named'}) + self.assertEqual(cf['section2']['name22'], 'value22') + self.assertNotIn('name2', cf['section2']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) + cf['section3'] = {} + self.assertEqual(set(cf['section3'].keys()), {'named'}) + self.assertNotIn('name3', cf['section3']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) + class StrictTestCase(BasicTestCase): config_class = configparser.RawConfigParser -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 23:51:25 2013 From: python-checkins at python.org (lukasz.langa) Date: Tue, 1 Jan 2013 23:51:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null-merged_3=2E2_section_order_preservation_fix_when_using_?= =?utf-8?b?YF9fc2V0aXRlbV9fYCAoaXNzdWU=?= Message-ID: <3YbVxT3kz7zS41@mail.python.org> http://hg.python.org/cpython/rev/2f5320497017 changeset: 81211:2f5320497017 branch: 3.3 parent: 81208:b0cc0b9e2472 parent: 81210:6f0cee62f0c6 user: ?ukasz Langa date: Tue Jan 01 23:50:03 2013 +0100 summary: Null-merged 3.2 section order preservation fix when using `__setitem__` (issue #16820) files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 1 23:51:26 2013 From: python-checkins at python.org (lukasz.langa) Date: Tue, 1 Jan 2013 23:51:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null-merged_3=2E2_section_order_preservation_fix_when_us?= =?utf-8?b?aW5nIGBfX3NldGl0ZW1fX2AgKGlzc3Vl?= Message-ID: <3YbVxV62GJzS5d@mail.python.org> http://hg.python.org/cpython/rev/27b698395d35 changeset: 81212:27b698395d35 parent: 81209:dbe607fdc271 parent: 81211:2f5320497017 user: ?ukasz Langa date: Tue Jan 01 23:50:59 2013 +0100 summary: Null-merged 3.2 section order preservation fix when using `__setitem__` (issue #16820) files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 01:03:43 2013 From: python-checkins at python.org (lukasz.langa) Date: Wed, 2 Jan 2013 01:03:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Misc/NEWS_upda?= =?utf-8?q?ted_to_tell_about_=2314590_and_=2316820?= Message-ID: <3YbXXv5ZwBzS8f@mail.python.org> http://hg.python.org/cpython/rev/d5c45089df2d changeset: 81213:d5c45089df2d branch: 3.3 parent: 81211:2f5320497017 user: ?ukasz Langa date: Wed Jan 02 00:39:59 2013 +0100 summary: Misc/NEWS updated to tell about #14590 and #16820 files: Misc/NEWS | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,17 @@ Library ------- +- Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. + This makes `parser.clean()` work correctly. + +- Issue #16820: In configparser, ``parser['section'] = {}`` now preserves + section order within the parser. This makes `parser.update()` preserve section + order as well. + +- Issue #16820: In configparser, ``parser['DEFAULT'] = {}`` now correctly + clears previous values stored in the default section. Same goes for + ``parser.update({'DEFAULT': {}})``. + - Issue #16819: IDLE method completion now correctly works for bytes literals. - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. @@ -840,6 +851,9 @@ Library ------- +- Issue #14590: configparser now correctly strips inline comments when delimiter + occurs earlier without preceding space. + - Issue #15424: Add a `__sizeof__()` implementation for array objects. Patch by Ludwig H?hne. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 01:03:45 2013 From: python-checkins at python.org (lukasz.langa) Date: Wed, 2 Jan 2013 01:03:45 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null-merged_Misc/NEWS_change?= Message-ID: <3YbXXx11m7zS8V@mail.python.org> http://hg.python.org/cpython/rev/0837362f6879 changeset: 81214:0837362f6879 parent: 81212:27b698395d35 parent: 81213:d5c45089df2d user: ?ukasz Langa date: Wed Jan 02 00:40:55 2013 +0100 summary: Null-merged Misc/NEWS change files: Misc/NEWS | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,17 @@ Library ------- +- Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. + This makes `parser.clean()` work correctly. + +- Issue #16820: In configparser, ``parser['section'] = {}`` now preserves + section order within the parser. This makes `parser.update()` preserve section + order as well. + +- Issue #16820: In configparser, ``parser['DEFAULT'] = {}`` now correctly + clears previous values stored in the default section. Same goes for + ``parser.update({'DEFAULT': {}})``. + - Issue #16819: IDLE method completion now correctly works for bytes literals. - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. @@ -1051,6 +1062,9 @@ Library ------- +- Issue #14590: configparser now correctly strips inline comments when delimiter + occurs earlier without preceding space. + - Issue #15424: Add a `__sizeof__()` implementation for array objects. Patch by Ludwig H?hne. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 01:03:46 2013 From: python-checkins at python.org (lukasz.langa) Date: Wed, 2 Jan 2013 01:03:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Misc/NEWS_upda?= =?utf-8?q?ted_to_tell_about_=2316820?= Message-ID: <3YbXXy3Qr3zS8b@mail.python.org> http://hg.python.org/cpython/rev/7938847b2641 changeset: 81215:7938847b2641 branch: 3.2 parent: 81210:6f0cee62f0c6 user: ?ukasz Langa date: Wed Jan 02 00:44:36 2013 +0100 summary: Misc/NEWS updated to tell about #16820 files: Misc/NEWS | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,13 @@ Library ------- +- Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. + This makes `parser.clean()` work correctly. + +- Issue #16820: In configparser, ``parser['section'] = {}`` now preserves + section order within the parser. This makes `parser.update()` preserve section + order as well. + - Issue #9644: Fix the encoding used by os.statvfs(): use the filesystem encoding with the surrogateescape error handler, instead of UTF-8 in strict mode. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 01:03:47 2013 From: python-checkins at python.org (lukasz.langa) Date: Wed, 2 Jan 2013 01:03:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null-merged_Misc/NEWS_change?= Message-ID: <3YbXXz5kS7zS8h@mail.python.org> http://hg.python.org/cpython/rev/4d28e50f20b8 changeset: 81216:4d28e50f20b8 branch: 3.3 parent: 81213:d5c45089df2d parent: 81215:7938847b2641 user: ?ukasz Langa date: Wed Jan 02 01:02:17 2013 +0100 summary: Null-merged Misc/NEWS change files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 01:03:49 2013 From: python-checkins at python.org (lukasz.langa) Date: Wed, 2 Jan 2013 01:03:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null-merged_Misc/NEWS_change?= Message-ID: <3YbXY111k7zS8V@mail.python.org> http://hg.python.org/cpython/rev/2044df71d391 changeset: 81217:2044df71d391 parent: 81214:0837362f6879 parent: 81216:4d28e50f20b8 user: ?ukasz Langa date: Wed Jan 02 01:03:09 2013 +0100 summary: Null-merged Misc/NEWS change files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 02:11:24 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 02:11:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_typos=2E?= Message-ID: <3YbZ302ZMDzSCw@mail.python.org> http://hg.python.org/peps/rev/eb668670ad0e changeset: 4646:eb668670ad0e user: Ezio Melotti date: Wed Jan 02 03:10:54 2013 +0200 summary: Fix typos. files: pep-0431.txt | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pep-0431.txt b/pep-0431.txt --- a/pep-0431.txt +++ b/pep-0431.txt @@ -48,7 +48,7 @@ for example Windows, a distribution containing the latest tz database should also be available at the Python Package Index, so it can be easily installed with the Python packaging tools such as ``easy_install`` or ``pip``. This -could also be done on Unices that are no longer recieving updates and +could also be done on Unices that are no longer receiving updates and therefore has an outdated database. With such a mechanism Python would have full time zone support in the @@ -66,7 +66,7 @@ On Unix there is no standard way of finding the name of the time zone that is being used. All the information that is available is the time zone abbreviations, such as ``EST`` and ``PDT``, but many of those abbreviations -are ambigious and therefore you can't rely on them to figure out which time +are ambiguous and therefore you can't rely on them to figure out which time zone you are located in. There is however a standard for finding the compiled time zone information @@ -84,7 +84,7 @@ When changing over from daylight savings time the clock is turned back one hour. This means that the times during that hour happens twice, once without -DST and then once with DST. Similarily, when changing to daylight savings +DST and then once with DST. Similarly, when changing to daylight savings time, one hour goes missing. The current time zone API can not differentiating between the two ambiguous @@ -129,7 +129,7 @@ * New function :``get_timezone(name=None, db=None)`` This function takes a name string that must be a string specifying a - valid zoneinfo timezone, ie "US/Eastern", "Europe/Warsaw" or "Etc/GMT+11". + valid zoneinfo timezone, i.e. "US/Eastern", "Europe/Warsaw" or "Etc/GMT+11". If not given, the local timezone will be looked up. If an invalid zone name are given, or the local timezone can not be retrieved, the function raises `UnknownTimeZoneError`. @@ -169,11 +169,11 @@ The ``is_dst`` parameter can be ``True`` (default), ``False``, or ``None``. ``True`` will specify that the given datetime should be interpreted as -happening during daylight savings time, ie that the time specified is before +happening during daylight savings time, i.e. that the time specified is before the change from DST. ``False`` will specify that the given datetime should be interpreted as not -happening during daylight savings time, ie that the time specified is after +happening during daylight savings time, i.e. that the time specified is after the change from DST. ``None`` will raise an ``AmbiguousTimeError`` exception if the time specified @@ -185,7 +185,7 @@ * ``AmbiguousTimeError`` This exception is raised when giving a datetime specification that are - ambigious while setting ``is_dst`` to None:: + ambiguous while setting ``is_dst`` to None:: >>> datetime(2012, 11, 28, 2, 0, tzinfo=timezone('Europe/Stockholm'), is_dst=None) >>> @@ -197,7 +197,7 @@ * ``NonExistentTimeError`` This exception is raised when giving a datetime specification that are - ambigious while setting ``is_dst`` to None:: + ambiguous while setting ``is_dst`` to None:: >>> datetime(2012, 3, 25, 2, 0, tzinfo=timezone('Europe/Stockholm'), is_dst=None) >>> -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 2 02:30:19 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 02:30:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_grammar=2C_whitespace=2C_?= =?utf-8?q?and_a_couple_of_semantic_mistakes_=28=2316818=29=2E?= Message-ID: <3YbZSq3slbzSBK@mail.python.org> http://hg.python.org/peps/rev/90a9e083933b changeset: 4647:90a9e083933b user: Ezio Melotti date: Wed Jan 02 03:30:04 2013 +0200 summary: Fix grammar, whitespace, and a couple of semantic mistakes (#16818). files: pep-0431.txt | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-) diff --git a/pep-0431.txt b/pep-0431.txt --- a/pep-0431.txt +++ b/pep-0431.txt @@ -7,7 +7,7 @@ Status: Draft Type: Standards Track Content-Type: text/x-rst -Created: 11-Dec-2012 +Created: 11-Dec-2012 Post-History: 11-Dec-2012 @@ -49,14 +49,14 @@ also be available at the Python Package Index, so it can be easily installed with the Python packaging tools such as ``easy_install`` or ``pip``. This could also be done on Unices that are no longer receiving updates and -therefore has an outdated database. +therefore have an outdated database. With such a mechanism Python would have full time zone support in the standard library on most platforms, and a simple package installation would provide time zone support on those platforms where the tz database isn't included, such as Windows. -The time zone support will be implemented by a new module called `timezone``, +The time zone support will be implemented by a new module called ``timezone``, based on Stuart Bishop's ``pytz`` module. @@ -82,12 +82,12 @@ Ambiguous times --------------- -When changing over from daylight savings time the clock is turned back one +When changing over from daylight savings time (DST) the clock is turned back one hour. This means that the times during that hour happens twice, once without DST and then once with DST. Similarly, when changing to daylight savings time, one hour goes missing. -The current time zone API can not differentiating between the two ambiguous +The current time zone API can not differentiate between the two ambiguous times during a change from DST. For example, in Stockholm the time of 2012-11-28 02:00:00 happens twice, both at UTC 2012-11-28 00:00:00 and also at 2012-11-28 01:00:00. @@ -124,25 +124,26 @@ This class provides a concrete implementation of the ``zoneinfo`` base class that implements DST support. - + * New function :``get_timezone(name=None, db=None)`` This function takes a name string that must be a string specifying a valid zoneinfo timezone, i.e. "US/Eastern", "Europe/Warsaw" or "Etc/GMT+11". If not given, the local timezone will be looked up. If an invalid zone name - are given, or the local timezone can not be retrieved, the function raises + is given, or the local timezone can not be retrieved, the function raises `UnknownTimeZoneError`. The function also takes an optional path to the location of the zoneinfo database which should be used. If not specified, the function will check if the `timezonedata` module is installed, and then use that location or otherwise use the database in ``/usr/share/zoneinfo``. - + If no database is found an ``UnknownTimeZoneError`` or subclass thereof will be raised with a message explaining that no zoneinfo database can be found, but that you can install one with the ``timezonedata`` package. - + + * New Exception: ``UnknownTimeZoneError`` This exception is raised when giving a time zone specification that can't be @@ -165,7 +166,7 @@ * ``tzinfo.dst(self, dt, is_dst=True)`` * ``tzinfo.tzname(self, dt, is_dst=True)`` - + The ``is_dst`` parameter can be ``True`` (default), ``False``, or ``None``. ``True`` will specify that the given datetime should be interpreted as @@ -184,7 +185,7 @@ * ``AmbiguousTimeError`` - This exception is raised when giving a datetime specification that are + This exception is raised when giving a datetime specification that is ambiguous while setting ``is_dst`` to None:: >>> datetime(2012, 11, 28, 2, 0, tzinfo=timezone('Europe/Stockholm'), is_dst=None) @@ -196,8 +197,8 @@ * ``NonExistentTimeError`` - This exception is raised when giving a datetime specification that are - ambiguous while setting ``is_dst`` to None:: + This exception is raised when giving a datetime specification that is + non-existent while setting ``is_dst`` to None:: >>> datetime(2012, 3, 25, 2, 0, tzinfo=timezone('Europe/Stockholm'), is_dst=None) >>> @@ -219,28 +220,28 @@ ================================= * ``pytz`` has the functions ``localize()`` and ``normalize()`` to work - around that ``tzinfo`` doesn't have is_dst. When ``is_dst`` is + around that ``tzinfo`` doesn't have is_dst. When ``is_dst`` is implemented directly in ``datetime.tzinfo`` they are no longer needed. - + * The ``pytz`` method ``timezone()`` is instead called ``get_timezone()`` for clarity. * ``get_timezone()`` will return the local time zone if called without - parameters. + arguments. * The class ``pytz.StaticTzInfo`` is there to provide the ``is_dst`` support for static timezones. When ``is_dst`` support is included in ``datetime.tzinfo`` it is no longer needed. - + Discussion ========== - + Should the windows installer include the data package? ------------------------------------------------------ It has been suggested that the Windows installer should include the data -package. This would mean that an explicit installation no longer would be +package. This would mean that an explicit installation would no longer be needed on Windows. On the other hand, that would mean that many using Windows would not be aware that the database quickly becomes outdated and would not keep it updated. -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Wed Jan 2 05:54:58 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 02 Jan 2013 05:54:58 +0100 Subject: [Python-checkins] Daily reference leaks (2044df71d391): sum=1 Message-ID: results for 2044df71d391 on branch "default" -------------------------------------------- test_concurrent_futures leaked [0, -2, 3] memory blocks, sum=1 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogMsRkxE', '-x'] From python-checkins at python.org Wed Jan 2 06:04:28 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 06:04:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_get_the_core_t?= =?utf-8?q?o_compile_--disable-unicode?= Message-ID: <3YbgCw0SptzS8m@mail.python.org> http://hg.python.org/cpython/rev/f6e74759d740 changeset: 81218:f6e74759d740 branch: 2.7 parent: 81201:de82da4b04cd user: Benjamin Peterson date: Tue Jan 01 23:04:16 2013 -0600 summary: get the core to compile --disable-unicode files: Modules/sre.h | 4 ++++ Objects/fileobject.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/Modules/sre.h b/Modules/sre.h --- a/Modules/sre.h +++ b/Modules/sre.h @@ -15,7 +15,11 @@ /* size of a code word (must be unsigned short or larger, and large enough to hold a UCS4 character) */ +#ifdef Py_USING_UNICODE #define SRE_CODE Py_UCS4 +#else +#define SRE_CODE unsigned long +#endif typedef struct { PyObject_VAR_HEAD diff --git a/Objects/fileobject.c b/Objects/fileobject.c --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -1816,7 +1816,6 @@ n = pbuf.len; } else { - const char *encoding, *errors; PyObject *text; if (!PyArg_ParseTuple(args, "O", &text)) return NULL; @@ -1824,7 +1823,9 @@ if (PyString_Check(text)) { s = PyString_AS_STRING(text); n = PyString_GET_SIZE(text); +#ifdef Py_USING_UNICODE } else if (PyUnicode_Check(text)) { + const char *encoding, *errors; if (f->f_encoding != Py_None) encoding = PyString_AS_STRING(f->f_encoding); else @@ -1838,6 +1839,7 @@ return NULL; s = PyString_AS_STRING(encoded); n = PyString_GET_SIZE(encoded); +#endif } else { if (PyObject_AsCharBuffer(text, &s, &n)) return NULL; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:03 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2NTQx?= =?utf-8?q?=3A_tk=5FsetPalette=28=29_now_works_with_keyword_arguments=2E?= Message-ID: <3YbmHg4J8TzMkq@mail.python.org> http://hg.python.org/cpython/rev/956cfe53a99f changeset: 81219:956cfe53a99f branch: 3.2 parent: 81202:99a06886b258 user: Serhiy Storchaka date: Wed Jan 02 00:03:58 2013 +0200 summary: Issue #16541: tk_setPalette() now works with keyword arguments. Added a test for tk_setPalette(). files: Lib/tkinter/__init__.py | 2 +- Lib/tkinter/test/test_tkinter/test_misc.py | 45 ++++++++++ Misc/NEWS | 2 + 3 files changed, 48 insertions(+), 1 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -380,7 +380,7 @@ background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) - + _flatten(args) + _flatten(kw.items())) + + _flatten(args) + _flatten(list(kw.items()))) def tk_menuBar(self, *args): """Do not use. Needed in Tk 3.6 and earlier.""" pass # obsolete since Tk 4.0 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py new file mode 100644 --- /dev/null +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -0,0 +1,45 @@ +import unittest +import tkinter +from tkinter import ttk +from test import support + +support.requires('gui') + +class MiscTest(unittest.TestCase): + + def setUp(self): + self.root = ttk.setup_master() + + def test_tk_setPalette(self): + root = self.root + root.tk_setPalette('black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette('white') + self.assertEqual(root['background'], 'white') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, 'spam') + + root.tk_setPalette(background='black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette(background='blue', highlightColor='yellow') + self.assertEqual(root['background'], 'blue') + self.assertEqual(root['highlightcolor'], 'yellow') + root.tk_setPalette(background='yellow', highlightColor='blue') + self.assertEqual(root['background'], 'yellow') + self.assertEqual(root['highlightcolor'], 'blue') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, background='spam') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, spam='white') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, highlightColor='blue') + + +tests_gui = (MiscTest, ) + +if __name__ == "__main__": + support.run_unittest(*tests_gui) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,8 @@ Library ------- +- Issue #16541: tk_setPalette() now works with keyword arguments. + - Issue #16819: IDLE method completion now correctly works for bytes literals. - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:05 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316541=3A_tk=5FsetPalette=28=29_now_works_with_keyword?= =?utf-8?q?_arguments=2E?= Message-ID: <3YbmHj02nTzSBN@mail.python.org> http://hg.python.org/cpython/rev/1ac028634b60 changeset: 81220:1ac028634b60 branch: 3.3 parent: 81205:f580342b63d8 parent: 81219:956cfe53a99f user: Serhiy Storchaka date: Wed Jan 02 00:07:21 2013 +0200 summary: Issue #16541: tk_setPalette() now works with keyword arguments. Added a test for tk_setPalette(). files: Lib/tkinter/__init__.py | 2 +- Lib/tkinter/test/test_tkinter/test_misc.py | 45 ++++++++++ Misc/NEWS | 2 + 3 files changed, 48 insertions(+), 1 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -391,7 +391,7 @@ background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) - + _flatten(args) + _flatten(kw.items())) + + _flatten(args) + _flatten(list(kw.items()))) def tk_menuBar(self, *args): """Do not use. Needed in Tk 3.6 and earlier.""" pass # obsolete since Tk 4.0 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py new file mode 100644 --- /dev/null +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -0,0 +1,45 @@ +import unittest +import tkinter +from tkinter import ttk +from test import support + +support.requires('gui') + +class MiscTest(unittest.TestCase): + + def setUp(self): + self.root = ttk.setup_master() + + def test_tk_setPalette(self): + root = self.root + root.tk_setPalette('black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette('white') + self.assertEqual(root['background'], 'white') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, 'spam') + + root.tk_setPalette(background='black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette(background='blue', highlightColor='yellow') + self.assertEqual(root['background'], 'blue') + self.assertEqual(root['highlightcolor'], 'yellow') + root.tk_setPalette(background='yellow', highlightColor='blue') + self.assertEqual(root['background'], 'yellow') + self.assertEqual(root['highlightcolor'], 'blue') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, background='spam') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, spam='white') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, highlightColor='blue') + + +tests_gui = (MiscTest, ) + +if __name__ == "__main__": + support.run_unittest(*tests_gui) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,8 @@ Library ------- +- Issue #16541: tk_setPalette() now works with keyword arguments. + - Issue #16819: IDLE method completion now correctly works for bytes literals. - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:06 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316541=3A_tk=5FsetPalette=28=29_now_works_with_k?= =?utf-8?q?eyword_arguments=2E?= Message-ID: <3YbmHk2SWnzSBN@mail.python.org> http://hg.python.org/cpython/rev/589e6175f037 changeset: 81221:589e6175f037 parent: 81206:a758f561a280 parent: 81220:1ac028634b60 user: Serhiy Storchaka date: Wed Jan 02 00:09:17 2013 +0200 summary: Issue #16541: tk_setPalette() now works with keyword arguments. Added a test for tk_setPalette(). files: Lib/tkinter/__init__.py | 2 +- Lib/tkinter/test/test_tkinter/test_misc.py | 45 ++++++++++ Misc/NEWS | 2 + 3 files changed, 48 insertions(+), 1 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -391,7 +391,7 @@ background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) - + _flatten(args) + _flatten(kw.items())) + + _flatten(args) + _flatten(list(kw.items()))) def tk_menuBar(self, *args): """Do not use. Needed in Tk 3.6 and earlier.""" pass # obsolete since Tk 4.0 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py new file mode 100644 --- /dev/null +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -0,0 +1,45 @@ +import unittest +import tkinter +from tkinter import ttk +from test import support + +support.requires('gui') + +class MiscTest(unittest.TestCase): + + def setUp(self): + self.root = ttk.setup_master() + + def test_tk_setPalette(self): + root = self.root + root.tk_setPalette('black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette('white') + self.assertEqual(root['background'], 'white') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, 'spam') + + root.tk_setPalette(background='black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette(background='blue', highlightColor='yellow') + self.assertEqual(root['background'], 'blue') + self.assertEqual(root['highlightcolor'], 'yellow') + root.tk_setPalette(background='yellow', highlightColor='blue') + self.assertEqual(root['background'], 'yellow') + self.assertEqual(root['highlightcolor'], 'blue') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, background='spam') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, spam='white') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, highlightColor='blue') + + +tests_gui = (MiscTest, ) + +if __name__ == "__main__": + support.run_unittest(*tests_gui) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,8 @@ Library ------- +- Issue #16541: tk_setPalette() now works with keyword arguments. + - Issue #16819: IDLE method completion now correctly works for bytes literals. - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:07 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMik6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YbmHl4y18zSH7@mail.python.org> http://hg.python.org/cpython/rev/94234055552d changeset: 81222:94234055552d branch: 3.2 parent: 81215:7938847b2641 parent: 81219:956cfe53a99f user: Serhiy Storchaka date: Wed Jan 02 10:32:13 2013 +0200 summary: Merge heads files: Lib/tkinter/__init__.py | 2 +- Lib/tkinter/test/test_tkinter/test_misc.py | 45 ++++++++++ Misc/NEWS | 2 + 3 files changed, 48 insertions(+), 1 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -380,7 +380,7 @@ background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) - + _flatten(args) + _flatten(kw.items())) + + _flatten(args) + _flatten(list(kw.items()))) def tk_menuBar(self, *args): """Do not use. Needed in Tk 3.6 and earlier.""" pass # obsolete since Tk 4.0 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py new file mode 100644 --- /dev/null +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -0,0 +1,45 @@ +import unittest +import tkinter +from tkinter import ttk +from test import support + +support.requires('gui') + +class MiscTest(unittest.TestCase): + + def setUp(self): + self.root = ttk.setup_master() + + def test_tk_setPalette(self): + root = self.root + root.tk_setPalette('black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette('white') + self.assertEqual(root['background'], 'white') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, 'spam') + + root.tk_setPalette(background='black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette(background='blue', highlightColor='yellow') + self.assertEqual(root['background'], 'blue') + self.assertEqual(root['highlightcolor'], 'yellow') + root.tk_setPalette(background='yellow', highlightColor='blue') + self.assertEqual(root['background'], 'yellow') + self.assertEqual(root['highlightcolor'], 'blue') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, background='spam') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, spam='white') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, highlightColor='blue') + + +tests_gui = (MiscTest, ) + +if __name__ == "__main__": + support.run_unittest(*tests_gui) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,8 @@ Library ------- +- Issue #16541: tk_setPalette() now works with keyword arguments. + - Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. This makes `parser.clean()` work correctly. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:09 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YbmHn0NvPzSGb@mail.python.org> http://hg.python.org/cpython/rev/d08c64a23e56 changeset: 81223:d08c64a23e56 branch: 3.3 parent: 81216:4d28e50f20b8 parent: 81222:94234055552d user: Serhiy Storchaka date: Wed Jan 02 10:37:54 2013 +0200 summary: Merge heads files: Lib/tkinter/__init__.py | 2 +- Lib/tkinter/test/test_tkinter/test_misc.py | 45 ++++++++++ Misc/NEWS | 2 + 3 files changed, 48 insertions(+), 1 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -391,7 +391,7 @@ background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) - + _flatten(args) + _flatten(kw.items())) + + _flatten(args) + _flatten(list(kw.items()))) def tk_menuBar(self, *args): """Do not use. Needed in Tk 3.6 and earlier.""" pass # obsolete since Tk 4.0 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py new file mode 100644 --- /dev/null +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -0,0 +1,45 @@ +import unittest +import tkinter +from tkinter import ttk +from test import support + +support.requires('gui') + +class MiscTest(unittest.TestCase): + + def setUp(self): + self.root = ttk.setup_master() + + def test_tk_setPalette(self): + root = self.root + root.tk_setPalette('black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette('white') + self.assertEqual(root['background'], 'white') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, 'spam') + + root.tk_setPalette(background='black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette(background='blue', highlightColor='yellow') + self.assertEqual(root['background'], 'blue') + self.assertEqual(root['highlightcolor'], 'yellow') + root.tk_setPalette(background='yellow', highlightColor='blue') + self.assertEqual(root['background'], 'yellow') + self.assertEqual(root['highlightcolor'], 'blue') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, background='spam') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, spam='white') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, highlightColor='blue') + + +tests_gui = (MiscTest, ) + +if __name__ == "__main__": + support.run_unittest(*tests_gui) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,8 @@ Library ------- +- Issue #16541: tk_setPalette() now works with keyword arguments. + - Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. This makes `parser.clean()` work correctly. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YbmHp32XqzS8P@mail.python.org> http://hg.python.org/cpython/rev/805132b88e54 changeset: 81224:805132b88e54 branch: 3.3 parent: 81223:d08c64a23e56 parent: 81220:1ac028634b60 user: Serhiy Storchaka date: Wed Jan 02 10:38:45 2013 +0200 summary: Merge heads files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:11 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_heads?= Message-ID: <3YbmHq5dVRzSGb@mail.python.org> http://hg.python.org/cpython/rev/ccc3e3bdcd0b changeset: 81225:ccc3e3bdcd0b parent: 81217:2044df71d391 parent: 81224:805132b88e54 user: Serhiy Storchaka date: Wed Jan 02 10:40:36 2013 +0200 summary: Merge heads files: Lib/tkinter/__init__.py | 2 +- Lib/tkinter/test/test_tkinter/test_misc.py | 45 ++++++++++ Misc/NEWS | 2 + 3 files changed, 48 insertions(+), 1 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -391,7 +391,7 @@ background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) - + _flatten(args) + _flatten(kw.items())) + + _flatten(args) + _flatten(list(kw.items()))) def tk_menuBar(self, *args): """Do not use. Needed in Tk 3.6 and earlier.""" pass # obsolete since Tk 4.0 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py new file mode 100644 --- /dev/null +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -0,0 +1,45 @@ +import unittest +import tkinter +from tkinter import ttk +from test import support + +support.requires('gui') + +class MiscTest(unittest.TestCase): + + def setUp(self): + self.root = ttk.setup_master() + + def test_tk_setPalette(self): + root = self.root + root.tk_setPalette('black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette('white') + self.assertEqual(root['background'], 'white') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, 'spam') + + root.tk_setPalette(background='black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette(background='blue', highlightColor='yellow') + self.assertEqual(root['background'], 'blue') + self.assertEqual(root['highlightcolor'], 'yellow') + root.tk_setPalette(background='yellow', highlightColor='blue') + self.assertEqual(root['background'], 'yellow') + self.assertEqual(root['highlightcolor'], 'blue') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, background='spam') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, spam='white') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, highlightColor='blue') + + +tests_gui = (MiscTest, ) + +if __name__ == "__main__": + support.run_unittest(*tests_gui) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,8 @@ Library ------- +- Issue #16541: tk_setPalette() now works with keyword arguments. + - Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. This makes `parser.clean()` work correctly. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 09:53:13 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 09:53:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge_heads?= Message-ID: <3YbmHs0tFrzSHQ@mail.python.org> http://hg.python.org/cpython/rev/9ea0beb8099e changeset: 81226:9ea0beb8099e parent: 81225:ccc3e3bdcd0b parent: 81221:589e6175f037 user: Serhiy Storchaka date: Wed Jan 02 10:41:08 2013 +0200 summary: Merge heads files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 11:24:13 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 11:24:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_incorrect_?= =?utf-8?q?grammar_in_Misc/NEWS=2E?= Message-ID: <3YbpJs1WMXzS89@mail.python.org> http://hg.python.org/cpython/rev/ee5123d6ab6c changeset: 81227:ee5123d6ab6c branch: 2.7 parent: 81218:f6e74759d740 user: Serhiy Storchaka date: Wed Jan 02 11:56:58 2013 +0200 summary: Fix incorrect grammar in Misc/NEWS. files: Misc/NEWS | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,8 +9,8 @@ Core and Builtins ----------------- -- Issue #16761: Calling ``int()`` and ``long()`` with *base* argument only - now raises TypeError. +- Issue #16761: Calling int() and long() with base argument only now raises + TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py when retreiving a REG_DWORD value. This corrects functions like @@ -181,8 +181,8 @@ - Issue 10527: make multiprocessing use poll() instead of select() if available. -- Issue #16485: Fix file descriptor not being closed if file header patching - fails on closing of aifc file. +- Issue #16485: Now file descriptors are closed if file header patching failed + on closing an aifc file. - Issue #12065: connect_ex() on an SSL socket now returns the original errno when the socket's timeout expires (it used to return None). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 11:24:14 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 11:24:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_incorrect_?= =?utf-8?q?grammar_in_Misc/NEWS=2E?= Message-ID: <3YbpJt3s4fzS89@mail.python.org> http://hg.python.org/cpython/rev/15d900cebc4a changeset: 81228:15d900cebc4a branch: 3.2 parent: 81222:94234055552d user: Serhiy Storchaka date: Wed Jan 02 11:57:22 2013 +0200 summary: Fix incorrect grammar in Misc/NEWS. files: Misc/NEWS | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,8 +10,7 @@ Core and Builtins ----------------- -- Issue #16761: Calling ``int()`` with *base* argument only now raises - TypeError. +- Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py when retreiving a REG_DWORD value. This corrects functions like @@ -208,8 +207,8 @@ - Issue 10527: make multiprocessing use poll() instead of select() if available. -- Issue #16485: Fix file descriptor not being closed if file header patching - fails on closing of aifc file. +- Issue #16485: Now file descriptors are closed if file header patching failed + on closing an aifc file. - Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by Roger Serwy. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 11:24:15 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 11:24:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Fix_incorrect_grammar_in_Misc/NEWS=2E?= Message-ID: <3YbpJv6cHyzS8H@mail.python.org> http://hg.python.org/cpython/rev/8683b2d43dca changeset: 81229:8683b2d43dca branch: 3.3 parent: 81224:805132b88e54 parent: 81228:15d900cebc4a user: Serhiy Storchaka date: Wed Jan 02 12:05:38 2013 +0200 summary: Fix incorrect grammar in Misc/NEWS. files: Misc/NEWS | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,8 +12,7 @@ Core and Builtins ----------------- -- Issue #16761: Calling ``int()`` with *base* argument only now raises - TypeError. +- Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py when retreiving a REG_DWORD value. This corrects functions like @@ -143,16 +142,16 @@ - Issue 10527: make multiprocessing use poll() instead of select() if available. -- Issue #16688: Fix backreferences did make case-insensitive regex fail on - non-ASCII strings. Patch by Matthew Barnett. - -- Issue #16485: Fix file descriptor not being closed if file header patching - fails on closing of aifc file. - -- Issue #16165: Fix sched.scheduler.run() method was block a scheduler for - other threads. - -- Issue #16641: Fix default values of sched.scheduler.enter arguments were +- Issue #16688: Now regexes contained backreferences correctly work with + non-ASCII strings. Patch by Matthew Barnett. + +- Issue #16485: Now file descriptors are closed if file header patching failed + on closing an aifc file. + +- Issue #16165: sched.scheduler.run() no longer blocks a scheduler for other + threads. + +- Issue #16641: Default values of sched.scheduler.enter() are no longer modifiable. - Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 11:24:17 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 11:24:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_incorrect_grammar_in_Misc/NEWS=2E?= Message-ID: <3YbpJx1rXPzS9N@mail.python.org> http://hg.python.org/cpython/rev/ec4a8df89d45 changeset: 81230:ec4a8df89d45 parent: 81226:9ea0beb8099e parent: 81229:8683b2d43dca user: Serhiy Storchaka date: Wed Jan 02 12:11:57 2013 +0200 summary: Fix incorrect grammar in Misc/NEWS. files: Misc/NEWS | 25 ++++++++++++------------- 1 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,8 +10,7 @@ Core and Builtins ----------------- -- Issue #16761: Calling ``int()`` with *base* argument only now raises - TypeError. +- Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py when retreiving a REG_DWORD value. This corrects functions like @@ -222,20 +221,20 @@ - Issue #10527: make multiprocessing use poll() instead of select() if available. -- Issue #16688: Fix backreferences did make case-insensitive regex fail on - non-ASCII strings. Patch by Matthew Barnett. - -- Issue #16486: Make aifc files work with 'with' as context managers. - -- Issue #16485: Fix file descriptor not being closed if file header patching - fails on closing of aifc file. +- Issue #16688: Now regexes contained backreferences correctly work with + non-ASCII strings. Patch by Matthew Barnett. + +- Issue #16486: Make aifc files act as context managers. + +- Issue #16485: Now file descriptors are closed if file header patching failed + on closing an aifc file. - Issue #16640: Run less code under a lock in sched module. -- Issue #16165: Fix sched.scheduler.run() method was block a scheduler for - other threads. - -- Issue #16641: Fix default values of sched.scheduler.enter arguments were +- Issue #16165: sched.scheduler.run() no longer blocks a scheduler for other + threads. + +- Issue #16641: Default values of sched.scheduler.enter() are no longer modifiable. - Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 11:33:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 11:33:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Fix_incorrect_?= =?utf-8?q?grammar_in_sched_documentation=2E?= Message-ID: <3YbpWB1G56zS15@mail.python.org> http://hg.python.org/cpython/rev/6db9ffce83ef changeset: 81231:6db9ffce83ef branch: 3.3 parent: 81229:8683b2d43dca user: Serhiy Storchaka date: Wed Jan 02 12:31:26 2013 +0200 summary: Fix incorrect grammar in sched documentation. files: Doc/library/sched.rst | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst --- a/Doc/library/sched.rst +++ b/Doc/library/sched.rst @@ -70,10 +70,8 @@ *priority*. Executing the event means executing ``action(*argument, **kwargs)``. - Optional *argument* argument must be a sequence holding the parameters - for *action* if any used. - Optional *kwargs* argument must be a dictionary holding the keyword - parameters for *action* if any used. + *argument* is a sequence holding the positional arguments for *action*. + *kwargs* is a dictionary holding the keyword arguments for *action*. Return value is an event which may be used for later cancellation of the event (see :meth:`cancel`). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 11:33:11 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 11:33:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_incorrect_grammar_in_sched_documentation=2E?= Message-ID: <3YbpWC4yRRzS15@mail.python.org> http://hg.python.org/cpython/rev/95379bf91df4 changeset: 81232:95379bf91df4 parent: 81230:ec4a8df89d45 parent: 81231:6db9ffce83ef user: Serhiy Storchaka date: Wed Jan 02 12:32:10 2013 +0200 summary: Fix incorrect grammar in sched documentation. files: Doc/library/sched.rst | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst --- a/Doc/library/sched.rst +++ b/Doc/library/sched.rst @@ -70,10 +70,8 @@ *priority*. Executing the event means executing ``action(*argument, **kwargs)``. - Optional *argument* argument must be a sequence holding the parameters - for *action* if any used. - Optional *kwargs* argument must be a dictionary holding the keyword - parameters for *action* if any used. + *argument* is a sequence holding the positional arguments for *action*. + *kwargs* is a dictionary holding the keyword arguments for *action*. Return value is an event which may be used for later cancellation of the event (see :meth:`cancel`). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 12:25:34 2013 From: python-checkins at python.org (nick.coghlan) Date: Wed, 2 Jan 2013 12:25:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Major_PEP_432_update?= Message-ID: <3Ybqgf1qN1zSG5@mail.python.org> http://hg.python.org/peps/rev/4930e5754292 changeset: 4648:4930e5754292 user: Nick Coghlan date: Wed Jan 02 21:25:24 2013 +1000 summary: Major PEP 432 update - rename the phases - switch from a config dict to a struct - flesh out the full list of config settings - subinterpreters require full initialisation - query API to see if __main__ is running - add a section on open questions files: pep-0432.txt | 259 +++++++++++++++++++++++++++----------- 1 files changed, 183 insertions(+), 76 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -8,7 +8,7 @@ Content-Type: text/x-rst Created: 28-Dec-2012 Python-Version: 3.4 -Post-History: 28-Dec-2012 +Post-History: 28-Dec-2012, 2-Jan-2013 Abstract @@ -40,9 +40,11 @@ well-defined phases during the startup sequence: * Pre-Initialization - no interpreter available -* Initialization - limited interpreter available -* Pre-Main - full interpreter available, __main__ related metadata incomplete -* Main Execution - normal interpreter operation +* Initialization - interpreter partially available +* Initialized - full interpreter available, __main__ related metadata + incomplete +* Main Execution - optional state, __main__ related metadata populated, + bytecode executing in the __main__ module namespace As a concrete use case to help guide any design changes, and to solve a known problem where the appropriate defaults for system utilities differ from those @@ -116,7 +118,7 @@ will now take place in that state. By basing the new design on a combination of C structures and Python -dictionaries, it should also be easier to modify the system in the +data types, it should also be easier to modify the system in the future to add new configuration options. @@ -492,26 +494,57 @@ CPython command line application. -Startup Phases --------------- +Interpreter Initialization Phases +--------------------------------- Four distinct phases are proposed: -* Pre-Initialization: no interpreter is available. Embedding application - determines the settings required to create the core interpreter and - moves to the next phase by calling ``Py_BeginInitialization``. -* Initialization - a limited interpreter is available. Embedding application - determines and applies the settings required to complete the initialization - process by calling ``Py_ReadConfiguration`` and ``Py_EndInitialization``. -* Pre-Main - the full interpreter is available, but ``__main__`` related - metadata is incomplete. -* Main Execution - normal interpreter operation +* Pre-Initialization: + + * no interpreter is available. + * ``Py_IsInitializing()`` returns ``0`` + * ``Py_IsInitialized()`` returns ``0`` + * ``Py_IsRunningMain()`` returns ``0`` + * The embedding application determines the settings required to create the + main interpreter and moves to the next phase by calling + ``Py_BeginInitialization``. + +* Initialization: + + * the main interpreter is available, but only partially configured. + * ``Py_IsInitializing()`` returns ``1`` + * ``Py_IsInitialized()`` returns ``0`` + * ``Py_RunningMain()`` returns ``0`` + * The embedding application determines and applies the settings + required to complete the initialization process by calling + ``Py_ReadConfiguration`` and ``Py_EndInitialization``. + +* Initialized: + + * the main interpreter is available and fully operational, but + ``__main__`` related metadata is incomplete. + * ``Py_IsInitializing()`` returns ``0`` + * ``Py_IsInitialized()`` returns ``1`` + * ``Py_IsRunningMain()`` returns ``0`` + * Optionally, the embedding application may identify and begin + executing code in the ``__main__`` module namespace by calling + ``Py_RunPathAsMain``, ``Py_RunModuleAsMain`` or ``Py_RunStreamAsMain``. + +* Main Execution: + + * bytecode is being executed in the ``__main__`` namespace + * ``Py_IsInitializing()`` returns ``0`` + * ``Py_IsInitialized()`` returns ``1`` + * ``Py_IsRunningMain()`` returns ``1`` + +As indicated by the phase reporting functions, main module execution is +an optional subphase of Initialized rather than a completely distinct phase. All 4 phases will be used by the standard CPython interpreter and the proposed System Python interpreter. Other embedding applications may -choose to skip the step of executing code in the ``__main__`` module. +choose to skip the step of executing code in the ``__main__`` namespace. -An embedding application may still continue to leave the second phase +An embedding application may still continue to leave initialization almost entirely under CPython's control by using the existing ``Py_Initialize`` API. Alternatively, if an embedding application wants greater control over CPython's initial state, it will be able to use the new, finer @@ -520,20 +553,18 @@ /* Phase 1: Pre-Initialization */ Py_CoreConfig core_config = Py_CoreConfig_INIT; - PyObject *full_config = NULL; + Py_Config config = Py_Config_INIT; /* Easily control the core configuration */ core_config.ignore_environment = 1; /* Ignore environment variables */ - core_config.use_hash_seed = 0; /* Full hash randomisation */ + core_config.use_hash_seed = 0; /* Full hash randomisation */ Py_BeginInitialization(&core_config); /* Phase 2: Initialization */ - full_config = PyDict_New(); - /* Can preconfigure settings here - they will then be + /* Optionally preconfigure some settings here - they will then be * used to derive other settings */ - Py_ReadConfiguration(full_config); + Py_ReadConfiguration(&config); /* Can completely override derived settings here */ - Py_EndInitialization(full_config); - /* Phase 3: Pre-Main */ - Py_DECREF(full_config); + Py_EndInitialization(&config); + /* Phase 3: Initialized */ /* If an embedding application has no real concept of a main module * it can leave the interpreter in this state indefinitely. * Otherwise, it can launch __main__ via the Py_Run*AsMain functions. @@ -553,12 +584,13 @@ The specific settings needed are a flag indicating whether or not to use a specific seed value for the randomised hashes, and if so, the specific value for the seed (a seed value of zero disables randomised hashing). In addition, -the question of whether or not to consider environment variables must be -addressed early. +due to the possible use of ``PYTHONHASHSEED`` in configuring the hash +randomisation, the question of whether or not to consider environment +variables must also be addressed early. The proposed API for this step in the startup sequence is:: - void Py_BeginInitialization(Py_CoreConfig *config); + void Py_BeginInitialization(const Py_CoreConfig *config); Like Py_Initialize, this part of the new API treats initialization failures as fatal errors. While that's still not particularly embedding friendly, @@ -566,13 +598,15 @@ to return error codes instead of aborting would be an even larger task than the one already being proposed. -The new Py_CoreConfig struct holds the settings required for preliminary +The new ``Py_CoreConfig`` struct holds the settings required for preliminary configuration:: + /* Note: if changing anything in Py_CoreConfig, also update + * Py_CoreConfig_INIT */ typedef struct { - int ignore_environment; - int use_hash_seed; - unsigned long hash_seed; + int ignore_environment; /* -E switch */ + int use_hash_seed; /* PYTHONHASHSEED */ + unsigned long hash_seed; /* PYTHONHASHSEED */ } Py_CoreConfig; #define Py_CoreConfig_INIT {0, -1, 0} @@ -642,6 +676,8 @@ * compilation is not allowed (as the parser and compiler are not yet configured properly) +* creation of subinterpreters is not allowed +* creation of additional thread states is not allowed * The following attributes in the ``sys`` module are all either missing or ``None``: * ``sys.path`` @@ -676,8 +712,8 @@ allow any further configuration data to be stored on the interpreter object rather than in C process globals. -Any call to Py_BeginInitialization() must have a matching call to -Py_Finalize(). It is acceptable to skip calling Py_EndInitialization() in +Any call to ``Py_BeginInitialization()`` must have a matching call to +``Py_Finalize()``. It is acceptable to skip calling Py_EndInitialization() in between (e.g. if attempting to read the configuration settings fails) @@ -688,57 +724,112 @@ settings needed to complete the process. No changes are made to the interpreter state at this point. The core API for this step is:: - int Py_ReadConfiguration(PyObject *config); + int Py_ReadConfiguration(PyConfig *config); The config argument should be a pointer to a Python dictionary. For any supported configuration setting already in the dictionary, CPython will sanity check the supplied value, but otherwise accept it as correct. -Unlike Py_Initialize and Py_BeginInitialization, this call will raise an -exception and report an error return rather than exhibiting fatal errors if -a problem is found with the config data. +Unlike ``Py_Initialize`` and ``Py_BeginInitialization``, this call will raise +an exception and report an error return rather than exhibiting fatal errors +if a problem is found with the config data. Any supported configuration setting which is not already set will be populated appropriately. The default configuration can be overridden -entirely by setting the value *before* calling Py_ReadConfiguration. The +entirely by setting the value *before* calling ``Py_ReadConfiguration``. The provided value will then also be used in calculating any settings derived from that value. -Alternatively, settings may be overridden *after* the Py_ReadConfiguration -call (this can be useful if an embedding application wants to adjust -a setting rather than replace it completely, such as removing -``sys.path[0]``). +Alternatively, settings may be overridden *after* the +``Py_ReadConfiguration`` call (this can be useful if an embedding +application wants to adjust a setting rather than replace it completely, +such as removing ``sys.path[0]``). Supported configuration settings -------------------------------- -At least the following configuration settings will be supported:: +The new ``Py_Config`` struct holds the settings required to complete the +interpreter configuration. All fields are either pointers to Python +data types (not set == ``NULL``) or numeric flags (not set == ``-1``):: - raw_argv (list of str, default = retrieved from OS APIs) + /* Note: if changing anything in Py_Config, also update Py_Config_INIT */ + typedef struct { + /* Argument processing */ + PyList *raw_argv; + PyList *argv; + PyList *warnoptions; /* -W switch, PYTHONWARNINGS */ + PyDict *xoptions; /* -X switch */ - argv (list of str, default = derived from raw_argv) - warnoptions (list of str, default = derived from raw_argv and environment) - xoptions (list of str, default = derived from raw_argv and environment) + /* Filesystem locations */ + PyUnicode *program_name; + PyUnicode *executable; + PyUnicode *prefix; /* PYTHONHOME */ + PyUnicode *exec_prefix; /* PYTHONHOME */ + PyUnicode *base_prefix; /* pyvenv.cfg */ + PyUnicode *base_exec_prefix; /* pyvenv.cfg */ - program_name (str, default = retrieved from OS APIs) - executable (str, default = derived from program_name) - home (str, default = complicated!) - prefix (str, default = complicated!) - exec_prefix (str, default = complicated!) - base_prefix (str, default = complicated!) - base_exec_prefix (str, default = complicated!) - path (list of str, default = complicated!) + /* Site module */ + int no_site; /* -S switch */ + int no_user_site; /* -s switch, PYTHONNOUSERSITE */ - io_encoding (str, default = derived from environment or OS APIs) - fs_encoding (str, default = derived from OS APIs) + /* Import configuration */ + int dont_write_bytecode; /* -B switch, PYTHONDONTWRITEBYTECODE */ + int ignore_module_case; /* PYTHONCASEOK */ + PyList *import_path; /* PYTHONPATH (etc) */ - skip_signal_handlers (boolean, default = derived from environment or False) - ignore_environment (boolean, default = derived from environment or False) - dont_write_bytecode (boolean, default = derived from environment or False) - no_site (boolean, default = derived from environment or False) - no_user_site (boolean, default = derived from environment or False) - + /* Standard streams */ + int use_unbuffered_io; /* -u switch, PYTHONUNBUFFEREDIO */ + PyUnicode *stdin_encoding; /* PYTHONIOENCODING */ + PyUnicode *stdin_errors; /* PYTHONIOENCODING */ + PyUnicode *stdout_encoding; /* PYTHONIOENCODING */ + PyUnicode *stdout_errors; /* PYTHONIOENCODING */ + PyUnicode *stderr_encoding; /* PYTHONIOENCODING */ + PyUnicode *stderr_errors; /* PYTHONIOENCODING */ + + /* Filesystem access */ + PyUnicode *fs_encoding; + + /* Interactive interpreter */ + int stdin_is_interactive; /* Force interactive behaviour */ + int inspect_main; /* -i switch, PYTHONINSPECT */ + PyUnicode *startup_file; /* PYTHONSTARTUP */ + + /* Debugging output */ + int debug_parser; /* -d switch, PYTHONDEBUG */ + int verbosity; /* -v switch */ + int suppress_banner; /* -q switch */ + + /* Code generation */ + int bytes_warnings; /* -b switch */ + int optimize; /* -O switch */ + + /* Signal handling */ + int install_sig_handlers; + } Py_Config; + + + /* Struct initialization is pretty ugly in C89. Avoiding this mess would + * be the most attractive aspect of using a PyDict* instead... */ + #define _Py_ArgConfig_INIT NULL, NULL, NULL, NULL + #define _Py_LocationConfig_INIT NULL, NULL, NULL, NULL, NULL, NULL + #define _Py_SiteConfig_INIT -1, -1 + #define _Py_ImportConfig_INIT -1, -1, NULL + #define _Py_StreamConfig_INIT -1, NULL, NULL, NULL, NULL, NULL, NULL + #define _Py_FilesystemConfig_INIT NULL + #define _Py_InteractiveConfig_INIT -1, -1, NULL + #define _Py_DebuggingConfig_INIT -1, -1, -1 + #define _Py_CodeGenConfig_INIT -1, -1 + #define _Py_SignalConfig_INIT -1 + + #define Py_Config_INIT {_Py_ArgConfig_INIT, _Py_LocationConfig_INIT, + _Py_SiteConfig_INIT, _Py_ImportConfig_INIT, + _Py_StreamConfig_INIT, _Py_FilesystemConfig_INIT, + _Py_InteractiveConfig_INIT, + _Py_DebuggingConfig_INIT, _Py_CodeGenConfig_INIT, + _Py_SignalConfig_INIT} + + Completing the interpreter initialization @@ -748,18 +839,18 @@ configuration settings into effect and finish bootstrapping the interpreter up to full operation:: - int Py_EndInitialization(PyObject *config); + int Py_EndInitialization(const PyConfig *config); Like Py_ReadConfiguration, this call will raise an exception and report an error return rather than exhibiting fatal errors if a problem is found with the config data. -All configuration settings are required - the configuration dictionary +All configuration settings are required - the configuration struct should always be passed through ``Py_ReadConfiguration()`` to ensure it is fully populated. -After a successful call, Py_IsInitializing() will be false, while -Py_IsInitialized() will become true. The caveats described above for the +After a successful call, ``Py_IsInitializing()`` will be false, while +``Py_IsInitialized()`` will become true. The caveats described above for the interpreter during the initialization phase will no longer hold. However, some metadata related to the ``__main__`` module may still be @@ -788,19 +879,22 @@ Py_RunModuleAsMain Py_RunStreamAsMain +Query API to indicate that ``sys.argv[0]`` is fully populated:: + + Py_IsRunningMain() Internal Storage of Configuration Data -------------------------------------- The interpreter state will be updated to include details of the configuration settings supplied during initialization by extending the interpreter state -object with an embedded copy of the ``Py_CoreConfig`` struct and an -additional ``PyObject`` pointer to hold a reference to a copy of the -supplied configuration dictionary. +object with an embedded copy of the ``Py_CoreConfig`` and ``Py_Config`` +structs. -For debugging purposes, the copied configuration dictionary will be -exposed as ``sys._configuration``. It will include additional keys for -the fields in the ``Py_CoreConfig`` struct. +For debugging purposes, the configuration settings will be exposed as +a ``sys._configuration`` simple namespace (similar to ``sys.flags`` and +``sys.implementation``. Field names will match those in the configuration +structs, exception for ``hash_seed``, which will be deliberately excluded. These are *snapshots* of the initial configuration settings. They are not consulted by the interpreter during runtime. @@ -849,6 +943,19 @@ of the old style initialization API. (very much TBC) +Open Questions +============== + +* Is ``Py_IsRunningMain()`` worth keeping? +* Should the answers to ``Py_IsInitialized()`` and ``Py_RunningMain()`` be + exposed via the ``sys`` module? +* Is the ``Py_Config`` struct too unwieldy to be practical? Would a Python + dictionary be a better choice? +* Would it be better to manage the flag variables in ``Py_Config`` as + Python integers so the struct can be initialized with a simple + ``memset(&config, 0, sizeof(*config))``? + + A System Python Executable ========================== @@ -867,7 +974,7 @@ change in the PEP is designed to help avoid acceptance of a design that sounds good in theory but proves to be problematic in practice. -Better supporting this kind of "alternate CLI" is the main reason for the +Cleanly supporting this kind of "alternate CLI" is the main reason for the proposed changes to better expose the core logic for deciding between the different execution modes supported by CPython: -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 2 14:55:23 2013 From: python-checkins at python.org (eli.bendersky) Date: Wed, 2 Jan 2013 14:55:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_method_nam?= =?utf-8?q?e_in_documentation_=28=5F=5Fsetstate=5F=5F_--=3E_=5F=5Fgetstate?= =?utf-8?b?X18p?= Message-ID: <3Ybv0W4qdVzS7m@mail.python.org> http://hg.python.org/cpython/rev/1f42ecc05d39 changeset: 81233:1f42ecc05d39 branch: 3.2 parent: 81228:15d900cebc4a user: Eli Bendersky date: Wed Jan 02 05:53:59 2013 -0800 summary: Fix method name in documentation (__setstate__ --> __getstate__) files: Doc/library/pickle.rst | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -367,8 +367,9 @@ * classes that are defined at the top level of a module -* instances of such classes whose :attr:`__dict__` or :meth:`__setstate__` is - picklable (see section :ref:`pickle-inst` for details) +* instances of such classes whose :attr:`__dict__` or the result of calling + :meth:`__getstate__` is picklable (see section :ref:`pickle-inst` for + details). Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` exception; when this happens, an unspecified number of bytes may have already @@ -379,8 +380,8 @@ Note that functions (built-in and user-defined) are pickled by "fully qualified" name reference, not by value. This means that only the function name is -pickled, along with the name of the module the function is defined in. Neither the -function's code, nor any of its function attributes are pickled. Thus the +pickled, along with the name of the module the function is defined in. Neither +the function's code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised. [#]_ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 14:55:25 2013 From: python-checkins at python.org (eli.bendersky) Date: Wed, 2 Jan 2013 14:55:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Fix_method_name_in_documentation_=28=5F=5Fsetstate=5F=5F_--=3E?= =?utf-8?b?IF9fZ2V0c3RhdGVfXyk=?= Message-ID: <3Ybv0Y031szS7m@mail.python.org> http://hg.python.org/cpython/rev/d7c46b0ab614 changeset: 81234:d7c46b0ab614 branch: 3.3 parent: 81231:6db9ffce83ef parent: 81233:1f42ecc05d39 user: Eli Bendersky date: Wed Jan 02 05:54:36 2013 -0800 summary: Fix method name in documentation (__setstate__ --> __getstate__) files: Doc/library/pickle.rst | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -390,8 +390,9 @@ * classes that are defined at the top level of a module -* instances of such classes whose :attr:`__dict__` or :meth:`__setstate__` is - picklable (see section :ref:`pickle-inst` for details) +* instances of such classes whose :attr:`__dict__` or the result of calling + :meth:`__getstate__` is picklable (see section :ref:`pickle-inst` for + details). Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` exception; when this happens, an unspecified number of bytes may have already @@ -402,8 +403,8 @@ Note that functions (built-in and user-defined) are pickled by "fully qualified" name reference, not by value. This means that only the function name is -pickled, along with the name of the module the function is defined in. Neither the -function's code, nor any of its function attributes are pickled. Thus the +pickled, along with the name of the module the function is defined in. Neither +the function's code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised. [#]_ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 14:55:26 2013 From: python-checkins at python.org (eli.bendersky) Date: Wed, 2 Jan 2013 14:55:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_method_name_in_documentation_=28=5F=5Fsetstate=5F=5F?= =?utf-8?b?IC0tPiBfX2dldHN0YXRlX18p?= Message-ID: <3Ybv0Z2gdpzS9J@mail.python.org> http://hg.python.org/cpython/rev/290189f6936c changeset: 81235:290189f6936c parent: 81232:95379bf91df4 parent: 81234:d7c46b0ab614 user: Eli Bendersky date: Wed Jan 02 05:55:17 2013 -0800 summary: Fix method name in documentation (__setstate__ --> __getstate__) files: Doc/library/pickle.rst | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -390,8 +390,9 @@ * classes that are defined at the top level of a module -* instances of such classes whose :attr:`__dict__` or :meth:`__setstate__` is - picklable (see section :ref:`pickle-inst` for details) +* instances of such classes whose :attr:`__dict__` or the result of calling + :meth:`__getstate__` is picklable (see section :ref:`pickle-inst` for + details). Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` exception; when this happens, an unspecified number of bytes may have already @@ -402,8 +403,8 @@ Note that functions (built-in and user-defined) are pickled by "fully qualified" name reference, not by value. This means that only the function name is -pickled, along with the name of the module the function is defined in. Neither the -function's code, nor any of its function attributes are pickled. Thus the +pickled, along with the name of the module the function is defined in. Neither +the function's code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised. [#]_ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 15:02:28 2013 From: python-checkins at python.org (eli.bendersky) Date: Wed, 2 Jan 2013 15:02:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_method_nam?= =?utf-8?q?e_in_documentation_=28=5F=5Fsetstate=5F=5F_--=3E_=5F=5Fgetstate?= =?utf-8?b?X18p?= Message-ID: <3Ybv8h0QzqzS2d@mail.python.org> http://hg.python.org/cpython/rev/08195c46f634 changeset: 81236:08195c46f634 branch: 2.7 parent: 81227:ee5123d6ab6c user: Eli Bendersky date: Wed Jan 02 06:02:23 2013 -0800 summary: Fix method name in documentation (__setstate__ --> __getstate__) files: Doc/library/pickle.rst | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -352,8 +352,9 @@ * classes that are defined at the top level of a module -* instances of such classes whose :attr:`__dict__` or :meth:`__setstate__` is - picklable (see section :ref:`pickle-protocol` for details) +* instances of such classes whose :attr:`__dict__` or the result of calling + :meth:`__getstate__` is picklable (see section :ref:`pickle-protocol` for + details). Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` exception; when this happens, an unspecified number of bytes may have already @@ -364,8 +365,8 @@ Note that functions (built-in and user-defined) are pickled by "fully qualified" name reference, not by value. This means that only the function name is -pickled, along with the name of the module the function is defined in. Neither the -function's code, nor any of its function attributes are pickled. Thus the +pickled, along with the name of the module the function is defined in. Neither +the function's code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised. [#]_ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 16:37:53 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 16:37:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_ensure_the_att?= =?utf-8?q?ribute_name_string_is_initalized_before_using_it_=28closes_=231?= =?utf-8?q?6839=29?= Message-ID: <3YbxGn2g5SzSFW@mail.python.org> http://hg.python.org/cpython/rev/0012d4f0ca59 changeset: 81237:0012d4f0ca59 branch: 2.7 parent: 81218:f6e74759d740 user: Benjamin Peterson date: Wed Jan 02 09:36:23 2013 -0600 summary: ensure the attribute name string is initalized before using it (closes #16839) files: Misc/NEWS | 3 +++ Objects/object.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,9 @@ Core and Builtins ----------------- +- Issue #16839: Fix a segfault when calling unicode() on a classic class early + in interpreter initialization. + - Issue #16761: Calling ``int()`` and ``long()`` with *base* argument only now raises TypeError. diff --git a/Objects/object.c b/Objects/object.c --- a/Objects/object.c +++ b/Objects/object.c @@ -474,7 +474,7 @@ PyObject *func; PyObject *str; int unicode_method_found = 0; - static PyObject *unicodestr; + static PyObject *unicodestr = NULL; if (v == NULL) { res = PyString_FromString(""); @@ -491,6 +491,11 @@ if (PyInstance_Check(v)) { /* We're an instance of a classic class */ /* Try __unicode__ from the instance -- alas we have no type */ + if (!unicodestr) { + unicodestr = PyString_InternFromString("__unicode__"); + if (!unicodestr) + return NULL; + } func = PyObject_GetAttr(v, unicodestr); if (func != NULL) { unicode_method_found = 1; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 16:37:54 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 16:37:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_merge_heads?= Message-ID: <3YbxGp56YWzSGD@mail.python.org> http://hg.python.org/cpython/rev/4264994fd6a3 changeset: 81238:4264994fd6a3 branch: 2.7 parent: 81237:0012d4f0ca59 parent: 81236:08195c46f634 user: Benjamin Peterson date: Wed Jan 02 09:37:33 2013 -0600 summary: merge heads files: Doc/library/pickle.rst | 9 +++++---- Misc/NEWS | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -352,8 +352,9 @@ * classes that are defined at the top level of a module -* instances of such classes whose :attr:`__dict__` or :meth:`__setstate__` is - picklable (see section :ref:`pickle-protocol` for details) +* instances of such classes whose :attr:`__dict__` or the result of calling + :meth:`__getstate__` is picklable (see section :ref:`pickle-protocol` for + details). Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` exception; when this happens, an unspecified number of bytes may have already @@ -364,8 +365,8 @@ Note that functions (built-in and user-defined) are pickled by "fully qualified" name reference, not by value. This means that only the function name is -pickled, along with the name of the module the function is defined in. Neither the -function's code, nor any of its function attributes are pickled. Thus the +pickled, along with the name of the module the function is defined in. Neither +the function's code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised. [#]_ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -184,8 +184,8 @@ - Issue 10527: make multiprocessing use poll() instead of select() if available. -- Issue #16485: Fix file descriptor not being closed if file header patching - fails on closing of aifc file. +- Issue #16485: Now file descriptors are closed if file header patching failed + on closing an aifc file. - Issue #12065: connect_ex() on an SSL socket now returns the original errno when the socket's timeout expires (it used to return None). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 17:23:55 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 2 Jan 2013 17:23:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316841=3A_Set_st?= =?utf-8?q?=5Fdev_on_Windows_as_unsigned_long_to_match_its_DWORD_type=2E?= Message-ID: <3YbyHv71D6zS1q@mail.python.org> http://hg.python.org/cpython/rev/07d07111cec9 changeset: 81239:07d07111cec9 parent: 81235:290189f6936c user: Serhiy Storchaka date: Wed Jan 02 18:22:23 2013 +0200 summary: Issue #16841: Set st_dev on Windows as unsigned long to match its DWORD type. files: Modules/posixmodule.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1951,7 +1951,9 @@ #else PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino)); #endif -#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) +#ifdef MS_WINDOWS + PyStructSequence_SET_ITEM(v, 2, PyLong_FromUnsignedLong(st->st_dev)); +#elif defined(HAVE_LONG_LONG) PyStructSequence_SET_ITEM(v, 2, PyLong_FromLongLong((PY_LONG_LONG)st->st_dev)); #else -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 19:23:46 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 19:23:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogY2FsbCBQeUVycl9D?= =?utf-8?q?lear=28=29_when_ignoring_error_from_PyNumber=5FInt_=28closes_?= =?utf-8?q?=2315516=29?= Message-ID: <3Yc0yB1SR3zS6w@mail.python.org> http://hg.python.org/cpython/rev/80cfd4caa726 changeset: 81240:80cfd4caa726 branch: 2.7 parent: 81238:4264994fd6a3 user: Benjamin Peterson date: Wed Jan 02 12:21:32 2013 -0600 summary: call PyErr_Clear() when ignoring error from PyNumber_Int (closes #15516) Patch from Tom Tromey. files: Lib/test/test_format.py | 10 ++++++++++ Misc/NEWS | 3 +++ Objects/stringobject.c | 5 ++++- 3 files changed, 17 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -234,6 +234,16 @@ testformat('%g', 1.1, '1.1') testformat('%#g', 1.1, '1.10000') + # Regression test for http://bugs.python.org/issue15516. + class IntFails(object): + def __int__(self): + raise TestFailed + def __long__(self): + return 0 + + fst = IntFails() + testformat("%x", fst, '0') + # Test exception for unknown format characters if verbose: print 'Testing exceptions' diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,9 @@ Core and Builtins ----------------- +- Issue #15516: Fix a bug in PyString_FromFormat where it failed to properly + ignore errors from a __int__() method. + - Issue #16839: Fix a segfault when calling unicode() on a classic class early in interpreter initialization. diff --git a/Objects/stringobject.c b/Objects/stringobject.c --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -4489,7 +4489,10 @@ } else { iobj = PyNumber_Int(v); - if (iobj==NULL) iobj = PyNumber_Long(v); + if (iobj==NULL) { + PyErr_Clear(); + iobj = PyNumber_Long(v); + } } if (iobj!=NULL) { if (PyInt_Check(iobj)) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 19:23:47 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 19:23:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_add_Tom_Tromey?= =?utf-8?q?_to_ACKS?= Message-ID: <3Yc0yC3rVRzS6w@mail.python.org> http://hg.python.org/cpython/rev/c5199d9eee04 changeset: 81241:c5199d9eee04 branch: 2.7 user: Benjamin Peterson date: Wed Jan 02 12:22:11 2013 -0600 summary: add Tom Tromey to ACKS files: Misc/ACKS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1000,6 +1000,7 @@ Sandro Tosi Richard Townsend Laurence Tratt +Tom Tromey John Tromp Jason Trowbridge Brent Tubbs -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 19:23:48 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 19:23:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_add_Tom_Tromey?= =?utf-8?q?_to_ACKS?= Message-ID: <3Yc0yD6DhSzS9S@mail.python.org> http://hg.python.org/cpython/rev/d547a5444392 changeset: 81242:d547a5444392 branch: 3.3 parent: 81234:d7c46b0ab614 user: Benjamin Peterson date: Wed Jan 02 12:22:11 2013 -0600 summary: add Tom Tromey to ACKS files: Misc/ACKS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1196,6 +1196,7 @@ Laurence Tratt Alberto Trevino Matthias Troffaes +Tom Tromey John Tromp Jason Trowbridge Brent Tubbs -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 19:23:50 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 19:23:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3Yc0yG1TMxzS1Z@mail.python.org> http://hg.python.org/cpython/rev/1f263ae10bd6 changeset: 81243:1f263ae10bd6 parent: 81235:290189f6936c parent: 81242:d547a5444392 user: Benjamin Peterson date: Wed Jan 02 12:23:05 2013 -0600 summary: merge 3.3 files: Misc/ACKS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1207,6 +1207,7 @@ Laurence Tratt Alberto Trevino Matthias Troffaes +Tom Tromey John Tromp Jason Trowbridge Brent Tubbs -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 19:23:51 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 19:23:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_merge_heads?= Message-ID: <3Yc0yH3yYmzS9S@mail.python.org> http://hg.python.org/cpython/rev/6a24dbc4bf49 changeset: 81244:6a24dbc4bf49 parent: 81243:1f263ae10bd6 parent: 81239:07d07111cec9 user: Benjamin Peterson date: Wed Jan 02 12:23:32 2013 -0600 summary: merge heads files: Modules/posixmodule.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1951,7 +1951,9 @@ #else PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino)); #endif -#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) +#ifdef MS_WINDOWS + PyStructSequence_SET_ITEM(v, 2, PyLong_FromUnsignedLong(st->st_dev)); +#elif defined(HAVE_LONG_LONG) PyStructSequence_SET_ITEM(v, 2, PyLong_FromLongLong((PY_LONG_LONG)st->st_dev)); #else -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 19:25:21 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 2 Jan 2013 19:25:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_untabify?= Message-ID: <3Yc10113HKzS1J@mail.python.org> http://hg.python.org/cpython/rev/ded5386604fd changeset: 81245:ded5386604fd branch: 2.7 parent: 81241:c5199d9eee04 user: Benjamin Peterson date: Wed Jan 02 12:25:15 2013 -0600 summary: untabify files: Objects/stringobject.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/stringobject.c b/Objects/stringobject.c --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -4490,9 +4490,9 @@ else { iobj = PyNumber_Int(v); if (iobj==NULL) { - PyErr_Clear(); - iobj = PyNumber_Long(v); - } + PyErr_Clear(); + iobj = PyNumber_Long(v); + } } if (iobj!=NULL) { if (PyInt_Check(iobj)) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 20:23:12 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 20:23:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2NzQ4OiB0ZXN0?= =?utf-8?q?=5Fheapq_now_works_with_unittest_test_discovery=2E?= Message-ID: <3Yc2Gm3wr2zS1n@mail.python.org> http://hg.python.org/cpython/rev/008bac4e181c changeset: 81246:008bac4e181c branch: 3.3 parent: 81242:d547a5444392 user: Ezio Melotti date: Wed Jan 02 21:19:37 2013 +0200 summary: #16748: test_heapq now works with unittest test discovery. files: Lib/test/test_heapq.py | 35 ++++++----------------------- Misc/NEWS | 2 + 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -2,6 +2,7 @@ import sys import random +import unittest from test import support from unittest import TestCase, skipUnless @@ -25,8 +26,7 @@ self.assertEqual(getattr(c_heapq, fname).__module__, '_heapq') -class TestHeap(TestCase): - module = None +class TestHeap: def test_push_pop(self): # 1) Push 256 random numbers and pop them off, verifying all's OK. @@ -214,12 +214,12 @@ self.assertRaises(TypeError, data, LE) -class TestHeapPython(TestHeap): +class TestHeapPython(TestHeap, TestCase): module = py_heapq @skipUnless(c_heapq, 'requires _heapq') -class TestHeapC(TestHeap): +class TestHeapC(TestHeap, TestCase): module = c_heapq @@ -319,8 +319,7 @@ return chain(map(lambda x:x, R(Ig(G(seqn))))) -class TestErrorHandling(TestCase): - module = None +class TestErrorHandling: def test_non_sequence(self): for f in (self.module.heapify, self.module.heappop): @@ -371,31 +370,13 @@ self.assertRaises(ZeroDivisionError, f, 2, E(s)) -class TestErrorHandlingPython(TestErrorHandling): +class TestErrorHandlingPython(TestErrorHandling, TestCase): module = py_heapq @skipUnless(c_heapq, 'requires _heapq') -class TestErrorHandlingC(TestErrorHandling): +class TestErrorHandlingC(TestErrorHandling, TestCase): module = c_heapq -#============================================================================== - - -def test_main(verbose=None): - test_classes = [TestModules, TestHeapPython, TestHeapC, - TestErrorHandlingPython, TestErrorHandlingC] - support.run_unittest(*test_classes) - - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_unittest(*test_classes) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) - if __name__ == "__main__": - test_main(verbose=True) + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -381,6 +381,8 @@ Tests ----- +- Issue #16748: test_heapq now works with unittest test discovery. + - Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize options. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 20:23:13 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 20:23:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2NzQ4OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3Yc2Gn6QvkzS5q@mail.python.org> http://hg.python.org/cpython/rev/de6bac0a40cc changeset: 81247:de6bac0a40cc parent: 81244:6a24dbc4bf49 parent: 81246:008bac4e181c user: Ezio Melotti date: Wed Jan 02 21:22:58 2013 +0200 summary: #16748: merge with 3.3. files: Lib/test/test_heapq.py | 35 ++++++----------------------- Misc/NEWS | 2 + 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -2,6 +2,7 @@ import sys import random +import unittest from test import support from unittest import TestCase, skipUnless @@ -25,8 +26,7 @@ self.assertEqual(getattr(c_heapq, fname).__module__, '_heapq') -class TestHeap(TestCase): - module = None +class TestHeap: def test_push_pop(self): # 1) Push 256 random numbers and pop them off, verifying all's OK. @@ -214,12 +214,12 @@ self.assertRaises(TypeError, data, LE) -class TestHeapPython(TestHeap): +class TestHeapPython(TestHeap, TestCase): module = py_heapq @skipUnless(c_heapq, 'requires _heapq') -class TestHeapC(TestHeap): +class TestHeapC(TestHeap, TestCase): module = c_heapq @@ -319,8 +319,7 @@ return chain(map(lambda x:x, R(Ig(G(seqn))))) -class TestErrorHandling(TestCase): - module = None +class TestErrorHandling: def test_non_sequence(self): for f in (self.module.heapify, self.module.heappop): @@ -371,31 +370,13 @@ self.assertRaises(ZeroDivisionError, f, 2, E(s)) -class TestErrorHandlingPython(TestErrorHandling): +class TestErrorHandlingPython(TestErrorHandling, TestCase): module = py_heapq @skipUnless(c_heapq, 'requires _heapq') -class TestErrorHandlingC(TestErrorHandling): +class TestErrorHandlingC(TestErrorHandling, TestCase): module = c_heapq -#============================================================================== - - -def test_main(verbose=None): - test_classes = [TestModules, TestHeapPython, TestHeapC, - TestErrorHandlingPython, TestErrorHandlingC] - support.run_unittest(*test_classes) - - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_unittest(*test_classes) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) - if __name__ == "__main__": - test_main(verbose=True) + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -571,6 +571,8 @@ Tests ----- +- Issue #16748: test_heapq now works with unittest test discovery. + - Issue #10646: Tests rearranged for os.samefile/samestat to check for not just symlinks but also hard links. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 21:30:10 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 21:30:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE2NzQ3OiBmaXgg?= =?utf-8?q?link_to_file_objects_in_the_glossary=2E?= Message-ID: <3Yc3m25gFCzS49@mail.python.org> http://hg.python.org/cpython/rev/2afc0997e440 changeset: 81248:2afc0997e440 branch: 3.2 parent: 81233:1f42ecc05d39 user: Ezio Melotti date: Wed Jan 02 22:29:09 2013 +0200 summary: #16747: fix link to file objects in the glossary. files: Doc/glossary.rst | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -356,17 +356,17 @@ slowly. See also :term:`interactive`. iterable - An object capable of returning its members one at a - time. Examples of iterables include all sequence types (such as - :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence - types like :class:`dict` and :class:`file` and objects of any classes you - define with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables - can be used in a :keyword:`for` loop and in many other places where a - sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable - object is passed as an argument to the built-in function :func:`iter`, it - returns an iterator for the object. This iterator is good for one pass - over the set of values. When using iterables, it is usually not necessary - to call :func:`iter` or deal with iterator objects yourself. The ``for`` + An object capable of returning its members one at a time. Examples of + iterables include all sequence types (such as :class:`list`, :class:`str`, + and :class:`tuple`) and some non-sequence types like :class:`dict`, + :term:`file objects `, and objects of any classes you define + with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be + used in a :keyword:`for` loop and in many other places where a sequence is + needed (:func:`zip`, :func:`map`, ...). When an iterable object is passed + as an argument to the built-in function :func:`iter`, it returns an + iterator for the object. This iterator is good for one pass over the set + of values. When using iterables, it is usually not necessary to call + :func:`iter` or deal with iterator objects yourself. The ``for`` statement does that automatically for you, creating a temporary unnamed variable to hold the iterator for the duration of the loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 21:30:12 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 21:30:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2316747=3A_merge_with_3=2E2=2E?= Message-ID: <3Yc3m40xy7zSJh@mail.python.org> http://hg.python.org/cpython/rev/6e4fc5e2acf8 changeset: 81249:6e4fc5e2acf8 branch: 3.3 parent: 81246:008bac4e181c parent: 81248:2afc0997e440 user: Ezio Melotti date: Wed Jan 02 22:29:41 2013 +0200 summary: #16747: merge with 3.2. files: Doc/glossary.rst | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -367,17 +367,17 @@ slowly. See also :term:`interactive`. iterable - An object capable of returning its members one at a - time. Examples of iterables include all sequence types (such as - :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence - types like :class:`dict` and :class:`file` and objects of any classes you - define with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables - can be used in a :keyword:`for` loop and in many other places where a - sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable - object is passed as an argument to the built-in function :func:`iter`, it - returns an iterator for the object. This iterator is good for one pass - over the set of values. When using iterables, it is usually not necessary - to call :func:`iter` or deal with iterator objects yourself. The ``for`` + An object capable of returning its members one at a time. Examples of + iterables include all sequence types (such as :class:`list`, :class:`str`, + and :class:`tuple`) and some non-sequence types like :class:`dict`, + :term:`file objects `, and objects of any classes you define + with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be + used in a :keyword:`for` loop and in many other places where a sequence is + needed (:func:`zip`, :func:`map`, ...). When an iterable object is passed + as an argument to the built-in function :func:`iter`, it returns an + iterator for the object. This iterator is good for one pass over the set + of values. When using iterables, it is usually not necessary to call + :func:`iter` or deal with iterator objects yourself. The ``for`` statement does that automatically for you, creating a temporary unnamed variable to hold the iterator for the duration of the loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 21:30:13 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 21:30:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2NzQ3OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3Yc3m53GzCzS49@mail.python.org> http://hg.python.org/cpython/rev/e19ed347523e changeset: 81250:e19ed347523e parent: 81247:de6bac0a40cc parent: 81249:6e4fc5e2acf8 user: Ezio Melotti date: Wed Jan 02 22:29:57 2013 +0200 summary: #16747: merge with 3.3. files: Doc/glossary.rst | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -367,17 +367,17 @@ slowly. See also :term:`interactive`. iterable - An object capable of returning its members one at a - time. Examples of iterables include all sequence types (such as - :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence - types like :class:`dict` and :class:`file` and objects of any classes you - define with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables - can be used in a :keyword:`for` loop and in many other places where a - sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable - object is passed as an argument to the built-in function :func:`iter`, it - returns an iterator for the object. This iterator is good for one pass - over the set of values. When using iterables, it is usually not necessary - to call :func:`iter` or deal with iterator objects yourself. The ``for`` + An object capable of returning its members one at a time. Examples of + iterables include all sequence types (such as :class:`list`, :class:`str`, + and :class:`tuple`) and some non-sequence types like :class:`dict`, + :term:`file objects `, and objects of any classes you define + with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be + used in a :keyword:`for` loop and in many other places where a sequence is + needed (:func:`zip`, :func:`map`, ...). When an iterable object is passed + as an argument to the built-in function :func:`iter`, it returns an + iterator for the object. This iterator is good for one pass over the set + of values. When using iterables, it is usually not necessary to call + :func:`iter` or deal with iterator objects yourself. The ``for`` statement does that automatically for you, creating a temporary unnamed variable to hold the iterator for the duration of the loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 21:48:42 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 2 Jan 2013 21:48:42 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_=2313810=3A_fix_Sphinx_UR?= =?utf-8?q?L=2E?= Message-ID: <3Yc49Q1zcmzS2B@mail.python.org> http://hg.python.org/devguide/rev/47df28c52840 changeset: 583:47df28c52840 user: Ezio Melotti date: Wed Jan 02 22:48:32 2013 +0200 summary: #13810: fix Sphinx URL. files: documenting.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/documenting.rst b/documenting.rst --- a/documenting.rst +++ b/documenting.rst @@ -19,7 +19,7 @@ .. _reStructuredText: http://docutils.sf.net/rst.html .. _docutils: http://docutils.sf.net/ -.. _Sphinx: http://sphinx.pocoo.org/ +.. _Sphinx: http://sphinx-doc.org/ .. note:: -- Repository URL: http://hg.python.org/devguide From root at python.org Wed Jan 2 21:50:08 2013 From: root at python.org (Cron Daemon) Date: Wed, 02 Jan 2013 21:50:08 +0100 Subject: [Python-checkins] Cron /home/docs/build-devguide Message-ID: /home/docs/devguide/documenting.rst:768: WARNING: term not in glossary: bytecode From python-checkins at python.org Wed Jan 2 22:14:46 2013 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 2 Jan 2013 22:14:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316833=3A_In_http?= =?utf-8?q?=2Eclient=2EHTTPConnection=2C_do_not_concatenate_the_request?= Message-ID: <3Yc4lV3tdkzPBl@mail.python.org> http://hg.python.org/cpython/rev/002bf9857278 changeset: 81251:002bf9857278 user: Antoine Pitrou date: Wed Jan 02 22:10:47 2013 +0100 summary: Issue #16833: In http.client.HTTPConnection, do not concatenate the request headers and body when the payload exceeds 16 KB, since it can consume more memory for no benefit. Patch by Benno Leslie. files: Lib/http/client.py | 15 +++++++++++++-- Lib/test/test_httplib.py | 24 ++++++++++++++++++++++++ Misc/ACKS | 1 + Misc/NEWS | 4 ++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Lib/http/client.py b/Lib/http/client.py --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -719,6 +719,14 @@ default_port = HTTP_PORT auto_open = 1 debuglevel = 0 + # TCP Maximum Segment Size (MSS) is determined by the TCP stack on + # a per-connection basis. There is no simple and efficient + # platform independent mechanism for determining the MSS, so + # instead a reasonable estimate is chosen. The getsockopt() + # interface using the TCP_MAXSEG parameter may be a suitable + # approach on some operating systems. A value of 16KiB is chosen + # as a reasonable estimate of the maximum MSS. + mss = 16384 def __init__(self, host, port=None, strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None): @@ -886,8 +894,11 @@ del self._buffer[:] # If msg and message_body are sent in a single send() call, # it will avoid performance problems caused by the interaction - # between delayed ack and the Nagle algorithm. - if isinstance(message_body, bytes): + # between delayed ack and the Nagle algorithm. However, + # there is no performance gain if the message is larger + # than MSS (and there is a memory penalty for the message + # copy). + if isinstance(message_body, bytes) and len(message_body) < self.mss: msg += message_body message_body = None self.send(msg) diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -27,8 +27,10 @@ self.text = text self.fileclass = fileclass self.data = b'' + self.sendall_calls = 0 def sendall(self, data): + self.sendall_calls += 1 self.data += data def makefile(self, mode, bufsize=None): @@ -558,6 +560,28 @@ self.assertEqual(resp.read(), b'') self.assertTrue(resp.isclosed()) + def test_delayed_ack_opt(self): + # Test that Nagle/delayed_ack optimistaion works correctly. + + # For small payloads, it should coalesce the body with + # headers, resulting in a single sendall() call + conn = client.HTTPConnection('example.com') + sock = FakeSocket(None) + conn.sock = sock + body = b'x' * (conn.mss - 1) + conn.request('POST', '/', body) + self.assertEqual(sock.sendall_calls, 1) + + # For large payloads, it should send the headers and + # then the body, resulting in more than one sendall() + # call + conn = client.HTTPConnection('example.com') + sock = FakeSocket(None) + conn.sock = sock + body = b'x' * conn.mss + conn.request('POST', '/', body) + self.assertGreater(sock.sendall_calls, 1) + class OfflineTest(TestCase): def test_responses(self): self.assertEqual(client.responses[client.NOT_FOUND], "Not Found") diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -705,6 +705,7 @@ Tshepang Lekhonkhobe Marc-Andr? Lemburg John Lenton +Benno Leslie Christopher Tur Lesniewski-Laas Alain Leufroy Mark Levinson diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -199,6 +199,10 @@ Library ------- +- Issue #16833: In http.client.HTTPConnection, do not concatenate the request + headers and body when the payload exceeds 16 KB, since it can consume more + memory for no benefit. Patch by Benno Leslie. + - Issue #16541: tk_setPalette() now works with keyword arguments. - Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 23:14:32 2013 From: python-checkins at python.org (nadeem.vawda) Date: Wed, 2 Jan 2013 23:14:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2ODI4?= =?utf-8?q?=3A_Fix_error_incorrectly_raised_by_bz2=2Ecompress=28=27=27=29?= =?utf-8?q?=2E?= Message-ID: <3Yc64S4VyRzMFC@mail.python.org> http://hg.python.org/cpython/rev/06a08144af1b changeset: 81252:06a08144af1b branch: 2.7 parent: 81245:ded5386604fd user: Nadeem Vawda date: Wed Jan 02 22:59:51 2013 +0100 summary: Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by Martin Packman. files: Lib/test/test_bz2.py | 18 ++++++++++++++++++ Misc/ACKS | 1 + Misc/NEWS | 3 +++ Modules/bz2module.c | 2 +- 4 files changed, 23 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -23,6 +23,7 @@ TEXT = 'root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:\ndaemon:x:2:2:daemon:/sbin:\nadm:x:3:4:adm:/var/adm:\nlp:x:4:7:lp:/var/spool/lpd:\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:\nnews:x:9:13:news:/var/spool/news:\nuucp:x:10:14:uucp:/var/spool/uucp:\noperator:x:11:0:operator:/root:\ngames:x:12:100:games:/usr/games:\ngopher:x:13:30:gopher:/usr/lib/gopher-data:\nftp:x:14:50:FTP User:/var/ftp:/bin/bash\nnobody:x:65534:65534:Nobody:/home:\npostfix:x:100:101:postfix:/var/spool/postfix:\nniemeyer:x:500:500::/home/niemeyer:/bin/bash\npostgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\nmysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\nwww:x:103:104::/var/www:/bin/false\n' DATA = 'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' DATA_CRLF = 'BZh91AY&SY\xaez\xbbN\x00\x01H\xdf\x80\x00\x12@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe0@\x01\xbc\xc6`\x86*\x8d=M\xa9\x9a\x86\xd0L@\x0fI\xa6!\xa1\x13\xc8\x88jdi\x8d@\x03@\x1a\x1a\x0c\x0c\x83 \x00\xc4h2\x19\x01\x82D\x84e\t\xe8\x99\x89\x19\x1ah\x00\r\x1a\x11\xaf\x9b\x0fG\xf5(\x1b\x1f?\t\x12\xcf\xb5\xfc\x95E\x00ps\x89\x12^\xa4\xdd\xa2&\x05(\x87\x04\x98\x89u\xe40%\xb6\x19\'\x8c\xc4\x89\xca\x07\x0e\x1b!\x91UIFU%C\x994!DI\xd2\xfa\xf0\xf1N8W\xde\x13A\xf5\x9cr%?\x9f3;I45A\xd1\x8bT\xb1\xa4\xc7\x8d\x1a\\"\xad\xa1\xabyBg\x15\xb9l\x88\x88\x91k"\x94\xa4\xd4\x89\xae*\xa6\x0b\x10\x0c\xd6\xd4m\xe86\xec\xb5j\x8a\x86j\';\xca.\x01I\xf2\xaaJ\xe8\x88\x8cU+t3\xfb\x0c\n\xa33\x13r2\r\x16\xe0\xb3(\xbf\x1d\x83r\xe7M\xf0D\x1365\xd8\x88\xd3\xa4\x92\xcb2\x06\x04\\\xc1\xb0\xea//\xbek&\xd8\xe6+t\xe5\xa1\x13\xada\x16\xder5"w]\xa2i\xb7[\x97R \xe2IT\xcd;Z\x04dk4\xad\x8a\t\xd3\x81z\x10\xf1:^`\xab\x1f\xc5\xdc\x91N\x14$+\x9e\xae\xd3\x80' + EMPTY_DATA = 'BZh9\x17rE8P\x90\x00\x00\x00\x00' with open(findfile("testbz2_bigmem.bz2"), "rb") as f: DATA_BIGMEM = f.read() @@ -336,6 +337,13 @@ data += bz2c.flush() self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + # "Test BZ2Compressor.compress()/flush() of empty string" + bz2c = BZ2Compressor() + data = bz2c.compress('') + data += bz2c.flush() + self.assertEqual(data, self.EMPTY_DATA) + def testCompressChunks10(self): # "Test BZ2Compressor.compress()/flush() with chunks of 10 bytes" bz2c = BZ2Compressor() @@ -418,6 +426,11 @@ data = bz2.compress(self.TEXT) self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + # "Test compress() of empty string" + text = bz2.compress('') + self.assertEqual(text, self.EMPTY_DATA) + def testDecompress(self): # "Test decompress() function" text = bz2.decompress(self.DATA) @@ -428,6 +441,11 @@ text = bz2.decompress("") self.assertEqual(text, "") + def testDecompressToEmptyString(self): + # "Test decompress() of minimal bz2 data to empty string" + text = bz2.decompress(self.EMPTY_DATA) + self.assertEqual(text, '') + def testDecompressIncomplete(self): # "Test decompress() function with incomplete data" self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -742,6 +742,7 @@ R. M. Oudkerk Russel Owen Joonas Paalasmaa +Martin Packman Shriphani Palakodety Ondrej Palkovsky Mike Pall diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -181,6 +181,9 @@ Library ------- +- Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by + Martin Packman. + - Issue #16819: IDLE method completion now correctly works for unicode literals. - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. diff --git a/Modules/bz2module.c b/Modules/bz2module.c --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -2175,7 +2175,7 @@ return NULL; } - action = BZ_RUN; + action = input_left > 0 ? BZ_RUN : BZ_FINISH; for (;;) { char *saved_next_out; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 23:14:34 2013 From: python-checkins at python.org (nadeem.vawda) Date: Wed, 2 Jan 2013 23:14:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2ODI4?= =?utf-8?q?=3A_Fix_error_incorrectly_raised_by_bz2=2Ecompress=28=27=27=29?= =?utf-8?q?=2E?= Message-ID: <3Yc64V12qBzS0f@mail.python.org> http://hg.python.org/cpython/rev/c4a4863b85b2 changeset: 81253:c4a4863b85b2 branch: 3.2 parent: 81248:2afc0997e440 user: Nadeem Vawda date: Wed Jan 02 23:02:00 2013 +0100 summary: Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by Martin Packman. files: Lib/test/test_bz2.py | 15 +++++++++++++++ Misc/ACKS | 1 + Misc/NEWS | 3 +++ Modules/bz2module.c | 2 +- 4 files changed, 20 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -24,6 +24,7 @@ TEXT = b'root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:\ndaemon:x:2:2:daemon:/sbin:\nadm:x:3:4:adm:/var/adm:\nlp:x:4:7:lp:/var/spool/lpd:\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:\nnews:x:9:13:news:/var/spool/news:\nuucp:x:10:14:uucp:/var/spool/uucp:\noperator:x:11:0:operator:/root:\ngames:x:12:100:games:/usr/games:\ngopher:x:13:30:gopher:/usr/lib/gopher-data:\nftp:x:14:50:FTP User:/var/ftp:/bin/bash\nnobody:x:65534:65534:Nobody:/home:\npostfix:x:100:101:postfix:/var/spool/postfix:\nniemeyer:x:500:500::/home/niemeyer:/bin/bash\npostgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\nmysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\nwww:x:103:104::/var/www:/bin/false\n' DATA = b'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' DATA_CRLF = b'BZh91AY&SY\xaez\xbbN\x00\x01H\xdf\x80\x00\x12@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe0@\x01\xbc\xc6`\x86*\x8d=M\xa9\x9a\x86\xd0L@\x0fI\xa6!\xa1\x13\xc8\x88jdi\x8d@\x03@\x1a\x1a\x0c\x0c\x83 \x00\xc4h2\x19\x01\x82D\x84e\t\xe8\x99\x89\x19\x1ah\x00\r\x1a\x11\xaf\x9b\x0fG\xf5(\x1b\x1f?\t\x12\xcf\xb5\xfc\x95E\x00ps\x89\x12^\xa4\xdd\xa2&\x05(\x87\x04\x98\x89u\xe40%\xb6\x19\'\x8c\xc4\x89\xca\x07\x0e\x1b!\x91UIFU%C\x994!DI\xd2\xfa\xf0\xf1N8W\xde\x13A\xf5\x9cr%?\x9f3;I45A\xd1\x8bT\xb1\xa4\xc7\x8d\x1a\\"\xad\xa1\xabyBg\x15\xb9l\x88\x88\x91k"\x94\xa4\xd4\x89\xae*\xa6\x0b\x10\x0c\xd6\xd4m\xe86\xec\xb5j\x8a\x86j\';\xca.\x01I\xf2\xaaJ\xe8\x88\x8cU+t3\xfb\x0c\n\xa33\x13r2\r\x16\xe0\xb3(\xbf\x1d\x83r\xe7M\xf0D\x1365\xd8\x88\xd3\xa4\x92\xcb2\x06\x04\\\xc1\xb0\xea//\xbek&\xd8\xe6+t\xe5\xa1\x13\xada\x16\xder5"w]\xa2i\xb7[\x97R \xe2IT\xcd;Z\x04dk4\xad\x8a\t\xd3\x81z\x10\xf1:^`\xab\x1f\xc5\xdc\x91N\x14$+\x9e\xae\xd3\x80' + EMPTY_DATA = b'BZh9\x17rE8P\x90\x00\x00\x00\x00' with open(findfile("testbz2_bigmem.bz2"), "rb") as f: DATA_BIGMEM = f.read() @@ -303,6 +304,12 @@ data += bz2c.flush() self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + bz2c = BZ2Compressor() + data = bz2c.compress(b'') + data += bz2c.flush() + self.assertEqual(data, self.EMPTY_DATA) + def testCompressChunks10(self): # "Test BZ2Compressor.compress()/flush() with chunks of 10 bytes" bz2c = BZ2Compressor() @@ -383,6 +390,10 @@ data = bz2.compress(self.TEXT) self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + text = bz2.compress(b'') + self.assertEqual(text, self.EMPTY_DATA) + def testDecompress(self): # "Test decompress() function" text = bz2.decompress(self.DATA) @@ -393,6 +404,10 @@ text = bz2.decompress(b"") self.assertEqual(text, b"") + def testDecompressToEmptyString(self): + text = bz2.decompress(self.EMPTY_DATA) + self.assertEqual(text, b'') + def testDecompressIncomplete(self): # "Test decompress() function with incomplete data" self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -801,6 +801,7 @@ R. M. Oudkerk Russel Owen Joonas Paalasmaa +Martin Packman Shriphani Palakodety Ondrej Palkovsky Mike Pall diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -188,6 +188,9 @@ Library ------- +- Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by + Martin Packman. + - Issue #16541: tk_setPalette() now works with keyword arguments. - Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. diff --git a/Modules/bz2module.c b/Modules/bz2module.c --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -1979,7 +1979,7 @@ return NULL; } - action = BZ_RUN; + action = input_left > 0 ? BZ_RUN : BZ_FINISH; for (;;) { char *saved_next_out; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 23:14:35 2013 From: python-checkins at python.org (nadeem.vawda) Date: Wed, 2 Jan 2013 23:14:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316828=3A_Fix_error_incorrectly_raised_by_bz2=2Ecompre?= =?utf-8?b?c3MoJycpLg==?= Message-ID: <3Yc64W51MFzS28@mail.python.org> http://hg.python.org/cpython/rev/011981143087 changeset: 81254:011981143087 branch: 3.3 parent: 81249:6e4fc5e2acf8 parent: 81253:c4a4863b85b2 user: Nadeem Vawda date: Wed Jan 02 23:05:56 2013 +0100 summary: Issue #16828: Fix error incorrectly raised by bz2.compress(''). Initial patch by Martin Packman. files: Lib/test/test_bz2.py | 15 ++++++++++++++ Misc/ACKS | 1 + Misc/NEWS | 3 ++ Modules/_bz2module.c | 34 ++++++++++++++++--------------- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -47,6 +47,7 @@ ] TEXT = b''.join(TEXT_LINES) DATA = b'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' + EMPTY_DATA = b'BZh9\x17rE8P\x90\x00\x00\x00\x00' def setUp(self): self.filename = TESTFN @@ -584,6 +585,12 @@ data += bz2c.flush() self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + bz2c = BZ2Compressor() + data = bz2c.compress(b'') + data += bz2c.flush() + self.assertEqual(data, self.EMPTY_DATA) + def testCompressChunks10(self): bz2c = BZ2Compressor() n = 0 @@ -671,6 +678,10 @@ data = bz2.compress(self.TEXT) self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + text = bz2.compress(b'') + self.assertEqual(text, self.EMPTY_DATA) + def testDecompress(self): text = bz2.decompress(self.DATA) self.assertEqual(text, self.TEXT) @@ -679,6 +690,10 @@ text = bz2.decompress(b"") self.assertEqual(text, b"") + def testDecompressToEmptyString(self): + text = bz2.decompress(self.EMPTY_DATA) + self.assertEqual(text, b'') + def testDecompressIncomplete(self): self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -884,6 +884,7 @@ R. M. Oudkerk Russel Owen Joonas Paalasmaa +Martin Packman Shriphani Palakodety Ondrej Palkovsky Mike Pall diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -123,6 +123,9 @@ Library ------- +- Issue #16828: Fix error incorrectly raised by bz2.compress(''). Initial patch + by Martin Packman. + - Issue #16541: tk_setPalette() now works with keyword arguments. - Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -145,34 +145,24 @@ result = PyBytes_FromStringAndSize(NULL, SMALLCHUNK); if (result == NULL) return NULL; + c->bzs.next_in = data; - /* On a 64-bit system, len might not fit in avail_in (an unsigned int). - Do compression in chunks of no more than UINT_MAX bytes each. */ - c->bzs.avail_in = MIN(len, UINT_MAX); - len -= c->bzs.avail_in; + c->bzs.avail_in = 0; c->bzs.next_out = PyBytes_AS_STRING(result); c->bzs.avail_out = PyBytes_GET_SIZE(result); for (;;) { char *this_out; int bzerror; - Py_BEGIN_ALLOW_THREADS - this_out = c->bzs.next_out; - bzerror = BZ2_bzCompress(&c->bzs, action); - data_size += c->bzs.next_out - this_out; - Py_END_ALLOW_THREADS - if (catch_bz2_error(bzerror)) - goto error; - + /* On a 64-bit system, len might not fit in avail_in (an unsigned int). + Do compression in chunks of no more than UINT_MAX bytes each. */ if (c->bzs.avail_in == 0 && len > 0) { c->bzs.avail_in = MIN(len, UINT_MAX); len -= c->bzs.avail_in; } - /* In regular compression mode, stop when input data is exhausted. - In flushing mode, stop when all buffered data has been flushed. */ - if ((action == BZ_RUN && c->bzs.avail_in == 0) || - (action == BZ_FINISH && bzerror == BZ_STREAM_END)) + /* In regular compression mode, stop when input data is exhausted. */ + if (action == BZ_RUN && c->bzs.avail_in == 0) break; if (c->bzs.avail_out == 0) { @@ -185,6 +175,18 @@ } c->bzs.avail_out = MIN(buffer_left, UINT_MAX); } + + Py_BEGIN_ALLOW_THREADS + this_out = c->bzs.next_out; + bzerror = BZ2_bzCompress(&c->bzs, action); + data_size += c->bzs.next_out - this_out; + Py_END_ALLOW_THREADS + if (catch_bz2_error(bzerror)) + goto error; + + /* In flushing mode, stop when all buffered data has been flushed. */ + if (action == BZ_FINISH && bzerror == BZ_STREAM_END) + break; } if (data_size != PyBytes_GET_SIZE(result)) if (_PyBytes_Resize(&result, data_size) < 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 23:14:37 2013 From: python-checkins at python.org (nadeem.vawda) Date: Wed, 2 Jan 2013 23:14:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogQ29ycmVjdGlvbjog?= =?utf-8?q?issue_=2316828_also_affects_BZ2Compressor=2Ecompress=28=29=2E?= Message-ID: <3Yc64Y0HCzzS0b@mail.python.org> http://hg.python.org/cpython/rev/93654d0d9b1e changeset: 81255:93654d0d9b1e branch: 3.3 user: Nadeem Vawda date: Wed Jan 02 23:10:47 2013 +0100 summary: Correction: issue #16828 also affects BZ2Compressor.compress(). files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -123,8 +123,8 @@ Library ------- -- Issue #16828: Fix error incorrectly raised by bz2.compress(''). Initial patch - by Martin Packman. +- Issue #16828: Fix error incorrectly raised by bz2.compress(b'') and + bz2.BZ2Compressor.compress(b''). Initial patch by Martin Packman. - Issue #16541: tk_setPalette() now works with keyword arguments. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 2 23:14:38 2013 From: python-checkins at python.org (nadeem.vawda) Date: Wed, 2 Jan 2013 23:14:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316828=3A_Fix_error_incorrectly_raised_by_bz2=2E?= =?utf-8?b?Y29tcHJlc3MoYicnKSBhbmQ=?= Message-ID: <3Yc64Z4bNLzS7c@mail.python.org> http://hg.python.org/cpython/rev/44cfd43b09f5 changeset: 81256:44cfd43b09f5 parent: 81251:002bf9857278 parent: 81255:93654d0d9b1e user: Nadeem Vawda date: Wed Jan 02 23:13:53 2013 +0100 summary: Issue #16828: Fix error incorrectly raised by bz2.compress(b'') and bz2.BZ2Compressor.compress(b''). Initial patch by Martin Packman. files: Lib/test/test_bz2.py | 15 ++++++++++++++ Misc/ACKS | 1 + Misc/NEWS | 3 ++ Modules/_bz2module.c | 34 ++++++++++++++++--------------- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -47,6 +47,7 @@ ] TEXT = b''.join(TEXT_LINES) DATA = b'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' + EMPTY_DATA = b'BZh9\x17rE8P\x90\x00\x00\x00\x00' def setUp(self): self.filename = support.TESTFN @@ -577,6 +578,12 @@ data += bz2c.flush() self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + bz2c = BZ2Compressor() + data = bz2c.compress(b'') + data += bz2c.flush() + self.assertEqual(data, self.EMPTY_DATA) + def testCompressChunks10(self): bz2c = BZ2Compressor() n = 0 @@ -664,6 +671,10 @@ data = bz2.compress(self.TEXT) self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + text = bz2.compress(b'') + self.assertEqual(text, self.EMPTY_DATA) + def testDecompress(self): text = bz2.decompress(self.DATA) self.assertEqual(text, self.TEXT) @@ -672,6 +683,10 @@ text = bz2.decompress(b"") self.assertEqual(text, b"") + def testDecompressToEmptyString(self): + text = bz2.decompress(self.EMPTY_DATA) + self.assertEqual(text, b'') + def testDecompressIncomplete(self): self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -890,6 +890,7 @@ R. M. Oudkerk Russel Owen Joonas Paalasmaa +Martin Packman Shriphani Palakodety Ondrej Palkovsky Mike Pall diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -199,6 +199,9 @@ Library ------- +- Issue #16828: Fix error incorrectly raised by bz2.compress(b'') and + bz2.BZ2Compressor.compress(b''). Initial patch by Martin Packman. + - Issue #16833: In http.client.HTTPConnection, do not concatenate the request headers and body when the payload exceeds 16 KB, since it can consume more memory for no benefit. Patch by Benno Leslie. diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -145,34 +145,24 @@ result = PyBytes_FromStringAndSize(NULL, SMALLCHUNK); if (result == NULL) return NULL; + c->bzs.next_in = data; - /* On a 64-bit system, len might not fit in avail_in (an unsigned int). - Do compression in chunks of no more than UINT_MAX bytes each. */ - c->bzs.avail_in = MIN(len, UINT_MAX); - len -= c->bzs.avail_in; + c->bzs.avail_in = 0; c->bzs.next_out = PyBytes_AS_STRING(result); c->bzs.avail_out = PyBytes_GET_SIZE(result); for (;;) { char *this_out; int bzerror; - Py_BEGIN_ALLOW_THREADS - this_out = c->bzs.next_out; - bzerror = BZ2_bzCompress(&c->bzs, action); - data_size += c->bzs.next_out - this_out; - Py_END_ALLOW_THREADS - if (catch_bz2_error(bzerror)) - goto error; - + /* On a 64-bit system, len might not fit in avail_in (an unsigned int). + Do compression in chunks of no more than UINT_MAX bytes each. */ if (c->bzs.avail_in == 0 && len > 0) { c->bzs.avail_in = MIN(len, UINT_MAX); len -= c->bzs.avail_in; } - /* In regular compression mode, stop when input data is exhausted. - In flushing mode, stop when all buffered data has been flushed. */ - if ((action == BZ_RUN && c->bzs.avail_in == 0) || - (action == BZ_FINISH && bzerror == BZ_STREAM_END)) + /* In regular compression mode, stop when input data is exhausted. */ + if (action == BZ_RUN && c->bzs.avail_in == 0) break; if (c->bzs.avail_out == 0) { @@ -185,6 +175,18 @@ } c->bzs.avail_out = MIN(buffer_left, UINT_MAX); } + + Py_BEGIN_ALLOW_THREADS + this_out = c->bzs.next_out; + bzerror = BZ2_bzCompress(&c->bzs, action); + data_size += c->bzs.next_out - this_out; + Py_END_ALLOW_THREADS + if (catch_bz2_error(bzerror)) + goto error; + + /* In flushing mode, stop when all buffered data has been flushed. */ + if (action == BZ_FINISH && bzerror == BZ_STREAM_END) + break; } if (data_size != PyBytes_GET_SIZE(result)) if (_PyBytes_Resize(&result, data_size) < 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 01:24:05 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 01:24:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2NDU1?= =?utf-8?q?=3A_On_FreeBSD_and_Solaris=2C_if_the_locale_is_C=2C_the?= Message-ID: <3Yc8xx1zfNzS2f@mail.python.org> http://hg.python.org/cpython/rev/c256764e2b3f changeset: 81257:c256764e2b3f branch: 3.2 parent: 81253:c4a4863b85b2 user: Victor Stinner date: Thu Jan 03 01:08:58 2013 +0100 summary: Issue #16455: On FreeBSD and Solaris, if the locale is C, the ASCII/surrogateescape codec is now used, instead of the locale encoding, to decode the command line arguments. This change fixes inconsistencies with os.fsencode() and os.fsdecode() because these operating systems announces an ASCII locale encoding, whereas the ISO-8859-1 encoding is used in practice. files: Misc/NEWS | 6 + Objects/unicodeobject.c | 8 +- Python/fileutils.c | 245 +++++++++++++++++++++++++-- 3 files changed, 232 insertions(+), 27 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,12 @@ Core and Builtins ----------------- +- Issue #16455: On FreeBSD and Solaris, if the locale is C, the + ASCII/surrogateescape codec is now used, instead of the locale encoding, to + decode the command line arguments. This change fixes inconsistencies with + os.fsencode() and os.fsdecode() because these operating systems announces an + ASCII locale encoding, whereas the ISO-8859-1 encoding is used in practice. + - Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1434,8 +1434,8 @@ /* Convert encoding to lower case and replace '_' with '-' in order to catch e.g. UTF_8. Return 0 on error (encoding is longer than lower_len-1), 1 on success. */ -static int -normalize_encoding(const char *encoding, +int +_Py_normalize_encoding(const char *encoding, char *lower, size_t lower_len) { @@ -1477,7 +1477,7 @@ encoding = PyUnicode_GetDefaultEncoding(); /* Shortcuts for common default encodings */ - if (normalize_encoding(encoding, lower, sizeof(lower))) { + if (_Py_normalize_encoding(encoding, lower, sizeof(lower))) { if (strcmp(lower, "utf-8") == 0) return PyUnicode_DecodeUTF8(s, size, errors); else if ((strcmp(lower, "latin-1") == 0) || @@ -1695,7 +1695,7 @@ encoding = PyUnicode_GetDefaultEncoding(); /* Shortcuts for common default encodings */ - if (normalize_encoding(encoding, lower, sizeof(lower))) { + if (_Py_normalize_encoding(encoding, lower, sizeof(lower))) { if (strcmp(lower, "utf-8") == 0) return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode), PyUnicode_GET_SIZE(unicode), diff --git a/Python/fileutils.c b/Python/fileutils.c --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -3,11 +3,191 @@ # include #endif +#ifdef HAVE_LANGINFO_H +#include +#include +#endif + #ifdef __APPLE__ extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size); #endif -#ifdef HAVE_STAT +#if !defined(__APPLE__) && !defined(MS_WINDOWS) +extern int _Py_normalize_encoding(const char *, char *, size_t); + +/* Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale. + On these operating systems, nl_langinfo(CODESET) announces an alias of the + ASCII encoding, whereas mbstowcs() and wcstombs() functions use the + ISO-8859-1 encoding. The problem is that os.fsencode() and os.fsdecode() use + locale.getpreferredencoding() codec. For example, if command line arguments + are decoded by mbstowcs() and encoded back by os.fsencode(), we get a + UnicodeEncodeError instead of retrieving the original byte string. + + The workaround is enabled if setlocale(LC_CTYPE, NULL) returns "C", + nl_langinfo(CODESET) announces "ascii" (or an alias to ASCII), and at least + one byte in range 0x80-0xff can be decoded from the locale encoding. The + workaround is also enabled on error, for example if getting the locale + failed. + + Values of locale_is_ascii: + + 1: the workaround is used: _Py_wchar2char() uses + encode_ascii_surrogateescape() and _Py_char2wchar() uses + decode_ascii_surrogateescape() + 0: the workaround is not used: _Py_wchar2char() uses wcstombs() and + _Py_char2wchar() uses mbstowcs() + -1: unknown, need to call check_force_ascii() to get the value +*/ +static int force_ascii = -1; + +static int +check_force_ascii(void) +{ + char *loc; +#if defined(HAVE_LANGINFO_H) && defined(CODESET) + char *codeset, **alias; + char encoding[100]; + int is_ascii; + unsigned int i; + char* ascii_aliases[] = { + "ascii", + "646", + "ansi-x3.4-1968", + "ansi-x3-4-1968", + "ansi-x3.4-1986", + "cp367", + "csascii", + "ibm367", + "iso646-us", + "iso-646.irv-1991", + "iso-ir-6", + "us", + "us-ascii", + NULL + }; +#endif + + loc = setlocale(LC_CTYPE, NULL); + if (loc == NULL) + goto error; + if (strcmp(loc, "C") != 0) { + /* the LC_CTYPE locale is different than C */ + return 0; + } + +#if defined(HAVE_LANGINFO_H) && defined(CODESET) + codeset = nl_langinfo(CODESET); + if (!codeset || codeset[0] == '\0') { + /* CODESET is not set or empty */ + goto error; + } + if (!_Py_normalize_encoding(codeset, encoding, sizeof(encoding))) + goto error; + + is_ascii = 0; + for (alias=ascii_aliases; *alias != NULL; alias++) { + if (strcmp(encoding, *alias) == 0) { + is_ascii = 1; + break; + } + } + if (!is_ascii) { + /* nl_langinfo(CODESET) is not "ascii" or an alias of ASCII */ + return 0; + } + + for (i=0x80; i<0xff; i++) { + unsigned char ch; + wchar_t wch; + size_t res; + + ch = (unsigned char)i; + res = mbstowcs(&wch, (char*)&ch, 1); + if (res != (size_t)-1) { + /* decoding a non-ASCII character from the locale encoding succeed: + the locale encoding is not ASCII, force ASCII */ + return 1; + } + } + /* None of the bytes in the range 0x80-0xff can be decoded from the locale + encoding: the locale encoding is really ASCII */ + return 0; +#else + /* nl_langinfo(CODESET) is not available: always force ASCII */ + return 1; +#endif + +error: + /* if an error occured, force the ASCII encoding */ + return 1; +} + +static char* +encode_ascii_surrogateescape(const wchar_t *text, size_t *error_pos) +{ + char *result = NULL, *out; + size_t len, i; + wchar_t ch; + + if (error_pos != NULL) + *error_pos = (size_t)-1; + + len = wcslen(text); + + result = PyMem_Malloc(len + 1); /* +1 for NUL byte */ + if (result == NULL) + return NULL; + + out = result; + for (i=0; i 128. This will still roundtrip correctly in the locale's charset, which must be an ASCII superset. */ - res = PyMem_Malloc((strlen(arg)+1)*sizeof(wchar_t)); - if (!res) goto oom; - in = (unsigned char*)arg; - out = res; - while(*in) - if(*in < 128) - *out++ = *in++; - else - *out++ = 0xdc00 + *in++; - *out = 0; + res = decode_ascii_surrogateescape(arg, size); + if (res == NULL) + goto oom; #endif /* HAVE_MBRTOWC */ - if (size != NULL) - *size = out - res; return res; oom: fprintf(stderr, "out of memory\n"); @@ -198,6 +386,14 @@ size_t i, size, converted; wchar_t c, buf[2]; +#ifndef MS_WINDOWS + if (force_ascii == -1) + force_ascii = check_force_ascii(); + + if (force_ascii) + return encode_ascii_surrogateescape(text, error_pos); +#endif + /* The function works in two steps: 1. compute the length of the output buffer in bytes (size) 2. outputs the bytes */ @@ -238,7 +434,7 @@ } } if (result != NULL) { - *bytes = 0; + *bytes = '\0'; break; } @@ -282,6 +478,8 @@ } #endif +#ifdef HAVE_STAT + /* Call _wstat() on Windows, or encode the path to the filesystem encoding and call stat() otherwise. Only fill st_mode attribute on Windows. @@ -310,6 +508,8 @@ #endif } +#endif + /* Open a file. Use _wfopen() on Windows, encode the path to the locale encoding and use fopen() otherwise. */ @@ -478,4 +678,3 @@ #endif } -#endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 01:24:06 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 01:24:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=28Merge_3=2E2=29_Issue_=2316455=3A_On_FreeBSD_and_Solaris=2C_?= =?utf-8?q?if_the_locale_is_C=2C_the?= Message-ID: <3Yc8xy6BZHzS2w@mail.python.org> http://hg.python.org/cpython/rev/5bb289e4fb35 changeset: 81258:5bb289e4fb35 branch: 3.3 parent: 81255:93654d0d9b1e parent: 81257:c256764e2b3f user: Victor Stinner date: Thu Jan 03 01:21:07 2013 +0100 summary: (Merge 3.2) Issue #16455: On FreeBSD and Solaris, if the locale is C, the ASCII/surrogateescape codec is now used, instead of the locale encoding, to decode the command line arguments. This change fixes inconsistencies with os.fsencode() and os.fsdecode() because these operating systems announces an ASCII locale encoding, whereas the ISO-8859-1 encoding is used in practice. files: Misc/NEWS | 6 + Objects/unicodeobject.c | 8 +- Python/fileutils.c | 240 +++++++++++++++++++++++++-- 3 files changed, 227 insertions(+), 27 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,12 @@ Core and Builtins ----------------- +- Issue #16455: On FreeBSD and Solaris, if the locale is C, the + ASCII/surrogateescape codec is now used, instead of the locale encoding, to + decode the command line arguments. This change fixes inconsistencies with + os.fsencode() and os.fsdecode() because these operating systems announces an + ASCII locale encoding, whereas the ISO-8859-1 encoding is used in practice. + - Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3045,8 +3045,8 @@ /* Convert encoding to lower case and replace '_' with '-' in order to catch e.g. UTF_8. Return 0 on error (encoding is longer than lower_len-1), 1 on success. */ -static int -normalize_encoding(const char *encoding, +int +_Py_normalize_encoding(const char *encoding, char *lower, size_t lower_len) { @@ -3090,7 +3090,7 @@ char lower[11]; /* Enough for any encoding shortcut */ /* Shortcuts for common default encodings */ - if (normalize_encoding(encoding, lower, sizeof(lower))) { + if (_Py_normalize_encoding(encoding, lower, sizeof(lower))) { if ((strcmp(lower, "utf-8") == 0) || (strcmp(lower, "utf8") == 0)) return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL); @@ -3455,7 +3455,7 @@ } /* Shortcuts for common default encodings */ - if (normalize_encoding(encoding, lower, sizeof(lower))) { + if (_Py_normalize_encoding(encoding, lower, sizeof(lower))) { if ((strcmp(lower, "utf-8") == 0) || (strcmp(lower, "utf8") == 0)) { diff --git a/Python/fileutils.c b/Python/fileutils.c --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -5,6 +5,7 @@ #endif #ifdef HAVE_LANGINFO_H +#include #include #endif @@ -42,7 +43,182 @@ Py_RETURN_NONE; } -#ifdef HAVE_STAT +#if !defined(__APPLE__) && !defined(MS_WINDOWS) +extern int _Py_normalize_encoding(const char *, char *, size_t); + +/* Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale. + On these operating systems, nl_langinfo(CODESET) announces an alias of the + ASCII encoding, whereas mbstowcs() and wcstombs() functions use the + ISO-8859-1 encoding. The problem is that os.fsencode() and os.fsdecode() use + locale.getpreferredencoding() codec. For example, if command line arguments + are decoded by mbstowcs() and encoded back by os.fsencode(), we get a + UnicodeEncodeError instead of retrieving the original byte string. + + The workaround is enabled if setlocale(LC_CTYPE, NULL) returns "C", + nl_langinfo(CODESET) announces "ascii" (or an alias to ASCII), and at least + one byte in range 0x80-0xff can be decoded from the locale encoding. The + workaround is also enabled on error, for example if getting the locale + failed. + + Values of locale_is_ascii: + + 1: the workaround is used: _Py_wchar2char() uses + encode_ascii_surrogateescape() and _Py_char2wchar() uses + decode_ascii_surrogateescape() + 0: the workaround is not used: _Py_wchar2char() uses wcstombs() and + _Py_char2wchar() uses mbstowcs() + -1: unknown, need to call check_force_ascii() to get the value +*/ +static int force_ascii = -1; + +static int +check_force_ascii(void) +{ + char *loc; +#if defined(HAVE_LANGINFO_H) && defined(CODESET) + char *codeset, **alias; + char encoding[100]; + int is_ascii; + unsigned int i; + char* ascii_aliases[] = { + "ascii", + "646", + "ansi-x3.4-1968", + "ansi-x3-4-1968", + "ansi-x3.4-1986", + "cp367", + "csascii", + "ibm367", + "iso646-us", + "iso-646.irv-1991", + "iso-ir-6", + "us", + "us-ascii", + NULL + }; +#endif + + loc = setlocale(LC_CTYPE, NULL); + if (loc == NULL) + goto error; + if (strcmp(loc, "C") != 0) { + /* the LC_CTYPE locale is different than C */ + return 0; + } + +#if defined(HAVE_LANGINFO_H) && defined(CODESET) + codeset = nl_langinfo(CODESET); + if (!codeset || codeset[0] == '\0') { + /* CODESET is not set or empty */ + goto error; + } + if (!_Py_normalize_encoding(codeset, encoding, sizeof(encoding))) + goto error; + + is_ascii = 0; + for (alias=ascii_aliases; *alias != NULL; alias++) { + if (strcmp(encoding, *alias) == 0) { + is_ascii = 1; + break; + } + } + if (!is_ascii) { + /* nl_langinfo(CODESET) is not "ascii" or an alias of ASCII */ + return 0; + } + + for (i=0x80; i<0xff; i++) { + unsigned char ch; + wchar_t wch; + size_t res; + + ch = (unsigned char)i; + res = mbstowcs(&wch, (char*)&ch, 1); + if (res != (size_t)-1) { + /* decoding a non-ASCII character from the locale encoding succeed: + the locale encoding is not ASCII, force ASCII */ + return 1; + } + } + /* None of the bytes in the range 0x80-0xff can be decoded from the locale + encoding: the locale encoding is really ASCII */ + return 0; +#else + /* nl_langinfo(CODESET) is not available: always force ASCII */ + return 1; +#endif + +error: + /* if an error occured, force the ASCII encoding */ + return 1; +} + +static char* +encode_ascii_surrogateescape(const wchar_t *text, size_t *error_pos) +{ + char *result = NULL, *out; + size_t len, i; + wchar_t ch; + + if (error_pos != NULL) + *error_pos = (size_t)-1; + + len = wcslen(text); + + result = PyMem_Malloc(len + 1); /* +1 for NUL byte */ + if (result == NULL) + return NULL; + + out = result; + for (i=0; i 128. This will still roundtrip correctly in the locale's charset, which must be an ASCII superset. */ - res = PyMem_Malloc((strlen(arg)+1)*sizeof(wchar_t)); - if (!res) + res = decode_ascii_surrogateescape(arg, size); + if (res == NULL) goto oom; - in = (unsigned char*)arg; - out = res; - while(*in) - if(*in < 128) - *out++ = *in++; - else - *out++ = 0xdc00 + *in++; - *out = 0; #endif /* HAVE_MBRTOWC */ - if (size != NULL) - *size = out - res; return res; oom: if (size != NULL) @@ -236,6 +419,14 @@ size_t i, size, converted; wchar_t c, buf[2]; +#ifndef MS_WINDOWS + if (force_ascii == -1) + force_ascii = check_force_ascii(); + + if (force_ascii) + return encode_ascii_surrogateescape(text, error_pos); +#endif + /* The function works in two steps: 1. compute the length of the output buffer in bytes (size) 2. outputs the bytes */ @@ -276,7 +467,7 @@ } } if (result != NULL) { - *bytes = 0; + *bytes = '\0'; break; } @@ -320,6 +511,8 @@ } #endif +#ifdef HAVE_STAT + /* Call _wstat() on Windows, or encode the path to the filesystem encoding and call stat() otherwise. Only fill st_mode attribute on Windows. @@ -352,6 +545,8 @@ #endif } +#endif + /* Open a file. Use _wfopen() on Windows, encode the path to the locale encoding and use fopen() otherwise. */ @@ -533,4 +728,3 @@ #endif } -#endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 01:24:08 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 01:24:08 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge_3=2E3_=28fix_already_applied_to_default=2C_it?= =?utf-8?q?_was_a_backport=29?= Message-ID: <3Yc8y01pNXzS2w@mail.python.org> http://hg.python.org/cpython/rev/4bf19545c016 changeset: 81259:4bf19545c016 parent: 81256:44cfd43b09f5 parent: 81258:5bb289e4fb35 user: Victor Stinner date: Thu Jan 03 01:21:44 2013 +0100 summary: Null merge 3.3 (fix already applied to default, it was a backport) files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 01:59:36 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 01:59:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2MjE4?= =?utf-8?q?=2C_=2316414=2C_=2316444=3A_Backport_FS=5FNONASCII=2C_TESTFN=5F?= =?utf-8?q?UNDECODABLE=2C?= Message-ID: <3Yc9kw0SVQzS0b@mail.python.org> http://hg.python.org/cpython/rev/41658a4fb3cc changeset: 81260:41658a4fb3cc branch: 3.2 parent: 81257:c256764e2b3f user: Victor Stinner date: Thu Jan 03 01:50:30 2013 +0100 summary: Issue #16218, #16414, #16444: Backport FS_NONASCII, TESTFN_UNDECODABLE, TESTFN_NONASCII of test.support from Python 3.4. Backport tests on non-ASCII paths. files: Lib/test/support.py | 78 ++++++++++++++++++++ Lib/test/test_cmd_line.py | 6 +- Lib/test/test_cmd_line_script.py | 24 ++++++ Lib/test/test_genericpath.py | 17 +++- Lib/test/test_os.py | 4 + 5 files changed, 122 insertions(+), 7 deletions(-) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -523,6 +523,49 @@ # module name. TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid()) +# FS_NONASCII: non-ASCII character encodable by os.fsencode(), +# or None if there is no such character. +FS_NONASCII = None +for character in ( + # First try printable and common characters to have a readable filename. + # For each character, the encoding list are just example of encodings able + # to encode the character (the list is not exhaustive). + + # U+00E6 (Latin Small Letter Ae): cp1252, iso-8859-1 + '\u00E6', + # U+0130 (Latin Capital Letter I With Dot Above): cp1254, iso8859_3 + '\u0130', + # U+0141 (Latin Capital Letter L With Stroke): cp1250, cp1257 + '\u0141', + # U+03C6 (Greek Small Letter Phi): cp1253 + '\u03C6', + # U+041A (Cyrillic Capital Letter Ka): cp1251 + '\u041A', + # U+05D0 (Hebrew Letter Alef): Encodable to cp424 + '\u05D0', + # U+060C (Arabic Comma): cp864, cp1006, iso8859_6, mac_arabic + '\u060C', + # U+062A (Arabic Letter Teh): cp720 + '\u062A', + # U+0E01 (Thai Character Ko Kai): cp874 + '\u0E01', + + # Then try more "special" characters. "special" because they may be + # interpreted or displayed differently depending on the exact locale + # encoding and the font. + + # U+00A0 (No-Break Space) + '\u00A0', + # U+20AC (Euro Sign) + '\u20AC', +): + try: + os.fsdecode(os.fsencode(character)) + except UnicodeError: + pass + else: + FS_NONASCII = character + break # TESTFN_UNICODE is a non-ascii filename TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f" @@ -567,6 +610,41 @@ # the byte 0xff. Skip some unicode filename tests. pass +# TESTFN_UNDECODABLE is a filename (bytes type) that should *not* be able to be +# decoded from the filesystem encoding (in strict mode). It can be None if we +# cannot generate such filename (ex: the latin1 encoding can decode any byte +# sequence). On UNIX, TESTFN_UNDECODABLE can be decoded by os.fsdecode() thanks +# to the surrogateescape error handler (PEP 383), but not from the filesystem +# encoding in strict mode. +TESTFN_UNDECODABLE = None +for name in ( + # b'\xff' is not decodable by os.fsdecode() with code page 932. Windows + # accepts it to create a file or a directory, or don't accept to enter to + # such directory (when the bytes name is used). So test b'\xe7' first: it is + # not decodable from cp932. + b'\xe7w\xf0', + # undecodable from ASCII, UTF-8 + b'\xff', + # undecodable from iso8859-3, iso8859-6, iso8859-7, cp424, iso8859-8, cp856 + # and cp857 + b'\xae\xd5' + # undecodable from UTF-8 (UNIX and Mac OS X) + b'\xed\xb2\x80', b'\xed\xb4\x80', + # undecodable from shift_jis, cp869, cp874, cp932, cp1250, cp1251, cp1252, + # cp1253, cp1254, cp1255, cp1257, cp1258 + b'\x81\x98', +): + try: + name.decode(TESTFN_ENCODING) + except UnicodeDecodeError: + TESTFN_UNDECODABLE = os.fsencode(TESTFN) + name + break + +if FS_NONASCII: + TESTFN_NONASCII = TESTFN + '-' + FS_NONASCII +else: + TESTFN_NONASCII = None + # Save the initial cwd SAVEDCWD = os.getcwd() diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -100,11 +100,11 @@ # All good if execution is successful assert_python_ok('-c', 'pass') - @unittest.skipIf(sys.getfilesystemencoding() == 'ascii', - 'need a filesystem encoding different than ASCII') + @unittest.skipUnless(test.support.FS_NONASCII, 'need support.FS_NONASCII') def test_non_ascii(self): # Test handling of non-ascii data - command = "assert(ord('\xe9') == 0xe9)" + command = ("assert(ord(%r) == %s)" + % (test.support.FS_NONASCII, ord(test.support.FS_NONASCII))) assert_python_ok('-c', command) # On Windows, pass bytes to subprocess doesn't test how Python decodes the diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -294,6 +294,30 @@ print(out) self.assertEqual(rc, 1) + def test_non_ascii(self): + # Mac OS X denies the creation of a file with an invalid UTF-8 name. + # Windows allows to create a name with an arbitrary bytes name, but + # Python cannot a undecodable bytes argument to a subprocess. + if (support.TESTFN_UNDECODABLE + and sys.platform not in ('win32', 'darwin')): + name = os.fsdecode(support.TESTFN_UNDECODABLE) + elif support.TESTFN_NONASCII: + name = support.TESTFN_NONASCII + else: + self.skipTest("need support.TESTFN_NONASCII") + + # Issue #16218 + source = 'print(ascii(__file__))\n' + script_name = _make_test_script(os.curdir, name, source) + self.addCleanup(support.unlink, script_name) + rc, stdout, stderr = assert_python_ok(script_name) + self.assertEqual( + ascii(script_name), + stdout.rstrip().decode('ascii'), + 'stdout=%r stderr=%r' % (stdout, stderr)) + self.assertEqual(0, rc) + + def test_main(): support.run_unittest(CmdLineTest) support.reap_children() diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -292,11 +292,20 @@ for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'): self.assertIsInstance(abspath(path), str) - @unittest.skipIf(sys.platform == 'darwin', - "Mac OS X denies the creation of a directory with an invalid utf8 name") def test_nonascii_abspath(self): - # Test non-ASCII, non-UTF8 bytes in the path. - with support.temp_cwd(b'\xe7w\xf0'): + if (support.TESTFN_UNDECODABLE + # Mac OS X denies the creation of a directory with an invalid + # UTF-8 name. Windows allows to create a directory with an + # arbitrary bytes name, but fails to enter this directory + # (when the bytes name is used). + and sys.platform not in ('win32', 'darwin')): + name = support.TESTFN_UNDECODABLE + elif support.TESTFN_NONASCII: + name = support.TESTFN_NONASCII + else: + self.skipTest("need support.TESTFN_NONASCII") + + with support.temp_cwd(name): self.test_abspath() diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1013,6 +1013,8 @@ def setUp(self): if support.TESTFN_UNENCODABLE: self.dir = support.TESTFN_UNENCODABLE + elif support.TESTFN_NONASCII: + self.dir = support.TESTFN_NONASCII else: self.dir = support.TESTFN self.bdir = os.fsencode(self.dir) @@ -1027,6 +1029,8 @@ add_filename(support.TESTFN_UNICODE) if support.TESTFN_UNENCODABLE: add_filename(support.TESTFN_UNENCODABLE) + if support.TESTFN_NONASCII: + add_filename(support.TESTFN_NONASCII) if not bytesfn: self.skipTest("couldn't create any non-ascii filename") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 01:59:37 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 01:59:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?b?IChNZXJnZSAzLjIpIElzc3VlICMxNjIxOCwgIzE2NDE0LCAjMTY0NDQ6IEJh?= =?utf-8?q?ckport_FS=5FNONASCII=2C?= Message-ID: <3Yc9kx3HCnzRrF@mail.python.org> http://hg.python.org/cpython/rev/4d40c1ce8566 changeset: 81261:4d40c1ce8566 branch: 3.3 parent: 81258:5bb289e4fb35 parent: 81260:41658a4fb3cc user: Victor Stinner date: Thu Jan 03 01:56:38 2013 +0100 summary: (Merge 3.2) Issue #16218, #16414, #16444: Backport FS_NONASCII, TESTFN_UNDECODABLE, TESTFN_NONASCII of test.support from Python 3.4. Backport tests on non-ASCII paths. files: Lib/test/support.py | 3 ++ Lib/test/test_cmd_line_script.py | 9 +++---- Lib/test/test_genericpath.py | 21 ++++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -710,6 +710,9 @@ b'\xae\xd5' # undecodable from UTF-8 (UNIX and Mac OS X) b'\xed\xb2\x80', b'\xed\xb4\x80', + # undecodable from shift_jis, cp869, cp874, cp932, cp1250, cp1251, cp1252, + # cp1253, cp1254, cp1255, cp1257, cp1258 + b'\x81\x98', ): try: name.decode(TESTFN_ENCODING) diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -367,11 +367,10 @@ # Mac OS X denies the creation of a file with an invalid UTF-8 name. # Windows allows to create a name with an arbitrary bytes name, but # Python cannot a undecodable bytes argument to a subprocess. - #if (support.TESTFN_UNDECODABLE - #and sys.platform not in ('win32', 'darwin')): - # name = os.fsdecode(support.TESTFN_UNDECODABLE) - #elif support.TESTFN_NONASCII: - if support.TESTFN_NONASCII: + if (support.TESTFN_UNDECODABLE + and sys.platform not in ('win32', 'darwin')): + name = os.fsdecode(support.TESTFN_UNDECODABLE) + elif support.TESTFN_NONASCII: name = support.TESTFN_NONASCII else: self.skipTest("need support.TESTFN_NONASCII") diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -308,17 +308,18 @@ for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'): self.assertIsInstance(abspath(path), str) - @unittest.skipIf(sys.platform == 'darwin', - "Mac OS X denies the creation of a directory with an invalid utf8 name") def test_nonascii_abspath(self): - name = b'\xe7w\xf0' - if sys.platform == 'win32': - try: - os.fsdecode(name) - except UnicodeDecodeError: - self.skipTest("the filename %a is not decodable " - "from the ANSI code page %s" - % (name, sys.getfilesystemencoding())) + if (support.TESTFN_UNDECODABLE + # Mac OS X denies the creation of a directory with an invalid + # UTF-8 name. Windows allows to create a directory with an + # arbitrary bytes name, but fails to enter this directory + # (when the bytes name is used). + and sys.platform not in ('win32', 'darwin')): + name = support.TESTFN_UNDECODABLE + elif support.TESTFN_NONASCII: + name = support.TESTFN_NONASCII + else: + self.skipTest("need support.TESTFN_NONASCII") # Test non-ASCII, non-UTF8 bytes in the path. with warnings.catch_warnings(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 01:59:38 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 01:59:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge_3=2E3?= Message-ID: <3Yc9ky5jmBzS1r@mail.python.org> http://hg.python.org/cpython/rev/5a2560cb4a8d changeset: 81262:5a2560cb4a8d parent: 81259:4bf19545c016 parent: 81261:4d40c1ce8566 user: Victor Stinner date: Thu Jan 03 01:56:51 2013 +0100 summary: Null merge 3.3 files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 02:55:35 2013 From: python-checkins at python.org (giampaolo.rodola) Date: Thu, 3 Jan 2013 02:55:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogaXNzdWUgMTA1Mjc6?= =?utf-8?q?_fix_missing_import?= Message-ID: <3YcBzW5rzYzS1Q@mail.python.org> http://hg.python.org/cpython/rev/7cf4ea64f603 changeset: 81263:7cf4ea64f603 branch: 2.7 parent: 81252:06a08144af1b user: Giampaolo Rodola' date: Thu Jan 03 02:53:28 2013 +0100 summary: issue 10527: fix missing import files: Doc/library/asyncore.rst | 5 +---- Lib/multiprocessing/connection.py | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/library/asyncore.rst b/Doc/library/asyncore.rst --- a/Doc/library/asyncore.rst +++ b/Doc/library/asyncore.rst @@ -318,13 +318,10 @@ def handle_accept(self): pair = self.accept() - if pair is None: - pass - else: + if pair is not None: sock, addr = pair print 'Incoming connection from %s' % repr(addr) handler = EchoHandler(sock) server = EchoServer('localhost', 8080) asyncore.loop() - diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -41,6 +41,7 @@ import time import tempfile import itertools +import select import _multiprocessing from multiprocessing import current_process, AuthenticationError -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 02:55:37 2013 From: python-checkins at python.org (giampaolo.rodola) Date: Thu, 3 Jan 2013 02:55:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogaXNzdWUgMTA1Mjc6?= =?utf-8?q?_fix_missing_import?= Message-ID: <3YcBzY10Z9zS2r@mail.python.org> http://hg.python.org/cpython/rev/d565d862545c changeset: 81264:d565d862545c branch: 3.2 parent: 81260:41658a4fb3cc user: Giampaolo Rodola' date: Thu Jan 03 02:54:27 2013 +0100 summary: issue 10527: fix missing import files: Lib/multiprocessing/connection.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -41,6 +41,7 @@ import time import tempfile import itertools +import select import _multiprocessing from multiprocessing import current_process, AuthenticationError -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 03:20:27 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 03:20:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Close_=2316281=3A_handle_t?= =?utf-8?q?ailmatch=28=29_failure_and_remove_useless_comment?= Message-ID: <3YcCXC6hNZzS27@mail.python.org> http://hg.python.org/cpython/rev/49eb2488145d changeset: 81265:49eb2488145d parent: 81262:5a2560cb4a8d user: Victor Stinner date: Thu Jan 03 03:18:09 2013 +0100 summary: Close #16281: handle tailmatch() failure and remove useless comment "honor direction and do a forward or backwards search": the runtime speed may be different, but I consider that it doesn't really matter in practice. The direction was never honored before: Python 2.7 uses memcmp() for the str type for example. files: Objects/unicodeobject.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8935,7 +8935,7 @@ if (PyUnicode_READY(self) == -1 || PyUnicode_READY(substring) == -1) - return 0; + return -1; if (PyUnicode_GET_LENGTH(substring) == 0) return 1; @@ -8973,7 +8973,6 @@ /* We do not need to compare 0 and len(substring)-1 because the if statement above ensured already that they are equal when we end up here. */ - /* TODO: honor direction and do a forward or backwards search */ for (i = 1; i < end_sub; ++i) { if (PyUnicode_READ(kind_self, data_self, offset + i) != PyUnicode_READ(kind_sub, data_sub, i)) @@ -12597,6 +12596,8 @@ return NULL; result = tailmatch(self, substring, start, end, -1); Py_DECREF(substring); + if (result == -1) + return NULL; if (result) { Py_RETURN_TRUE; } @@ -12613,6 +12614,8 @@ } result = tailmatch(self, substring, start, end, -1); Py_DECREF(substring); + if (result == -1) + return NULL; return PyBool_FromLong(result); } @@ -12646,6 +12649,8 @@ return NULL; result = tailmatch(self, substring, start, end, +1); Py_DECREF(substring); + if (result == -1) + return NULL; if (result) { Py_RETURN_TRUE; } @@ -12660,6 +12665,8 @@ return NULL; } result = tailmatch(self, substring, start, end, +1); + if (result == -1) + return NULL; Py_DECREF(substring); return PyBool_FromLong(result); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 03:42:54 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 03:42:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2MzY3?= =?utf-8?q?=3A_Fix_FileIO=2Ereadall=28=29_on_Windows_for_files_larger_than?= =?utf-8?q?_2_GB?= Message-ID: <3YcD266KLwzRx5@mail.python.org> http://hg.python.org/cpython/rev/9aba9ad6c15b changeset: 81266:9aba9ad6c15b branch: 3.2 parent: 81264:d565d862545c user: Victor Stinner date: Thu Jan 03 03:33:21 2013 +0100 summary: Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB files: Misc/NEWS | 2 ++ Modules/_io/fileio.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. + - Issue #16455: On FreeBSD and Solaris, if the locale is C, the ASCII/surrogateescape codec is now used, instead of the locale encoding, to decode the command line arguments. This change fixes inconsistencies with diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -558,7 +558,7 @@ { PyObject *result; Py_ssize_t total = 0; - int n; + Py_ssize_t n; if (self->fd < 0) return err_closed(); @@ -591,9 +591,18 @@ } Py_BEGIN_ALLOW_THREADS errno = 0; + n = newsize - total; +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (n > INT_MAX) + n = INT_MAX; n = read(self->fd, PyBytes_AS_STRING(result) + total, - newsize - total); + (int)n); +#else + n = read(self->fd, + PyBytes_AS_STRING(result) + total, + n); +#endif Py_END_ALLOW_THREADS if (n == 0) break; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 03:42:56 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 03:42:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=28Merge_3=2E2=29_Issue_=2316367=3A_Fix_FileIO=2Ereadall=28=29?= =?utf-8?q?_on_Windows_for_files_larger_than?= Message-ID: <3YcD282428zS26@mail.python.org> http://hg.python.org/cpython/rev/5f96e4619ceb changeset: 81267:5f96e4619ceb branch: 3.3 parent: 81261:4d40c1ce8566 parent: 81266:9aba9ad6c15b user: Victor Stinner date: Thu Jan 03 03:37:47 2013 +0100 summary: (Merge 3.2) Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. files: Misc/NEWS | 2 ++ Modules/_io/fileio.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. + - Issue #16455: On FreeBSD and Solaris, if the locale is C, the ASCII/surrogateescape codec is now used, instead of the locale encoding, to decode the command line arguments. This change fixes inconsistencies with diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -607,7 +607,7 @@ #endif PyObject *result; Py_ssize_t total = 0; - int n; + Py_ssize_t n; size_t newsize; if (self->fd < 0) @@ -656,9 +656,18 @@ } Py_BEGIN_ALLOW_THREADS errno = 0; + n = newsize - total; +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (n > INT_MAX) + n = INT_MAX; n = read(self->fd, PyBytes_AS_STRING(result) + total, - newsize - total); + (int)n); +#else + n = read(self->fd, + PyBytes_AS_STRING(result) + total, + n); +#endif Py_END_ALLOW_THREADS if (n == 0) break; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 03:42:57 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 03:42:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_=28Merge_3=2E3=29_Issue_=2316367=3A_Fix_FileIO=2Ereadall?= =?utf-8?q?=28=29_on_Windows_for_files_larger_than?= Message-ID: <3YcD294YjPzRy8@mail.python.org> http://hg.python.org/cpython/rev/d81d4b3059e4 changeset: 81268:d81d4b3059e4 parent: 81265:49eb2488145d parent: 81267:5f96e4619ceb user: Victor Stinner date: Thu Jan 03 03:38:38 2013 +0100 summary: (Merge 3.3) Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. files: Misc/NEWS | 2 ++ Modules/_io/fileio.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. + - Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -602,7 +602,7 @@ #endif PyObject *result; Py_ssize_t total = 0; - int n; + Py_ssize_t n; size_t newsize; if (self->fd < 0) @@ -651,9 +651,18 @@ } Py_BEGIN_ALLOW_THREADS errno = 0; + n = newsize - total; +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (n > INT_MAX) + n = INT_MAX; n = read(self->fd, PyBytes_AS_STRING(result) + total, - newsize - total); + (int)n); +#else + n = read(self->fd, + PyBytes_AS_STRING(result) + total, + n); +#endif Py_END_ALLOW_THREADS if (n == 0) break; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 03:42:59 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 3 Jan 2013 03:42:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2MzY3?= =?utf-8?q?=3A_Fix_FileIO=2Ereadall=28=29_on_Windows_for_files_larger_than?= =?utf-8?q?_2_GB?= Message-ID: <3YcD2C0KSjzS40@mail.python.org> http://hg.python.org/cpython/rev/f26c91bf61bf changeset: 81269:f26c91bf61bf branch: 2.7 parent: 81263:7cf4ea64f603 user: Victor Stinner date: Thu Jan 03 03:33:21 2013 +0100 summary: Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB files: Misc/NEWS | 2 ++ Modules/_io/fileio.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,8 @@ Core and Builtins ----------------- +- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. + - Issue #15516: Fix a bug in PyString_FromFormat where it failed to properly ignore errors from a __int__() method. diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -530,7 +530,7 @@ { PyObject *result; Py_ssize_t total = 0; - int n; + Py_ssize_t n; if (self->fd < 0) return err_closed(); @@ -563,9 +563,18 @@ } Py_BEGIN_ALLOW_THREADS errno = 0; + n = newsize - total; +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (n > INT_MAX) + n = INT_MAX; n = read(self->fd, PyBytes_AS_STRING(result) + total, - newsize - total); + (int)n); +#else + n = read(self->fd, + PyBytes_AS_STRING(result) + total, + n); +#endif Py_END_ALLOW_THREADS if (n == 0) break; -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Thu Jan 3 05:55:26 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 03 Jan 2013 05:55:26 +0100 Subject: [Python-checkins] Daily reference leaks (49eb2488145d): sum=-1 Message-ID: results for 49eb2488145d on branch "default" -------------------------------------------- test_support leaked [0, 0, -1] references, sum=-1 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogODAufQ', '-x'] From python-checkins at python.org Thu Jan 3 07:44:28 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 3 Jan 2013 07:44:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_=2316009=3A_JSON_error_mes?= =?utf-8?q?sages_now_provide_more_information=2E__Patch_by_Serhiy?= Message-ID: <3YcKNr2vLqzS4t@mail.python.org> http://hg.python.org/cpython/rev/17b4bf9e9f43 changeset: 81270:17b4bf9e9f43 parent: 81268:d81d4b3059e4 user: Ezio Melotti date: Thu Jan 03 08:44:15 2013 +0200 summary: #16009: JSON error messages now provide more information. Patch by Serhiy Storchaka. files: Lib/json/decoder.py | 14 +- Lib/json/scanner.py | 4 +- Lib/test/json_tests/test_fail.py | 77 ++++++++++++++++++++ Misc/NEWS | 2 + Modules/_json.c | 48 ++++++------ 5 files changed, 112 insertions(+), 33 deletions(-) diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py --- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -188,8 +188,8 @@ try: value, end = scan_once(s, end) - except StopIteration: - raise ValueError(errmsg("Expecting object", s, end)) + except StopIteration as err: + raise ValueError(errmsg("Expecting value", s, err.value)) from None pairs_append((key, value)) try: nextchar = s[end] @@ -232,8 +232,8 @@ while True: try: value, end = scan_once(s, end) - except StopIteration: - raise ValueError(errmsg("Expecting object", s, end)) + except StopIteration as err: + raise ValueError(errmsg("Expecting value", s, err.value)) from None _append(value) nextchar = s[end:end + 1] if nextchar in _ws: @@ -243,7 +243,7 @@ if nextchar == ']': break elif nextchar != ',': - raise ValueError(errmsg("Expecting ',' delimiter", s, end)) + raise ValueError(errmsg("Expecting ',' delimiter", s, end - 1)) try: if s[end] in _ws: end += 1 @@ -358,6 +358,6 @@ """ try: obj, end = self.scan_once(s, idx) - except StopIteration: - raise ValueError("No JSON object could be decoded") + except StopIteration as err: + raise ValueError(errmsg("Expecting value", s, err.value)) from None return obj, end diff --git a/Lib/json/scanner.py b/Lib/json/scanner.py --- a/Lib/json/scanner.py +++ b/Lib/json/scanner.py @@ -29,7 +29,7 @@ try: nextchar = string[idx] except IndexError: - raise StopIteration + raise StopIteration(idx) if nextchar == '"': return parse_string(string, idx + 1, strict) @@ -60,7 +60,7 @@ elif nextchar == '-' and string[idx:idx + 9] == '-Infinity': return parse_constant('-Infinity'), idx + 9 else: - raise StopIteration + raise StopIteration(idx) def scan_once(string, idx): try: diff --git a/Lib/test/json_tests/test_fail.py b/Lib/test/json_tests/test_fail.py --- a/Lib/test/json_tests/test_fail.py +++ b/Lib/test/json_tests/test_fail.py @@ -1,4 +1,5 @@ from test.json_tests import PyTest, CTest +import re # 2007-10-05 JSONDOCS = [ @@ -100,6 +101,82 @@ #This is for python encoder self.assertRaises(TypeError, self.dumps, data, indent=True) + def test_truncated_input(self): + test_cases = [ + ('', 'Expecting value', 0), + ('[', 'Expecting value', 1), + ('[42', "Expecting ',' delimiter", 3), + ('[42,', 'Expecting value', 4), + ('["', 'Unterminated string starting at', 1), + ('["spam', 'Unterminated string starting at', 1), + ('["spam"', "Expecting ',' delimiter", 7), + ('["spam",', 'Expecting value', 8), + ('{', 'Expecting property name enclosed in double quotes', 1), + ('{"', 'Unterminated string starting at', 1), + ('{"spam', 'Unterminated string starting at', 1), + ('{"spam"', "Expecting ':' delimiter", 7), + ('{"spam":', 'Expecting value', 8), + ('{"spam":42', "Expecting ',' delimiter", 10), + ('{"spam":42,', 'Expecting property name enclosed in double quotes', 11), + ] + test_cases += [ + ('"', 'Unterminated string starting at', 0), + ('"spam', 'Unterminated string starting at', 0), + ] + for data, msg, idx in test_cases: + self.assertRaisesRegex(ValueError, + r'^{0}: line 1 column {1} \(char {1}\)'.format( + re.escape(msg), idx), + self.loads, data) + + def test_unexpected_data(self): + test_cases = [ + ('[,', 'Expecting value', 1), + ('{"spam":[}', 'Expecting value', 9), + ('[42:', "Expecting ',' delimiter", 3), + ('[42 "spam"', "Expecting ',' delimiter", 4), + ('[42,]', 'Expecting value', 4), + ('{"spam":[42}', "Expecting ',' delimiter", 11), + ('["]', 'Unterminated string starting at', 1), + ('["spam":', "Expecting ',' delimiter", 7), + ('["spam",]', 'Expecting value', 8), + ('{:', 'Expecting property name enclosed in double quotes', 1), + ('{,', 'Expecting property name enclosed in double quotes', 1), + ('{42', 'Expecting property name enclosed in double quotes', 1), + ('[{]', 'Expecting property name enclosed in double quotes', 2), + ('{"spam",', "Expecting ':' delimiter", 7), + ('{"spam"}', "Expecting ':' delimiter", 7), + ('[{"spam"]', "Expecting ':' delimiter", 8), + ('{"spam":}', 'Expecting value', 8), + ('[{"spam":]', 'Expecting value', 9), + ('{"spam":42 "ham"', "Expecting ',' delimiter", 11), + ('[{"spam":42]', "Expecting ',' delimiter", 11), + ('{"spam":42,}', 'Expecting property name enclosed in double quotes', 11), + ] + for data, msg, idx in test_cases: + self.assertRaisesRegex(ValueError, + r'^{0}: line 1 column {1} \(char {1}\)'.format( + re.escape(msg), idx), + self.loads, data) + + def test_extra_data(self): + test_cases = [ + ('[]]', 'Extra data', 2), + ('{}}', 'Extra data', 2), + ('[],[]', 'Extra data', 2), + ('{},{}', 'Extra data', 2), + ] + test_cases += [ + ('42,"spam"', 'Extra data', 2), + ('"spam",42', 'Extra data', 6), + ] + for data, msg, idx in test_cases: + self.assertRaisesRegex(ValueError, + r'^{0}: line 1 column {1} - line 1 column {2}' + r' \(char {1} - {2}\)'.format( + re.escape(msg), idx, len(data)), + self.loads, data) + class TestPyFail(TestFail, PyTest): pass class TestCFail(TestFail, CTest): pass diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -201,6 +201,8 @@ Library ------- +- Issue #16009: JSON error messages now provide more information. + - Issue #16828: Fix error incorrectly raised by bz2.compress(b'') and bz2.BZ2Compressor.compress(b''). Initial patch by Martin Packman. diff --git a/Modules/_json.c b/Modules/_json.c --- a/Modules/_json.c +++ b/Modules/_json.c @@ -237,6 +237,16 @@ } } +static void +raise_stop_iteration(Py_ssize_t idx) +{ + PyObject *value = PyLong_FromSsize_t(idx); + if (value != NULL) { + PyErr_SetObject(PyExc_StopIteration, value); + Py_DECREF(value); + } +} + static PyObject * _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx) { /* return (rval, idx) tuple, stealing reference to rval */ @@ -306,7 +316,7 @@ buf = PyUnicode_DATA(pystr); kind = PyUnicode_KIND(pystr); - if (end < 0 || len <= end) { + if (end < 0 || len < end) { PyErr_SetString(PyExc_ValueError, "end is out of bounds"); goto bail; } @@ -604,12 +614,12 @@ while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind,str, idx))) idx++; /* only loop if the object is non-empty */ - if (idx <= end_idx && PyUnicode_READ(kind, str, idx) != '}') { - while (idx <= end_idx) { + if (idx > end_idx || PyUnicode_READ(kind, str, idx) != '}') { + while (1) { PyObject *memokey; /* read key */ - if (PyUnicode_READ(kind, str, idx) != '"') { + if (idx > end_idx || PyUnicode_READ(kind, str, idx) != '"') { raise_errmsg("Expecting property name enclosed in double quotes", pystr, idx); goto bail; } @@ -666,11 +676,9 @@ while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++; /* bail if the object is closed or we didn't get the , delimiter */ - if (idx > end_idx) break; - if (PyUnicode_READ(kind, str, idx) == '}') { + if (idx <= end_idx && PyUnicode_READ(kind, str, idx) == '}') break; - } - else if (PyUnicode_READ(kind, str, idx) != ',') { + if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ',') { raise_errmsg("Expecting ',' delimiter", pystr, idx); goto bail; } @@ -681,12 +689,6 @@ } } - /* verify that idx < end_idx, str[idx] should be '}' */ - if (idx > end_idx || PyUnicode_READ(kind, str, idx) != '}') { - raise_errmsg("Expecting object", pystr, end_idx); - goto bail; - } - *next_idx_ptr = idx + 1; if (has_pairs_hook) { @@ -738,8 +740,8 @@ while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++; /* only loop if the array is non-empty */ - if (idx <= end_idx && PyUnicode_READ(kind, str, idx) != ']') { - while (idx <= end_idx) { + if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ']') { + while (1) { /* read any JSON term */ val = scan_once_unicode(s, pystr, idx, &next_idx); @@ -756,11 +758,9 @@ while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++; /* bail if the array is closed or we didn't get the , delimiter */ - if (idx > end_idx) break; - if (PyUnicode_READ(kind, str, idx) == ']') { + if (idx <= end_idx && PyUnicode_READ(kind, str, idx) == ']') break; - } - else if (PyUnicode_READ(kind, str, idx) != ',') { + if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ',') { raise_errmsg("Expecting ',' delimiter", pystr, idx); goto bail; } @@ -773,7 +773,7 @@ /* verify that idx < end_idx, PyUnicode_READ(kind, str, idx) should be ']' */ if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ']') { - raise_errmsg("Expecting object", pystr, end_idx); + raise_errmsg("Expecting value", pystr, end_idx); goto bail; } *next_idx_ptr = idx + 1; @@ -841,7 +841,7 @@ if (PyUnicode_READ(kind, str, idx) == '-') { idx++; if (idx > end_idx) { - PyErr_SetNone(PyExc_StopIteration); + raise_stop_iteration(start); return NULL; } } @@ -857,7 +857,7 @@ } /* no integer digits, error */ else { - PyErr_SetNone(PyExc_StopIteration); + raise_stop_iteration(start); return NULL; } @@ -950,7 +950,7 @@ length = PyUnicode_GET_LENGTH(pystr); if (idx >= length) { - PyErr_SetNone(PyExc_StopIteration); + raise_stop_iteration(idx); return NULL; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 08:14:43 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 3 Jan 2013 08:14:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_Fix_markup=2E?= Message-ID: <3YcL3l5KY6zS1l@mail.python.org> http://hg.python.org/devguide/rev/40b259aa4efd changeset: 584:40b259aa4efd user: Ezio Melotti date: Thu Jan 03 09:14:35 2013 +0200 summary: Fix markup. files: committing.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/committing.rst b/committing.rst --- a/committing.rst +++ b/committing.rst @@ -19,15 +19,15 @@ Patch Checklist --------------- -Here's the simple patch checklist that ``make patchcheck`` (or ``./python.exe +Here's the simple patch checklist that ``make patchcheck`` (or ``./python.exe Tools/scripts/patchcheck.py`` on Windows) will run through on a system that uses the makefile to build Python: * Are there any whitespace problems in Python files? - (using Tools/scripts/reindent.py) + (using ``Tools/scripts/reindent.py``) * Are there any whitespace problems in C files? * Are there any whitespace problems in the documentation? - (using Tools/scripts/reindent-rst.py) + (using ``Tools/scripts/reindent-rst.py``) * Has the documentation been updated? * Has the test suite been updated? * Has ``Misc/NEWS`` been updated? -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Thu Jan 3 09:23:03 2013 From: python-checkins at python.org (christian.heimes) Date: Thu, 3 Jan 2013 09:23:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2ODQ3?= =?utf-8?q?=3A_Fixed_improper_use_of_=5FPyUnicode=5FCheckConsistency=28=29?= =?utf-8?q?_in?= Message-ID: <3YcMZb6Mw3zS1K@mail.python.org> http://hg.python.org/cpython/rev/944e86223d1f changeset: 81271:944e86223d1f branch: 3.3 parent: 81267:5f96e4619ceb user: Christian Heimes date: Thu Jan 03 09:21:55 2013 +0100 summary: Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in non-pydebug builds. Several extension modules now compile cleanly when assert()s are enabled in standard builds (-DDEBUG flag). files: Misc/NEWS | 4 ++++ Modules/_json.c | 2 ++ Modules/md5module.c | 2 ++ Modules/sha1module.c | 2 ++ Modules/sha256module.c | 2 ++ Modules/sha512module.c | 2 ++ 6 files changed, 14 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -4293,6 +4293,10 @@ Extension Modules ----------------- +- Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in + non-pydebug builds. Several extension modules now compile cleanly when + assert()s are enabled in standard builds (-DDEBUG flag). + - Issue #13840: The error message produced by ctypes.create_string_buffer when given a Unicode string has been fixed. diff --git a/Modules/_json.c b/Modules/_json.c --- a/Modules/_json.c +++ b/Modules/_json.c @@ -246,7 +246,9 @@ } } output[chars++] = '"'; +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(rval, 1)); +#endif return rval; } diff --git a/Modules/md5module.c b/Modules/md5module.c --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -399,7 +399,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } diff --git a/Modules/sha1module.c b/Modules/sha1module.c --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -376,7 +376,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } diff --git a/Modules/sha256module.c b/Modules/sha256module.c --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -466,7 +466,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } diff --git a/Modules/sha512module.c b/Modules/sha512module.c --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -532,7 +532,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 3 09:23:05 2013 From: python-checkins at python.org (christian.heimes) Date: Thu, 3 Jan 2013 09:23:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316847=3A_Fixed_improper_use_of_=5FPyUnicode=5FC?= =?utf-8?q?heckConsistency=28=29_in?= Message-ID: <3YcMZd2BszzS55@mail.python.org> http://hg.python.org/cpython/rev/4b42d7f288c5 changeset: 81272:4b42d7f288c5 parent: 81270:17b4bf9e9f43 parent: 81271:944e86223d1f user: Christian Heimes date: Thu Jan 03 09:22:41 2013 +0100 summary: Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in non-pydebug builds. Several extension modules now compile cleanly when assert()s are enabled in standard builds (-DDEBUG flag). files: Misc/NEWS | 4 ++++ Modules/_json.c | 2 ++ Modules/_sha3/sha3module.c | 2 ++ Modules/md5module.c | 2 ++ Modules/sha1module.c | 2 ++ Modules/sha256module.c | 2 ++ Modules/sha512module.c | 2 ++ 7 files changed, 16 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -4501,6 +4501,10 @@ Extension Modules ----------------- +- Issue #16847: Fixed improper use of _PyUnicode_CheckConsistency() in + non-pydebug builds. Several extension modules now compile cleanly when + assert()s are enabled in standard builds (-DDEBUG flag). + - Issue #13840: The error message produced by ctypes.create_string_buffer when given a Unicode string has been fixed. diff --git a/Modules/_json.c b/Modules/_json.c --- a/Modules/_json.c +++ b/Modules/_json.c @@ -210,7 +210,9 @@ } } output[chars++] = '"'; +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(rval, 1)); +#endif return rval; } diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c --- a/Modules/_sha3/sha3module.c +++ b/Modules/_sha3/sha3module.c @@ -300,7 +300,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } diff --git a/Modules/md5module.c b/Modules/md5module.c --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -399,7 +399,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } diff --git a/Modules/sha1module.c b/Modules/sha1module.c --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -376,7 +376,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } diff --git a/Modules/sha256module.c b/Modules/sha256module.c --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -456,7 +456,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } diff --git a/Modules/sha512module.c b/Modules/sha512module.c --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -522,7 +522,9 @@ c = (digest[i] & 0xf); hex_digest[j++] = Py_hexdigits[c]; } +#ifdef Py_DEBUG assert(_PyUnicode_CheckConsistency(retval, 1)); +#endif return retval; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 05:35:25 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 4 Jan 2013 05:35:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogZHJvcCBlbWFpbCAo?= =?utf-8?q?closes_=2316857=29?= Message-ID: <3YctTT2q84zS8b@mail.python.org> http://hg.python.org/cpython/rev/c7ae3772b4d4 changeset: 81273:c7ae3772b4d4 branch: 3.2 parent: 80949:74da2dbb5e50 user: Benjamin Peterson date: Thu Jan 03 20:34:19 2013 -0800 summary: drop email (closes #16857) files: Doc/howto/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -2,7 +2,7 @@ Argparse Tutorial ***************** -:author: Tshepang Lekhonkhobe +:author: Tshepang Lekhonkhobe .. _argparse-tutorial: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 05:35:27 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 4 Jan 2013 05:35:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMik6?= =?utf-8?q?_merge_heads?= Message-ID: <3YctTW60fNzS9G@mail.python.org> http://hg.python.org/cpython/rev/f81522ee5b37 changeset: 81274:f81522ee5b37 branch: 3.2 parent: 81273:c7ae3772b4d4 parent: 81266:9aba9ad6c15b user: Benjamin Peterson date: Thu Jan 03 20:34:40 2013 -0800 summary: merge heads files: Doc/faq/programming.rst | 4 + Doc/glossary.rst | 27 +- Doc/howto/regex.rst | 49 +- Doc/library/argparse.rst | 2 +- Doc/library/audioop.rst | 6 +- Doc/library/configparser.rst | 8 +- Doc/library/ftplib.rst | 8 +- Doc/library/pickle.rst | 9 +- Doc/library/poplib.rst | 2 +- Doc/library/smtplib.rst | 3 +- Doc/library/socketserver.rst | 4 +- Doc/reference/compound_stmts.rst | 14 +- Doc/reference/expressions.rst | 28 +- Doc/using/windows.rst | 2 + Lib/aifc.py | 8 +- Lib/configparser.py | 23 +- Lib/curses/__init__.py | 2 +- Lib/glob.py | 7 +- Lib/idlelib/EditorWindow.py | 23 +- Lib/idlelib/FormatParagraph.py | 6 +- Lib/idlelib/HyperParser.py | 5 + Lib/idlelib/configDialog.py | 19 +- Lib/idlelib/configHandler.py | 51 +- Lib/multiprocessing/connection.py | 22 + Lib/socketserver.py | 7 +- Lib/subprocess.py | 4 +- Lib/test/regrtest.py | 6 +- Lib/test/support.py | 78 +++ Lib/test/test_aifc.py | 11 +- Lib/test/test_bz2.py | 15 + Lib/test/test_cfgparser.py | 53 ++ Lib/test/test_cmd_line.py | 6 +- Lib/test/test_cmd_line_script.py | 24 + Lib/test/test_genericpath.py | 17 +- Lib/test/test_glob.py | 77 ++- Lib/test/test_int.py | 21 +- Lib/test/test_multiprocessing.py | 1 + Lib/test/test_os.py | 59 ++ Lib/test/test_ssl.py | 11 + Lib/test/test_subprocess.py | 3 +- Lib/test/test_tarfile.py | 24 +- Lib/test/test_urllib2.py | 34 +- Lib/test/test_urllib2_localnet.py | 2 + Lib/test/test_urlparse.py | 29 + Lib/test/test_winreg.py | 29 + Lib/tkinter/__init__.py | 2 +- Lib/tkinter/test/test_tkinter/test_misc.py | 45 + Lib/urllib/error.py | 4 + Lib/urllib/parse.py | 2 +- Mac/IDLE/IDLE.app/Contents/Info.plist | 2 +- Mac/PythonLauncher/Info.plist.in | 2 +- Mac/Resources/app/Info.plist.in | 6 +- Mac/Resources/framework/Info.plist.in | 4 +- Misc/ACKS | 4 + Misc/NEWS | 65 ++ Modules/_ctypes/callproc.c | 2 +- Modules/_io/fileio.c | 13 +- Modules/_multiprocessing/semaphore.c | 7 + Modules/_sre.c | 72 ++- Modules/bz2module.c | 2 +- Modules/posixmodule.c | 14 +- Objects/longobject.c | 10 +- Objects/unicodeobject.c | 8 +- PC/winreg.c | 6 +- Python/fileutils.c | 245 +++++++++- 65 files changed, 1103 insertions(+), 255 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -313,6 +313,10 @@ g(x, *args, **kwargs) +.. index:: + single: argument; difference from parameter + single: parameter; difference from argument + .. _faq-argument-vs-parameter: What is the difference between arguments and parameters? diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -240,8 +240,9 @@ function A series of statements which returns some value to a caller. It can also - be passed zero or more arguments which may be used in the execution of - the body. See also :term:`argument` and :term:`method`. + be passed zero or more :term:`arguments ` which may be used in + the execution of the body. See also :term:`parameter`, :term:`method`, + and the :ref:`function` section. __future__ A pseudo-module which programmers can use to enable new language features @@ -355,17 +356,17 @@ slowly. See also :term:`interactive`. iterable - An object capable of returning its members one at a - time. Examples of iterables include all sequence types (such as - :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence - types like :class:`dict` and :class:`file` and objects of any classes you - define with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables - can be used in a :keyword:`for` loop and in many other places where a - sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable - object is passed as an argument to the built-in function :func:`iter`, it - returns an iterator for the object. This iterator is good for one pass - over the set of values. When using iterables, it is usually not necessary - to call :func:`iter` or deal with iterator objects yourself. The ``for`` + An object capable of returning its members one at a time. Examples of + iterables include all sequence types (such as :class:`list`, :class:`str`, + and :class:`tuple`) and some non-sequence types like :class:`dict`, + :term:`file objects `, and objects of any classes you define + with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be + used in a :keyword:`for` loop and in many other places where a sequence is + needed (:func:`zip`, :func:`map`, ...). When an iterable object is passed + as an argument to the built-in function :func:`iter`, it returns an + iterator for the object. This iterator is good for one pass over the set + of values. When using iterables, it is usually not necessary to call + :func:`iter` or deal with iterator objects yourself. The ``for`` statement does that automatically for you, creating a temporary unnamed variable to hold the iterator for the duration of the loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`. diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -354,9 +354,9 @@ +------------------+-----------------------------------------------+ :meth:`match` and :meth:`search` return ``None`` if no match can be found. If -they're successful, a ``MatchObject`` instance is returned, containing -information about the match: where it starts and ends, the substring it matched, -and more. +they're successful, a :ref:`match object ` instance is returned, +containing information about the match: where it starts and ends, the substring +it matched, and more. You can learn about this by interactively experimenting with the :mod:`re` module. If you have :mod:`tkinter` available, you may also want to look at @@ -386,16 +386,16 @@ None Now, let's try it on a string that it should match, such as ``tempo``. In this -case, :meth:`match` will return a :class:`MatchObject`, so you should store the -result in a variable for later use. :: +case, :meth:`match` will return a :ref:`match object `, so you +should store the result in a variable for later use. :: >>> m = p.match('tempo') >>> m #doctest: +ELLIPSIS <_sre.SRE_Match object at 0x...> -Now you can query the :class:`MatchObject` for information about the matching -string. :class:`MatchObject` instances also have several methods and -attributes; the most important ones are: +Now you can query the :ref:`match object ` for information +about the matching string. :ref:`match object ` instances +also have several methods and attributes; the most important ones are: +------------------+--------------------------------------------+ | Method/Attribute | Purpose | @@ -436,8 +436,9 @@ >>> m.span() (4, 11) -In actual programs, the most common style is to store the :class:`MatchObject` -in a variable, and then check if it was ``None``. This usually looks like:: +In actual programs, the most common style is to store the +:ref:`match object ` in a variable, and then check if it was +``None``. This usually looks like:: p = re.compile( ... ) m = p.match( 'string goes here' ) @@ -454,8 +455,8 @@ ['12', '11', '10'] :meth:`findall` has to create the entire list before it can be returned as the -result. The :meth:`finditer` method returns a sequence of :class:`MatchObject` -instances as an :term:`iterator`:: +result. The :meth:`finditer` method returns a sequence of +:ref:`match object ` instances as an :term:`iterator`:: >>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...') >>> iterator #doctest: +ELLIPSIS @@ -476,7 +477,7 @@ :func:`search`, :func:`findall`, :func:`sub`, and so forth. These functions take the same arguments as the corresponding pattern method, with the RE string added as the first argument, and still return either ``None`` or a -:class:`MatchObject` instance. :: +:ref:`match object ` instance. :: >>> print(re.match(r'From\s+', 'Fromage amk')) None @@ -786,9 +787,9 @@ index of the text that they match; this can be retrieved by passing an argument to :meth:`group`, :meth:`start`, :meth:`end`, and :meth:`span`. Groups are numbered starting with 0. Group 0 is always present; it's the whole RE, so -:class:`MatchObject` methods all have group 0 as their default argument. Later -we'll see how to express groups that don't capture the span of text that they -match. :: +:ref:`match object ` methods all have group 0 as their default +argument. Later we'll see how to express groups that don't capture the span +of text that they match. :: >>> p = re.compile('(a)b') >>> m = p.match('ab') @@ -908,10 +909,10 @@ The syntax for a named group is one of the Python-specific extensions: ``(?P...)``. *name* is, obviously, the name of the group. Named groups also behave exactly like capturing groups, and additionally associate a name -with a group. The :class:`MatchObject` methods that deal with capturing groups -all accept either integers that refer to the group by number or strings that -contain the desired group's name. Named groups are still given numbers, so you -can retrieve information about a group in two ways:: +with a group. The :ref:`match object ` methods that deal with +capturing groups all accept either integers that refer to the group by number +or strings that contain the desired group's name. Named groups are still +given numbers, so you can retrieve information about a group in two ways:: >>> p = re.compile(r'(?P\b\w+\b)') >>> m = p.search( '(((( Lots of punctuation )))' ) @@ -1175,11 +1176,11 @@ *replacement* can also be a function, which gives you even more control. If *replacement* is a function, the function is called for every non-overlapping -occurrence of *pattern*. On each call, the function is passed a -:class:`MatchObject` argument for the match and can use this information to -compute the desired replacement string and return it. +occurrence of *pattern*. On each call, the function is passed a +:ref:`match object ` argument for the match and can use this +information to compute the desired replacement string and return it. -In the following example, the replacement function translates decimals into +In the following example, the replacement function translates decimals into hexadecimal:: >>> def hexrepl(match): diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1440,7 +1440,7 @@ different functions which require different kinds of command-line arguments. :class:`ArgumentParser` supports the creation of such sub-commands with the :meth:`add_subparsers` method. The :meth:`add_subparsers` method is normally - called with no arguments and returns an special action object. This object + called with no arguments and returns a special action object. This object has a single method, :meth:`~ArgumentParser.add_parser`, which takes a command name and any :class:`ArgumentParser` constructor arguments, and returns an :class:`ArgumentParser` object that can be modified as usual. diff --git a/Doc/library/audioop.rst b/Doc/library/audioop.rst --- a/Doc/library/audioop.rst +++ b/Doc/library/audioop.rst @@ -7,7 +7,7 @@ The :mod:`audioop` module contains some useful operations on sound fragments. It operates on sound fragments consisting of signed integer samples 8, 16 or 32 -bits wide, stored in Python strings. All scalar items are integers, unless +bits wide, stored in bytes objects. All scalar items are integers, unless specified otherwise. .. index:: @@ -126,7 +126,7 @@ .. function:: lin2alaw(fragment, width) Convert samples in the audio fragment to a-LAW encoding and return this as a - Python string. a-LAW is an audio encoding format whereby you get a dynamic + bytes object. a-LAW is an audio encoding format whereby you get a dynamic range of about 13 bits using only 8 bit samples. It is used by the Sun audio hardware, among others. @@ -151,7 +151,7 @@ .. function:: lin2ulaw(fragment, width) Convert samples in the audio fragment to u-LAW encoding and return this as a - Python string. u-LAW is an audio encoding format whereby you get a dynamic + bytes object. u-LAW is an audio encoding format whereby you get a dynamic range of about 14 bits using only 8 bit samples. It is used by the Sun audio hardware, among others. diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -389,7 +389,13 @@ the default value to be visible again. Trying to delete a default value causes a ``KeyError``. -* Trying to delete the ``DEFAULTSECT`` raises ``ValueError``. +* ``DEFAULTSECT`` cannot be removed from the parser: + + * trying to delete it raises ``ValueError``, + + * ``parser.clear()`` leaves it intact, + + * ``parser.popitem()`` never returns it. * ``parser.get(section, option, **kwargs)`` - the second argument is **not** a fallback value. Note however that the section-level ``get()`` methods are diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -377,10 +377,10 @@ .. method:: FTP.close() Close the connection unilaterally. This should not be applied to an already - closed connection such as after a successful call to :meth:`quit`. After this - call the :class:`FTP` instance should not be used any more (after a call to - :meth:`close` or :meth:`quit` you cannot reopen the connection by issuing - another :meth:`login` method). + closed connection such as after a successful call to :meth:`~FTP.quit`. + After this call the :class:`FTP` instance should not be used any more (after + a call to :meth:`close` or :meth:`~FTP.quit` you cannot reopen the + connection by issuing another :meth:`login` method). FTP_TLS Objects diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -367,8 +367,9 @@ * classes that are defined at the top level of a module -* instances of such classes whose :attr:`__dict__` or :meth:`__setstate__` is - picklable (see section :ref:`pickle-inst` for details) +* instances of such classes whose :attr:`__dict__` or the result of calling + :meth:`__getstate__` is picklable (see section :ref:`pickle-inst` for + details). Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` exception; when this happens, an unspecified number of bytes may have already @@ -379,8 +380,8 @@ Note that functions (built-in and user-defined) are pickled by "fully qualified" name reference, not by value. This means that only the function name is -pickled, along with the name of the module the function is defined in. Neither the -function's code, nor any of its function attributes are pickled. Thus the +pickled, along with the name of the module the function is defined in. Neither +the function's code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised. [#]_ diff --git a/Doc/library/poplib.rst b/Doc/library/poplib.rst --- a/Doc/library/poplib.rst +++ b/Doc/library/poplib.rst @@ -105,7 +105,7 @@ .. method:: POP3.pass_(password) Send password, response includes message count and mailbox size. Note: the - mailbox on the server is locked until :meth:`quit` is called. + mailbox on the server is locked until :meth:`~poplib.quit` is called. .. method:: POP3.apop(user, secret) diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -32,7 +32,8 @@ setting will be used). For normal use, you should only require the initialization/connect, - :meth:`sendmail`, and :meth:`quit` methods. An example is included below. + :meth:`sendmail`, and :meth:`~smtplib.quit` methods. + An example is included below. .. class:: SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, certfile=None[, timeout]) diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -299,8 +299,8 @@ .. method:: RequestHandler.finish() Called after the :meth:`handle` method to perform any clean-up actions - required. The default implementation does nothing. If :meth:`setup` or - :meth:`handle` raise an exception, this function will not be called. + required. The default implementation does nothing. If :meth:`setup` + raises an exception, this function will not be called. .. method:: RequestHandler.handle() diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -417,6 +417,9 @@ statement. +.. index:: + single: parameter; function definition + .. _function: .. _def: @@ -478,11 +481,14 @@ def func(): pass func = f1(arg)(f2(func)) -.. index:: triple: default; parameter; value +.. index:: + triple: default; parameter; value + single: argument; function definition -When one or more parameters have the form *parameter* ``=`` *expression*, the -function is said to have "default parameter values." For a parameter with a -default value, the corresponding argument may be omitted from a call, in which +When one or more :term:`parameters ` have the form *parameter* ``=`` +*expression*, the function is said to have "default parameter values." For a +parameter with a default value, the corresponding :term:`argument` may be +omitted from a call, in which case the parameter's default value is substituted. If a parameter has a default value, all following parameters up until the "``*``" must also have a default value --- this is a syntactic restriction that is not expressed by the grammar. diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -600,17 +600,18 @@ expressions. +.. index:: + object: callable + single: call + single: argument; call semantics + .. _calls: Calls ----- -.. index:: single: call - -.. index:: object: callable - -A call calls a callable object (e.g., a function) with a possibly empty series -of arguments: +A call calls a callable object (e.g., a :term:`function`) with a possibly empty +series of :term:`arguments `: .. productionlist:: call: `primary` "(" [`argument_list` [","] | `comprehension`] ")" @@ -628,11 +629,14 @@ A trailing comma may be present after the positional and keyword arguments but does not affect the semantics. +.. index:: + single: parameter; call semantics + The primary must evaluate to a callable object (user-defined functions, built-in functions, methods of built-in objects, class objects, methods of class instances, and all objects having a :meth:`__call__` method are callable). All argument expressions are evaluated before the call is attempted. Please refer -to section :ref:`function` for the syntax of formal parameter lists. +to section :ref:`function` for the syntax of formal :term:`parameter` lists. .. XXX update with kwonly args PEP @@ -1266,8 +1270,8 @@ .. _operator-summary: -Summary -======= +Operator precedence +=================== .. index:: pair: operator; precedence @@ -1291,9 +1295,9 @@ +-----------------------------------------------+-------------------------------------+ | :keyword:`and` | Boolean AND | +-----------------------------------------------+-------------------------------------+ -| :keyword:`not` *x* | Boolean NOT | +| :keyword:`not` ``x`` | Boolean NOT | +-----------------------------------------------+-------------------------------------+ -| :keyword:`in`, :keyword:`not` :keyword:`in`, | Comparisons, including membership | +| :keyword:`in`, :keyword:`not in`, | Comparisons, including membership | | :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests, | | ``<=``, ``>``, ``>=``, ``!=``, ``==`` | | +-----------------------------------------------+-------------------------------------+ @@ -1319,7 +1323,7 @@ +-----------------------------------------------+-------------------------------------+ | ``(expressions...)``, | Binding or tuple display, | | ``[expressions...]``, | list display, | -| ``{key:datum...}``, | dictionary display, | +| ``{key: value...}``, | dictionary display, | | ``{expressions...}`` | set display | +-----------------------------------------------+-------------------------------------+ diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -82,6 +82,8 @@ settings in Windows. +.. _setting-envvars: + Excursus: Setting environment variables --------------------------------------- diff --git a/Lib/aifc.py b/Lib/aifc.py --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -692,7 +692,9 @@ self._patchheader() def close(self): - if self._file: + if self._file is None: + return + try: self._ensure_header_written(0) if self._datawritten & 1: # quick pad to even size @@ -703,10 +705,12 @@ self._datalength != self._datawritten or \ self._marklength: self._patchheader() + finally: # Prevent ref cycles self._convert = None - self._file.close() + f = self._file self._file = None + f.close() # # Internal methods. diff --git a/Lib/configparser.py b/Lib/configparser.py --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -99,10 +99,9 @@ yes, on for True). Returns False or True. items(section=_UNSET, raw=False, vars=None) - If section is given, return a list of tuples with (section_name, - section_proxy) for each section, including DEFAULTSECT. Otherwise, - return a list of tuples with (name, value) for each option - in the section. + If section is given, return a list of tuples with (name, value) for + each option in the section. Otherwise, return a list of tuples with + (section_name, section_proxy) for each section, including DEFAULTSECT. remove_section(section) Remove the given file section and all its options. @@ -852,6 +851,19 @@ value_getter = lambda option: d[option] return [(option, value_getter(option)) for option in d.keys()] + def popitem(self): + """Remove a section from the parser and return it as + a (section_name, section_proxy) tuple. If no section is present, raise + KeyError. + + The section DEFAULT is never returned because it cannot be removed. + """ + for key in self.sections(): + value = self[key] + del self[key] + return key, value + raise KeyError + def optionxform(self, optionstr): return optionstr.lower() @@ -947,7 +959,8 @@ # XXX this is not atomic if read_dict fails at any point. Then again, # no update method in configparser is atomic in this implementation. - self.remove_section(key) + if key in self._sections: + self._sections[key].clear() self.read_dict({key: value}) def __delitem__(self, key): diff --git a/Lib/curses/__init__.py b/Lib/curses/__init__.py --- a/Lib/curses/__init__.py +++ b/Lib/curses/__init__.py @@ -5,7 +5,7 @@ import curses from curses import textpad - curses.initwin() + curses.initscr() ... """ diff --git a/Lib/glob.py b/Lib/glob.py --- a/Lib/glob.py +++ b/Lib/glob.py @@ -58,8 +58,8 @@ names = os.listdir(dirname) except os.error: return [] - if pattern[0] != '.': - names = [x for x in names if x[0] != '.'] + if not _ishidden(pattern): + names = [x for x in names if not _ishidden(x)] return fnmatch.filter(names, pattern) def glob0(dirname, basename): @@ -83,3 +83,6 @@ else: match = magic_check.search(s) return match is not None + +def _ishidden(path): + return path[0] in ('.', b'.'[0]) diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -170,13 +170,15 @@ 'recent-files.lst') self.text_frame = text_frame = Frame(top) self.vbar = vbar = Scrollbar(text_frame, name='vbar') - self.width = idleConf.GetOption('main','EditorWindow','width') + self.width = idleConf.GetOption('main', 'EditorWindow', + 'width', type='int') text_options = { 'name': 'text', 'padx': 5, 'wrap': 'none', 'width': self.width, - 'height': idleConf.GetOption('main', 'EditorWindow', 'height')} + 'height': idleConf.GetOption('main', 'EditorWindow', + 'height', type='int')} if TkVersion >= 8.5: # Starting with tk 8.5 we have to set the new tabstyle option # to 'wordprocessor' to achieve the same display of tabs as in @@ -253,7 +255,8 @@ if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'): fontWeight='bold' text.config(font=(idleConf.GetOption('main', 'EditorWindow', 'font'), - idleConf.GetOption('main', 'EditorWindow', 'font-size'), + idleConf.GetOption('main', 'EditorWindow', + 'font-size', type='int'), fontWeight)) text_frame.pack(side=LEFT, fill=BOTH, expand=1) text.pack(side=TOP, fill=BOTH, expand=1) @@ -268,7 +271,8 @@ # Although use-spaces=0 can be configured manually in config-main.def, # configuration of tabs v. spaces is not supported in the configuration # dialog. IDLE promotes the preferred Python indentation: use spaces! - usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces', type='bool') + usespaces = idleConf.GetOption('main', 'Indent', + 'use-spaces', type='bool') self.usetabs = not usespaces # tabwidth is the display width of a literal tab character. @@ -382,9 +386,11 @@ self.text.tag_remove("sel", "1.0", "end") else: if not self.text.index("sel.first"): - self.text.mark_set("my_anchor", "insert") # there was no previous selection + # there was no previous selection + self.text.mark_set("my_anchor", "insert") else: - if self.text.compare(self.text.index("sel.first"), "<", self.text.index("insert")): + if self.text.compare(self.text.index("sel.first"), "<", + self.text.index("insert")): self.text.mark_set("my_anchor", "sel.first") # extend back else: self.text.mark_set("my_anchor", "sel.last") # extend forward @@ -766,7 +772,8 @@ if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'): fontWeight='bold' self.text.config(font=(idleConf.GetOption('main','EditorWindow','font'), - idleConf.GetOption('main','EditorWindow','font-size'), + idleConf.GetOption('main','EditorWindow','font-size', + type='int'), fontWeight)) def RemoveKeybindings(self): @@ -1611,7 +1618,7 @@ tokens = _tokenize.generate_tokens(self.readline) for token in tokens: self.tokeneater(*token) - except _tokenize.TokenError: + except (_tokenize.TokenError, SyntaxError): # since we cut off the tokenizer early, we can trigger # spurious errors pass diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py --- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/FormatParagraph.py @@ -32,7 +32,8 @@ self.editwin = None def format_paragraph_event(self, event): - maxformatwidth = int(idleConf.GetOption('main','FormatParagraph','paragraph')) + maxformatwidth = int(idleConf.GetOption('main', 'FormatParagraph', + 'paragraph', type='int')) text = self.editwin.text first, last = self.editwin.get_selection_indices() if first and last: @@ -46,7 +47,8 @@ lines = data.split("\n") lines = map(lambda st, l=len(comment_header): st[l:], lines) data = "\n".join(lines) - # Reformat to maxformatwidth chars or a 20 char width, whichever is greater. + # Reformat to maxformatwidth chars or a 20 char width, + # whichever is greater. format_width = max(maxformatwidth - len(comment_header), 20) newdata = reformat_paragraph(data, format_width) # re-split and re-insert the comment header. diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/HyperParser.py @@ -232,6 +232,11 @@ pass else: # We can't continue after other types of brackets + if rawtext[pos] in "'\"": + # Scan a string prefix + while pos > 0 and rawtext[pos - 1] in "rRbB": + pos -= 1 + last_identifier_pos = pos break else: diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -925,7 +925,7 @@ for font in fonts: self.listFontName.insert(END,font) configuredFont=idleConf.GetOption('main','EditorWindow','font', - default='courier') + default='courier') lc_configuredFont = configuredFont.lower() self.fontName.set(lc_configuredFont) lc_fonts = [s.lower() for s in fonts] @@ -935,13 +935,13 @@ self.listFontName.select_set(currentFontIndex) self.listFontName.select_anchor(currentFontIndex) ##font size dropdown - fontSize=idleConf.GetOption('main','EditorWindow','font-size', - default='10') + fontSize=idleConf.GetOption('main', 'EditorWindow', 'font-size', + type='int', default='10') self.optMenuFontSize.SetMenu(('7','8','9','10','11','12','13','14', - '16','18','20','22'),fontSize ) + '16','18','20','22'), fontSize ) ##fontWeight self.fontBold.set(idleConf.GetOption('main','EditorWindow', - 'font-bold',default=0,type='bool')) + 'font-bold',default=0,type='bool')) ##font sample self.SetFontSample() @@ -1022,10 +1022,13 @@ self.autoSave.set(idleConf.GetOption('main', 'General', 'autosave', default=0, type='bool')) #initial window size - self.winWidth.set(idleConf.GetOption('main','EditorWindow','width')) - self.winHeight.set(idleConf.GetOption('main','EditorWindow','height')) + self.winWidth.set(idleConf.GetOption('main','EditorWindow','width', + type='int')) + self.winHeight.set(idleConf.GetOption('main','EditorWindow','height', + type='int')) #initial paragraph reformat size - self.paraWidth.set(idleConf.GetOption('main','FormatParagraph','paragraph')) + self.paraWidth.set(idleConf.GetOption('main','FormatParagraph','paragraph', + type='int')) # default source encoding self.encoding.set(idleConf.GetOption('main', 'EditorWindow', 'encoding', default='none')) diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -237,24 +237,39 @@ printed to stderr. """ - if self.userCfg[configType].has_option(section,option): - return self.userCfg[configType].Get(section, option, - type=type, raw=raw) - elif self.defaultCfg[configType].has_option(section,option): - return self.defaultCfg[configType].Get(section, option, - type=type, raw=raw) - else: #returning default, print warning - if warn_on_default: - warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' - ' problem retrieving configuration option %r\n' - ' from section %r.\n' - ' returning default value: %r\n' % - (option, section, default)) - try: - sys.stderr.write(warning) - except IOError: - pass - return default + try: + if self.userCfg[configType].has_option(section,option): + return self.userCfg[configType].Get(section, option, + type=type, raw=raw) + except ValueError: + warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' + ' invalid %r value for configuration option %r\n' + ' from section %r: %r\n' % + (type, option, section, + self.userCfg[configType].Get(section, option, + raw=raw))) + try: + sys.stderr.write(warning) + except IOError: + pass + try: + if self.defaultCfg[configType].has_option(section,option): + return self.defaultCfg[configType].Get(section, option, + type=type, raw=raw) + except ValueError: + pass + #returning default, print warning + if warn_on_default: + warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' + ' problem retrieving configuration option %r\n' + ' from section %r.\n' + ' returning default value: %r\n' % + (option, section, default)) + try: + sys.stderr.write(warning) + except IOError: + pass + return default def SetOption(self, configType, section, option, value): """In user's config file, set section's option to value. diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -41,6 +41,7 @@ import time import tempfile import itertools +import select import _multiprocessing from multiprocessing import current_process, AuthenticationError @@ -213,6 +214,27 @@ return c1, c2 else: + if hasattr(select, 'poll'): + def _poll(fds, timeout): + if timeout is not None: + timeout = int(timeout) * 1000 # timeout is in milliseconds + fd_map = {} + pollster = select.poll() + for fd in fds: + pollster.register(fd, select.POLLIN) + if hasattr(fd, 'fileno'): + fd_map[fd.fileno()] = fd + else: + fd_map[fd] = fd + ls = [] + for fd, event in pollster.poll(timeout): + if event & select.POLLNVAL: + raise ValueError('invalid file descriptor %i' % fd) + ls.append(fd_map[fd]) + return ls + else: + def _poll(fds, timeout): + return select.select(fds, [], [], timeout)[0] from _multiprocessing import win32 diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -700,7 +700,12 @@ def finish(self): if not self.wfile.closed: - self.wfile.flush() + try: + self.wfile.flush() + except socket.error: + # An final socket error may have occurred here, such as + # the local error ECONNABORTED. + pass self.wfile.close() self.rfile.close() diff --git a/Lib/subprocess.py b/Lib/subprocess.py --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1411,7 +1411,7 @@ def _internal_poll(self, _deadstate=None, _waitpid=os.waitpid, - _WNOHANG=os.WNOHANG, _os_error=os.error): + _WNOHANG=os.WNOHANG, _os_error=os.error, _ECHILD=errno.ECHILD): """Check if child process has terminated. Returns returncode attribute. @@ -1427,7 +1427,7 @@ except _os_error as e: if _deadstate is not None: self.returncode = _deadstate - elif e.errno == errno.ECHILD: + elif e.errno == _ECHILD: # This happens if SIGCLD is set to be ignored or # waiting for child processes has otherwise been # disabled for our process. This child is dead, we diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -33,7 +33,7 @@ Selecting tests --r/--random -- randomize test execution order (see below) +-r/--randomize -- randomize test execution order (see below) --randseed -- pass a random seed to reproduce a previous random run -f/--fromfile -- read names of tests to run from a file (see below) -x/--exclude -- arguments are tests to *exclude* @@ -274,11 +274,11 @@ try: opts, args = getopt.getopt(sys.argv[1:], 'hvqxsoS:rf:lu:t:TD:NLR:FdwWM:nj:Gm:', ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', - 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks', + 'exclude', 'single', 'slow', 'randomize', 'fromfile=', 'findleaks', 'use=', 'threshold=', 'coverdir=', 'nocoverdir', 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=', 'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug', - 'start=', 'nowindows', 'header', 'failfast', 'match']) + 'start=', 'nowindows', 'header', 'failfast', 'match=']) except getopt.error as msg: usage(msg) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -523,6 +523,49 @@ # module name. TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid()) +# FS_NONASCII: non-ASCII character encodable by os.fsencode(), +# or None if there is no such character. +FS_NONASCII = None +for character in ( + # First try printable and common characters to have a readable filename. + # For each character, the encoding list are just example of encodings able + # to encode the character (the list is not exhaustive). + + # U+00E6 (Latin Small Letter Ae): cp1252, iso-8859-1 + '\u00E6', + # U+0130 (Latin Capital Letter I With Dot Above): cp1254, iso8859_3 + '\u0130', + # U+0141 (Latin Capital Letter L With Stroke): cp1250, cp1257 + '\u0141', + # U+03C6 (Greek Small Letter Phi): cp1253 + '\u03C6', + # U+041A (Cyrillic Capital Letter Ka): cp1251 + '\u041A', + # U+05D0 (Hebrew Letter Alef): Encodable to cp424 + '\u05D0', + # U+060C (Arabic Comma): cp864, cp1006, iso8859_6, mac_arabic + '\u060C', + # U+062A (Arabic Letter Teh): cp720 + '\u062A', + # U+0E01 (Thai Character Ko Kai): cp874 + '\u0E01', + + # Then try more "special" characters. "special" because they may be + # interpreted or displayed differently depending on the exact locale + # encoding and the font. + + # U+00A0 (No-Break Space) + '\u00A0', + # U+20AC (Euro Sign) + '\u20AC', +): + try: + os.fsdecode(os.fsencode(character)) + except UnicodeError: + pass + else: + FS_NONASCII = character + break # TESTFN_UNICODE is a non-ascii filename TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f" @@ -567,6 +610,41 @@ # the byte 0xff. Skip some unicode filename tests. pass +# TESTFN_UNDECODABLE is a filename (bytes type) that should *not* be able to be +# decoded from the filesystem encoding (in strict mode). It can be None if we +# cannot generate such filename (ex: the latin1 encoding can decode any byte +# sequence). On UNIX, TESTFN_UNDECODABLE can be decoded by os.fsdecode() thanks +# to the surrogateescape error handler (PEP 383), but not from the filesystem +# encoding in strict mode. +TESTFN_UNDECODABLE = None +for name in ( + # b'\xff' is not decodable by os.fsdecode() with code page 932. Windows + # accepts it to create a file or a directory, or don't accept to enter to + # such directory (when the bytes name is used). So test b'\xe7' first: it is + # not decodable from cp932. + b'\xe7w\xf0', + # undecodable from ASCII, UTF-8 + b'\xff', + # undecodable from iso8859-3, iso8859-6, iso8859-7, cp424, iso8859-8, cp856 + # and cp857 + b'\xae\xd5' + # undecodable from UTF-8 (UNIX and Mac OS X) + b'\xed\xb2\x80', b'\xed\xb4\x80', + # undecodable from shift_jis, cp869, cp874, cp932, cp1250, cp1251, cp1252, + # cp1253, cp1254, cp1255, cp1257, cp1258 + b'\x81\x98', +): + try: + name.decode(TESTFN_ENCODING) + except UnicodeDecodeError: + TESTFN_UNDECODABLE = os.fsencode(TESTFN) + name + break + +if FS_NONASCII: + TESTFN_NONASCII = TESTFN + '-' + FS_NONASCII +else: + TESTFN_NONASCII = None + # Save the initial cwd SAVEDCWD = os.getcwd() diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py --- a/Lib/test/test_aifc.py +++ b/Lib/test/test_aifc.py @@ -112,6 +112,13 @@ self.assertEqual(testfile.closed, False) f.close() self.assertEqual(testfile.closed, True) + testfile = open(TESTFN, 'wb') + fout = aifc.open(testfile, 'wb') + self.assertFalse(testfile.closed) + with self.assertRaises(aifc.Error): + fout.close() + self.assertTrue(testfile.closed) + fout.close() # do nothing def test_write_header_comptype_sampwidth(self): for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'): @@ -291,11 +298,13 @@ def test_write_header_raises(self): fout = aifc.open(io.BytesIO(), 'wb') self.assertRaises(aifc.Error, fout.close) + fout = aifc.open(io.BytesIO(), 'wb') fout.setnchannels(1) self.assertRaises(aifc.Error, fout.close) + fout = aifc.open(io.BytesIO(), 'wb') + fout.setnchannels(1) fout.setsampwidth(1) self.assertRaises(aifc.Error, fout.close) - fout.initfp(None) def test_write_header_comptype_raises(self): for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'): diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -24,6 +24,7 @@ TEXT = b'root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:\ndaemon:x:2:2:daemon:/sbin:\nadm:x:3:4:adm:/var/adm:\nlp:x:4:7:lp:/var/spool/lpd:\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:\nnews:x:9:13:news:/var/spool/news:\nuucp:x:10:14:uucp:/var/spool/uucp:\noperator:x:11:0:operator:/root:\ngames:x:12:100:games:/usr/games:\ngopher:x:13:30:gopher:/usr/lib/gopher-data:\nftp:x:14:50:FTP User:/var/ftp:/bin/bash\nnobody:x:65534:65534:Nobody:/home:\npostfix:x:100:101:postfix:/var/spool/postfix:\nniemeyer:x:500:500::/home/niemeyer:/bin/bash\npostgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\nmysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\nwww:x:103:104::/var/www:/bin/false\n' DATA = b'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' DATA_CRLF = b'BZh91AY&SY\xaez\xbbN\x00\x01H\xdf\x80\x00\x12@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe0@\x01\xbc\xc6`\x86*\x8d=M\xa9\x9a\x86\xd0L@\x0fI\xa6!\xa1\x13\xc8\x88jdi\x8d@\x03@\x1a\x1a\x0c\x0c\x83 \x00\xc4h2\x19\x01\x82D\x84e\t\xe8\x99\x89\x19\x1ah\x00\r\x1a\x11\xaf\x9b\x0fG\xf5(\x1b\x1f?\t\x12\xcf\xb5\xfc\x95E\x00ps\x89\x12^\xa4\xdd\xa2&\x05(\x87\x04\x98\x89u\xe40%\xb6\x19\'\x8c\xc4\x89\xca\x07\x0e\x1b!\x91UIFU%C\x994!DI\xd2\xfa\xf0\xf1N8W\xde\x13A\xf5\x9cr%?\x9f3;I45A\xd1\x8bT\xb1\xa4\xc7\x8d\x1a\\"\xad\xa1\xabyBg\x15\xb9l\x88\x88\x91k"\x94\xa4\xd4\x89\xae*\xa6\x0b\x10\x0c\xd6\xd4m\xe86\xec\xb5j\x8a\x86j\';\xca.\x01I\xf2\xaaJ\xe8\x88\x8cU+t3\xfb\x0c\n\xa33\x13r2\r\x16\xe0\xb3(\xbf\x1d\x83r\xe7M\xf0D\x1365\xd8\x88\xd3\xa4\x92\xcb2\x06\x04\\\xc1\xb0\xea//\xbek&\xd8\xe6+t\xe5\xa1\x13\xada\x16\xder5"w]\xa2i\xb7[\x97R \xe2IT\xcd;Z\x04dk4\xad\x8a\t\xd3\x81z\x10\xf1:^`\xab\x1f\xc5\xdc\x91N\x14$+\x9e\xae\xd3\x80' + EMPTY_DATA = b'BZh9\x17rE8P\x90\x00\x00\x00\x00' with open(findfile("testbz2_bigmem.bz2"), "rb") as f: DATA_BIGMEM = f.read() @@ -303,6 +304,12 @@ data += bz2c.flush() self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + bz2c = BZ2Compressor() + data = bz2c.compress(b'') + data += bz2c.flush() + self.assertEqual(data, self.EMPTY_DATA) + def testCompressChunks10(self): # "Test BZ2Compressor.compress()/flush() with chunks of 10 bytes" bz2c = BZ2Compressor() @@ -383,6 +390,10 @@ data = bz2.compress(self.TEXT) self.assertEqual(self.decompress(data), self.TEXT) + def testCompressEmptyString(self): + text = bz2.compress(b'') + self.assertEqual(text, self.EMPTY_DATA) + def testDecompress(self): # "Test decompress() function" text = bz2.decompress(self.DATA) @@ -393,6 +404,10 @@ text = bz2.decompress(b"") self.assertEqual(text, b"") + def testDecompressToEmptyString(self): + text = bz2.decompress(self.EMPTY_DATA) + self.assertEqual(text, b'') + def testDecompressIncomplete(self): # "Test decompress() function with incomplete data" self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -770,6 +770,59 @@ with self.assertRaises(configparser.NoSectionError): cf.items("no such section") + def test_popitem(self): + cf = self.fromstring(""" + [section1] + name1 {0[0]} value1 + [section2] + name2 {0[0]} value2 + [section3] + name3 {0[0]} value3 + """.format(self.delimiters), defaults={"default": ""}) + self.assertEqual(cf.popitem()[0], 'section1') + self.assertEqual(cf.popitem()[0], 'section2') + self.assertEqual(cf.popitem()[0], 'section3') + with self.assertRaises(KeyError): + cf.popitem() + + def test_clear(self): + cf = self.newconfig({"foo": "Bar"}) + self.assertEqual( + cf.get(self.default_section, "Foo"), "Bar", + "could not locate option, expecting case-insensitive option names") + cf['zing'] = {'option1': 'value1', 'option2': 'value2'} + self.assertEqual(cf.sections(), ['zing']) + self.assertEqual(set(cf['zing'].keys()), {'option1', 'option2', 'foo'}) + cf.clear() + self.assertEqual(set(cf.sections()), set()) + self.assertEqual(set(cf[self.default_section].keys()), {'foo'}) + + def test_setitem(self): + cf = self.fromstring(""" + [section1] + name1 {0[0]} value1 + [section2] + name2 {0[0]} value2 + [section3] + name3 {0[0]} value3 + """.format(self.delimiters), defaults={"nameD": "valueD"}) + self.assertEqual(set(cf['section1'].keys()), {'name1', 'named'}) + self.assertEqual(set(cf['section2'].keys()), {'name2', 'named'}) + self.assertEqual(set(cf['section3'].keys()), {'name3', 'named'}) + self.assertEqual(cf['section1']['name1'], 'value1') + self.assertEqual(cf['section2']['name2'], 'value2') + self.assertEqual(cf['section3']['name3'], 'value3') + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) + cf['section2'] = {'name22': 'value22'} + self.assertEqual(set(cf['section2'].keys()), {'name22', 'named'}) + self.assertEqual(cf['section2']['name22'], 'value22') + self.assertNotIn('name2', cf['section2']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) + cf['section3'] = {} + self.assertEqual(set(cf['section3'].keys()), {'named'}) + self.assertNotIn('name3', cf['section3']) + self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) + class StrictTestCase(BasicTestCase): config_class = configparser.RawConfigParser diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -100,11 +100,11 @@ # All good if execution is successful assert_python_ok('-c', 'pass') - @unittest.skipIf(sys.getfilesystemencoding() == 'ascii', - 'need a filesystem encoding different than ASCII') + @unittest.skipUnless(test.support.FS_NONASCII, 'need support.FS_NONASCII') def test_non_ascii(self): # Test handling of non-ascii data - command = "assert(ord('\xe9') == 0xe9)" + command = ("assert(ord(%r) == %s)" + % (test.support.FS_NONASCII, ord(test.support.FS_NONASCII))) assert_python_ok('-c', command) # On Windows, pass bytes to subprocess doesn't test how Python decodes the diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -294,6 +294,30 @@ print(out) self.assertEqual(rc, 1) + def test_non_ascii(self): + # Mac OS X denies the creation of a file with an invalid UTF-8 name. + # Windows allows to create a name with an arbitrary bytes name, but + # Python cannot a undecodable bytes argument to a subprocess. + if (support.TESTFN_UNDECODABLE + and sys.platform not in ('win32', 'darwin')): + name = os.fsdecode(support.TESTFN_UNDECODABLE) + elif support.TESTFN_NONASCII: + name = support.TESTFN_NONASCII + else: + self.skipTest("need support.TESTFN_NONASCII") + + # Issue #16218 + source = 'print(ascii(__file__))\n' + script_name = _make_test_script(os.curdir, name, source) + self.addCleanup(support.unlink, script_name) + rc, stdout, stderr = assert_python_ok(script_name) + self.assertEqual( + ascii(script_name), + stdout.rstrip().decode('ascii'), + 'stdout=%r stderr=%r' % (stdout, stderr)) + self.assertEqual(0, rc) + + def test_main(): support.run_unittest(CmdLineTest) support.reap_children() diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -292,11 +292,20 @@ for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'): self.assertIsInstance(abspath(path), str) - @unittest.skipIf(sys.platform == 'darwin', - "Mac OS X denies the creation of a directory with an invalid utf8 name") def test_nonascii_abspath(self): - # Test non-ASCII, non-UTF8 bytes in the path. - with support.temp_cwd(b'\xe7w\xf0'): + if (support.TESTFN_UNDECODABLE + # Mac OS X denies the creation of a directory with an invalid + # UTF-8 name. Windows allows to create a directory with an + # arbitrary bytes name, but fails to enter this directory + # (when the bytes name is used). + and sys.platform not in ('win32', 'darwin')): + name = support.TESTFN_UNDECODABLE + elif support.TESTFN_NONASCII: + name = support.TESTFN_NONASCII + else: + self.skipTest("need support.TESTFN_NONASCII") + + with support.temp_cwd(name): self.test_abspath() diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -1,9 +1,10 @@ -import unittest -from test.support import run_unittest, TESTFN, skip_unless_symlink, can_symlink import glob import os import shutil import sys +import unittest + +from test.support import run_unittest, TESTFN, skip_unless_symlink, can_symlink class GlobTests(unittest.TestCase): @@ -31,7 +32,8 @@ self.mktemp('a', 'bcd', 'efg', 'ha') if can_symlink(): os.symlink(self.norm('broken'), self.norm('sym1')) - os.symlink(self.norm('broken'), self.norm('sym2')) + os.symlink('broken', self.norm('sym2')) + os.symlink(os.path.join('a', 'bcd'), self.norm('sym3')) def tearDown(self): shutil.rmtree(self.tempdir) @@ -44,10 +46,16 @@ p = os.path.join(self.tempdir, pattern) res = glob.glob(p) self.assertEqual(list(glob.iglob(p)), res) + bres = [os.fsencode(x) for x in res] + self.assertEqual(glob.glob(os.fsencode(p)), bres) + self.assertEqual(list(glob.iglob(os.fsencode(p))), bres) return res def assertSequencesEqual_noorder(self, l1, l2): + l1 = list(l1) + l2 = list(l2) self.assertEqual(set(l1), set(l2)) + self.assertEqual(sorted(l1), sorted(l2)) def test_glob_literal(self): eq = self.assertSequencesEqual_noorder @@ -56,15 +64,15 @@ eq(self.glob('aab'), [self.norm('aab')]) eq(self.glob('zymurgy'), []) - # test return types are unicode, but only if os.listdir - # returns unicode filenames - uniset = set([str]) - tmp = os.listdir('.') - if set(type(x) for x in tmp) == uniset: - u1 = glob.glob('*') - u2 = glob.glob('./*') - self.assertEqual(set(type(r) for r in u1), uniset) - self.assertEqual(set(type(r) for r in u2), uniset) + res = glob.glob('*') + self.assertEqual({type(r) for r in res}, {str}) + res = glob.glob(os.path.join(os.curdir, '*')) + self.assertEqual({type(r) for r in res}, {str}) + + res = glob.glob(b'*') + self.assertEqual({type(r) for r in res}, {bytes}) + res = glob.glob(os.path.join(os.fsencode(os.curdir), b'*')) + self.assertEqual({type(r) for r in res}, {bytes}) def test_glob_one_directory(self): eq = self.assertSequencesEqual_noorder @@ -93,20 +101,20 @@ eq(self.glob('*', '*a'), []) eq(self.glob('a', '*', '*', '*a'), [self.norm('a', 'bcd', 'efg', 'ha')]) - eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'), - os.path.join('aab', 'F')])) + eq(self.glob('?a?', '*F'), [self.norm('aaa', 'zzzF'), + self.norm('aab', 'F')]) def test_glob_directory_with_trailing_slash(self): # Patterns ending with a slash shouldn't match non-dirs - res = glob.glob(os.path.join(self.tempdir, 'Z*Z') + os.sep) + res = glob.glob(self.norm('Z*Z') + os.sep) self.assertEqual(res, []) - res = glob.glob(os.path.join(self.tempdir, 'ZZZ') + os.sep) + res = glob.glob(self.norm('ZZZ') + os.sep) self.assertEqual(res, []) - # When there is wildcard pattern which ends with os.sep, glob() + # When there is a wildcard pattern which ends with os.sep, glob() # doesn't blow up. - res = glob.glob(os.path.join(self.tempdir, 'aa*') + os.sep) + res = glob.glob(self.norm('aa*') + os.sep) self.assertEqual(len(res), 2) - # either of these results are reasonable + # either of these results is reasonable self.assertIn(set(res), [ {self.norm('aaa'), self.norm('aab')}, {self.norm('aaa') + os.sep, self.norm('aab') + os.sep}, @@ -115,22 +123,37 @@ def test_glob_bytes_directory_with_trailing_slash(self): # Same as test_glob_directory_with_trailing_slash, but with a # bytes argument. - res = glob.glob(os.fsencode(os.path.join(self.tempdir, 'Z*Z') + os.sep)) + res = glob.glob(os.fsencode(self.norm('Z*Z') + os.sep)) self.assertEqual(res, []) - res = glob.glob(os.fsencode(os.path.join(self.tempdir, 'ZZZ') + os.sep)) + res = glob.glob(os.fsencode(self.norm('ZZZ') + os.sep)) self.assertEqual(res, []) - res = glob.glob(os.fsencode(os.path.join(self.tempdir, 'aa*') + os.sep)) + res = glob.glob(os.fsencode(self.norm('aa*') + os.sep)) self.assertEqual(len(res), 2) - # either of these results are reasonable - self.assertIn({os.fsdecode(x) for x in res}, [ - {self.norm('aaa'), self.norm('aab')}, - {self.norm('aaa') + os.sep, self.norm('aab') + os.sep}, + # either of these results is reasonable + self.assertIn(set(res), [ + {os.fsencode(self.norm('aaa')), + os.fsencode(self.norm('aab'))}, + {os.fsencode(self.norm('aaa') + os.sep), + os.fsencode(self.norm('aab') + os.sep)}, ]) @skip_unless_symlink + def test_glob_symlinks(self): + eq = self.assertSequencesEqual_noorder + eq(self.glob('sym3'), [self.norm('sym3')]) + eq(self.glob('sym3', '*'), [self.norm('sym3', 'EF'), + self.norm('sym3', 'efg')]) + self.assertIn(self.glob('sym3' + os.sep), + [[self.norm('sym3')], [self.norm('sym3') + os.sep]]) + eq(self.glob('*', '*F'), + [self.norm('aaa', 'zzzF'), + self.norm('aab', 'F'), self.norm('sym3', 'EF')]) + + @skip_unless_symlink def test_glob_broken_symlinks(self): eq = self.assertSequencesEqual_noorder - eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2')]) + eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2'), + self.norm('sym3')]) eq(self.glob('sym1'), [self.norm('sym1')]) eq(self.glob('sym2'), [self.norm('sym2')]) diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py --- a/Lib/test/test_int.py +++ b/Lib/test/test_int.py @@ -1,6 +1,7 @@ import sys import unittest +from test import support from test.support import run_unittest L = [ @@ -100,10 +101,6 @@ self.assertRaises(ValueError, int, "0b", 2) self.assertRaises(ValueError, int, "0b", 0) - # Bug #3236: Return small longs from PyLong_FromString - self.assertTrue(int("10") is 10) - self.assertTrue(int("-1") is -1) - # SF bug 1334662: int(string, base) wrong answers # Various representations of 2**32 evaluated to 0 # rather than 2**32 in previous versions @@ -221,6 +218,22 @@ self.assertEqual(int('2br45qc', 35), 4294967297) self.assertEqual(int('1z141z5', 36), 4294967297) + @support.cpython_only + def test_small_ints(self): + # Bug #3236: Return small longs from PyLong_FromString + self.assertIs(int('10'), 10) + self.assertIs(int('-1'), -1) + self.assertIs(int(b'10'), 10) + self.assertIs(int(b'-1'), -1) + + def test_keyword_args(self): + # Test invoking int() using keyword arguments. + self.assertEqual(int(x=1.2), 1) + self.assertEqual(int('100', base=2), 4) + self.assertEqual(int(x='100', base=2), 4) + self.assertRaises(TypeError, int, base=10) + self.assertRaises(TypeError, int, base=0) + def test_intconversion(self): # Test __int__() class ClassicMissingMethods: diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1574,6 +1574,7 @@ self.assertTimingAlmostEqual(poll.elapsed, TIMEOUT1) conn.send(None) + time.sleep(.1) self.assertEqual(poll(TIMEOUT1), True) self.assertTimingAlmostEqual(poll.elapsed, 0) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -634,6 +634,50 @@ os.removedirs(path) + +class RemoveDirsTests(unittest.TestCase): + def setUp(self): + os.makedirs(support.TESTFN) + + def tearDown(self): + support.rmtree(support.TESTFN) + + def test_remove_all(self): + dira = os.path.join(support.TESTFN, 'dira') + os.mkdir(dira) + dirb = os.path.join(dira, 'dirb') + os.mkdir(dirb) + os.removedirs(dirb) + self.assertFalse(os.path.exists(dirb)) + self.assertFalse(os.path.exists(dira)) + self.assertFalse(os.path.exists(support.TESTFN)) + + def test_remove_partial(self): + dira = os.path.join(support.TESTFN, 'dira') + os.mkdir(dira) + dirb = os.path.join(dira, 'dirb') + os.mkdir(dirb) + with open(os.path.join(dira, 'file.txt'), 'w') as f: + f.write('text') + os.removedirs(dirb) + self.assertFalse(os.path.exists(dirb)) + self.assertTrue(os.path.exists(dira)) + self.assertTrue(os.path.exists(support.TESTFN)) + + def test_remove_nothing(self): + dira = os.path.join(support.TESTFN, 'dira') + os.mkdir(dira) + dirb = os.path.join(dira, 'dirb') + os.mkdir(dirb) + with open(os.path.join(dirb, 'file.txt'), 'w') as f: + f.write('text') + with self.assertRaises(OSError): + os.removedirs(dirb) + self.assertTrue(os.path.exists(dirb)) + self.assertTrue(os.path.exists(dira)) + self.assertTrue(os.path.exists(support.TESTFN)) + + class DevNullTests(unittest.TestCase): def test_devnull(self): with open(os.devnull, 'wb') as f: @@ -642,6 +686,7 @@ with open(os.devnull, 'rb') as f: self.assertEqual(f.read(), b'') + class URandomTests(unittest.TestCase): def test_urandom_length(self): self.assertEqual(len(os.urandom(0)), 0) @@ -968,6 +1013,8 @@ def setUp(self): if support.TESTFN_UNENCODABLE: self.dir = support.TESTFN_UNENCODABLE + elif support.TESTFN_NONASCII: + self.dir = support.TESTFN_NONASCII else: self.dir = support.TESTFN self.bdir = os.fsencode(self.dir) @@ -982,6 +1029,8 @@ add_filename(support.TESTFN_UNICODE) if support.TESTFN_UNENCODABLE: add_filename(support.TESTFN_UNENCODABLE) + if support.TESTFN_NONASCII: + add_filename(support.TESTFN_NONASCII) if not bytesfn: self.skipTest("couldn't create any non-ascii filename") @@ -1012,6 +1061,15 @@ f = open(os.path.join(self.dir, fn), 'rb') f.close() + @unittest.skipUnless(hasattr(os, 'statvfs'), + "need os.statvfs()") + def test_statvfs(self): + # issue #9645 + for fn in self.unicodefn: + # should not fail with file not found error + fullname = os.path.join(self.dir, fn) + os.statvfs(fullname) + def test_stat(self): for fn in self.unicodefn: os.stat(os.path.join(self.dir, fn)) @@ -1310,6 +1368,7 @@ PidTests, LoginTests, LinkTests, + RemoveDirsTests, ) if __name__ == "__main__": diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -558,6 +558,17 @@ finally: s.close() + def test_connect_ex_error(self): + with support.transient_internet("svn.python.org"): + s = ssl.wrap_socket(socket.socket(socket.AF_INET), + cert_reqs=ssl.CERT_REQUIRED, + ca_certs=SVN_PYTHON_ORG_ROOT_CERT) + try: + self.assertEqual(errno.ECONNREFUSED, + s.connect_ex(("svn.python.org", 444))) + finally: + s.close() + def test_connect_with_context(self): with support.transient_internet("svn.python.org"): # Same as test_connect, but with a separately created context diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -2023,8 +2023,7 @@ stderr=subprocess.PIPE) as proc: pass - if c.exception.errno != errno.ENOENT: # ignore "no such file" - raise c.exception + self.assertEqual(c.exception.errno, errno.ENOENT) def test_main(): diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -328,31 +328,21 @@ @support.skip_unless_symlink def test_extract_hardlink(self): # Test hardlink extraction (e.g. bug #857297). - tar = tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") + with tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") as tar: + tar.extract("ustar/regtype", TEMPDIR) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/regtype")) - try: - tar.extract("ustar/regtype", TEMPDIR) - try: - tar.extract("ustar/lnktype", TEMPDIR) - except EnvironmentError as e: - if e.errno == errno.ENOENT: - self.fail("hardlink not extracted properly") - + tar.extract("ustar/lnktype", TEMPDIR) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/lnktype")) with open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb") as f: data = f.read() self.assertEqual(md5sum(data), md5_regtype) - try: - tar.extract("ustar/symtype", TEMPDIR) - except EnvironmentError as e: - if e.errno == errno.ENOENT: - self.fail("symlink not extracted properly") - + tar.extract("ustar/symtype", TEMPDIR) + self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/symtype")) with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f: data = f.read() self.assertEqual(md5sum(data), md5_regtype) - finally: - tar.close() def test_extractall(self): # Test if extractall() correctly restores directory permissions diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1438,16 +1438,32 @@ req = Request(url) self.assertEqual(req.get_full_url(), url) -def test_HTTPError_interface(): - """ - Issue 13211 reveals that HTTPError didn't implement the URLError - interface even though HTTPError is a subclass of URLError. + def test_HTTPError_interface(self): + """ + Issue 13211 reveals that HTTPError didn't implement the URLError + interface even though HTTPError is a subclass of URLError. - >>> err = urllib.error.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) - >>> assert hasattr(err, 'reason') - >>> err.reason - 'something bad happened' - """ + >>> err = urllib.error.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) + >>> assert hasattr(err, 'reason') + >>> err.reason + 'something bad happened' + """ + + def test_HTTPError_interface_call(self): + """ + Issue 15701 - HTTPError interface has info method available from URLError + """ + err = urllib.request.HTTPError(msg="something bad happened", url=None, + code=None, hdrs='Content-Length:42', fp=None) + self.assertTrue(hasattr(err, 'reason')) + assert hasattr(err, 'reason') + assert hasattr(err, 'info') + assert callable(err.info) + try: + err.info() + except AttributeError: + self.fail('err.info call failed.') + self.assertEqual(err.info(), "Content-Length:42") def test_main(verbose=None): from test import test_urllib2 diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -352,6 +352,8 @@ def setUp(self): super(TestUrlopen, self).setUp() + # Ignore proxies for localhost tests. + os.environ['NO_PROXY'] = '*' self.server = None def tearDown(self): diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -818,6 +818,35 @@ p2 = urllib.parse.urlsplit('tel:+31641044153') self.assertEqual(p2.scheme, 'tel') self.assertEqual(p2.path, '+31641044153') + # assert the behavior for urlparse + p1 = urllib.parse.urlparse('tel:+31-641044153') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+31-641044153') + p2 = urllib.parse.urlparse('tel:+31641044153') + self.assertEqual(p2.scheme, 'tel') + self.assertEqual(p2.path, '+31641044153') + + def test_telurl_params(self): + p1 = urllib.parse.urlparse('tel:123-4;phone-context=+1-650-516') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '123-4') + self.assertEqual(p1.params, 'phone-context=+1-650-516') + + p1 = urllib.parse.urlparse('tel:+1-201-555-0123') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+1-201-555-0123') + self.assertEqual(p1.params, '') + + p1 = urllib.parse.urlparse('tel:7042;phone-context=example.com') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '7042') + self.assertEqual(p1.params, 'phone-context=example.com') + + p1 = urllib.parse.urlparse('tel:863-1234;phone-context=+1-914-555') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '863-1234') + self.assertEqual(p1.params, 'phone-context=+1-914-555') + def test_main(): support.run_unittest(UrlParseTestCase) diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -323,6 +323,35 @@ finally: DeleteKey(HKEY_CURRENT_USER, test_key_name) + def test_setvalueex_value_range(self): + # Test for Issue #14420, accept proper ranges for SetValueEx. + # Py2Reg, which gets called by SetValueEx, was using PyLong_AsLong, + # thus raising OverflowError. The implementation now uses + # PyLong_AsUnsignedLong to match DWORD's size. + try: + with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: + self.assertNotEqual(ck.handle, 0) + SetValueEx(ck, "test_name", None, REG_DWORD, 0x80000000) + finally: + DeleteKey(HKEY_CURRENT_USER, test_key_name) + + def test_queryvalueex_return_value(self): + # Test for Issue #16759, return unsigned int from QueryValueEx. + # Reg2Py, which gets called by QueryValueEx, was returning a value + # generated by PyLong_FromLong. The implmentation now uses + # PyLong_FromUnsignedLong to match DWORD's size. + try: + with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: + self.assertNotEqual(ck.handle, 0) + test_val = 0x80000000 + SetValueEx(ck, "test_name", None, REG_DWORD, test_val) + ret_val, ret_type = QueryValueEx(ck, "test_name") + self.assertEqual(ret_type, REG_DWORD) + self.assertEqual(ret_val, test_val) + finally: + DeleteKey(HKEY_CURRENT_USER, test_key_name) + + @unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests") class RemoteWinregTests(BaseWinregTests): diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -380,7 +380,7 @@ background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor.""" self.tk.call(('tk_setPalette',) - + _flatten(args) + _flatten(kw.items())) + + _flatten(args) + _flatten(list(kw.items()))) def tk_menuBar(self, *args): """Do not use. Needed in Tk 3.6 and earlier.""" pass # obsolete since Tk 4.0 diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py new file mode 100644 --- /dev/null +++ b/Lib/tkinter/test/test_tkinter/test_misc.py @@ -0,0 +1,45 @@ +import unittest +import tkinter +from tkinter import ttk +from test import support + +support.requires('gui') + +class MiscTest(unittest.TestCase): + + def setUp(self): + self.root = ttk.setup_master() + + def test_tk_setPalette(self): + root = self.root + root.tk_setPalette('black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette('white') + self.assertEqual(root['background'], 'white') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, 'spam') + + root.tk_setPalette(background='black') + self.assertEqual(root['background'], 'black') + root.tk_setPalette(background='blue', highlightColor='yellow') + self.assertEqual(root['background'], 'blue') + self.assertEqual(root['highlightcolor'], 'yellow') + root.tk_setPalette(background='yellow', highlightColor='blue') + self.assertEqual(root['background'], 'yellow') + self.assertEqual(root['highlightcolor'], 'blue') + self.assertRaisesRegex(tkinter.TclError, + '^unknown color name "spam"$', + root.tk_setPalette, background='spam') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, spam='white') + self.assertRaisesRegex(tkinter.TclError, + '^must specify a background color$', + root.tk_setPalette, highlightColor='blue') + + +tests_gui = (MiscTest, ) + +if __name__ == "__main__": + support.run_unittest(*tests_gui) diff --git a/Lib/urllib/error.py b/Lib/urllib/error.py --- a/Lib/urllib/error.py +++ b/Lib/urllib/error.py @@ -58,6 +58,10 @@ def reason(self): return self.msg + def info(self): + return self.hdrs + + # exception raised when downloaded size does not match content-length class ContentTooShortError(URLError): def __init__(self, message, content): diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -46,7 +46,7 @@ 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh'] uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', - 'mms', '', 'sftp'] + 'mms', '', 'sftp', 'tel'] # These are not actually used anymore, but should stay for backwards # compatibility. (They are undocumented, but have a public-looking name.) diff --git a/Mac/IDLE/IDLE.app/Contents/Info.plist b/Mac/IDLE/IDLE.app/Contents/Info.plist --- a/Mac/IDLE/IDLE.app/Contents/Info.plist +++ b/Mac/IDLE/IDLE.app/Contents/Info.plist @@ -36,7 +36,7 @@ CFBundleExecutable IDLE CFBundleGetInfoString - %version%, ? 2001-2012 Python Software Foundation + %version%, ? 2001-2013 Python Software Foundation CFBundleIconFile IDLE.icns CFBundleIdentifier diff --git a/Mac/PythonLauncher/Info.plist.in b/Mac/PythonLauncher/Info.plist.in --- a/Mac/PythonLauncher/Info.plist.in +++ b/Mac/PythonLauncher/Info.plist.in @@ -40,7 +40,7 @@ CFBundleExecutable PythonLauncher CFBundleGetInfoString - %VERSION%, ? 2001-2012 Python Software Foundation + %VERSION%, ? 2001-2013 Python Software Foundation CFBundleIconFile PythonLauncher.icns CFBundleIdentifier diff --git a/Mac/Resources/app/Info.plist.in b/Mac/Resources/app/Info.plist.in --- a/Mac/Resources/app/Info.plist.in +++ b/Mac/Resources/app/Info.plist.in @@ -20,7 +20,7 @@ CFBundleExecutable Python CFBundleGetInfoString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleHelpBookFolder Documentation @@ -37,7 +37,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - %version%, (c) 2004-2012 Python Software Foundation. + %version%, (c) 2004-2013 Python Software Foundation. CFBundleName Python CFBundlePackageType @@ -55,6 +55,6 @@ NSAppleScriptEnabled NSHumanReadableCopyright - (c) 2012 Python Software Foundation. + (c) 2013 Python Software Foundation. diff --git a/Mac/Resources/framework/Info.plist.in b/Mac/Resources/framework/Info.plist.in --- a/Mac/Resources/framework/Info.plist.in +++ b/Mac/Resources/framework/Info.plist.in @@ -17,9 +17,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleLongVersionString - %VERSION%, (c) 2004-2012 Python Software Foundation. + %VERSION%, (c) 2004-2013 Python Software Foundation. CFBundleSignature ???? CFBundleVersion diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -543,6 +543,7 @@ Rafe Kaplan Jacob Kaplan-Moss Jan Kaliszewski +Anton Kasyanov Lou Kates Hiroaki Kawai Sebastien Keim @@ -800,6 +801,7 @@ R. M. Oudkerk Russel Owen Joonas Paalasmaa +Martin Packman Shriphani Palakodety Ondrej Palkovsky Mike Pall @@ -946,6 +948,7 @@ Andreas Schawo Neil Schemenauer David Scherer +Wolfgang Scherer Hynek Schlawack Bob Schmertz Gregor Schmid @@ -1077,6 +1080,7 @@ Matias Torchinsky Sandro Tosi Richard Townsend +Nathan Trapuzzano Laurence Tratt John Tromp Jason Trowbridge diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,23 @@ Core and Builtins ----------------- +- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. + +- Issue #16455: On FreeBSD and Solaris, if the locale is C, the + ASCII/surrogateescape codec is now used, instead of the locale encoding, to + decode the command line arguments. This change fixes inconsistencies with + os.fsencode() and os.fsdecode() because these operating systems announces an + ASCII locale encoding, whereas the ISO-8859-1 encoding is used in practice. + +- Issue #16761: Calling int() with base argument only now raises TypeError. + +- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py + when retreiving a REG_DWORD value. This corrects functions like + winreg.QueryValueEx that may have been returning truncated values. + +- Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg + when passed a REG_DWORD value. Fixes OverflowError in winreg.SetValueEx. + - Issue #16602: When a weakref's target was part of a long deallocation chain, the object could remain reachable through its weakref even though its refcount had dropped to zero. @@ -179,6 +196,51 @@ Library ------- +- Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by + Martin Packman. + +- Issue #16541: tk_setPalette() now works with keyword arguments. + +- Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError. + This makes `parser.clean()` work correctly. + +- Issue #16820: In configparser, ``parser['section'] = {}`` now preserves + section order within the parser. This makes `parser.update()` preserve section + order as well. + +- Issue #9644: Fix the encoding used by os.statvfs(): use the filesystem + encoding with the surrogateescape error handler, instead of UTF-8 in strict + mode. + +- Issue #16819: IDLE method completion now correctly works for bytes literals. + +- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. + +- Issue 10527: make multiprocessing use poll() instead of select() if available. + +- Issue #16485: Now file descriptors are closed if file header patching failed + on closing an aifc file. + +- Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by + Roger Serwy. + +- Issue #16618: Make glob.glob match consistently across strings and bytes + regarding leading dots. Patch by Serhiy Storchaka. + +- Issue #16702: test_urllib2_localnet tests now correctly ignores proxies for + localhost tests. + +- Issue #16511: Use default IDLE width and height if config param is not valid. + Patch Serhiy Storchaka. + +- Issue #16713: Parsing of 'tel' urls using urlparse separates params from + path. + +- Issue #16443: Add docstrings to regular expression match objects. + Patch by Anton Kasyanov. + +- Issue #15701: Fix HTTPError info method call to return the headers information. + - Issue #16646: ftplib.FTP.makeport() might lose socket error details. (patch by Serhiy Storchaka) @@ -696,6 +758,9 @@ Tests ----- +- Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize + options. + - Issue #16664: Add regression tests for glob's behaviour concerning entries starting with a ".". Patch by Sebastian Kreft. diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -825,11 +825,11 @@ space[0] = errno; errno = temp; } - Py_XDECREF(error_object); #ifdef WITH_THREAD if ((flags & FUNCFLAG_PYTHONAPI) == 0) Py_BLOCK_THREADS #endif + Py_XDECREF(error_object); #ifdef MS_WIN32 #ifndef DONT_USE_SEH if (dwExceptionCode) { diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -558,7 +558,7 @@ { PyObject *result; Py_ssize_t total = 0; - int n; + Py_ssize_t n; if (self->fd < 0) return err_closed(); @@ -591,9 +591,18 @@ } Py_BEGIN_ALLOW_THREADS errno = 0; + n = newsize - total; +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (n > INT_MAX) + n = INT_MAX; n = read(self->fd, PyBytes_AS_STRING(result) + total, - newsize - total); + (int)n); +#else + n = read(self->fd, + PyBytes_AS_STRING(result) + total, + n); +#endif Py_END_ALLOW_THREADS if (n == 0) break; diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -197,6 +197,13 @@ #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) +/* OS X 10.4 defines SEM_FAILED as -1 instead of (sem_t *)-1; this gives + compiler warnings, and (potentially) undefined behaviour. */ +#ifdef __APPLE__ +# undef SEM_FAILED +# define SEM_FAILED ((sem_t *)-1) +#endif + #ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2559,35 +2559,35 @@ } PyDoc_STRVAR(pattern_match_doc, -"match(string[, pos[, endpos]]) --> match object or None.\n\ +"match(string[, pos[, endpos]]) -> match object or None.\n\n\ Matches zero or more characters at the beginning of the string"); PyDoc_STRVAR(pattern_search_doc, -"search(string[, pos[, endpos]]) --> match object or None.\n\ +"search(string[, pos[, endpos]]) -> match object or None.\n\n\ Scan through string looking for a match, and return a corresponding\n\ - MatchObject instance. Return None if no position in the string matches."); + match object instance. Return None if no position in the string matches."); PyDoc_STRVAR(pattern_split_doc, -"split(string[, maxsplit = 0]) --> list.\n\ +"split(string[, maxsplit = 0]) -> list.\n\n\ Split string by the occurrences of pattern."); PyDoc_STRVAR(pattern_findall_doc, -"findall(string[, pos[, endpos]]) --> list.\n\ +"findall(string[, pos[, endpos]]) -> list.\n\n\ Return a list of all non-overlapping matches of pattern in string."); PyDoc_STRVAR(pattern_finditer_doc, -"finditer(string[, pos[, endpos]]) --> iterator.\n\ +"finditer(string[, pos[, endpos]]) -> iterator.\n\n\ Return an iterator over all non-overlapping matches for the \n\ RE pattern in string. For each match, the iterator returns a\n\ match object."); PyDoc_STRVAR(pattern_sub_doc, -"sub(repl, string[, count = 0]) --> newstring\n\ +"sub(repl, string[, count = 0]) -> newstring.\n\n\ Return the string obtained by replacing the leftmost non-overlapping\n\ occurrences of pattern in string by the replacement repl."); PyDoc_STRVAR(pattern_subn_doc, -"subn(repl, string[, count = 0]) --> (newstring, number of subs)\n\ +"subn(repl, string[, count = 0]) -> (newstring, number of subs)\n\n\ Return the tuple (new_string, number_of_subs_made) found by replacing\n\ the leftmost non-overlapping occurrences of pattern with the\n\ replacement repl."); @@ -3579,14 +3579,54 @@ #endif } +PyDoc_STRVAR(match_doc, +"The result of re.match() and re.search().\n\ +Match objects always have a boolean value of True."); + +PyDoc_STRVAR(match_group_doc, +"group([group1, ...]) -> str or tuple.\n\n\ + Return subgroup(s) of the match by indices or names.\n\ + For 0 returns the entire match."); + +PyDoc_STRVAR(match_start_doc, +"start([group=0]) -> int.\n\n\ + Return index of the start of the substring matched by group."); + +PyDoc_STRVAR(match_end_doc, +"end([group=0]) -> int.\n\n\ + Return index of the end of the substring matched by group."); + +PyDoc_STRVAR(match_span_doc, +"span([group]) -> tuple.\n\n\ + For MatchObject m, return the 2-tuple (m.start(group), m.end(group))."); + +PyDoc_STRVAR(match_groups_doc, +"groups([default=None]) -> tuple.\n\n\ + Return a tuple containing all the subgroups of the match, from 1.\n\ + The default argument is used for groups\n\ + that did not participate in the match"); + +PyDoc_STRVAR(match_groupdict_doc, +"groupdict([default=None]) -> dict.\n\n\ + Return a dictionary containing all the named subgroups of the match,\n\ + keyed by the subgroup name. The default argument is used for groups\n\ + that did not participate in the match"); + +PyDoc_STRVAR(match_expand_doc, +"expand(template) -> str.\n\n\ + Return the string obtained by doing backslash substitution\n\ + on the string template, as done by the sub() method."); + static PyMethodDef match_methods[] = { - {"group", (PyCFunction) match_group, METH_VARARGS}, - {"start", (PyCFunction) match_start, METH_VARARGS}, - {"end", (PyCFunction) match_end, METH_VARARGS}, - {"span", (PyCFunction) match_span, METH_VARARGS}, - {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS}, - {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS}, - {"expand", (PyCFunction) match_expand, METH_O}, + {"group", (PyCFunction) match_group, METH_VARARGS, match_group_doc}, + {"start", (PyCFunction) match_start, METH_VARARGS, match_start_doc}, + {"end", (PyCFunction) match_end, METH_VARARGS, match_end_doc}, + {"span", (PyCFunction) match_span, METH_VARARGS, match_span_doc}, + {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS, + match_groups_doc}, + {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS, + match_groupdict_doc}, + {"expand", (PyCFunction) match_expand, METH_O, match_expand_doc}, {"__copy__", (PyCFunction) match_copy, METH_NOARGS}, {"__deepcopy__", (PyCFunction) match_deepcopy, METH_O}, {NULL, NULL} @@ -3665,7 +3705,7 @@ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ - 0, /* tp_doc */ + match_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/Modules/bz2module.c b/Modules/bz2module.c --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -1979,7 +1979,7 @@ return NULL; } - action = BZ_RUN; + action = input_left > 0 ? BZ_RUN : BZ_FINISH; for (;;) { char *saved_next_out; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6463,18 +6463,22 @@ static PyObject * posix_statvfs(PyObject *self, PyObject *args) { + PyObject *opath, *result = NULL; char *path; int res; struct statvfs st; - if (!PyArg_ParseTuple(args, "s:statvfs", &path)) - return NULL; + if (!PyArg_ParseTuple(args, "O&:statvfs", PyUnicode_FSConverter, &opath)) + return NULL; + path = PyBytes_AS_STRING(opath); Py_BEGIN_ALLOW_THREADS res = statvfs(path, &st); Py_END_ALLOW_THREADS if (res != 0) - return posix_error_with_filename(path); - - return _pystatvfs_fromstructstatvfs(st); + return posix_error_with_allocated_filename(opath); + + result = _pystatvfs_fromstructstatvfs(st); + Py_DECREF(opath); + return result; } #endif /* HAVE_STATVFS */ diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4130,8 +4130,14 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:int", kwlist, &x, &obase)) return NULL; - if (x == NULL) + if (x == NULL) { + if (obase != NULL) { + PyErr_SetString(PyExc_TypeError, + "int() missing string argument"); + return NULL; + } return PyLong_FromLong(0L); + } if (obase == NULL) return PyNumber_Long(x); @@ -4140,7 +4146,7 @@ return NULL; if (overflow || (base != 0 && base < 2) || base > 36) { PyErr_SetString(PyExc_ValueError, - "int() arg 2 must be >= 2 and <= 36"); + "int() base must be >= 2 and <= 36"); return NULL; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1434,8 +1434,8 @@ /* Convert encoding to lower case and replace '_' with '-' in order to catch e.g. UTF_8. Return 0 on error (encoding is longer than lower_len-1), 1 on success. */ -static int -normalize_encoding(const char *encoding, +int +_Py_normalize_encoding(const char *encoding, char *lower, size_t lower_len) { @@ -1477,7 +1477,7 @@ encoding = PyUnicode_GetDefaultEncoding(); /* Shortcuts for common default encodings */ - if (normalize_encoding(encoding, lower, sizeof(lower))) { + if (_Py_normalize_encoding(encoding, lower, sizeof(lower))) { if (strcmp(lower, "utf-8") == 0) return PyUnicode_DecodeUTF8(s, size, errors); else if ((strcmp(lower, "latin-1") == 0) || @@ -1695,7 +1695,7 @@ encoding = PyUnicode_GetDefaultEncoding(); /* Shortcuts for common default encodings */ - if (normalize_encoding(encoding, lower, sizeof(lower))) { + if (_Py_normalize_encoding(encoding, lower, sizeof(lower))) { if (strcmp(lower, "utf-8") == 0) return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode), PyUnicode_GET_SIZE(unicode), diff --git a/PC/winreg.c b/PC/winreg.c --- a/PC/winreg.c +++ b/PC/winreg.c @@ -785,7 +785,7 @@ memcpy(*retDataBuf, &zero, sizeof(DWORD)); } else { - DWORD d = PyLong_AsLong(value); + DWORD d = PyLong_AsUnsignedLong(value); memcpy(*retDataBuf, &d, sizeof(DWORD)); } break; @@ -900,9 +900,9 @@ switch (typ) { case REG_DWORD: if (retDataSize == 0) - obData = PyLong_FromLong(0); + obData = PyLong_FromUnsignedLong(0); else - obData = PyLong_FromLong(*(int *)retDataBuf); + obData = PyLong_FromUnsignedLong(*(int *)retDataBuf); break; case REG_SZ: case REG_EXPAND_SZ: diff --git a/Python/fileutils.c b/Python/fileutils.c --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -3,11 +3,191 @@ # include #endif +#ifdef HAVE_LANGINFO_H +#include +#include +#endif + #ifdef __APPLE__ extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size); #endif -#ifdef HAVE_STAT +#if !defined(__APPLE__) && !defined(MS_WINDOWS) +extern int _Py_normalize_encoding(const char *, char *, size_t); + +/* Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale. + On these operating systems, nl_langinfo(CODESET) announces an alias of the + ASCII encoding, whereas mbstowcs() and wcstombs() functions use the + ISO-8859-1 encoding. The problem is that os.fsencode() and os.fsdecode() use + locale.getpreferredencoding() codec. For example, if command line arguments + are decoded by mbstowcs() and encoded back by os.fsencode(), we get a + UnicodeEncodeError instead of retrieving the original byte string. + + The workaround is enabled if setlocale(LC_CTYPE, NULL) returns "C", + nl_langinfo(CODESET) announces "ascii" (or an alias to ASCII), and at least + one byte in range 0x80-0xff can be decoded from the locale encoding. The + workaround is also enabled on error, for example if getting the locale + failed. + + Values of locale_is_ascii: + + 1: the workaround is used: _Py_wchar2char() uses + encode_ascii_surrogateescape() and _Py_char2wchar() uses + decode_ascii_surrogateescape() + 0: the workaround is not used: _Py_wchar2char() uses wcstombs() and + _Py_char2wchar() uses mbstowcs() + -1: unknown, need to call check_force_ascii() to get the value +*/ +static int force_ascii = -1; + +static int +check_force_ascii(void) +{ + char *loc; +#if defined(HAVE_LANGINFO_H) && defined(CODESET) + char *codeset, **alias; + char encoding[100]; + int is_ascii; + unsigned int i; + char* ascii_aliases[] = { + "ascii", + "646", + "ansi-x3.4-1968", + "ansi-x3-4-1968", + "ansi-x3.4-1986", + "cp367", + "csascii", + "ibm367", + "iso646-us", + "iso-646.irv-1991", + "iso-ir-6", + "us", + "us-ascii", + NULL + }; +#endif + + loc = setlocale(LC_CTYPE, NULL); + if (loc == NULL) + goto error; + if (strcmp(loc, "C") != 0) { + /* the LC_CTYPE locale is different than C */ + return 0; + } + +#if defined(HAVE_LANGINFO_H) && defined(CODESET) + codeset = nl_langinfo(CODESET); + if (!codeset || codeset[0] == '\0') { + /* CODESET is not set or empty */ + goto error; + } + if (!_Py_normalize_encoding(codeset, encoding, sizeof(encoding))) + goto error; + + is_ascii = 0; + for (alias=ascii_aliases; *alias != NULL; alias++) { + if (strcmp(encoding, *alias) == 0) { + is_ascii = 1; + break; + } + } + if (!is_ascii) { + /* nl_langinfo(CODESET) is not "ascii" or an alias of ASCII */ + return 0; + } + + for (i=0x80; i<0xff; i++) { + unsigned char ch; + wchar_t wch; + size_t res; + + ch = (unsigned char)i; + res = mbstowcs(&wch, (char*)&ch, 1); + if (res != (size_t)-1) { + /* decoding a non-ASCII character from the locale encoding succeed: + the locale encoding is not ASCII, force ASCII */ + return 1; + } + } + /* None of the bytes in the range 0x80-0xff can be decoded from the locale + encoding: the locale encoding is really ASCII */ + return 0; +#else + /* nl_langinfo(CODESET) is not available: always force ASCII */ + return 1; +#endif + +error: + /* if an error occured, force the ASCII encoding */ + return 1; +} + +static char* +encode_ascii_surrogateescape(const wchar_t *text, size_t *error_pos) +{ + char *result = NULL, *out; + size_t len, i; + wchar_t ch; + + if (error_pos != NULL) + *error_pos = (size_t)-1; + + len = wcslen(text); + + result = PyMem_Malloc(len + 1); /* +1 for NUL byte */ + if (result == NULL) + return NULL; + + out = result; + for (i=0; i 128. This will still roundtrip correctly in the locale's charset, which must be an ASCII superset. */ - res = PyMem_Malloc((strlen(arg)+1)*sizeof(wchar_t)); - if (!res) goto oom; - in = (unsigned char*)arg; - out = res; - while(*in) - if(*in < 128) - *out++ = *in++; - else - *out++ = 0xdc00 + *in++; - *out = 0; + res = decode_ascii_surrogateescape(arg, size); + if (res == NULL) + goto oom; #endif /* HAVE_MBRTOWC */ - if (size != NULL) - *size = out - res; return res; oom: fprintf(stderr, "out of memory\n"); @@ -198,6 +386,14 @@ size_t i, size, converted; wchar_t c, buf[2]; +#ifndef MS_WINDOWS + if (force_ascii == -1) + force_ascii = check_force_ascii(); + + if (force_ascii) + return encode_ascii_surrogateescape(text, error_pos); +#endif + /* The function works in two steps: 1. compute the length of the output buffer in bytes (size) 2. outputs the bytes */ @@ -238,7 +434,7 @@ } } if (result != NULL) { - *bytes = 0; + *bytes = '\0'; break; } @@ -282,6 +478,8 @@ } #endif +#ifdef HAVE_STAT + /* Call _wstat() on Windows, or encode the path to the filesystem encoding and call stat() otherwise. Only fill st_mode attribute on Windows. @@ -310,6 +508,8 @@ #endif } +#endif + /* Open a file. Use _wfopen() on Windows, encode the path to the locale encoding and use fopen() otherwise. */ @@ -478,4 +678,3 @@ #endif } -#endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 05:35:29 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 4 Jan 2013 05:35:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_merge_3=2E2?= Message-ID: <3YctTY1BTbzSB0@mail.python.org> http://hg.python.org/cpython/rev/c06b4a6afa42 changeset: 81275:c06b4a6afa42 branch: 3.3 parent: 81271:944e86223d1f parent: 81274:f81522ee5b37 user: Benjamin Peterson date: Thu Jan 03 20:34:49 2013 -0800 summary: merge 3.2 files: Doc/howto/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -2,7 +2,7 @@ Argparse Tutorial ***************** -:author: Tshepang Lekhonkhobe +:author: Tshepang Lekhonkhobe .. _argparse-tutorial: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 05:35:30 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 4 Jan 2013 05:35:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3YctTZ3drGzSB9@mail.python.org> http://hg.python.org/cpython/rev/a733e7535e2d changeset: 81276:a733e7535e2d parent: 81272:4b42d7f288c5 parent: 81275:c06b4a6afa42 user: Benjamin Peterson date: Thu Jan 03 20:34:58 2013 -0800 summary: merge 3.3 files: Doc/howto/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -2,7 +2,7 @@ Argparse Tutorial ***************** -:author: Tshepang Lekhonkhobe +:author: Tshepang Lekhonkhobe .. _argparse-tutorial: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 05:35:31 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 4 Jan 2013 05:35:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogZHJvcCBlbWFpbCAo?= =?utf-8?q?closes_=2316857=29?= Message-ID: <3YctTb5yPNzS9j@mail.python.org> http://hg.python.org/cpython/rev/c8e885ecbc89 changeset: 81277:c8e885ecbc89 branch: 2.7 parent: 81269:f26c91bf61bf user: Benjamin Peterson date: Thu Jan 03 20:34:19 2013 -0800 summary: drop email (closes #16857) files: Doc/howto/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -2,7 +2,7 @@ Argparse Tutorial ***************** -:author: Tshepang Lekhonkhobe +:author: Tshepang Lekhonkhobe .. _argparse-tutorial: -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Fri Jan 4 05:52:23 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 04 Jan 2013 05:52:23 +0100 Subject: [Python-checkins] Daily reference leaks (4b42d7f288c5): sum=0 Message-ID: results for 4b42d7f288c5 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogSRJUC5', '-x'] From python-checkins at python.org Fri Jan 4 11:20:55 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 4 Jan 2013 11:20:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316674=3A_random?= =?utf-8?q?=2Egetrandbits=28=29_is_now_20-40=25_faster_for_small_integers?= =?utf-8?q?=2E?= Message-ID: <3Yd2871nHQzSLG@mail.python.org> http://hg.python.org/cpython/rev/b0926ddcab5e changeset: 81278:b0926ddcab5e parent: 81276:a733e7535e2d user: Serhiy Storchaka date: Fri Jan 04 12:18:35 2013 +0200 summary: Issue #16674: random.getrandbits() is now 20-40% faster for small integers. files: Misc/NEWS | 2 ++ Modules/_randommodule.c | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -201,6 +201,8 @@ Library ------- +- Issue #16674: random.getrandbits() is now 20-40% faster for small integers. + - Issue #16009: JSON error messages now provide more information. - Issue #16828: Fix error incorrectly raised by bz2.compress(b'') and diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -360,6 +360,9 @@ return NULL; } + if (k <= 32) /* Fast path */ + return PyLong_FromUnsignedLong(genrand_int32(self) >> (32 - k)); + bytes = ((k - 1) / 32 + 1) * 4; bytearray = (unsigned char *)PyMem_Malloc(bytes); if (bytearray == NULL) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 11:42:04 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 4 Jan 2013 11:42:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2ODU2?= =?utf-8?q?=3A_Fix_a_segmentation_fault_from_calling_repr=28=29_on_a_dict_?= =?utf-8?q?with?= Message-ID: <3Yd2cX5fNpzS7d@mail.python.org> http://hg.python.org/cpython/rev/3cee61137598 changeset: 81279:3cee61137598 branch: 3.3 parent: 81275:c06b4a6afa42 user: Serhiy Storchaka date: Fri Jan 04 12:39:34 2013 +0200 summary: Issue #16856: Fix a segmentation fault from calling repr() on a dict with a key whose repr raise an exception. files: Misc/NEWS | 3 +++ Objects/unicodeobject.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #16856: Fix a segmentation fault from calling repr() on a dict with + a key whose repr raise an exception. + - Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. - Issue #16455: On FreeBSD and Solaris, if the locale is C, the diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -10672,7 +10672,7 @@ return; } left = *p_left; - if (right == NULL || !PyUnicode_Check(left)) { + if (right == NULL || left == NULL || !PyUnicode_Check(left)) { if (!PyErr_Occurred()) PyErr_BadInternalCall(); goto error; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 11:42:06 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 4 Jan 2013 11:42:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316856=3A_Fix_a_segmentation_fault_from_calling_?= =?utf-8?q?repr=28=29_on_a_dict_with?= Message-ID: <3Yd2cZ1gQkzSC0@mail.python.org> http://hg.python.org/cpython/rev/fee4bc043d73 changeset: 81280:fee4bc043d73 parent: 81278:b0926ddcab5e parent: 81279:3cee61137598 user: Serhiy Storchaka date: Fri Jan 04 12:40:35 2013 +0200 summary: Issue #16856: Fix a segmentation fault from calling repr() on a dict with a key whose repr raise an exception. files: Misc/NEWS | 3 +++ Objects/unicodeobject.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #16856: Fix a segmentation fault from calling repr() on a dict with + a key whose repr raise an exception. + - Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. - Issue #16761: Calling int() with base argument only now raises TypeError. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -10548,7 +10548,7 @@ return; } left = *p_left; - if (right == NULL || !PyUnicode_Check(left)) { + if (right == NULL || left == NULL || !PyUnicode_Check(left)) { if (!PyErr_Occurred()) PyErr_BadInternalCall(); goto error; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 13:46:36 2013 From: python-checkins at python.org (chris.jerdonek) Date: Fri, 4 Jan 2013 13:46:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2NzQ3?= =?utf-8?q?=3A_Reflow_iterable_glossary_entry_to_match_3=2Ex_change_e19ed3?= =?utf-8?q?47523e=2E?= Message-ID: <3Yd5ND40ZszSBS@mail.python.org> http://hg.python.org/cpython/rev/dea89ee34402 changeset: 81281:dea89ee34402 branch: 2.7 parent: 81277:c8e885ecbc89 user: Chris Jerdonek date: Fri Jan 04 04:41:34 2013 -0800 summary: Issue #16747: Reflow iterable glossary entry to match 3.x change e19ed347523e. files: Doc/glossary.rst | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -378,17 +378,17 @@ slowly. See also :term:`interactive`. iterable - An object capable of returning its members one at a - time. Examples of iterables include all sequence types (such as - :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence - types like :class:`dict` and :class:`file` and objects of any classes you - define with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables - can be used in a :keyword:`for` loop and in many other places where a - sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable - object is passed as an argument to the built-in function :func:`iter`, it - returns an iterator for the object. This iterator is good for one pass - over the set of values. When using iterables, it is usually not necessary - to call :func:`iter` or deal with iterator objects yourself. The ``for`` + An object capable of returning its members one at a time. Examples of + iterables include all sequence types (such as :class:`list`, :class:`str`, + and :class:`tuple`) and some non-sequence types like :class:`dict` + and :class:`file` and objects of any classes you define + with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be + used in a :keyword:`for` loop and in many other places where a sequence is + needed (:func:`zip`, :func:`map`, ...). When an iterable object is passed + as an argument to the built-in function :func:`iter`, it returns an + iterator for the object. This iterator is good for one pass over the set + of values. When using iterables, it is usually not necessary to call + :func:`iter` or deal with iterator objects yourself. The ``for`` statement does that automatically for you, creating a temporary unnamed variable to hold the iterator for the duration of the loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 18:33:35 2013 From: python-checkins at python.org (charles-francois.natali) Date: Fri, 4 Jan 2013 18:33:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316860=3A_In_tempf?= =?utf-8?q?ile=2C_use_O=5FCLOEXEC_when_available_to_set_the?= Message-ID: <3YdClM5MTkzP1P@mail.python.org> http://hg.python.org/cpython/rev/64883c614c88 changeset: 81282:64883c614c88 parent: 81280:fee4bc043d73 user: Charles-Fran?ois Natali date: Fri Jan 04 18:33:02 2013 +0100 summary: Issue #16860: In tempfile, use O_CLOEXEC when available to set the close-on-exec flag atomically. files: Lib/tempfile.py | 2 ++ Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Lib/tempfile.py b/Lib/tempfile.py --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -57,6 +57,8 @@ _allocate_lock = _thread.allocate_lock _text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL +if hasattr(_os, 'O_CLOEXEC'): + _text_openflags |= _os.O_CLOEXEC if hasattr(_os, 'O_NOINHERIT'): _text_openflags |= _os.O_NOINHERIT if hasattr(_os, 'O_NOFOLLOW'): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -204,6 +204,9 @@ Library ------- +- Issue #16860: In tempfile, use O_CLOEXEC when available to set the + close-on-exec flag atomically. + - Issue #16674: random.getrandbits() is now 20-40% faster for small integers. - Issue #16009: JSON error messages now provide more information. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 19:35:29 2013 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 4 Jan 2013 19:35:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Clarify_description_of_wait?= =?utf-8?b?KCku?= Message-ID: <3YdF6n2ZpHzRmv@mail.python.org> http://hg.python.org/peps/rev/e7df098ee19e changeset: 4649:e7df098ee19e user: Guido van Rossum date: Fri Jan 04 10:35:19 2013 -0800 summary: Clarify description of wait(). files: pep-3156.txt | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -765,12 +765,13 @@ provided: - ``tulip.wait(fs, ...)``. Wait for the Futures or coroutines given - by ``fs`` to complete. This is a coroutine whose result on success - is a tuple of two sets of Futures, ``(done, not_done)``. Optional - arguments ``timeout`` and ``return_when`` have the same meaning and - defaults as for ``concurrent.futures.wait()``. The constants - ``FIRST_COMPLETED``, ``FIRST_EXCEPTION``, ``ALL_COMPLETED`` are - defined with the same values and the same meanings as in PEP 3148. + by ``fs`` to complete. Coroutine arguments will be wrapped in Tasks + (see below). The result is a tuple of two sets of Futures, ``(done, + not_done)``. Optional arguments ``timeout`` and ``return_when`` + have the same meaning and defaults as for + ``concurrent.futures.wait()``. The constants ``FIRST_COMPLETED``, + ``FIRST_EXCEPTION``, ``ALL_COMPLETED`` are defined with the same + values and the same meanings as in PEP 3148. - ``as_completed(fs, ...)``. Return an iterator whose values are coroutines; waiting for successive values waits until the next -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Fri Jan 4 21:24:02 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 4 Jan 2013 21:24:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_=2316835=3A_update_PEP_399_id?= =?utf-8?q?iom_to_make_it_compatible_with_unittest_test_discovery=2E?= Message-ID: <3YdHX26WbhzS3l@mail.python.org> http://hg.python.org/peps/rev/3740f42d3b94 changeset: 4650:3740f42d3b94 user: Ezio Melotti date: Fri Jan 04 22:23:50 2013 +0200 summary: #16835: update PEP 399 idiom to make it compatible with unittest test discovery. files: pep-0399.txt | 37 +++++++++++++++++++------------------ 1 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pep-0399.txt b/pep-0399.txt --- a/pep-0399.txt +++ b/pep-0399.txt @@ -8,7 +8,7 @@ Content-Type: text/x-rst Created: 04-Apr-2011 Python-Version: 3.3 -Post-History: 04-Apr-2011, 12-Apr-2011, 17-Jul-2011, 15-Aug-2011 +Post-History: 04-Apr-2011, 12-Apr-2011, 17-Jul-2011, 15-Aug-2011, 01-Jan-2013 Abstract ======== @@ -124,7 +124,7 @@ py_heapq = import_fresh_module('heapq', blocked=['_heapq']) - class ExampleTest(unittest.TestCase): + class ExampleTest: def test_heappop_exc_for_non_MutableSequence(self): # Raise TypeError when heap is not a @@ -136,33 +136,34 @@ return 0 heap = Spam() - self.assertFalse(isinstance(heap, - collections.abc.MutableSequence)) + self.assertIsInstance(heap, collections.abc.MutableSequence) with self.assertRaises(TypeError): self.heapq.heappop(heap) - class AcceleratedExampleTest(ExampleTest): + class PyExampleTest(ExampleTest, unittest.TestCase): + """Test with just the pure Python code.""" + heapq = py_heapq + + @unittest.skipUnless(c_heapq, 'requires the C _heapq module') + class CExampleTest(ExampleTest, unittest.TestCase): """Test using the accelerated code.""" - heapq = c_heapq - class PyExampleTest(ExampleTest): + if __name__ == '__main__': + unittest.main() - """Test with just the pure Python code.""" - heapq = py_heapq - - - def test_main(): - run_unittest(AcceleratedExampleTest, PyExampleTest) - - - if __name__ == '__main__': - test_main() - +The test module defines a base class (``ExampleTest``) with test methods +that access the ``heapq`` module through a ``self.heapq`` class attribute, +and two subclasses that set this attribute to either the Python or the C +version of the module. Note that only the two subclasses inherit from +``unittest.TestCase`` -- this prevents the ``ExampleTest`` class from +being detected as a ``TestCase`` subclass by ``unittest`` test discovery. +A ``skipUnless`` decorator can be added to the class that tests the C code +in order to have these tests skipped when the C module is not available. If this test were to provide extensive coverage for ``heapq.heappop()`` in the pure Python implementation then the -- Repository URL: http://hg.python.org/peps From root at python.org Fri Jan 4 22:50:01 2013 From: root at python.org (Cron Daemon) Date: Fri, 04 Jan 2013 22:50:01 +0100 Subject: [Python-checkins] Cron /home/docs/build-devguide Message-ID: abort: error: Connection refused From python-checkins at python.org Fri Jan 4 23:51:57 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 4 Jan 2013 23:51:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzEzMDk0OiBhZGQg?= =?utf-8?q?Programming_FAQ_entry_about_the_behavior_of_closures=2E?= Message-ID: <3YdLpj2YMQzSCM@mail.python.org> http://hg.python.org/cpython/rev/fdc894d44d82 changeset: 81283:fdc894d44d82 branch: 2.7 parent: 81281:dea89ee34402 user: Ezio Melotti date: Sat Jan 05 00:49:48 2013 +0200 summary: #13094: add Programming FAQ entry about the behavior of closures. files: Doc/faq/programming.rst | 52 +++++++++++++++++++++++++++++ Misc/NEWS | 3 + 2 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -352,6 +352,58 @@ declaration for identifying side-effects. +Why do lambdas defined in a loop with different values all return the same result? +---------------------------------------------------------------------------------- + +Assume you use a for loop to define a few different lambdas (or even plain +functions), e.g.:: + + squares = [] + for x in range(5): + squares.append(lambda: x**2) + +This gives you a list that contains 5 lambdas that calculate ``x**2``. You +might expect that, when called, they would return, respectively, ``0``, ``1``, +``4``, ``9``, and ``16``. However, when you actually try you will see that +they all return ``16``:: + + >>> squares[2]() + 16 + >>> squares[4]() + 16 + +This happens because ``x`` is not local to the lambdas, but is defined in +the outer scope, and it is accessed when the lambda is called --- not when it +is defined. At the end of the loop, the value of ``x`` is ``4``, so all the +functions now return ``4**2``, i.e. ``16``. You can also verify this by +changing the value of ``x`` and see how the results of the lambdas change:: + + >>> x = 8 + >>> squares[2]() + 64 + +In order to avoid this, you need to save the values in variables local to the +lambdas, so that they don't rely on the value of the global ``x``:: + + squares = [] + for x in range(5): + squares.append(lambda n=x: n**2) + +Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed +when the lambda is defined so that it has the same value that ``x`` had at +that point in the loop. This means that the value of ``n`` will be ``0`` +in the first lambda, ``1`` in the second, ``2`` in the third, and so on. +Therefore each lambda will now return the correct result:: + + >>> squares[2]() + 4 + >>> squares[4]() + 16 + +Note that this behaviour is not peculiar to lambdas, but applies to regular +functions too. + + How do I share global variables across modules? ------------------------------------------------ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -693,6 +693,9 @@ Documentation ------------- +- Issue #13094: add "Why do lambdas defined in a loop with different values + all return the same result?" programming FAQ. + - Issue #14901: Update portions of the Windows FAQ. Patch by Ashish Nitin Patil. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 23:51:58 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 4 Jan 2013 23:51:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzEzMDk0OiBhZGQg?= =?utf-8?q?Programming_FAQ_entry_about_the_behavior_of_closures=2E?= Message-ID: <3YdLpk5MGMzSGh@mail.python.org> http://hg.python.org/cpython/rev/02933454b7ce changeset: 81284:02933454b7ce branch: 3.2 parent: 81274:f81522ee5b37 user: Ezio Melotti date: Sat Jan 05 00:50:46 2013 +0200 summary: #13094: add Programming FAQ entry about the behavior of closures. files: Doc/faq/programming.rst | 52 +++++++++++++++++++++++++++++ Misc/NEWS | 3 + 2 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -206,6 +206,58 @@ declaration for identifying side-effects. +Why do lambdas defined in a loop with different values all return the same result? +---------------------------------------------------------------------------------- + +Assume you use a for loop to define a few different lambdas (or even plain +functions), e.g.:: + + squares = [] + for x in range(5): + squares.append(lambda: x**2) + +This gives you a list that contains 5 lambdas that calculate ``x**2``. You +might expect that, when called, they would return, respectively, ``0``, ``1``, +``4``, ``9``, and ``16``. However, when you actually try you will see that +they all return ``16``:: + + >>> squares[2]() + 16 + >>> squares[4]() + 16 + +This happens because ``x`` is not local to the lambdas, but is defined in +the outer scope, and it is accessed when the lambda is called --- not when it +is defined. At the end of the loop, the value of ``x`` is ``4``, so all the +functions now return ``4**2``, i.e. ``16``. You can also verify this by +changing the value of ``x`` and see how the results of the lambdas change:: + + >>> x = 8 + >>> squares[2]() + 64 + +In order to avoid this, you need to save the values in variables local to the +lambdas, so that they don't rely on the value of the global ``x``:: + + squares = [] + for x in range(5): + squares.append(lambda n=x: n**2) + +Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed +when the lambda is defined so that it has the same value that ``x`` had at +that point in the loop. This means that the value of ``n`` will be ``0`` +in the first lambda, ``1`` in the second, ``2`` in the third, and so on. +Therefore each lambda will now return the correct result:: + + >>> squares[2]() + 4 + >>> squares[4]() + 16 + +Note that this behaviour is not peculiar to lambdas, but applies to regular +functions too. + + How do I share global variables across modules? ------------------------------------------------ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -867,6 +867,9 @@ Documentation ------------- +- Issue #13094: add "Why do lambdas defined in a loop with different values + all return the same result?" programming FAQ. + - Issue #14901: Update portions of the Windows FAQ. Patch by Ashish Nitin Patil. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 23:52:00 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 4 Jan 2013 23:52:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2313094=3A_merge_with_3=2E2=2E?= Message-ID: <3YdLpm0p71zSHk@mail.python.org> http://hg.python.org/cpython/rev/827ddaaa45e4 changeset: 81285:827ddaaa45e4 branch: 3.3 parent: 81279:3cee61137598 parent: 81284:02933454b7ce user: Ezio Melotti date: Sat Jan 05 00:51:20 2013 +0200 summary: #13094: merge with 3.2. files: Doc/faq/programming.rst | 52 +++++++++++++++++++++++++++++ Misc/NEWS | 3 + 2 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -206,6 +206,58 @@ declaration for identifying side-effects. +Why do lambdas defined in a loop with different values all return the same result? +---------------------------------------------------------------------------------- + +Assume you use a for loop to define a few different lambdas (or even plain +functions), e.g.:: + + squares = [] + for x in range(5): + squares.append(lambda: x**2) + +This gives you a list that contains 5 lambdas that calculate ``x**2``. You +might expect that, when called, they would return, respectively, ``0``, ``1``, +``4``, ``9``, and ``16``. However, when you actually try you will see that +they all return ``16``:: + + >>> squares[2]() + 16 + >>> squares[4]() + 16 + +This happens because ``x`` is not local to the lambdas, but is defined in +the outer scope, and it is accessed when the lambda is called --- not when it +is defined. At the end of the loop, the value of ``x`` is ``4``, so all the +functions now return ``4**2``, i.e. ``16``. You can also verify this by +changing the value of ``x`` and see how the results of the lambdas change:: + + >>> x = 8 + >>> squares[2]() + 64 + +In order to avoid this, you need to save the values in variables local to the +lambdas, so that they don't rely on the value of the global ``x``:: + + squares = [] + for x in range(5): + squares.append(lambda n=x: n**2) + +Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed +when the lambda is defined so that it has the same value that ``x`` had at +that point in the loop. This means that the value of ``n`` will be ``0`` +in the first lambda, ``1`` in the second, ``2`` in the third, and so on. +Therefore each lambda will now return the correct result:: + + >>> squares[2]() + 4 + >>> squares[4]() + 16 + +Note that this behaviour is not peculiar to lambdas, but applies to regular +functions too. + + How do I share global variables across modules? ------------------------------------------------ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -456,6 +456,9 @@ Documentation ------------- +- Issue #13094: add "Why do lambdas defined in a loop with different values + all return the same result?" programming FAQ. + - Issue #14901: Update portions of the Windows FAQ. Patch by Ashish Nitin Patil. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 4 23:52:01 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 4 Jan 2013 23:52:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzEzMDk0OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YdLpn3NQdzSCM@mail.python.org> http://hg.python.org/cpython/rev/1bf7ae6c5324 changeset: 81286:1bf7ae6c5324 parent: 81282:64883c614c88 parent: 81285:827ddaaa45e4 user: Ezio Melotti date: Sat Jan 05 00:51:40 2013 +0200 summary: #13094: merge with 3.3. files: Doc/faq/programming.rst | 52 +++++++++++++++++++++++++++++ Misc/NEWS | 3 + 2 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -206,6 +206,58 @@ declaration for identifying side-effects. +Why do lambdas defined in a loop with different values all return the same result? +---------------------------------------------------------------------------------- + +Assume you use a for loop to define a few different lambdas (or even plain +functions), e.g.:: + + squares = [] + for x in range(5): + squares.append(lambda: x**2) + +This gives you a list that contains 5 lambdas that calculate ``x**2``. You +might expect that, when called, they would return, respectively, ``0``, ``1``, +``4``, ``9``, and ``16``. However, when you actually try you will see that +they all return ``16``:: + + >>> squares[2]() + 16 + >>> squares[4]() + 16 + +This happens because ``x`` is not local to the lambdas, but is defined in +the outer scope, and it is accessed when the lambda is called --- not when it +is defined. At the end of the loop, the value of ``x`` is ``4``, so all the +functions now return ``4**2``, i.e. ``16``. You can also verify this by +changing the value of ``x`` and see how the results of the lambdas change:: + + >>> x = 8 + >>> squares[2]() + 64 + +In order to avoid this, you need to save the values in variables local to the +lambdas, so that they don't rely on the value of the global ``x``:: + + squares = [] + for x in range(5): + squares.append(lambda n=x: n**2) + +Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed +when the lambda is defined so that it has the same value that ``x`` had at +that point in the loop. This means that the value of ``n`` will be ``0`` +in the first lambda, ``1`` in the second, ``2`` in the third, and so on. +Therefore each lambda will now return the correct result:: + + >>> squares[2]() + 4 + >>> squares[4]() + 16 + +Note that this behaviour is not peculiar to lambdas, but applies to regular +functions too. + + How do I share global variables across modules? ------------------------------------------------ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -655,6 +655,9 @@ Documentation ------------- +- Issue #13094: add "Why do lambdas defined in a loop with different values + all return the same result?" programming FAQ. + - Issue #14901: Update portions of the Windows FAQ. Patch by Ashish Nitin Patil. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 01:06:16 2013 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 5 Jan 2013 01:06:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Augment_section_on_datagrams_?= =?utf-8?q?a_little=2E?= Message-ID: <3YdNSS1qSbzP6t@mail.python.org> http://hg.python.org/peps/rev/5cff02a56194 changeset: 4651:5cff02a56194 parent: 4649:e7df098ee19e user: Guido van Rossum date: Fri Jan 04 15:58:48 2013 -0800 summary: Augment section on datagrams a little. files: pep-3156.txt | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -884,11 +884,15 @@ (because to wait for a lock we'd have to use ``yield from``, which the ``with`` statement can't do). -- Support for datagram protocols, "connected" or otherwise? Probably +- Support for datagram protocols, "connected" or otherwise. Probably need more socket I/O methods, e.g. ``sock_sendto()`` and ``sock_recvfrom()``. Or users can write their own (it's not rocket science). Is it reasonable to map ``write()``, ``writelines()``, - ``data_received()`` to single datagrams? + ``data_received()`` to single datagrams? Or should we have a + different ``datagram_received()`` method on datagram protocols? + (Glyph recommends the latter.) And then what instead of ``write()``? + Finally, do we need support for unconnected datagram protocols? + (That would mean wrappers for ``sendto()`` and ``recvfrom()``.) - An EventEmitter in the style of NodeJS? Or make this a separate PEP? It's easy enough to do in user space, though it may benefit -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sat Jan 5 01:06:17 2013 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 5 Jan 2013 01:06:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps_=28merge_default_-=3E_default=29?= =?utf-8?q?=3A_Merge=2E?= Message-ID: <3YdNST3s3gzP6t@mail.python.org> http://hg.python.org/peps/rev/e198762fc2c0 changeset: 4652:e198762fc2c0 parent: 4650:3740f42d3b94 parent: 4651:5cff02a56194 user: Guido van Rossum date: Fri Jan 04 16:06:11 2013 -0800 summary: Merge. files: pep-3156.txt | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -884,11 +884,15 @@ (because to wait for a lock we'd have to use ``yield from``, which the ``with`` statement can't do). -- Support for datagram protocols, "connected" or otherwise? Probably +- Support for datagram protocols, "connected" or otherwise. Probably need more socket I/O methods, e.g. ``sock_sendto()`` and ``sock_recvfrom()``. Or users can write their own (it's not rocket science). Is it reasonable to map ``write()``, ``writelines()``, - ``data_received()`` to single datagrams? + ``data_received()`` to single datagrams? Or should we have a + different ``datagram_received()`` method on datagram protocols? + (Glyph recommends the latter.) And then what instead of ``write()``? + Finally, do we need support for unconnected datagram protocols? + (That would mean wrappers for ``sendto()`` and ``recvfrom()``.) - An EventEmitter in the style of NodeJS? Or make this a separate PEP? It's easy enough to do in user space, though it may benefit -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sat Jan 5 05:54:51 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 05:54:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_example_by?= =?utf-8?q?_making_the_exception_inherit_from_Exception=2E?= Message-ID: <3YdVsR0vF0zS8h@mail.python.org> http://hg.python.org/cpython/rev/ed618d1210ae changeset: 81287:ed618d1210ae branch: 3.2 parent: 81284:02933454b7ce user: Ezio Melotti date: Sat Jan 05 06:53:27 2013 +0200 summary: Fix example by making the exception inherit from Exception. files: Doc/faq/design.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -728,7 +728,7 @@ reasonable uses of the "go" or "goto" constructs of C, Fortran, and other languages. For example:: - class label: pass # declare a label + class label(Exception): pass # declare a label try: ... -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 05:54:52 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 05:54:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge_example_fix_with_3=2E2=2E?= Message-ID: <3YdVsS3M1yzRph@mail.python.org> http://hg.python.org/cpython/rev/320e7b9b8002 changeset: 81288:320e7b9b8002 branch: 3.3 parent: 81285:827ddaaa45e4 parent: 81287:ed618d1210ae user: Ezio Melotti date: Sat Jan 05 06:54:23 2013 +0200 summary: Merge example fix with 3.2. files: Doc/faq/design.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -730,7 +730,7 @@ reasonable uses of the "go" or "goto" constructs of C, Fortran, and other languages. For example:: - class label: pass # declare a label + class label(Exception): pass # declare a label try: ... -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 05:54:53 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 05:54:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_example_fix_with_3=2E3=2E?= Message-ID: <3YdVsT5gQ3zP3J@mail.python.org> http://hg.python.org/cpython/rev/3c15b940454d changeset: 81289:3c15b940454d parent: 81286:1bf7ae6c5324 parent: 81288:320e7b9b8002 user: Ezio Melotti date: Sat Jan 05 06:54:38 2013 +0200 summary: Merge example fix with 3.3. files: Doc/faq/design.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -730,7 +730,7 @@ reasonable uses of the "go" or "goto" constructs of C, Fortran, and other languages. For example:: - class label: pass # declare a label + class label(Exception): pass # declare a label try: ... -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Sat Jan 5 05:53:48 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 05 Jan 2013 05:53:48 +0100 Subject: [Python-checkins] Daily reference leaks (1bf7ae6c5324): sum=2 Message-ID: results for 1bf7ae6c5324 on branch "default" -------------------------------------------- test_concurrent_futures leaked [-2, 1, 3] memory blocks, sum=2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflog9Uju9N', '-x'] From python-checkins at python.org Sat Jan 5 07:54:20 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 07:54:20 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Cleanup_a_few_?= =?utf-8?q?minor_things=2E?= Message-ID: <3YdYWJ4pcNzS7c@mail.python.org> http://hg.python.org/cpython/rev/786ab480923f changeset: 81290:786ab480923f branch: 3.2 parent: 81287:ed618d1210ae user: Ezio Melotti date: Sat Jan 05 07:36:54 2013 +0200 summary: Cleanup a few minor things. files: Doc/faq/design.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -214,7 +214,7 @@ generic for a group of types and which were intended to work even for objects that didn't have methods at all (e.g. tuples). It is also convenient to have a function that can readily be applied to an amorphous collection of objects when -you use the functional features of Python (``map()``, ``apply()`` et al). +you use the functional features of Python (``map()``, ``zip()`` et al). In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in function is actually less code than implementing them as methods for each type. One can @@ -707,7 +707,7 @@ requested again. This is called "memoizing", and can be implemented like this:: # Callers will never provide a third parameter for this function. - def expensive (arg1, arg2, _cache={}): + def expensive(arg1, arg2, _cache={}): if (arg1, arg2) in _cache: return _cache[(arg1, arg2)] @@ -732,7 +732,7 @@ try: ... - if (condition): raise label() # goto label + if condition: raise label() # goto label ... except label: # where to goto pass -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 07:54:22 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 07:54:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE2ODYyOiByZW1v?= =?utf-8?q?ve_outdated_statements_about_Stackless=2E?= Message-ID: <3YdYWL03jfzS7y@mail.python.org> http://hg.python.org/cpython/rev/d2867c430333 changeset: 81291:d2867c430333 branch: 3.2 user: Ezio Melotti date: Sat Jan 05 07:37:47 2013 +0200 summary: #16862: remove outdated statements about Stackless. files: Doc/faq/design.rst | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -345,9 +345,6 @@ Answer 2: Fortunately, there is `Stackless Python `_, which has a completely redesigned interpreter loop that avoids the C stack. -It's still experimental but looks very promising. Although it is binary -compatible with standard Python, it's still unclear whether Stackless will make -it into the core -- maybe it's just too revolutionary. Why can't lambda forms contain statements? -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 07:54:23 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 07:54:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2316862=3A_merge_with_3=2E2=2E?= Message-ID: <3YdYWM2fwyzS95@mail.python.org> http://hg.python.org/cpython/rev/b66049748535 changeset: 81292:b66049748535 branch: 3.3 parent: 81288:320e7b9b8002 parent: 81291:d2867c430333 user: Ezio Melotti date: Sat Jan 05 07:38:37 2013 +0200 summary: #16862: merge with 3.2. files: Doc/faq/design.rst | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -214,7 +214,7 @@ generic for a group of types and which were intended to work even for objects that didn't have methods at all (e.g. tuples). It is also convenient to have a function that can readily be applied to an amorphous collection of objects when -you use the functional features of Python (``map()``, ``apply()`` et al). +you use the functional features of Python (``map()``, ``zip()`` et al). In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in function is actually less code than implementing them as methods for each type. One can @@ -345,9 +345,6 @@ Answer 2: Fortunately, there is `Stackless Python `_, which has a completely redesigned interpreter loop that avoids the C stack. -It's still experimental but looks very promising. Although it is binary -compatible with standard Python, it's still unclear whether Stackless will make -it into the core -- maybe it's just too revolutionary. Why can't lambda forms contain statements? @@ -709,7 +706,7 @@ requested again. This is called "memoizing", and can be implemented like this:: # Callers will never provide a third parameter for this function. - def expensive (arg1, arg2, _cache={}): + def expensive(arg1, arg2, _cache={}): if (arg1, arg2) in _cache: return _cache[(arg1, arg2)] @@ -734,7 +731,7 @@ try: ... - if (condition): raise label() # goto label + if condition: raise label() # goto label ... except label: # where to goto pass -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 07:54:24 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 07:54:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2ODYyOiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YdYWN4z4rzS8W@mail.python.org> http://hg.python.org/cpython/rev/547dc3aa3e9a changeset: 81293:547dc3aa3e9a parent: 81289:3c15b940454d parent: 81292:b66049748535 user: Ezio Melotti date: Sat Jan 05 07:38:52 2013 +0200 summary: #16862: merge with 3.3. files: Doc/faq/design.rst | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -214,7 +214,7 @@ generic for a group of types and which were intended to work even for objects that didn't have methods at all (e.g. tuples). It is also convenient to have a function that can readily be applied to an amorphous collection of objects when -you use the functional features of Python (``map()``, ``apply()`` et al). +you use the functional features of Python (``map()``, ``zip()`` et al). In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in function is actually less code than implementing them as methods for each type. One can @@ -345,9 +345,6 @@ Answer 2: Fortunately, there is `Stackless Python `_, which has a completely redesigned interpreter loop that avoids the C stack. -It's still experimental but looks very promising. Although it is binary -compatible with standard Python, it's still unclear whether Stackless will make -it into the core -- maybe it's just too revolutionary. Why can't lambda forms contain statements? @@ -709,7 +706,7 @@ requested again. This is called "memoizing", and can be implemented like this:: # Callers will never provide a third parameter for this function. - def expensive (arg1, arg2, _cache={}): + def expensive(arg1, arg2, _cache={}): if (arg1, arg2) in _cache: return _cache[(arg1, arg2)] @@ -734,7 +731,7 @@ try: ... - if (condition): raise label() # goto label + if condition: raise label() # goto label ... except label: # where to goto pass -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 07:54:26 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 07:54:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Cleanup_a_few_?= =?utf-8?q?minor_things=2E?= Message-ID: <3YdYWQ090rzS7c@mail.python.org> http://hg.python.org/cpython/rev/97b24aa84df1 changeset: 81294:97b24aa84df1 branch: 2.7 parent: 81283:fdc894d44d82 user: Ezio Melotti date: Sat Jan 05 07:36:54 2013 +0200 summary: Cleanup a few minor things. files: Doc/faq/design.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -225,7 +225,7 @@ generic for a group of types and which were intended to work even for objects that didn't have methods at all (e.g. tuples). It is also convenient to have a function that can readily be applied to an amorphous collection of objects when -you use the functional features of Python (``map()``, ``apply()`` et al). +you use the functional features of Python (``map()``, ``zip()`` et al). In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in function is actually less code than implementing them as methods for each type. One can @@ -757,7 +757,7 @@ requested again. This is called "memoizing", and can be implemented like this:: # Callers will never provide a third parameter for this function. - def expensive (arg1, arg2, _cache={}): + def expensive(arg1, arg2, _cache={}): if (arg1, arg2) in _cache: return _cache[(arg1, arg2)] @@ -782,7 +782,7 @@ try: ... - if (condition): raise label() # goto label + if condition: raise label() # goto label ... except label: # where to goto pass -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 07:54:27 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 5 Jan 2013 07:54:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE2ODYyOiByZW1v?= =?utf-8?q?ve_outdated_statements_about_Stackless=2E?= Message-ID: <3YdYWR2TPvzS93@mail.python.org> http://hg.python.org/cpython/rev/0f24c65fb7e5 changeset: 81295:0f24c65fb7e5 branch: 2.7 user: Ezio Melotti date: Sat Jan 05 07:37:47 2013 +0200 summary: #16862: remove outdated statements about Stackless. files: Doc/faq/design.rst | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -370,9 +370,6 @@ Answer 2: Fortunately, there is `Stackless Python `_, which has a completely redesigned interpreter loop that avoids the C stack. -It's still experimental but looks very promising. Although it is binary -compatible with standard Python, it's still unclear whether Stackless will make -it into the core -- maybe it's just too revolutionary. Why can't lambda forms contain statements? -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 15:31:42 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 5 Jan 2013 15:31:42 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogVGhlIGdldCgpIGFu?= =?utf-8?q?d_iter=28=29_are_now_able_to_accept_keyword_arguments=2E?= Message-ID: <3Ydlg26MY8zRxF@mail.python.org> http://hg.python.org/cpython/rev/c1fc6b6d1cfc changeset: 81296:c1fc6b6d1cfc branch: 3.3 parent: 81292:b66049748535 user: Eli Bendersky date: Sat Jan 05 06:26:39 2013 -0800 summary: The get() and iter() are now able to accept keyword arguments. In conformance with the documentation and the Python version. Patch by Franck Michea. files: Lib/test/test_xml_etree.py | 10 ++++++++++ Misc/ACKS | 1 + Modules/_elementtree.c | 21 +++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1769,6 +1769,11 @@ self.assertEqual(flag, True) self.assertEqual(wref(), None) + def test_get_keyword_args(self): + e1 = ET.Element('foo' , x=1, y=2, z=3) + self.assertEqual(e1.get('x', default=7), 1) + self.assertEqual(e1.get('w', default=7), 7) + def test_pickle(self): # For now this test only works for the Python version of ET, # so set sys.modules accordingly because pickle uses __import__ @@ -1897,6 +1902,11 @@ self.assertEqual(self._ilist(doc, 'room'), ['room'] * 3) self.assertEqual(self._ilist(doc, 'house'), ['house'] * 2) + # test that iter also accepts 'tag' as a keyword arg + self.assertEqual( + summarize_list(doc.iter(tag='room')), + ['room'] * 3) + # make sure both tag=None and tag='*' return all tags all_tags = ['document', 'house', 'room', 'room', 'shed', 'house', 'room'] diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -794,6 +794,7 @@ Alexis M?taireau Steven Miale Trent Mick +Franck Michea Tom Middleton Stan Mihai Stefan Mihaila diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1031,13 +1031,16 @@ } static PyObject* -element_get(ElementObject* self, PyObject* args) +element_get(ElementObject* self, PyObject* args, PyObject* kwds) { PyObject* value; + static char* kwlist[] = {"key", "default", 0}; PyObject* key; PyObject* default_value = Py_None; - if (!PyArg_ParseTuple(args, "O|O:get", &key, &default_value)) + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:get", kwlist, &key, + &default_value)) return NULL; if (!self->extra || self->extra->attrib == Py_None) @@ -1085,10 +1088,12 @@ static PyObject * -element_iter(ElementObject *self, PyObject *args) +element_iter(ElementObject *self, PyObject *args, PyObject *kwds) { PyObject* tag = Py_None; - if (!PyArg_ParseTuple(args, "|O:iter", &tag)) + static char* kwlist[] = {"tag", 0}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:iter", kwlist, &tag)) return NULL; return create_elementiter(self, tag, 0); @@ -1555,7 +1560,7 @@ {"clear", (PyCFunction) element_clearmethod, METH_VARARGS}, - {"get", (PyCFunction) element_get, METH_VARARGS}, + {"get", (PyCFunction) element_get, METH_VARARGS | METH_KEYWORDS}, {"set", (PyCFunction) element_set, METH_VARARGS}, {"find", (PyCFunction) element_find, METH_VARARGS | METH_KEYWORDS}, @@ -1567,11 +1572,11 @@ {"insert", (PyCFunction) element_insert, METH_VARARGS}, {"remove", (PyCFunction) element_remove, METH_VARARGS}, - {"iter", (PyCFunction) element_iter, METH_VARARGS}, + {"iter", (PyCFunction) element_iter, METH_VARARGS | METH_KEYWORDS}, {"itertext", (PyCFunction) element_itertext, METH_VARARGS}, {"iterfind", (PyCFunction) element_iterfind, METH_VARARGS | METH_KEYWORDS}, - {"getiterator", (PyCFunction) element_iter, METH_VARARGS}, + {"getiterator", (PyCFunction) element_iter, METH_VARARGS | METH_KEYWORDS}, {"getchildren", (PyCFunction) element_getchildren, METH_VARARGS}, {"items", (PyCFunction) element_items, METH_VARARGS}, @@ -3461,7 +3466,7 @@ /* python module interface */ static PyMethodDef _functions[] = { - {"SubElement", (PyCFunction) subelement, METH_VARARGS|METH_KEYWORDS}, + {"SubElement", (PyCFunction) subelement, METH_VARARGS | METH_KEYWORDS}, {NULL, NULL} }; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 15:31:44 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 5 Jan 2013 15:31:44 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_The_get=28=29_and_iter=28=29_are_now_able_to_accept_keyw?= =?utf-8?q?ord_arguments=2E?= Message-ID: <3Ydlg43DpgzRyt@mail.python.org> http://hg.python.org/cpython/rev/e1bee8b09828 changeset: 81297:e1bee8b09828 parent: 81293:547dc3aa3e9a parent: 81296:c1fc6b6d1cfc user: Eli Bendersky date: Sat Jan 05 06:31:36 2013 -0800 summary: The get() and iter() are now able to accept keyword arguments. In conformance with the documentation and the Python version. Patch by Franck Michea. files: Lib/test/test_xml_etree.py | 10 ++++++++++ Misc/ACKS | 1 + Modules/_elementtree.c | 21 +++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1769,6 +1769,11 @@ self.assertEqual(flag, True) self.assertEqual(wref(), None) + def test_get_keyword_args(self): + e1 = ET.Element('foo' , x=1, y=2, z=3) + self.assertEqual(e1.get('x', default=7), 1) + self.assertEqual(e1.get('w', default=7), 7) + def test_pickle(self): # For now this test only works for the Python version of ET, # so set sys.modules accordingly because pickle uses __import__ @@ -1897,6 +1902,11 @@ self.assertEqual(self._ilist(doc, 'room'), ['room'] * 3) self.assertEqual(self._ilist(doc, 'house'), ['house'] * 2) + # test that iter also accepts 'tag' as a keyword arg + self.assertEqual( + summarize_list(doc.iter(tag='room')), + ['room'] * 3) + # make sure both tag=None and tag='*' return all tags all_tags = ['document', 'house', 'room', 'room', 'shed', 'house', 'room'] diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -800,6 +800,7 @@ Alexis M?taireau Steven Miale Trent Mick +Franck Michea Tom Middleton Stan Mihai Stefan Mihaila diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1031,13 +1031,16 @@ } static PyObject* -element_get(ElementObject* self, PyObject* args) +element_get(ElementObject* self, PyObject* args, PyObject* kwds) { PyObject* value; + static char* kwlist[] = {"key", "default", 0}; PyObject* key; PyObject* default_value = Py_None; - if (!PyArg_ParseTuple(args, "O|O:get", &key, &default_value)) + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:get", kwlist, &key, + &default_value)) return NULL; if (!self->extra || self->extra->attrib == Py_None) @@ -1085,10 +1088,12 @@ static PyObject * -element_iter(ElementObject *self, PyObject *args) +element_iter(ElementObject *self, PyObject *args, PyObject *kwds) { PyObject* tag = Py_None; - if (!PyArg_ParseTuple(args, "|O:iter", &tag)) + static char* kwlist[] = {"tag", 0}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:iter", kwlist, &tag)) return NULL; return create_elementiter(self, tag, 0); @@ -1555,7 +1560,7 @@ {"clear", (PyCFunction) element_clearmethod, METH_VARARGS}, - {"get", (PyCFunction) element_get, METH_VARARGS}, + {"get", (PyCFunction) element_get, METH_VARARGS | METH_KEYWORDS}, {"set", (PyCFunction) element_set, METH_VARARGS}, {"find", (PyCFunction) element_find, METH_VARARGS | METH_KEYWORDS}, @@ -1567,11 +1572,11 @@ {"insert", (PyCFunction) element_insert, METH_VARARGS}, {"remove", (PyCFunction) element_remove, METH_VARARGS}, - {"iter", (PyCFunction) element_iter, METH_VARARGS}, + {"iter", (PyCFunction) element_iter, METH_VARARGS | METH_KEYWORDS}, {"itertext", (PyCFunction) element_itertext, METH_VARARGS}, {"iterfind", (PyCFunction) element_iterfind, METH_VARARGS | METH_KEYWORDS}, - {"getiterator", (PyCFunction) element_iter, METH_VARARGS}, + {"getiterator", (PyCFunction) element_iter, METH_VARARGS | METH_KEYWORDS}, {"getchildren", (PyCFunction) element_getchildren, METH_VARARGS}, {"items", (PyCFunction) element_items, METH_VARARGS}, @@ -3461,7 +3466,7 @@ /* python module interface */ static PyMethodDef _functions[] = { - {"SubElement", (PyCFunction) subelement, METH_VARARGS|METH_KEYWORDS}, + {"SubElement", (PyCFunction) subelement, METH_VARARGS | METH_KEYWORDS}, {NULL, NULL} }; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 5 21:22:50 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 5 Jan 2013 21:22:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=238109=3A_The_ssl_m?= =?utf-8?q?odule_now_has_support_for_server-side_SNI=2C_thanks_to_a?= Message-ID: <3YdvSB47kpzQjG@mail.python.org> http://hg.python.org/cpython/rev/927afb7bca2a changeset: 81298:927afb7bca2a user: Antoine Pitrou date: Sat Jan 05 21:20:29 2013 +0100 summary: Issue #8109: The ssl module now has support for server-side SNI, thanks to a :meth:`SSLContext.set_servername_callback` method. Patch by Daniel Black. files: Doc/library/ssl.rst | 71 +++++++ Lib/ssl.py | 92 +++++--- Lib/test/keycert3.pem | 73 +++++++ Lib/test/keycert4.pem | 73 +++++++ Lib/test/make_ssl_certs.py | 112 ++++++++++- Lib/test/pycacert.pem | 78 +++++++ Lib/test/pycakey.pem | 28 ++ Lib/test/test_ssl.py | 138 +++++++++++++- Misc/ACKS | 1 + Misc/NEWS | 4 + Modules/_ssl.c | 253 ++++++++++++++++++++++++- 11 files changed, 881 insertions(+), 42 deletions(-) diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -533,6 +533,19 @@ .. versionadded:: 3.2 +.. data:: ALERT_DESCRIPTION_HANDSHAKE_FAILURE + ALERT_DESCRIPTION_INTERNAL_ERROR + ALERT_DESCRIPTION_* + + Alert Descriptions from :rfc:`5246` and others. The `IANA TLS Alert Registry + `_ + contains this list and references to the RFCs where their meaning is defined. + + Used as the return value of the callback function in + :meth:`SSLContext.set_servername_callback`. + + .. versionadded:: 3.4 + SSL Sockets ----------- @@ -780,6 +793,55 @@ .. versionadded:: 3.3 +.. method:: SSLContext.set_servername_callback(server_name_callback) + + Register a callback function that will be called after the TLS Client Hello + handshake message has been received by the SSL/TLS server when the TLS client + specifies a server name indication. The server name indication mechanism + is specified in :rfc:`6066` section 3 - Server Name Indication. + + Only one callback can be set per ``SSLContext``. If *server_name_callback* + is ``None`` then the callback is disabled. Calling this function a + subsequent time will disable the previously registered callback. + + The callback function, *server_name_callback*, will be called with three + arguments; the first being the :class:`ssl.SSLSocket`, the second is a string + that represents the server name that the client is intending to communicate + and the third argument is the original :class:`SSLContext`. The server name + argument is the IDNA decoded server name. + + A typical use of this callback is to change the :class:`ssl.SSLSocket`'s + :attr:`SSLSocket.context` attribute to a new object of type + :class:`SSLContext` representing a certificate chain that matches the server + name. + + Due to the early negotiation phase of the TLS connection, only limited + methods and attributes are usable like + :meth:`SSLSocket.selected_npn_protocol` and :attr:`SSLSocket.context`. + :meth:`SSLSocket.getpeercert`, :meth:`SSLSocket.getpeercert`, + :meth:`SSLSocket.cipher` and :meth:`SSLSocket.compress` methods require that + the TLS connection has progressed beyond the TLS Client Hello and therefore + will not contain return meaningful values nor can they be called safely. + + The *server_name_callback* function must return ``None`` to allow the + the TLS negotiation to continue. If a TLS failure is required, a constant + :const:`ALERT_DESCRIPTION_* ` can be + returned. Other return values will result in a TLS fatal error with + :const:`ALERT_DESCRIPTION_INTERNAL_ERROR`. + + If there is a IDNA decoding error on the server name, the TLS connection + will terminate with an :const:`ALERT_DESCRIPTION_INTERNAL_ERROR` fatal TLS + alert message to the client. + + If an exception is raised from the *server_name_callback* function the TLS + connection will terminate with a fatal TLS alert message + :const:`ALERT_DESCRIPTION_HANDSHAKE_FAILURE`. + + This method will raise :exc:`NotImplementedError` if the OpenSSL library + had OPENSSL_NO_TLSEXT defined when it was built. + + .. versionadded:: 3.4 + .. method:: SSLContext.load_dh_params(dhfile) Load the key generation parameters for Diffie-Helman (DH) key exchange. @@ -1313,3 +1375,12 @@ `RFC 4366: Transport Layer Security (TLS) Extensions `_ Blake-Wilson et. al. + + `RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 `_ + T. Dierks et. al. + + `RFC 6066: Transport Layer Security (TLS) Extensions `_ + D. Eastlake + + `IANA TLS: Transport Layer Security (TLS) Parameters `_ + IANA diff --git a/Lib/ssl.py b/Lib/ssl.py --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -52,6 +52,37 @@ PROTOCOL_SSLv3 PROTOCOL_SSLv23 PROTOCOL_TLSv1 + +The following constants identify various SSL alert message descriptions as per +http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6 + +ALERT_DESCRIPTION_CLOSE_NOTIFY +ALERT_DESCRIPTION_UNEXPECTED_MESSAGE +ALERT_DESCRIPTION_BAD_RECORD_MAC +ALERT_DESCRIPTION_RECORD_OVERFLOW +ALERT_DESCRIPTION_DECOMPRESSION_FAILURE +ALERT_DESCRIPTION_HANDSHAKE_FAILURE +ALERT_DESCRIPTION_BAD_CERTIFICATE +ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE +ALERT_DESCRIPTION_CERTIFICATE_REVOKED +ALERT_DESCRIPTION_CERTIFICATE_EXPIRED +ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN +ALERT_DESCRIPTION_ILLEGAL_PARAMETER +ALERT_DESCRIPTION_UNKNOWN_CA +ALERT_DESCRIPTION_ACCESS_DENIED +ALERT_DESCRIPTION_DECODE_ERROR +ALERT_DESCRIPTION_DECRYPT_ERROR +ALERT_DESCRIPTION_PROTOCOL_VERSION +ALERT_DESCRIPTION_INSUFFICIENT_SECURITY +ALERT_DESCRIPTION_INTERNAL_ERROR +ALERT_DESCRIPTION_USER_CANCELLED +ALERT_DESCRIPTION_NO_RENEGOTIATION +ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION +ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +ALERT_DESCRIPTION_UNRECOGNIZED_NAME +ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE +ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE +ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY """ import textwrap @@ -66,35 +97,24 @@ SSLSyscallError, SSLEOFError, ) from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED -from _ssl import ( - OP_ALL, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1, - OP_CIPHER_SERVER_PREFERENCE, OP_SINGLE_DH_USE - ) -try: - from _ssl import OP_NO_COMPRESSION -except ImportError: - pass -try: - from _ssl import OP_SINGLE_ECDH_USE -except ImportError: - pass from _ssl import RAND_status, RAND_egd, RAND_add, RAND_bytes, RAND_pseudo_bytes -from _ssl import ( - SSL_ERROR_ZERO_RETURN, - SSL_ERROR_WANT_READ, - SSL_ERROR_WANT_WRITE, - SSL_ERROR_WANT_X509_LOOKUP, - SSL_ERROR_SYSCALL, - SSL_ERROR_SSL, - SSL_ERROR_WANT_CONNECT, - SSL_ERROR_EOF, - SSL_ERROR_INVALID_ERROR_CODE, - ) + +def _import_symbols(prefix): + for n in dir(_ssl): + if n.startswith(prefix): + globals()[n] = getattr(_ssl, n) + +_import_symbols('OP_') +_import_symbols('ALERT_DESCRIPTION_') +_import_symbols('SSL_ERROR_') + from _ssl import HAS_SNI, HAS_ECDH, HAS_NPN + from _ssl import (PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1) from _ssl import _OPENSSL_API_VERSION + _PROTOCOL_NAMES = { PROTOCOL_TLSv1: "TLSv1", PROTOCOL_SSLv23: "SSLv23", @@ -190,7 +210,7 @@ """An SSLContext holds various SSL-related configuration options and data, such as certificates and possibly a private key.""" - __slots__ = ('protocol',) + __slots__ = ('protocol', '__weakref__') def __new__(cls, protocol, *args, **kwargs): self = _SSLContext.__new__(cls, protocol) @@ -238,7 +258,7 @@ _context=None): if _context: - self.context = _context + self._context = _context else: if server_side and not certfile: raise ValueError("certfile must be specified for server-side " @@ -247,16 +267,16 @@ raise ValueError("certfile must be specified") if certfile and not keyfile: keyfile = certfile - self.context = SSLContext(ssl_version) - self.context.verify_mode = cert_reqs + self._context = SSLContext(ssl_version) + self._context.verify_mode = cert_reqs if ca_certs: - self.context.load_verify_locations(ca_certs) + self._context.load_verify_locations(ca_certs) if certfile: - self.context.load_cert_chain(certfile, keyfile) + self._context.load_cert_chain(certfile, keyfile) if npn_protocols: - self.context.set_npn_protocols(npn_protocols) + self._context.set_npn_protocols(npn_protocols) if ciphers: - self.context.set_ciphers(ciphers) + self._context.set_ciphers(ciphers) self.keyfile = keyfile self.certfile = certfile self.cert_reqs = cert_reqs @@ -298,7 +318,7 @@ if connected: # create the SSL object try: - self._sslobj = self.context._wrap_socket(self, server_side, + self._sslobj = self._context._wrap_socket(self, server_side, server_hostname) if do_handshake_on_connect: timeout = self.gettimeout() @@ -310,6 +330,14 @@ except OSError as x: self.close() raise x + @property + def context(self): + return self._context + + @context.setter + def context(self, ctx): + self._context = ctx + self._sslobj.context = ctx def dup(self): raise NotImplemented("Can't dup() %s instances" % diff --git a/Lib/test/keycert3.pem b/Lib/test/keycert3.pem new file mode 100644 --- /dev/null +++ b/Lib/test/keycert3.pem @@ -0,0 +1,73 @@ +-----BEGIN PRIVATE KEY----- +MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMLgD0kAKDb5cFyP +jbwNfR5CtewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM +9z2j1OlaN+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZ +aggEdkj1TsSsv1zWIYKlPIjlvhuxAgMBAAECgYA0aH+T2Vf3WOPv8KdkcJg6gCRe +yJKXOWgWRcicx/CUzOEsTxmFIDPLxqAWA3k7v0B+3vjGw5Y9lycV/5XqXNoQI14j +y09iNsumds13u5AKkGdTJnZhQ7UKdoVHfuP44ZdOv/rJ5/VD6F4zWywpe90pcbK+ +AWDVtusgGQBSieEl1QJBAOyVrUG5l2yoUBtd2zr/kiGm/DYyXlIthQO/A3/LngDW +5/ydGxVsT7lAVOgCsoT+0L4efTh90PjzW8LPQrPBWVMCQQDS3h/FtYYd5lfz+FNL +9CEe1F1w9l8P749uNUD0g317zv1tatIqVCsQWHfVHNdVvfQ+vSFw38OORO00Xqs9 +1GJrAkBkoXXEkxCZoy4PteheO/8IWWLGGr6L7di6MzFl1lIqwT6D8L9oaV2vynFT +DnKop0pa09Unhjyw57KMNmSE2SUJAkEArloTEzpgRmCq4IK2/NpCeGdHS5uqRlbh +1VIa/xGps7EWQl5Mn8swQDel/YP3WGHTjfx7pgSegQfkyaRtGpZ9OQJAa9Vumj8m +JAAtI0Bnga8hgQx7BhTQY4CadDxyiRGOGYhwUzYVCqkb2sbVRH9HnwUaJT7cWBY3 +RnJdHOMXWem7/w== +-----END PRIVATE KEY----- +Certificate: + Data: + Version: 1 (0x0) + Serial Number: 12723342612721443281 (0xb09264b1f2da21d1) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server + Validity + Not Before: Jan 4 19:47:07 2013 GMT + Not After : Nov 13 19:47:07 2022 GMT + Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=localhost + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (1024 bit) + Modulus: + 00:c2:e0:0f:49:00:28:36:f9:70:5c:8f:8d:bc:0d: + 7d:1e:42:b5:ec:1d:5c:2f:a4:31:70:16:0f:c0:cb: + c6:24:d3:be:13:16:ee:a5:67:97:03:a6:df:a9:99: + 96:cc:c7:2a:fb:11:7f:4e:65:4f:8a:5e:82:21:4c: + f7:3d:a3:d4:e9:5a:37:e7:22:fd:7e:cd:53:6d:93: + 34:de:9c:ad:84:a2:37:be:c5:8d:82:4f:e3:ae:23: + f3:be:a7:75:2c:72:0f:ea:f3:ca:cd:fc:e9:3f:b5: + af:56:99:6a:08:04:76:48:f5:4e:c4:ac:bf:5c:d6: + 21:82:a5:3c:88:e5:be:1b:b1 + Exponent: 65537 (0x10001) + Signature Algorithm: sha1WithRSAEncryption + 2f:42:5f:a3:09:2c:fa:51:88:c7:37:7f:ea:0e:63:f0:a2:9a: + e5:5a:e2:c8:20:f0:3f:60:bc:c8:0f:b6:c6:76:ce:db:83:93: + f5:a3:33:67:01:8e:04:cd:00:9a:73:fd:f3:35:86:fa:d7:13: + e2:46:c6:9d:c0:29:53:d4:a9:90:b8:77:4b:e6:83:76:e4:92: + d6:9c:50:cf:43:d0:c6:01:77:61:9a:de:9b:70:f7:72:cd:59: + 00:31:69:d9:b4:ca:06:9c:6d:c3:c7:80:8c:68:e6:b5:a2:f8: + ef:1d:bb:16:9f:77:77:ef:87:62:22:9b:4d:69:a4:3a:1a:f1: + 21:5e:8c:32:ac:92:fd:15:6b:18:c2:7f:15:0d:98:30:ca:75: + 8f:1a:71:df:da:1d:b2:ef:9a:e8:2d:2e:02:fd:4a:3c:aa:96: + 0b:06:5d:35:b3:3d:24:87:4b:e0:b0:58:60:2f:45:ac:2e:48: + 8a:b0:99:10:65:27:ff:cc:b1:d8:fd:bd:26:6b:b9:0c:05:2a: + f4:45:63:35:51:07:ed:83:85:fe:6f:69:cb:bb:40:a8:ae:b6: + 3b:56:4a:2d:a4:ed:6d:11:2c:4d:ed:17:24:fd:47:bc:d3:41: + a2:d3:06:fe:0c:90:d8:d8:94:26:c4:ff:cc:a1:d8:42:77:eb: + fc:a9:94:71 +-----BEGIN CERTIFICATE----- +MIICpDCCAYwCCQCwkmSx8toh0TANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY +WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV +BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 +WjBfMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV +BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRIwEAYDVQQDEwlsb2NhbGhv +c3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMLgD0kAKDb5cFyPjbwNfR5C +tewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM9z2j1Ola +N+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZaggEdkj1 +TsSsv1zWIYKlPIjlvhuxAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAC9CX6MJLPpR +iMc3f+oOY/CimuVa4sgg8D9gvMgPtsZ2ztuDk/WjM2cBjgTNAJpz/fM1hvrXE+JG +xp3AKVPUqZC4d0vmg3bkktacUM9D0MYBd2Ga3ptw93LNWQAxadm0ygacbcPHgIxo +5rWi+O8duxafd3fvh2Iim01ppDoa8SFejDKskv0VaxjCfxUNmDDKdY8acd/aHbLv +mugtLgL9SjyqlgsGXTWzPSSHS+CwWGAvRawuSIqwmRBlJ//Msdj9vSZruQwFKvRF +YzVRB+2Dhf5vacu7QKiutjtWSi2k7W0RLE3tFyT9R7zTQaLTBv4MkNjYlCbE/8yh +2EJ36/yplHE= +-----END CERTIFICATE----- diff --git a/Lib/test/keycert4.pem b/Lib/test/keycert4.pem new file mode 100644 --- /dev/null +++ b/Lib/test/keycert4.pem @@ -0,0 +1,73 @@ +-----BEGIN PRIVATE KEY----- +MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAK5UQiMI5VkNs2Qv +L7gUaiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2 +NkX0ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1 +L2OQhEx1GM6RydHdgX69G64LXcY5AgMBAAECgYAhsRMfJkb9ERLMl/oG/5sLQu9L +pWDKt6+ZwdxzlZbggQ85CMYshjLKIod2DLL/sLf2x1PRXyRG131M1E3k8zkkz6de +R1uDrIN/x91iuYzfLQZGh8bMY7Yjd2eoroa6R/7DjpElGejLxOAaDWO0ST2IFQy9 +myTGS2jSM97wcXfsSQJBANP3jelJoS5X6BRjTSneY21wcocxVuQh8pXpErALVNsT +drrFTeaBuZp7KvbtnIM5g2WRNvaxLZlAY/hXPJvi6ncCQQDSix1cebml6EmPlEZS +Mm8gwI2F9ufUunwJmBJcz826Do0ZNGByWDAM/JQZH4FX4GfAFNuj8PUb+GQfadkx +i1DPAkEA0lVsNHojvuDsIo8HGuzarNZQT2beWjJ1jdxh9t7HrTx7LIps6rb/fhOK +Zs0R6gVAJaEbcWAPZ2tFyECInAdnsQJAUjaeXXjuxFkjOFym5PvqpvhpivEx78Bu +JPTr3rAKXmfGMxxfuOa0xK1wSyshP6ZR/RBn/+lcXPKubhHQDOegwwJAJF1DBQnN ++/tLmOPULtDwfP4Zixn+/8GmGOahFoRcu6VIGHmRilJTn6MOButw7Glv2YdeC6l/ +e83Gq6ffLVfKNQ== +-----END PRIVATE KEY----- +Certificate: + Data: + Version: 1 (0x0) + Serial Number: 12723342612721443282 (0xb09264b1f2da21d2) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server + Validity + Not Before: Jan 4 19:47:07 2013 GMT + Not After : Nov 13 19:47:07 2022 GMT + Subject: C=XY, L=Castle Anthrax, O=Python Software Foundation, CN=fakehostname + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (1024 bit) + Modulus: + 00:ae:54:42:23:08:e5:59:0d:b3:64:2f:2f:b8:14: + 6a:20:dd:15:eb:cd:51:74:63:53:80:c7:01:ed:d9: + cf:36:0b:64:d1:3a:f6:1f:60:3b:d5:42:49:2d:7a: + b4:9e:5f:4f:95:44:bb:41:19:c8:6a:f4:7b:75:76: + 36:45:f4:66:85:34:1d:cf:d4:69:8e:2a:c7:b2:c7: + 9a:7e:52:61:9a:48:c6:12:67:91:fe:d2:c8:72:4a: + d7:35:1a:1a:55:34:fc:bc:58:a8:8b:86:0a:d1:79: + 76:ac:75:2f:63:90:84:4c:75:18:ce:91:c9:d1:dd: + 81:7e:bd:1b:ae:0b:5d:c6:39 + Exponent: 65537 (0x10001) + Signature Algorithm: sha1WithRSAEncryption + ad:45:8a:8e:ef:c6:ef:04:41:5c:2c:4a:84:dc:02:76:0c:d0: + 66:0f:f0:16:04:58:4d:fd:68:b7:b8:d3:a8:41:a5:5c:3c:6f: + 65:3c:d1:f8:ce:43:35:e7:41:5f:53:3d:c9:2c:c3:7d:fc:56: + 4a:fa:47:77:38:9d:bb:97:28:0a:3b:91:19:7f:bc:74:ae:15: + 6b:bd:20:36:67:45:a5:1e:79:d7:75:e6:89:5c:6d:54:84:d1: + 95:d7:a7:b4:33:3c:af:37:c4:79:8f:5e:75:dc:75:c2:18:fb: + 61:6f:2d:dc:38:65:5b:ba:67:28:d0:88:d7:8d:b9:23:5a:8e: + e8:c6:bb:db:ce:d5:b8:41:2a:ce:93:08:b6:95:ad:34:20:18: + d5:3b:37:52:74:50:0b:07:2c:b0:6d:a4:4c:7b:f4:e0:fd:d1: + af:17:aa:20:cd:62:e3:f0:9d:37:69:db:41:bd:d4:1c:fb:53: + 20:da:88:9d:76:26:67:ce:01:90:a7:80:1d:a9:5b:39:73:68: + 54:0a:d1:2a:03:1b:8f:3c:43:5d:5d:c4:51:f1:a7:e7:11:da: + 31:2c:49:06:af:04:f4:b8:3c:99:c4:20:b9:06:36:a2:00:92: + 61:1d:0c:6d:24:05:e2:82:e1:47:db:a0:5f:ba:b9:fb:ba:fa: + 49:12:1e:ce +-----BEGIN CERTIFICATE----- +MIICpzCCAY8CCQCwkmSx8toh0jANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJY +WTEmMCQGA1UECgwdUHl0aG9uIFNvZnR3YXJlIEZvdW5kYXRpb24gQ0ExFjAUBgNV +BAMMDW91ci1jYS1zZXJ2ZXIwHhcNMTMwMTA0MTk0NzA3WhcNMjIxMTEzMTk0NzA3 +WjBiMQswCQYDVQQGEwJYWTEXMBUGA1UEBxMOQ2FzdGxlIEFudGhyYXgxIzAhBgNV +BAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRUwEwYDVQQDEwxmYWtlaG9z +dG5hbWUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK5UQiMI5VkNs2QvL7gU +aiDdFevNUXRjU4DHAe3ZzzYLZNE69h9gO9VCSS16tJ5fT5VEu0EZyGr0e3V2NkX0 +ZoU0Hc/UaY4qx7LHmn5SYZpIxhJnkf7SyHJK1zUaGlU0/LxYqIuGCtF5dqx1L2OQ +hEx1GM6RydHdgX69G64LXcY5AgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAK1Fio7v +xu8EQVwsSoTcAnYM0GYP8BYEWE39aLe406hBpVw8b2U80fjOQzXnQV9TPcksw338 +Vkr6R3c4nbuXKAo7kRl/vHSuFWu9IDZnRaUeedd15olcbVSE0ZXXp7QzPK83xHmP +XnXcdcIY+2FvLdw4ZVu6ZyjQiNeNuSNajujGu9vO1bhBKs6TCLaVrTQgGNU7N1J0 +UAsHLLBtpEx79OD90a8XqiDNYuPwnTdp20G91Bz7UyDaiJ12JmfOAZCngB2pWzlz +aFQK0SoDG488Q11dxFHxp+cR2jEsSQavBPS4PJnEILkGNqIAkmEdDG0kBeKC4Ufb +oF+6ufu6+kkSHs4= +-----END CERTIFICATE----- diff --git a/Lib/test/make_ssl_certs.py b/Lib/test/make_ssl_certs.py --- a/Lib/test/make_ssl_certs.py +++ b/Lib/test/make_ssl_certs.py @@ -2,6 +2,7 @@ and friends.""" import os +import shutil import sys import tempfile from subprocess import * @@ -20,11 +21,52 @@ [req_x509_extensions] subjectAltName = DNS:{hostname} + + [ ca ] + default_ca = CA_default + + [ CA_default ] + dir = cadir + database = $dir/index.txt + default_md = sha1 + default_days = 3600 + certificate = pycacert.pem + private_key = pycakey.pem + serial = $dir/serial + RANDFILE = $dir/.rand + + policy = policy_match + + [ policy_match ] + countryName = match + stateOrProvinceName = optional + organizationName = match + organizationalUnitName = optional + commonName = supplied + emailAddress = optional + + [ policy_anything ] + countryName = optional + stateOrProvinceName = optional + localityName = optional + organizationName = optional + organizationalUnitName = optional + commonName = supplied + emailAddress = optional + + + [ v3_ca ] + + subjectKeyIdentifier=hash + authorityKeyIdentifier=keyid:always,issuer + basicConstraints = CA:true + """ here = os.path.abspath(os.path.dirname(__file__)) -def make_cert_key(hostname): +def make_cert_key(hostname, sign=False): + print("creating cert for " + hostname) tempnames = [] for i in range(3): with tempfile.NamedTemporaryFile(delete=False) as f: @@ -33,10 +75,25 @@ try: with open(req_file, 'w') as f: f.write(req_template.format(hostname=hostname)) - args = ['req', '-new', '-days', '3650', '-nodes', '-x509', + args = ['req', '-new', '-days', '3650', '-nodes', '-newkey', 'rsa:1024', '-keyout', key_file, - '-out', cert_file, '-config', req_file] + '-config', req_file] + if sign: + with tempfile.NamedTemporaryFile(delete=False) as f: + tempnames.append(f.name) + reqfile = f.name + args += ['-out', reqfile ] + + else: + args += ['-x509', '-out', cert_file ] check_call(['openssl'] + args) + + if sign: + args = ['ca', '-config', req_file, '-out', cert_file, '-outdir', 'cadir', + '-policy', 'policy_anything', '-batch', '-infiles', reqfile ] + check_call(['openssl'] + args) + + with open(cert_file, 'r') as f: cert = f.read() with open(key_file, 'r') as f: @@ -46,6 +103,32 @@ for name in tempnames: os.remove(name) +TMP_CADIR = 'cadir' + +def unmake_ca(): + shutil.rmtree(TMP_CADIR) + +def make_ca(): + os.mkdir(TMP_CADIR) + with open(os.path.join('cadir','index.txt'),'a+') as f: + pass # empty file + with open(os.path.join('cadir','index.txt.attr'),'w+') as f: + f.write('unique_subject = no') + + with tempfile.NamedTemporaryFile("w") as t: + t.write(req_template.format(hostname='our-ca-server')) + t.flush() + with tempfile.NamedTemporaryFile() as f: + args = ['req', '-new', '-days', '3650', '-extensions', 'v3_ca', '-nodes', + '-newkey', 'rsa:2048', '-keyout', 'pycakey.pem', + '-out', f.name, + '-subj', '/C=XY/L=Castle Anthrax/O=Python Software Foundation CA/CN=our-ca-server'] + check_call(['openssl'] + args) + args = ['ca', '-config', t.name, '-create_serial', + '-out', 'pycacert.pem', '-batch', '-outdir', TMP_CADIR, + '-keyfile', 'pycakey.pem', '-days', '3650', + '-selfsign', '-extensions', 'v3_ca', '-infiles', f.name ] + check_call(['openssl'] + args) if __name__ == '__main__': os.chdir(here) @@ -54,11 +137,34 @@ f.write(cert) with open('ssl_key.pem', 'w') as f: f.write(key) + print("password protecting ssl_key.pem in ssl_key.passwd.pem") + check_call(['openssl','rsa','-in','ssl_key.pem','-out','ssl_key.passwd.pem','-des3','-passout','pass:somepass']) + check_call(['openssl','rsa','-in','ssl_key.pem','-out','keycert.passwd.pem','-des3','-passout','pass:somepass']) + with open('keycert.pem', 'w') as f: f.write(key) f.write(cert) + + with open('keycert.passwd.pem', 'a+') as f: + f.write(cert) + # For certificate matching tests + make_ca() cert, key = make_cert_key('fakehostname') with open('keycert2.pem', 'w') as f: f.write(key) f.write(cert) + + cert, key = make_cert_key('localhost', True) + with open('keycert3.pem', 'w') as f: + f.write(key) + f.write(cert) + + cert, key = make_cert_key('fakehostname', True) + with open('keycert4.pem', 'w') as f: + f.write(key) + f.write(cert) + + unmake_ca() + print("\n\nPlease change the values in test_ssl.py, test_parse_cert function related to notAfter,notBefore and serialNumber") + check_call(['openssl','x509','-in','keycert.pem','-dates','-serial','-noout']) diff --git a/Lib/test/pycacert.pem b/Lib/test/pycacert.pem new file mode 100644 --- /dev/null +++ b/Lib/test/pycacert.pem @@ -0,0 +1,78 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 12723342612721443280 (0xb09264b1f2da21d0) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=XY, O=Python Software Foundation CA, CN=our-ca-server + Validity + Not Before: Jan 4 19:47:07 2013 GMT + Not After : Jan 2 19:47:07 2023 GMT + Subject: C=XY, O=Python Software Foundation CA, CN=our-ca-server + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (2048 bit) + Modulus: + 00:e7:de:e9:e3:0c:9f:00:b6:a1:fd:2b:5b:96:d2: + 6f:cc:e0:be:86:b9:20:5e:ec:03:7a:55:ab:ea:a4: + e9:f9:49:85:d2:66:d5:ed:c7:7a:ea:56:8e:2d:8f: + e7:42:e2:62:28:a9:9f:d6:1b:8e:eb:b5:b4:9c:9f: + 14:ab:df:e6:94:8b:76:1d:3e:6d:24:61:ed:0c:bf: + 00:8a:61:0c:df:5c:c8:36:73:16:00:cd:47:ba:6d: + a4:a4:74:88:83:23:0a:19:fc:09:a7:3c:4a:4b:d3: + e7:1d:2d:e4:ea:4c:54:21:f3:26:db:89:37:18:d4: + 02:bb:40:32:5f:a4:ff:2d:1c:f7:d4:bb:ec:8e:cf: + 5c:82:ac:e6:7c:08:6c:48:85:61:07:7f:25:e0:5c: + e0:bc:34:5f:e0:b9:04:47:75:c8:47:0b:8d:bc:d6: + c8:68:5f:33:83:62:d2:20:44:35:b1:ad:81:1a:8a: + cd:bc:35:b0:5c:8b:47:d6:18:e9:9c:18:97:cc:01: + 3c:29:cc:e8:1e:e4:e4:c1:b8:de:e7:c2:11:18:87: + 5a:93:34:d8:a6:25:f7:14:71:eb:e4:21:a2:d2:0f: + 2e:2e:d4:62:00:35:d3:d6:ef:5c:60:4b:4c:a9:14: + e2:dd:15:58:46:37:33:26:b7:e7:2e:5d:ed:42:e4: + c5:4d + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B + X509v3 Authority Key Identifier: + keyid:BC:DD:62:D9:76:DA:1B:D2:54:6B:CF:E0:66:9B:1E:1E:7B:56:0C:0B + + X509v3 Basic Constraints: + CA:TRUE + Signature Algorithm: sha1WithRSAEncryption + 7d:0a:f5:cb:8d:d3:5d:bd:99:8e:f8:2b:0f:ba:eb:c2:d9:a6: + 27:4f:2e:7b:2f:0e:64:d8:1c:35:50:4e:ee:fc:90:b9:8d:6d: + a8:c5:c6:06:b0:af:f3:2d:bf:3b:b8:42:07:dd:18:7d:6d:95: + 54:57:85:18:60:47:2f:eb:78:1b:f9:e8:17:fd:5a:0d:87:17: + 28:ac:4c:6a:e6:bc:29:f4:f4:55:70:29:42:de:85:ea:ab:6c: + 23:06:64:30:75:02:8e:53:bc:5e:01:33:37:cc:1e:cd:b8:a4: + fd:ca:e4:5f:65:3b:83:1c:86:f1:55:02:a0:3a:8f:db:91:b7: + 40:14:b4:e7:8d:d2:ee:73:ba:e3:e5:34:2d:bc:94:6f:4e:24: + 06:f7:5f:8b:0e:a7:8e:6b:de:5e:75:f4:32:9a:50:b1:44:33: + 9a:d0:05:e2:78:82:ff:db:da:8a:63:eb:a9:dd:d1:bf:a0:61: + ad:e3:9e:8a:24:5d:62:0e:e7:4c:91:7f:ef:df:34:36:3b:2f: + 5d:f5:84:b2:2f:c4:6d:93:96:1a:6f:30:28:f1:da:12:9a:64: + b4:40:33:1d:bd:de:2b:53:a8:ea:be:d6:bc:4e:96:f5:44:fb: + 32:18:ae:d5:1f:f6:69:af:b6:4e:7b:1d:58:ec:3b:a9:53:a3: + 5e:58:c8:9e +-----BEGIN CERTIFICATE----- +MIIDbTCCAlWgAwIBAgIJALCSZLHy2iHQMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV +BAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUgRm91bmRhdGlvbiBDQTEW +MBQGA1UEAwwNb3VyLWNhLXNlcnZlcjAeFw0xMzAxMDQxOTQ3MDdaFw0yMzAxMDIx +OTQ3MDdaME0xCzAJBgNVBAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUg +Rm91bmRhdGlvbiBDQTEWMBQGA1UEAwwNb3VyLWNhLXNlcnZlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAOfe6eMMnwC2of0rW5bSb8zgvoa5IF7sA3pV +q+qk6flJhdJm1e3HeupWji2P50LiYiipn9Ybjuu1tJyfFKvf5pSLdh0+bSRh7Qy/ +AIphDN9cyDZzFgDNR7ptpKR0iIMjChn8Cac8SkvT5x0t5OpMVCHzJtuJNxjUArtA +Ml+k/y0c99S77I7PXIKs5nwIbEiFYQd/JeBc4Lw0X+C5BEd1yEcLjbzWyGhfM4Ni +0iBENbGtgRqKzbw1sFyLR9YY6ZwYl8wBPCnM6B7k5MG43ufCERiHWpM02KYl9xRx +6+QhotIPLi7UYgA109bvXGBLTKkU4t0VWEY3Mya35y5d7ULkxU0CAwEAAaNQME4w +HQYDVR0OBBYEFLzdYtl22hvSVGvP4GabHh57VgwLMB8GA1UdIwQYMBaAFLzdYtl2 +2hvSVGvP4GabHh57VgwLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB +AH0K9cuN0129mY74Kw+668LZpidPLnsvDmTYHDVQTu78kLmNbajFxgawr/Mtvzu4 +QgfdGH1tlVRXhRhgRy/reBv56Bf9Wg2HFyisTGrmvCn09FVwKULeheqrbCMGZDB1 +Ao5TvF4BMzfMHs24pP3K5F9lO4MchvFVAqA6j9uRt0AUtOeN0u5zuuPlNC28lG9O +JAb3X4sOp45r3l519DKaULFEM5rQBeJ4gv/b2opj66nd0b+gYa3jnookXWIO50yR +f+/fNDY7L131hLIvxG2TlhpvMCjx2hKaZLRAMx293itTqOq+1rxOlvVE+zIYrtUf +9mmvtk57HVjsO6lTo15YyJ4= +-----END CERTIFICATE----- diff --git a/Lib/test/pycakey.pem b/Lib/test/pycakey.pem new file mode 100644 --- /dev/null +++ b/Lib/test/pycakey.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDn3unjDJ8AtqH9 +K1uW0m/M4L6GuSBe7AN6VavqpOn5SYXSZtXtx3rqVo4tj+dC4mIoqZ/WG47rtbSc +nxSr3+aUi3YdPm0kYe0MvwCKYQzfXMg2cxYAzUe6baSkdIiDIwoZ/AmnPEpL0+cd +LeTqTFQh8ybbiTcY1AK7QDJfpP8tHPfUu+yOz1yCrOZ8CGxIhWEHfyXgXOC8NF/g +uQRHdchHC4281shoXzODYtIgRDWxrYEais28NbBci0fWGOmcGJfMATwpzOge5OTB +uN7nwhEYh1qTNNimJfcUcevkIaLSDy4u1GIANdPW71xgS0ypFOLdFVhGNzMmt+cu +Xe1C5MVNAgMBAAECggEBAJPM7QuUrPn4cLN/Ysd15lwTWn9oHDFFgkYFvCs66gXE +ju/6Kx2BjWE4wTJby09AHM/MqB0DvguT7Mf1Q2j3tPQ1HZowg8OwRDleuwp6KIls +jBbhL0Jdl/5HC67ktWvZ9wNvO/wFG1rQfT6FVajf9LUbWEaSZbOG2SLhHfsHorzu +xjTJaI3bQ/0+79B1exwk5ruwhzFRd/XpY8hls7D/RfPIuHDlBghkW3N59KFWrf5h +6bNEh2THm0+IyGcGqs0FD+QCOXyvsjwSUswqrr2ctLREOeDcd5ReUjSxYgjcJRrm +J7ceIY/+uwDJxw/OlnmBvF6pQMkKwYW2gFztu+g2t4UCgYEA/9yo01Exz4crxXsy +tAlnDJM++nZcm07rtFjTKHUfKY/cCgNTa8udM0svnfwlid/dpgLsI38gx04HHC1i +EZ4acz+ToIWedLxM0nq73//xeRWEazOvCz1mMTZaMldahTWAyzN8qVK2B/625Yy4 +wNYWyweBBwEB8MzaCs73spksXOsCgYEA5/7wvhiofYGFAfMuANeJIwDL2OtBnoOv +mVNfCmi3GC38fzwyi5ZpskWDiS2woJ+LQfs9Qu4EcZbUFLd7gbeOvb5gmFUtYope +LitUUKunIR18MkQ+mQDBpQPQPhk4QJP5reCbWkrfTu7b5o/iS41s6fBTFmuzhLcT +C71vFdCyeKcCgYAiCCqYeOtELDmBOeLDmaCQRqGQ1N96dOPbCBmF/xYXBCCDYG/f +HaUaJnz96YTgstsbcrYP/p/Qgqtlbw/lQf9IpwMuzbcG1ejt8g89OyDWNyt2ytgU +iaUnFJCos3/Byh0Iah/BsdOueo2/OJl2ZMOBW80orlSgv86cs2y037TL4wKBgQDm +OOyW+MlbowhnIvfoBfwlLEkefnej4nKD6WRLZBcue5Qyf355X06Mhsc9foXlH+6G +D9h/bswiHNdhp6N82rdgPGiHQx/CxiUoE/+b/nvgNO5mw6qLE2EXbG1e8pAMJcyE +bHw+YkawggDfELI036fRj5gki8SeUz8nS1nNgElbyQKBgCRDX9Jh+MwSLu4QBWdt +/fi+lv3K6kun/fI7EOV1vCV/j871tICu7pu5BrOLxAHqoVfU9AUX299/2KjCb5pv +kjogiUK6qWCWBlfuqDNWGCoUGt1rhznUva0nNjSMy5rinBhhjpROZC2pw48lOluP +UuvXsaPph7GTqPuy4Kab12YC +-----END PRIVATE KEY----- diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -48,6 +48,11 @@ CAPATH = data_file("capath") BYTES_CAPATH = os.fsencode(CAPATH) +# Two keys and certs signed by the same CA (for SNI tests) +SIGNED_CERTFILE = data_file("keycert3.pem") +SIGNED_CERTFILE2 = data_file("keycert4.pem") +SIGNING_CA = data_file("pycacert.pem") + SVN_PYTHON_ORG_ROOT_CERT = data_file("https_svn_python_org_root.pem") EMPTYCERT = data_file("nullcert.pem") @@ -59,6 +64,7 @@ DHFILE = data_file("dh512.pem") BYTES_DHFILE = os.fsencode(DHFILE) + def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) if support.verbose: @@ -89,6 +95,8 @@ else: return func +needs_sni = unittest.skipUnless(ssl.HAS_SNI, "SNI support needed for this test") + class BasicSocketTests(unittest.TestCase): @@ -142,6 +150,7 @@ (('organizationName', 'Python Software Foundation'),), (('commonName', 'localhost'),)) ) + # Note the next three asserts will fail if the keys are regenerated self.assertEqual(p['notAfter'], 'Oct 5 23:01:56 2020 GMT') self.assertEqual(p['notBefore'], 'Oct 8 23:01:56 2010 GMT') self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E') @@ -585,6 +594,34 @@ self.assertRaises(ValueError, ctx.set_ecdh_curve, "foo") self.assertRaises(ValueError, ctx.set_ecdh_curve, b"foo") + @needs_sni + def test_sni_callback(self): + ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + + # set_servername_callback expects a callable, or None + self.assertRaises(TypeError, ctx.set_servername_callback) + self.assertRaises(TypeError, ctx.set_servername_callback, 4) + self.assertRaises(TypeError, ctx.set_servername_callback, "") + self.assertRaises(TypeError, ctx.set_servername_callback, ctx) + + def dummycallback(sock, servername, ctx): + pass + ctx.set_servername_callback(None) + ctx.set_servername_callback(dummycallback) + + @needs_sni + def test_sni_callback_refcycle(self): + # Reference cycles through the servername callback are detected + # and cleared. + ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + def dummycallback(sock, servername, ctx, cycle=ctx): + pass + ctx.set_servername_callback(dummycallback) + wr = weakref.ref(ctx) + del ctx, dummycallback + gc.collect() + self.assertIs(wr(), None) + class SSLErrorTests(unittest.TestCase): @@ -1249,7 +1286,7 @@ raise AssertionError("Use of invalid cert should have failed!") def server_params_test(client_context, server_context, indata=b"FOO\n", - chatty=True, connectionchatty=False): + chatty=True, connectionchatty=False, sni_name=None): """ Launch a server, connect a client to it and try various reads and writes. @@ -1259,7 +1296,8 @@ chatty=chatty, connectionchatty=False) with server: - with client_context.wrap_socket(socket.socket()) as s: + with client_context.wrap_socket(socket.socket(), + server_hostname=sni_name) as s: s.connect((HOST, server.port)) for arg in [indata, bytearray(indata), memoryview(indata)]: if connectionchatty: @@ -1283,6 +1321,7 @@ stats.update({ 'compression': s.compression(), 'cipher': s.cipher(), + 'peercert': s.getpeercert(), 'client_npn_protocol': s.selected_npn_protocol() }) s.close() @@ -1988,6 +2027,100 @@ if len(stats['server_npn_protocols']) else 'nothing' self.assertEqual(server_result, expected, msg % (server_result, "server")) + def sni_contexts(self): + server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + server_context.load_cert_chain(SIGNED_CERTFILE) + other_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + other_context.load_cert_chain(SIGNED_CERTFILE2) + client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + client_context.verify_mode = ssl.CERT_REQUIRED + client_context.load_verify_locations(SIGNING_CA) + return server_context, other_context, client_context + + def check_common_name(self, stats, name): + cert = stats['peercert'] + self.assertIn((('commonName', name),), cert['subject']) + + @needs_sni + def test_sni_callback(self): + calls = [] + server_context, other_context, client_context = self.sni_contexts() + + def servername_cb(ssl_sock, server_name, initial_context): + calls.append((server_name, initial_context)) + ssl_sock.context = other_context + server_context.set_servername_callback(servername_cb) + + stats = server_params_test(client_context, server_context, + chatty=True, + sni_name='supermessage') + # The hostname was fetched properly, and the certificate was + # changed for the connection. + self.assertEqual(calls, [("supermessage", server_context)]) + # CERTFILE4 was selected + self.check_common_name(stats, 'fakehostname') + + # Check disabling the callback + calls = [] + server_context.set_servername_callback(None) + + stats = server_params_test(client_context, server_context, + chatty=True, + sni_name='notfunny') + # Certificate didn't change + self.check_common_name(stats, 'localhost') + self.assertEqual(calls, []) + + @needs_sni + def test_sni_callback_alert(self): + # Returning a TLS alert is reflected to the connecting client + server_context, other_context, client_context = self.sni_contexts() + + def cb_returning_alert(ssl_sock, server_name, initial_context): + return ssl.ALERT_DESCRIPTION_ACCESS_DENIED + server_context.set_servername_callback(cb_returning_alert) + + with self.assertRaises(ssl.SSLError) as cm: + stats = server_params_test(client_context, server_context, + chatty=False, + sni_name='supermessage') + self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_ACCESS_DENIED') + + @needs_sni + def test_sni_callback_raising(self): + # Raising fails the connection with a TLS handshake failure alert. + server_context, other_context, client_context = self.sni_contexts() + + def cb_raising(ssl_sock, server_name, initial_context): + 1/0 + server_context.set_servername_callback(cb_raising) + + with self.assertRaises(ssl.SSLError) as cm, \ + support.captured_stderr() as stderr: + stats = server_params_test(client_context, server_context, + chatty=False, + sni_name='supermessage') + self.assertEqual(cm.exception.reason, 'SSLV3_ALERT_HANDSHAKE_FAILURE') + self.assertIn("ZeroDivisionError", stderr.getvalue()) + + @needs_sni + def test_sni_callback_wrong_return_type(self): + # Returning the wrong return type terminates the TLS connection + # with an internal error alert. + server_context, other_context, client_context = self.sni_contexts() + + def cb_wrong_return_type(ssl_sock, server_name, initial_context): + return "foo" + server_context.set_servername_callback(cb_wrong_return_type) + + with self.assertRaises(ssl.SSLError) as cm, \ + support.captured_stderr() as stderr: + stats = server_params_test(client_context, server_context, + chatty=False, + sni_name='supermessage') + self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_INTERNAL_ERROR') + self.assertIn("TypeError", stderr.getvalue()) + def test_main(verbose=False): if support.verbose: @@ -2011,6 +2144,7 @@ for filename in [ CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, + SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -116,6 +116,7 @@ Philippe Biondi Stuart Bishop Roy Bixler +Daniel Black Jonathan Black Renaud Blanch Mike Bland diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -204,6 +204,10 @@ Library ------- +- Issue #8109: The ssl module now has support for server-side SNI, thanks + to a :meth:`SSLContext.set_servername_callback` method. Patch by Daniel + Black. + - Issue #16860: In tempfile, use O_CLOEXEC when available to set the close-on-exec flag atomically. diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -181,12 +181,16 @@ char *npn_protocols; int npn_protocols_len; #endif +#ifndef OPENSSL_NO_TLSEXT + PyObject *set_hostname; +#endif } PySSLContext; typedef struct { PyObject_HEAD PyObject *Socket; /* weakref to socket on which we're layered */ SSL *ssl; + PySSLContext *ctx; /* weakref to SSL context */ X509 *peer_cert; int shutdown_seen_zero; enum py_ssl_server_or_client socket_type; @@ -437,11 +441,12 @@ */ static PySSLSocket * -newPySSLSocket(SSL_CTX *ctx, PySocketSockObject *sock, +newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock, enum py_ssl_server_or_client socket_type, char *server_hostname) { PySSLSocket *self; + SSL_CTX *ctx = sslctx->ctx; self = PyObject_New(PySSLSocket, &PySSLSocket_Type); if (self == NULL) @@ -450,6 +455,8 @@ self->peer_cert = NULL; self->ssl = NULL; self->Socket = NULL; + self->ctx = sslctx; + Py_INCREF(sslctx); /* Make sure the SSL error state is initialized */ (void) ERR_get_state(); @@ -458,6 +465,7 @@ PySSL_BEGIN_ALLOW_THREADS self->ssl = SSL_new(ctx); PySSL_END_ALLOW_THREADS + SSL_set_app_data(self->ssl,self); SSL_set_fd(self->ssl, sock->sock_fd); #ifdef SSL_MODE_AUTO_RETRY SSL_set_mode(self->ssl, SSL_MODE_AUTO_RETRY); @@ -1164,6 +1172,38 @@ #endif } +static PySSLContext *PySSL_get_context(PySSLSocket *self, void *closure) { + Py_INCREF(self->ctx); + return self->ctx; +} + +static int PySSL_set_context(PySSLSocket *self, PyObject *value, + void *closure) { + + if (PyObject_TypeCheck(value, &PySSLContext_Type)) { + + Py_INCREF(value); + Py_DECREF(self->ctx); + self->ctx = (PySSLContext *) value; + SSL_set_SSL_CTX(self->ssl, self->ctx->ctx); + } else { + PyErr_SetString(PyExc_TypeError, "The value must be a SSLContext"); + return -1; + } + + return 0; +} + +PyDoc_STRVAR(PySSL_set_context_doc, +"_setter_context(ctx)\n\ +\ +This changes the context associated with the SSLSocket. This is typically\n\ +used from within a callback function set by the set_servername_callback\n\ +on the SSLContext to change the certificate information associated with the\n\ +SSLSocket before the cryptographic exchange handshake messages\n"); + + + static void PySSL_dealloc(PySSLSocket *self) { if (self->peer_cert) /* Possible not to have one? */ @@ -1171,6 +1211,7 @@ if (self->ssl) SSL_free(self->ssl); Py_XDECREF(self->Socket); + Py_XDECREF(self->ctx); PyObject_Del(self); } @@ -1606,6 +1647,12 @@ #endif /* HAVE_OPENSSL_FINISHED */ +static PyGetSetDef ssl_getsetlist[] = { + {"context", (getter) PySSL_get_context, + (setter) PySSL_set_context, PySSL_set_context_doc}, + {NULL}, /* sentinel */ +}; + static PyMethodDef PySSLMethods[] = { {"do_handshake", (PyCFunction)PySSL_SSLdo_handshake, METH_NOARGS}, {"write", (PyCFunction)PySSL_SSLwrite, METH_VARARGS, @@ -1660,6 +1707,8 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ PySSLMethods, /*tp_methods*/ + 0, /*tp_members*/ + ssl_getsetlist, /*tp_getset*/ }; @@ -1716,6 +1765,9 @@ #ifdef OPENSSL_NPN_NEGOTIATED self->npn_protocols = NULL; #endif +#ifndef OPENSSL_NO_TLSEXT + self->set_hostname = NULL; +#endif /* Defaults */ SSL_CTX_set_verify(self->ctx, SSL_VERIFY_NONE, NULL); SSL_CTX_set_options(self->ctx, @@ -1729,9 +1781,28 @@ return (PyObject *)self; } +static int +context_traverse(PySSLContext *self, visitproc visit, void *arg) +{ +#ifndef OPENSSL_NO_TLSEXT + Py_VISIT(self->set_hostname); +#endif + return 0; +} + +static int +context_clear(PySSLContext *self) +{ +#ifndef OPENSSL_NO_TLSEXT + Py_CLEAR(self->set_hostname); +#endif + return 0; +} + static void context_dealloc(PySSLContext *self) { + context_clear(self); SSL_CTX_free(self->ctx); #ifdef OPENSSL_NPN_NEGOTIATED PyMem_Free(self->npn_protocols); @@ -2223,7 +2294,7 @@ #endif } - res = (PyObject *) newPySSLSocket(self->ctx, sock, server_side, + res = (PyObject *) newPySSLSocket(self, sock, server_side, hostname); if (hostname != NULL) PyMem_Free(hostname); @@ -2308,6 +2379,131 @@ } #endif +#ifndef OPENSSL_NO_TLSEXT +static int +_servername_callback(SSL *s, int *al, void *args) +{ + int ret; + PySSLContext *ssl_ctx = (PySSLContext *) args; + PySSLSocket *ssl; + PyObject *servername_o; + PyObject *servername_idna; + PyObject *result; + /* The high-level ssl.SSLSocket object */ + PyObject *ssl_socket; + PyGILState_STATE gstate; + const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); + + gstate = PyGILState_Ensure(); + + if (ssl_ctx->set_hostname == NULL) { + /* remove race condition in this the call back while if removing the + * callback is in progress */ + PyGILState_Release(gstate); + return ret; + } + + ssl = SSL_get_app_data(s); + assert(PySSLSocket_Check(ssl)); + ssl_socket = PyWeakref_GetObject(ssl->Socket); + Py_INCREF(ssl_socket); + if (ssl_socket == Py_None) { + goto error; + } + + servername_o = PyBytes_FromString(servername); + if (servername_o == NULL) { + PyErr_WriteUnraisable((PyObject *) ssl_ctx); + goto error; + } + servername_idna = PyUnicode_FromEncodedObject(servername_o, "idna", NULL); + if (servername_idna == NULL) { + PyErr_WriteUnraisable(servername_o); + Py_DECREF(servername_o); + goto error; + } + Py_DECREF(servername_o); + result = PyObject_CallFunctionObjArgs(ssl_ctx->set_hostname, ssl_socket, + servername_idna, ssl_ctx, NULL); + Py_DECREF(ssl_socket); + Py_DECREF(servername_idna); + + if (result == NULL) { + PyErr_WriteUnraisable(ssl_ctx->set_hostname); + *al = SSL_AD_HANDSHAKE_FAILURE; + ret = SSL_TLSEXT_ERR_ALERT_FATAL; + } + else { + if (result != Py_None) { + *al = (int) PyLong_AsLong(result); + if (PyErr_Occurred()) { + PyErr_WriteUnraisable(result); + *al = SSL_AD_INTERNAL_ERROR; + } + ret = SSL_TLSEXT_ERR_ALERT_FATAL; + } + else { + ret = SSL_TLSEXT_ERR_OK; + } + Py_DECREF(result); + } + + PyGILState_Release(gstate); + return ret; + +error: + Py_DECREF(ssl_socket); + *al = SSL_AD_INTERNAL_ERROR; + ret = SSL_TLSEXT_ERR_ALERT_FATAL; + PyGILState_Release(gstate); + return ret; +} + +PyDoc_STRVAR(PySSL_set_servername_callback_doc, +"set_servername_callback(method)\n\ +\ +This sets a callback that will be called when a server name is provided by\n\ +the SSL/TLS client in the SNI extension.\n\ +\ +If the argument is None then the callback is disabled. The method is called\n\ +with the SSLSocket, the server name as a string, and the SSLContext object.\n\ +See RFC 6066 for details of the SNI"); +#endif + +static PyObject * +set_servername_callback(PySSLContext *self, PyObject *args) +{ +#ifndef OPENSSL_NO_TLSEXT + PyObject *cb; + + if (!PyArg_ParseTuple(args, "O", &cb)) + return NULL; + + Py_CLEAR(self->set_hostname); + if (cb == Py_None) { + SSL_CTX_set_tlsext_servername_callback(self->ctx, NULL); + } + else { + if (!PyCallable_Check(cb)) { + SSL_CTX_set_tlsext_servername_callback(self->ctx, NULL); + PyErr_SetString(PyExc_TypeError, + "not a callable object"); + return NULL; + } + Py_INCREF(cb); + self->set_hostname = cb; + SSL_CTX_set_tlsext_servername_callback(self->ctx, _servername_callback); + SSL_CTX_set_tlsext_servername_arg(self->ctx, self); + } + Py_RETURN_NONE; +#else + PyErr_SetString(PyExc_NotImplementedError, + "The TLS extension servername callback, " + "SSL_CTX_set_tlsext_servername_callback, " + "is not in the current OpenSSL library."); +#endif +} + static PyGetSetDef context_getsetlist[] = { {"options", (getter) get_options, (setter) set_options, NULL}, @@ -2337,6 +2533,8 @@ {"set_ecdh_curve", (PyCFunction) set_ecdh_curve, METH_O, NULL}, #endif + {"set_servername_callback", (PyCFunction) set_servername_callback, + METH_VARARGS, PySSL_set_servername_callback_doc}, {NULL, NULL} /* sentinel */ }; @@ -2360,10 +2558,10 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + (traverseproc) context_traverse, /*tp_traverse*/ + (inquiry) context_clear, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -2743,6 +2941,51 @@ PyModule_AddIntConstant(m, "CERT_REQUIRED", PY_SSL_CERT_REQUIRED); + /* Alert Descriptions from ssl.h */ + /* note RESERVED constants no longer intended for use have been removed */ + /* http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6 */ + +#define ADD_AD_CONSTANT(s) \ + PyModule_AddIntConstant(m, "ALERT_DESCRIPTION_"#s, \ + SSL_AD_##s) + + ADD_AD_CONSTANT(CLOSE_NOTIFY); + ADD_AD_CONSTANT(UNEXPECTED_MESSAGE); + ADD_AD_CONSTANT(BAD_RECORD_MAC); + ADD_AD_CONSTANT(RECORD_OVERFLOW); + ADD_AD_CONSTANT(DECOMPRESSION_FAILURE); + ADD_AD_CONSTANT(HANDSHAKE_FAILURE); + ADD_AD_CONSTANT(BAD_CERTIFICATE); + ADD_AD_CONSTANT(UNSUPPORTED_CERTIFICATE); + ADD_AD_CONSTANT(CERTIFICATE_REVOKED); + ADD_AD_CONSTANT(CERTIFICATE_EXPIRED); + ADD_AD_CONSTANT(CERTIFICATE_UNKNOWN); + ADD_AD_CONSTANT(ILLEGAL_PARAMETER); + ADD_AD_CONSTANT(UNKNOWN_CA); + ADD_AD_CONSTANT(ACCESS_DENIED); + ADD_AD_CONSTANT(DECODE_ERROR); + ADD_AD_CONSTANT(DECRYPT_ERROR); + ADD_AD_CONSTANT(PROTOCOL_VERSION); + ADD_AD_CONSTANT(INSUFFICIENT_SECURITY); + ADD_AD_CONSTANT(INTERNAL_ERROR); + ADD_AD_CONSTANT(USER_CANCELLED); + ADD_AD_CONSTANT(NO_RENEGOTIATION); + ADD_AD_CONSTANT(UNSUPPORTED_EXTENSION); + ADD_AD_CONSTANT(CERTIFICATE_UNOBTAINABLE); + ADD_AD_CONSTANT(UNRECOGNIZED_NAME); + /* Not all constants are in old OpenSSL versions */ +#ifdef SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE + ADD_AD_CONSTANT(BAD_CERTIFICATE_STATUS_RESPONSE); +#endif +#ifdef SSL_AD_BAD_CERTIFICATE_HASH_VALUE + ADD_AD_CONSTANT(BAD_CERTIFICATE_HASH_VALUE); +#endif +#ifdef SSL_AD_UNKNOWN_PSK_IDENTITY + ADD_AD_CONSTANT(UNKNOWN_PSK_IDENTITY); +#endif + +#undef ADD_AD_CONSTANT + /* protocol versions */ #ifndef OPENSSL_NO_SSL2 PyModule_AddIntConstant(m, "PROTOCOL_SSLv2", -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 00:32:05 2013 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 6 Jan 2013 00:32:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Open_issues=3A_signals=2C_tim?= =?utf-8?q?eouts=2E_Reminder=3A_factories_can_be_partial_funcs=2E?= Message-ID: <3YdzfY4RhDzS8m@mail.python.org> http://hg.python.org/peps/rev/cd5c24a3130f changeset: 4653:cd5c24a3130f user: Guido van Rossum date: Sat Jan 05 15:32:00 2013 -0800 summary: Open issues: signals, timeouts. Reminder: factories can be partial funcs. files: pep-3156.txt | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -269,12 +269,16 @@ Creates a transport and a protocol and ties them together. Returns a Future whose result on success is a (transport, protocol) pair. The protocol is created by calling ``protocol_factory()`` without - arguments. Note that when the Future completes, the protocol's + arguments(*). Note that when the Future completes, the protocol's ``connection_made()`` method has not yet been called; that will happen when the connection handshake is complete. When it is impossible to connect to the given host and port, the Future will raise an exception instead. + (*) There is no requirement that ``protocol_factory`` is a class. + If your protocol class needs to have specific arguments passed to + its constructor, you can use ``lambda`` or ``functools.partial()``. + Optional keyword arguments: - ``family``, ``type``, ``proto``, ``flags``: Address familty, @@ -292,10 +296,12 @@ loop that accepts connections. Returns a Future that completes once the loop is set up to serve; its return value is None. Each time a connection is accepted, ``protocol_factory`` is called without - arguments to create a protocol, a transport is created to represent + arguments(*) to create a protocol, a transport is created to represent the network side of the connection, and the two are tied together by calling ``protocol.connection_made(transport)``. + (*) See footnote above for ``create_transport()``. + Optional keyword arguments: - ``family``, ``type``, ``proto``, ``flags``: Address familty, @@ -894,6 +900,24 @@ Finally, do we need support for unconnected datagram protocols? (That would mean wrappers for ``sendto()`` and ``recvfrom()``.) +- Signal handling. This is pretty UNIX-specific, but sometimes an + application needs to intercept signals. It may be handy to have a + standard interface for this in the event loop, so everyone doesn't + have to reinvent this same wheel (with the same bugs). It's + possible that this can be a thin wrapper on top of + ``call_soon_threadsafe()`` (assuming its implementation doesn't use + locks -- if it does, something different is needed, since a signal + handler may run while the thread is already holding a lock). + +- We may need APIs to control various timeouts. E.g. we may want to + limit the time spent in DNS resolution, connecting, ssl handshake, + idle connection, close/shutdown, even per session. Possibly it's + sufficient to add ``timeout`` keyword parameters to some methods, + and other timeouts can probably be implemented by clever use of + ``call_later()`` and ``Task.cancel()``. But it's possible that some + operations need default timeouts, and we may want to change the + default for a specific operation globally (i.e., per event loop). + - An EventEmitter in the style of NodeJS? Or make this a separate PEP? It's easy enough to do in user space, though it may benefit from standardization. (See -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Sun Jan 6 05:55:07 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 06 Jan 2013 05:55:07 +0100 Subject: [Python-checkins] Daily reference leaks (927afb7bca2a): sum=0 Message-ID: results for 927afb7bca2a on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflog65m1Ic', '-x'] From python-checkins at python.org Sun Jan 6 08:25:44 2013 From: python-checkins at python.org (nick.coghlan) Date: Sun, 6 Jan 2013 08:25:44 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Updates_in_response_to_Barry_?= =?utf-8?q?Warsaw=27s_feedback?= Message-ID: <3YfB945Y7zzRpX@mail.python.org> http://hg.python.org/peps/rev/3eb7e4b587da changeset: 4654:3eb7e4b587da user: Nick Coghlan date: Sun Jan 06 17:22:45 2013 +1000 summary: Updates in response to Barry Warsaw's feedback files: pep-0432.txt | 217 ++++++++++++++++++++++++++------------ 1 files changed, 146 insertions(+), 71 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -40,19 +40,21 @@ well-defined phases during the startup sequence: * Pre-Initialization - no interpreter available -* Initialization - interpreter partially available -* Initialized - full interpreter available, __main__ related metadata +* Initializing - interpreter partially available +* Initialized - interpreter available, __main__ related metadata incomplete -* Main Execution - optional state, __main__ related metadata populated, - bytecode executing in the __main__ module namespace +* Main Execution - __main__ related metadata populated, bytecode + executing in the __main__ module namespace (embedding applications + may choose not to use this phase) As a concrete use case to help guide any design changes, and to solve a known problem where the appropriate defaults for system utilities differ from those for running user scripts, this PEP also proposes the creation and -distribution of a separate system Python (``spython``) executable which, by -default, ignores user site directories and environment variables, and does -not implicitly set ``sys.path[0]`` based on the current directory or the -script being executed. +distribution of a separate system Python (``pysystem``) executable +which, by default, ignores user site directories and environment variables, +and does not implicitly set ``sys.path[0]`` based on the current directory +or the script being executed (it will, however, still support virtual +environments). To keep the implementation complexity under control, this PEP does *not* propose wholesale changes to the way the interpreter state is accessed at @@ -84,12 +86,14 @@ safely. A number of proposals are on the table for even *more* sophisticated -startup behaviour, such as better control over ``sys.path`` initialization -(easily adding additional directories on the command line in a cross-platform -fashion, as well as controlling the configuration of ``sys.path[0]``), easier -configuration of utilities like coverage tracing when launching Python -subprocesses, and easier control of the encoding used for the standard IO -streams when embedding CPython in a larger application. +startup behaviour, such as an isolated mode equivalent to that described in +this PEP as a "system Python" [6_], better control over ``sys.path`` +initialization (easily adding additional directories on the command line +in a cross-platform fashion [7_], as well as controlling the configuration of +``sys.path[0]`` [8_]), easier configuration of utilities like coverage tracing +when launching Python subprocesses [9_], and easier control of the encoding +used for the standard IO streams when embedding CPython in a larger +application [10_]. Rather than attempting to bolt such behaviour onto an already complicated system, this PEP proposes to instead simplify the status quo *first*, with @@ -290,7 +294,7 @@ by several elements. The algorithm used to perform the calculation is not documented anywhere other than in the source code [3_,4_]. Even that description is incomplete, as it failed to be updated for the virtual -environment support added in Python 3.3 (detailed in PEP 420). +environment support added in Python 3.3 (detailed in PEP 405). These calculations are affected by the following function calls (made prior to calling ``Py_Initialize()``) and environment variables: @@ -299,11 +303,11 @@ * ``Py_SetPythonHome()`` * ``PYTHONHOME`` -The filesystem is also inspected for ``pyvenv.cfg`` files (see PEP 420) or, +The filesystem is also inspected for ``pyvenv.cfg`` files (see PEP 405) or, failing that, a ``lib/os.py`` (Windows) or ``lib/python$VERSION/os.py`` file. -The build time settings for PREFIX and EXEC_PREFIX are also relevant, +The build time settings for ``PREFIX`` and ``EXEC_PREFIX`` are also relevant, as are some registry settings on Windows. The hardcoded fallbacks are based on the layout of the CPython source tree and build output when working in a source checkout. @@ -509,7 +513,7 @@ main interpreter and moves to the next phase by calling ``Py_BeginInitialization``. -* Initialization: +* Initializing: * the main interpreter is available, but only partially configured. * ``Py_IsInitializing()`` returns ``1`` @@ -522,7 +526,8 @@ * Initialized: * the main interpreter is available and fully operational, but - ``__main__`` related metadata is incomplete. + ``__main__`` related metadata is incomplete and the site module may + not have been imported. * ``Py_IsInitializing()`` returns ``0`` * ``Py_IsInitialized()`` returns ``1`` * ``Py_IsRunningMain()`` returns ``0`` @@ -726,25 +731,36 @@ int Py_ReadConfiguration(PyConfig *config); -The config argument should be a pointer to a Python dictionary. For any -supported configuration setting already in the dictionary, CPython will -sanity check the supplied value, but otherwise accept it as correct. +The config argument should be a pointer to a config struct (which may be +a temporary one stored on the C stack). For any already configured value +(i.e. non-NULL pointer or non-negative numeric value), CPython will sanity +check the supplied value, but otherwise accept it as correct. + +A struct is used rather than a Python dictionary as the struct is easier +to work with from C, the list of supported fields is fixed for a given +CPython version and only a read-only view need to be exposed to Python +code (which is relatively straightforward, thanks to the infrastructure +already put in place to expose ``sys.implementation``). Unlike ``Py_Initialize`` and ``Py_BeginInitialization``, this call will raise an exception and report an error return rather than exhibiting fatal errors if a problem is found with the config data. Any supported configuration setting which is not already set will be -populated appropriately. The default configuration can be overridden -entirely by setting the value *before* calling ``Py_ReadConfiguration``. The -provided value will then also be used in calculating any settings derived -from that value. +populated appropriately in the supplied configuration struct. The default +configuration can be overridden entirely by setting the value *before* calling ``Py_ReadConfiguration``. The provided value will then also be used in +calculating any other settings derived from that value. Alternatively, settings may be overridden *after* the ``Py_ReadConfiguration`` call (this can be useful if an embedding application wants to adjust a setting rather than replace it completely, such as removing ``sys.path[0]``). +Merely reading the configuration has no effect on the interpreter state: it +only modifies the passed in configuration struct. The settings are not +applied to the running interpreter until the ``Py_EndInitialization`` call +(see below). + Supported configuration settings -------------------------------- @@ -756,44 +772,44 @@ /* Note: if changing anything in Py_Config, also update Py_Config_INIT */ typedef struct { /* Argument processing */ - PyList *raw_argv; - PyList *argv; - PyList *warnoptions; /* -W switch, PYTHONWARNINGS */ - PyDict *xoptions; /* -X switch */ + PyListObject *raw_argv; + PyListObject *argv; + PyListObject *warnoptions; /* -W switch, PYTHONWARNINGS */ + PyDictObject *xoptions; /* -X switch */ /* Filesystem locations */ - PyUnicode *program_name; - PyUnicode *executable; - PyUnicode *prefix; /* PYTHONHOME */ - PyUnicode *exec_prefix; /* PYTHONHOME */ - PyUnicode *base_prefix; /* pyvenv.cfg */ - PyUnicode *base_exec_prefix; /* pyvenv.cfg */ + PyUnicodeObject *program_name; + PyUnicodeObject *executable; + PyUnicodeObject *prefix; /* PYTHONHOME */ + PyUnicodeObject *exec_prefix; /* PYTHONHOME */ + PyUnicodeObject *base_prefix; /* pyvenv.cfg */ + PyUnicodeObject *base_exec_prefix; /* pyvenv.cfg */ /* Site module */ - int no_site; /* -S switch */ - int no_user_site; /* -s switch, PYTHONNOUSERSITE */ + int enable_site_config; /* -S switch (inverted) */ + int no_user_site; /* -s switch, PYTHONNOUSERSITE */ /* Import configuration */ - int dont_write_bytecode; /* -B switch, PYTHONDONTWRITEBYTECODE */ - int ignore_module_case; /* PYTHONCASEOK */ - PyList *import_path; /* PYTHONPATH (etc) */ + int dont_write_bytecode; /* -B switch, PYTHONDONTWRITEBYTECODE */ + int ignore_module_case; /* PYTHONCASEOK */ + PyListObject *import_path; /* PYTHONPATH (etc) */ /* Standard streams */ - int use_unbuffered_io; /* -u switch, PYTHONUNBUFFEREDIO */ - PyUnicode *stdin_encoding; /* PYTHONIOENCODING */ - PyUnicode *stdin_errors; /* PYTHONIOENCODING */ - PyUnicode *stdout_encoding; /* PYTHONIOENCODING */ - PyUnicode *stdout_errors; /* PYTHONIOENCODING */ - PyUnicode *stderr_encoding; /* PYTHONIOENCODING */ - PyUnicode *stderr_errors; /* PYTHONIOENCODING */ + int use_unbuffered_io; /* -u switch, PYTHONUNBUFFEREDIO */ + PyUnicodeObject *stdin_encoding; /* PYTHONIOENCODING */ + PyUnicodeObject *stdin_errors; /* PYTHONIOENCODING */ + PyUnicodeObject *stdout_encoding; /* PYTHONIOENCODING */ + PyUnicodeObject *stdout_errors; /* PYTHONIOENCODING */ + PyUnicodeObject *stderr_encoding; /* PYTHONIOENCODING */ + PyUnicodeObject *stderr_errors; /* PYTHONIOENCODING */ /* Filesystem access */ - PyUnicode *fs_encoding; + PyUnicodeObject *fs_encoding; /* Interactive interpreter */ - int stdin_is_interactive; /* Force interactive behaviour */ - int inspect_main; /* -i switch, PYTHONINSPECT */ - PyUnicode *startup_file; /* PYTHONSTARTUP */ + int stdin_is_interactive; /* Force interactive behaviour */ + int inspect_main; /* -i switch, PYTHONINSPECT */ + PyUnicodeObject *startup_file; /* PYTHONSTARTUP */ /* Debugging output */ int debug_parser; /* -d switch, PYTHONDEBUG */ @@ -810,7 +826,7 @@ /* Struct initialization is pretty ugly in C89. Avoiding this mess would - * be the most attractive aspect of using a PyDict* instead... */ + * be the most attractive aspect of using a PyDictObject* instead... */ #define _Py_ArgConfig_INIT NULL, NULL, NULL, NULL #define _Py_LocationConfig_INIT NULL, NULL, NULL, NULL, NULL, NULL #define _Py_SiteConfig_INIT -1, -1 @@ -839,7 +855,7 @@ configuration settings into effect and finish bootstrapping the interpreter up to full operation:: - int Py_EndInitialization(const PyConfig *config); + int Py_EndInitialization(const Py_Config *config); Like Py_ReadConfiguration, this call will raise an exception and report an error return rather than exhibiting fatal errors if a problem is found with @@ -853,6 +869,10 @@ ``Py_IsInitialized()`` will become true. The caveats described above for the interpreter during the initialization phase will no longer hold. +Attempting to call ``Py_EndInitialization()`` again when +``Py_IsInitializing()`` is false or ``Py_IsInitialized()`` is true is an +error. + However, some metadata related to the ``__main__`` module may still be incomplete: @@ -866,6 +886,12 @@ * the metadata in the ``__main__`` module will still indicate it is a builtin module +This function will normally implicitly import site as its final operation +(after ``Py_IsInitialized()`` is already set). Clearing the +"enable_site_config" flag in the configuration settings will disable this +behaviour, as well as eliminating any side effects on global state if +``import site`` is later explicitly executed in the process. + Executing the main module ------------------------- @@ -896,6 +922,13 @@ ``sys.implementation``. Field names will match those in the configuration structs, exception for ``hash_seed``, which will be deliberately excluded. +An underscored attribute is chosen deliberately, as these configuration +settings are part of the CPython implementation, rather than part of the +Python language definition. If settings are needed to support +cross-implementation compatibility in the standard library, then those +should be agreed with the other implementations and exposed as new required +attributes on ``sys.implementation``, as described in PEP 421. + These are *snapshots* of the initial configuration settings. They are not consulted by the interpreter during runtime. @@ -908,14 +941,22 @@ than merely writing an extension. +Build time configuration +------------------------ + +This PEP makes no changes to the handling of build time configuration +settings, and thus has no effect on the contents of ``sys.implementation`` +or the result of ``sysconfig.get_config_vars()``. + + Backwards Compatibility ----------------------- Backwards compatibility will be preserved primarily by ensuring that -Py_ReadConfiguration() interrogates all the previously defined configuration -settings stored in global variables and environment variables, and that -Py_EndInitialization() writes affected settings back to the relevant -locations. +``Py_ReadConfiguration()`` interrogates all the previously defined +configuration settings stored in global variables and environment variables, +and that ``Py_EndInitialization()`` writes affected settings back to the +relevant locations. One acknowledged incompatiblity is that some environment variables which are currently read lazily may instead be read once during interpreter @@ -943,19 +984,6 @@ of the old style initialization API. (very much TBC) -Open Questions -============== - -* Is ``Py_IsRunningMain()`` worth keeping? -* Should the answers to ``Py_IsInitialized()`` and ``Py_RunningMain()`` be - exposed via the ``sys`` module? -* Is the ``Py_Config`` struct too unwieldy to be practical? Would a Python - dictionary be a better choice? -* Would it be better to manage the flag variables in ``Py_Config`` as - Python integers so the struct can be initialized with a simple - ``memset(&config, 0, sizeof(*config))``? - - A System Python Executable ========================== @@ -966,6 +994,11 @@ environment variables are trusted and that the directory containing the executed file is placed at the beginning of the import path. +Issue 16499 [6_] proposes adding a ``-I`` option to change the behaviour of +the normal CPython executable, but this is a hard to discover solution (and +adds yet another option to an already complex CLI). This PEP proposes to +instead add a separate ``pysystem`` executable + Currently, providing a separate executable with different default behaviour would be prohibitively hard to maintain. One of the goals of this PEP is to make it possible to replace much of the hard to maintain bootstrapping code @@ -985,6 +1018,30 @@ * execution from stdin (non-interactive) * interactive stdin +Actually implementing this may also reveal the need for some better +argument parsing infrastructure for use during the initializing phase. + + +Open Questions +============== + +* Error details for Py_ReadConfiguration and Py_EndInitialization (these + should become clear as the implementation progresses) +* Is ``Py_IsRunningMain()`` worth keeping? +* Should the answers to ``Py_IsInitialized()`` and ``Py_IsRunningMain()`` be + exposed via the ``sys`` module? +* Is the ``Py_Config`` struct too unwieldy to be practical? Would a Python + dictionary be a better choice? +* Would it be better to manage the flag variables in ``Py_Config`` as + Python integers or as "negative means false, positive means true, zero + means not set" so the struct can be initialized with a simple + ``memset(&config, 0, sizeof(*config))``, eliminating the need to update + both Py_Config and Py_Config_INIT when adding new fields? +* The name of the system Python executable is a bikeshed waiting to be + painted. The 3 options considered so far are ``spython``, ``pysystem`` + and ``python-minimal``. The PEP text reflects my current preferred choice + i.e. ``pysystem``. + Implementation ============== @@ -1011,6 +1068,24 @@ .. [5] Site module documentation (http://docs.python.org/3/library/site.html) +.. [6] Proposed CLI option for isolated mode + (http://bugs.python.org/issue16499) + +.. [7] Adding to sys.path on the command line + (http://mail.python.org/pipermail/python-ideas/2010-October/008299.html) + (http://mail.python.org/pipermail/python-ideas/2012-September/016128.html) + +.. [8] Control sys.path[0] initialisation + (http://bugs.python.org/issue13475) + +.. [9] Enabling code coverage in subprocesses when testing + (http://bugs.python.org/issue14803) + +.. [10] Problems with PYTHONIOENCODING in Blender + (http://bugs.python.org/issue16129) + + + Copyright =========== This document has been placed in the public domain. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 6 13:30:15 2013 From: python-checkins at python.org (nick.coghlan) Date: Sun, 6 Jan 2013 13:30:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Correctly_mark_PEP_369_as_Wit?= =?utf-8?q?hdrawn_=28not_Rejected=29?= Message-ID: <3YfJwR4bg4zS0Y@mail.python.org> http://hg.python.org/peps/rev/235a1e14b4e2 changeset: 4655:235a1e14b4e2 user: Nick Coghlan date: Sun Jan 06 22:18:28 2013 +1000 summary: Correctly mark PEP 369 as Withdrawn (not Rejected) files: pep-0369.txt | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pep-0369.txt b/pep-0369.txt --- a/pep-0369.txt +++ b/pep-0369.txt @@ -3,18 +3,18 @@ Version: $Revision$ Last-Modified: $Date$ Author: Christian Heimes -Status: Rejected +Status: Withdrawn Type: Standards Track Content-Type: text/x-rst Created: 02-Jan-2008 Python-Version: 2.6, 3.0 Post-History: 02-Dec-2012 -Rejection Notice -================ +Withdrawal Notice +================= -This PEP is rejected by its author, because it has been superseded by the new -importlib. +This PEP is withdrawn by its author, because it has been superseded by the +new importlib. Abstract -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 6 13:30:16 2013 From: python-checkins at python.org (nick.coghlan) Date: Sun, 6 Jan 2013 13:30:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Clarify_PEP_369_withdrawal_no?= =?utf-8?q?tice?= Message-ID: <3YfJwS73FTzS0q@mail.python.org> http://hg.python.org/peps/rev/992e14d49bff changeset: 4656:992e14d49bff user: Nick Coghlan date: Sun Jan 06 22:29:09 2013 +1000 summary: Clarify PEP 369 withdrawal notice files: pep-0369.txt | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pep-0369.txt b/pep-0369.txt --- a/pep-0369.txt +++ b/pep-0369.txt @@ -10,11 +10,12 @@ Python-Version: 2.6, 3.0 Post-History: 02-Dec-2012 + Withdrawal Notice ================= -This PEP is withdrawn by its author, because it has been superseded by the -new importlib. +This PEP has been withdrawn by its author, as much of the detailed design +is no longer valid following the migration to importlib in Python 3.3. Abstract -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 6 15:27:57 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 6 Jan 2013 15:27:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_returning_uninitialize?= =?utf-8?q?d_variable_=28issue_=238109=29=2E?= Message-ID: <3YfMXF5w7HzP8y@mail.python.org> http://hg.python.org/cpython/rev/52b4d9bfc9ea changeset: 81299:52b4d9bfc9ea user: Antoine Pitrou date: Sun Jan 06 15:25:36 2013 +0100 summary: Fix returning uninitialized variable (issue #8109). Found by Christian with Coverity. files: Modules/_ssl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2400,7 +2400,7 @@ /* remove race condition in this the call back while if removing the * callback is in progress */ PyGILState_Release(gstate); - return ret; + return SSL_TLSEXT_ERR_OK; } ssl = SSL_get_app_data(s); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 16:42:30 2013 From: python-checkins at python.org (christian.heimes) Date: Sun, 6 Jan 2013 16:42:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2ODgx?= =?utf-8?q?=3A_Fix_Py=5FARRAY=5FLENGTH_macro_for_GCC_=3C_3=2E1=2E?= Message-ID: <3YfPBG22yBzQSF@mail.python.org> http://hg.python.org/cpython/rev/13c83199c211 changeset: 81300:13c83199c211 branch: 3.3 parent: 81296:c1fc6b6d1cfc user: Christian Heimes date: Sun Jan 06 16:41:56 2013 +0100 summary: Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. files: Include/pymacro.h | 7 +++++-- Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Include/pymacro.h b/Include/pymacro.h --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -29,8 +29,11 @@ parameters. With correct compiler support, such usage will cause a build error (see Py_BUILD_ASSERT_EXPR). - Written by Rusty Russell, public domain, http://ccodearchive.net/ */ -#if (defined(__GNUC__) && !defined(__STRICT_ANSI__)) + Written by Rusty Russell, public domain, http://ccodearchive.net/ + + Requires at GCC 3.1+ */ +#if (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \ + ((__GNUC__ == 3) && (__GNU_MINOR__ >= 1)) || (__GNUC__ >= 4)) /* Two gcc extensions. &a[0] degrades to a pointer: a different type from an array */ #define Py_ARRAY_LENGTH(array) \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. + - Issue #16856: Fix a segmentation fault from calling repr() on a dict with a key whose repr raise an exception. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 16:42:31 2013 From: python-checkins at python.org (christian.heimes) Date: Sun, 6 Jan 2013 16:42:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316881=3A_Fix_Py=5FARRAY=5FLENGTH_macro_for_GCC_?= =?utf-8?b?PCAzLjEu?= Message-ID: <3YfPBH4VtQzRpf@mail.python.org> http://hg.python.org/cpython/rev/2b5c0eeb2789 changeset: 81301:2b5c0eeb2789 parent: 81299:52b4d9bfc9ea parent: 81300:13c83199c211 user: Christian Heimes date: Sun Jan 06 16:42:20 2013 +0100 summary: Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. files: Include/pymacro.h | 7 +++++-- Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Include/pymacro.h b/Include/pymacro.h --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -29,8 +29,11 @@ parameters. With correct compiler support, such usage will cause a build error (see Py_BUILD_ASSERT_EXPR). - Written by Rusty Russell, public domain, http://ccodearchive.net/ */ -#if (defined(__GNUC__) && !defined(__STRICT_ANSI__)) + Written by Rusty Russell, public domain, http://ccodearchive.net/ + + Requires at GCC 3.1+ */ +#if (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \ + ((__GNUC__ == 3) && (__GNU_MINOR__ >= 1)) || (__GNUC__ >= 4)) /* Two gcc extensions. &a[0] degrades to a pointer: a different type from an array */ #define Py_ARRAY_LENGTH(array) \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. + - Issue #16856: Fix a segmentation fault from calling repr() on a dict with a key whose repr raise an exception. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 20:37:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 6 Jan 2013 20:37:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316320=3A_Remove_r?= =?utf-8?q?edundant_Makefile_dependencies_for_strings_and_bytes=2E?= Message-ID: <3YfVP40FWXzP77@mail.python.org> http://hg.python.org/cpython/rev/8a6068ec220e changeset: 81302:8a6068ec220e user: Serhiy Storchaka date: Sun Jan 06 21:36:21 2013 +0200 summary: Issue #16320: Remove redundant Makefile dependencies for strings and bytes. files: Makefile.pre.in | 21 ++++++++++----------- Misc/NEWS | 2 ++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -689,28 +689,30 @@ $(srcdir)/Objects/unicodetype_db.h BYTESTR_DEPS = \ - $(srcdir)/Include/bytes_methods.h \ $(srcdir)/Objects/stringlib/count.h \ $(srcdir)/Objects/stringlib/ctype.h \ - $(srcdir)/Objects/stringlib/eq.h \ $(srcdir)/Objects/stringlib/fastsearch.h \ $(srcdir)/Objects/stringlib/find.h \ - $(srcdir)/Objects/stringlib/find_max_char.h \ $(srcdir)/Objects/stringlib/join.h \ $(srcdir)/Objects/stringlib/partition.h \ $(srcdir)/Objects/stringlib/split.h \ $(srcdir)/Objects/stringlib/stringdefs.h \ - $(srcdir)/Objects/stringlib/transmogrify.h \ - $(srcdir)/Objects/stringlib/unicodedefs.h \ - $(srcdir)/Objects/stringlib/localeutil.h \ - $(srcdir)/Objects/stringlib/undef.h + $(srcdir)/Objects/stringlib/transmogrify.h -UNICODE_DEPS = $(BYTESTR_DEPS) \ +UNICODE_DEPS = \ $(srcdir)/Objects/stringlib/asciilib.h \ $(srcdir)/Objects/stringlib/codecs.h \ + $(srcdir)/Objects/stringlib/count.h \ + $(srcdir)/Objects/stringlib/fastsearch.h \ + $(srcdir)/Objects/stringlib/find.h \ + $(srcdir)/Objects/stringlib/find_max_char.h \ + $(srcdir)/Objects/stringlib/localeutil.h \ + $(srcdir)/Objects/stringlib/partition.h \ + $(srcdir)/Objects/stringlib/split.h \ $(srcdir)/Objects/stringlib/ucs1lib.h \ $(srcdir)/Objects/stringlib/ucs2lib.h \ $(srcdir)/Objects/stringlib/ucs4lib.h \ + $(srcdir)/Objects/stringlib/undef.h \ $(srcdir)/Objects/stringlib/unicode_format.h \ $(srcdir)/Objects/stringlib/unicodedefs.h @@ -728,9 +730,6 @@ Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h -Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \ - $(BYTESTR_DEPS) - Python/frozen.o: Python/importlib.h Objects/typeobject.o: Objects/typeslots.inc diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -633,6 +633,8 @@ Build ----- +- Issue #16320: Remove redundant Makefile dependencies for strings and bytes. + - Cross compiling needs host and build settings. configure no longer creates a broken PYTHON_FOR_BUILD variable when --build is missing. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 22:15:21 2013 From: python-checkins at python.org (r.david.murray) Date: Sun, 6 Jan 2013 22:15:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE2ODc3OiBBZGQg?= =?utf-8?q?mention_that_shell-style_path_expansions_are_not_automatic=2E?= Message-ID: <3YfXZK6m8rzS6w@mail.python.org> http://hg.python.org/cpython/rev/02e2fa22f8b7 changeset: 81303:02e2fa22f8b7 branch: 3.2 parent: 81291:d2867c430333 user: R David Murray date: Sun Jan 06 16:13:10 2013 -0500 summary: #16877: Add mention that shell-style path expansions are not automatic. files: Doc/library/os.path.rst | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -17,6 +17,11 @@ names on Windows (in the standard ``mbcs`` encoding), hence Windows applications should use string objects to access all files. +Unlike a unix shell, Python does not do any *automatic* path expansions. +Functions such as :func:`expanduser` and :func:`expandvars` can be invoked +explicitly when an application desires shell-like path expansion. (See also +the :mod:`glob` module.) + .. note:: All of these functions accept either only bytes or only string objects as -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 22:15:23 2013 From: python-checkins at python.org (r.david.murray) Date: Sun, 6 Jan 2013 22:15:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_merge_=2316877=3A_Add_mention_that_shell-style_path_expansions?= =?utf-8?q?_are_not_automatic=2E?= Message-ID: <3YfXZM1vYvzS78@mail.python.org> http://hg.python.org/cpython/rev/2ff547c165fd changeset: 81304:2ff547c165fd branch: 3.3 parent: 81300:13c83199c211 parent: 81303:02e2fa22f8b7 user: R David Murray date: Sun Jan 06 16:13:51 2013 -0500 summary: merge #16877: Add mention that shell-style path expansions are not automatic. files: Doc/library/os.path.rst | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -17,6 +17,11 @@ names on Windows (in the standard ``mbcs`` encoding), hence Windows applications should use string objects to access all files. +Unlike a unix shell, Python does not do any *automatic* path expansions. +Functions such as :func:`expanduser` and :func:`expandvars` can be invoked +explicitly when an application desires shell-like path expansion. (See also +the :mod:`glob` module.) + .. note:: All of these functions accept either only bytes or only string objects as -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 22:15:24 2013 From: python-checkins at python.org (r.david.murray) Date: Sun, 6 Jan 2013 22:15:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_=2316877=3A_Add_mention_that_shell-style_path_expa?= =?utf-8?q?nsions_are_not_automatic=2E?= Message-ID: <3YfXZN4GH9zS65@mail.python.org> http://hg.python.org/cpython/rev/b6284d2aaada changeset: 81305:b6284d2aaada parent: 81302:8a6068ec220e parent: 81304:2ff547c165fd user: R David Murray date: Sun Jan 06 16:14:22 2013 -0500 summary: merge #16877: Add mention that shell-style path expansions are not automatic. files: Doc/library/os.path.rst | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -17,6 +17,11 @@ names on Windows (in the standard ``mbcs`` encoding), hence Windows applications should use string objects to access all files. +Unlike a unix shell, Python does not do any *automatic* path expansions. +Functions such as :func:`expanduser` and :func:`expandvars` can be invoked +explicitly when an application desires shell-like path expansion. (See also +the :mod:`glob` module.) + .. note:: All of these functions accept either only bytes or only string objects as -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 6 22:15:25 2013 From: python-checkins at python.org (r.david.murray) Date: Sun, 6 Jan 2013 22:15:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE2ODc3OiBBZGQg?= =?utf-8?q?mention_that_shell-style_path_expansions_are_not_automatic=2E?= Message-ID: <3YfXZP702VzS66@mail.python.org> http://hg.python.org/cpython/rev/58ac62bc3cd5 changeset: 81306:58ac62bc3cd5 branch: 2.7 parent: 81295:0f24c65fb7e5 user: R David Murray date: Sun Jan 06 16:14:57 2013 -0500 summary: #16877: Add mention that shell-style path expansions are not automatic. files: Doc/library/os.path.rst | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -16,6 +16,11 @@ :func:`splitunc` and :func:`ismount` do handle them correctly. +Unlike a unix shell, Python does not do any *automatic* path expansions. +Functions such as :func:`expanduser` and :func:`expandvars` can be invoked +explicitly when an application desires shell-like path expansion. (See also +the :mod:`glob` module.) + .. note:: Since different operating systems have different path name conventions, there -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 7 02:28:16 2013 From: python-checkins at python.org (guido.van.rossum) Date: Mon, 7 Jan 2013 02:28:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_some_references=2E?= Message-ID: <3YffB83fT7zS89@mail.python.org> http://hg.python.org/peps/rev/d816017c5e42 changeset: 4657:d816017c5e42 parent: 4653:cd5c24a3130f user: Guido van Rossum date: Sun Jan 06 17:27:43 2013 -0800 summary: Add some references. files: pep-3156.txt | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -925,6 +925,26 @@ https://github.com/mnot/thor/blob/master/doc/events.md for examples.) +References +========== + +- PEP 380 describes the semantics of ``yield from``. TBD: Greg + Ewing's tutorial. + +- PEP 3148 describes ``concurrent.futures.Future``. + +- PEP 3153, while rejected, has a good write-up explaining the need + to separate transports and protocols. + +- Nick Coghlan wrote a nice blog post with some background, thoughts + about different approaches to async I/O, gevent, and how to use + futures with constructs like ``while``, ``for`` and ``with``: + http://python-notes.boredomandlaziness.org/en/latest/pep_ideas/async_programming.html + +- TBD: references to the relevant parts of Twisted, Tornado, ZeroMQ, + pyftpdlib, libevent, libev, pyev, libuv, wattle, and so on. + + Acknowledgments =============== -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Mon Jan 7 02:28:18 2013 From: python-checkins at python.org (guido.van.rossum) Date: Mon, 7 Jan 2013 02:28:18 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps_=28merge_default_-=3E_default=29?= =?utf-8?q?=3A_Merge?= Message-ID: <3YffBB1mVJzS89@mail.python.org> http://hg.python.org/peps/rev/98298221aaca changeset: 4658:98298221aaca parent: 4657:d816017c5e42 parent: 4656:992e14d49bff user: Guido van Rossum date: Sun Jan 06 17:28:08 2013 -0800 summary: Merge files: pep-0369.txt | 11 +- pep-0432.txt | 217 ++++++++++++++++++++++++++------------ 2 files changed, 152 insertions(+), 76 deletions(-) diff --git a/pep-0369.txt b/pep-0369.txt --- a/pep-0369.txt +++ b/pep-0369.txt @@ -3,18 +3,19 @@ Version: $Revision$ Last-Modified: $Date$ Author: Christian Heimes -Status: Rejected +Status: Withdrawn Type: Standards Track Content-Type: text/x-rst Created: 02-Jan-2008 Python-Version: 2.6, 3.0 Post-History: 02-Dec-2012 -Rejection Notice -================ -This PEP is rejected by its author, because it has been superseded by the new -importlib. +Withdrawal Notice +================= + +This PEP has been withdrawn by its author, as much of the detailed design +is no longer valid following the migration to importlib in Python 3.3. Abstract diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -40,19 +40,21 @@ well-defined phases during the startup sequence: * Pre-Initialization - no interpreter available -* Initialization - interpreter partially available -* Initialized - full interpreter available, __main__ related metadata +* Initializing - interpreter partially available +* Initialized - interpreter available, __main__ related metadata incomplete -* Main Execution - optional state, __main__ related metadata populated, - bytecode executing in the __main__ module namespace +* Main Execution - __main__ related metadata populated, bytecode + executing in the __main__ module namespace (embedding applications + may choose not to use this phase) As a concrete use case to help guide any design changes, and to solve a known problem where the appropriate defaults for system utilities differ from those for running user scripts, this PEP also proposes the creation and -distribution of a separate system Python (``spython``) executable which, by -default, ignores user site directories and environment variables, and does -not implicitly set ``sys.path[0]`` based on the current directory or the -script being executed. +distribution of a separate system Python (``pysystem``) executable +which, by default, ignores user site directories and environment variables, +and does not implicitly set ``sys.path[0]`` based on the current directory +or the script being executed (it will, however, still support virtual +environments). To keep the implementation complexity under control, this PEP does *not* propose wholesale changes to the way the interpreter state is accessed at @@ -84,12 +86,14 @@ safely. A number of proposals are on the table for even *more* sophisticated -startup behaviour, such as better control over ``sys.path`` initialization -(easily adding additional directories on the command line in a cross-platform -fashion, as well as controlling the configuration of ``sys.path[0]``), easier -configuration of utilities like coverage tracing when launching Python -subprocesses, and easier control of the encoding used for the standard IO -streams when embedding CPython in a larger application. +startup behaviour, such as an isolated mode equivalent to that described in +this PEP as a "system Python" [6_], better control over ``sys.path`` +initialization (easily adding additional directories on the command line +in a cross-platform fashion [7_], as well as controlling the configuration of +``sys.path[0]`` [8_]), easier configuration of utilities like coverage tracing +when launching Python subprocesses [9_], and easier control of the encoding +used for the standard IO streams when embedding CPython in a larger +application [10_]. Rather than attempting to bolt such behaviour onto an already complicated system, this PEP proposes to instead simplify the status quo *first*, with @@ -290,7 +294,7 @@ by several elements. The algorithm used to perform the calculation is not documented anywhere other than in the source code [3_,4_]. Even that description is incomplete, as it failed to be updated for the virtual -environment support added in Python 3.3 (detailed in PEP 420). +environment support added in Python 3.3 (detailed in PEP 405). These calculations are affected by the following function calls (made prior to calling ``Py_Initialize()``) and environment variables: @@ -299,11 +303,11 @@ * ``Py_SetPythonHome()`` * ``PYTHONHOME`` -The filesystem is also inspected for ``pyvenv.cfg`` files (see PEP 420) or, +The filesystem is also inspected for ``pyvenv.cfg`` files (see PEP 405) or, failing that, a ``lib/os.py`` (Windows) or ``lib/python$VERSION/os.py`` file. -The build time settings for PREFIX and EXEC_PREFIX are also relevant, +The build time settings for ``PREFIX`` and ``EXEC_PREFIX`` are also relevant, as are some registry settings on Windows. The hardcoded fallbacks are based on the layout of the CPython source tree and build output when working in a source checkout. @@ -509,7 +513,7 @@ main interpreter and moves to the next phase by calling ``Py_BeginInitialization``. -* Initialization: +* Initializing: * the main interpreter is available, but only partially configured. * ``Py_IsInitializing()`` returns ``1`` @@ -522,7 +526,8 @@ * Initialized: * the main interpreter is available and fully operational, but - ``__main__`` related metadata is incomplete. + ``__main__`` related metadata is incomplete and the site module may + not have been imported. * ``Py_IsInitializing()`` returns ``0`` * ``Py_IsInitialized()`` returns ``1`` * ``Py_IsRunningMain()`` returns ``0`` @@ -726,25 +731,36 @@ int Py_ReadConfiguration(PyConfig *config); -The config argument should be a pointer to a Python dictionary. For any -supported configuration setting already in the dictionary, CPython will -sanity check the supplied value, but otherwise accept it as correct. +The config argument should be a pointer to a config struct (which may be +a temporary one stored on the C stack). For any already configured value +(i.e. non-NULL pointer or non-negative numeric value), CPython will sanity +check the supplied value, but otherwise accept it as correct. + +A struct is used rather than a Python dictionary as the struct is easier +to work with from C, the list of supported fields is fixed for a given +CPython version and only a read-only view need to be exposed to Python +code (which is relatively straightforward, thanks to the infrastructure +already put in place to expose ``sys.implementation``). Unlike ``Py_Initialize`` and ``Py_BeginInitialization``, this call will raise an exception and report an error return rather than exhibiting fatal errors if a problem is found with the config data. Any supported configuration setting which is not already set will be -populated appropriately. The default configuration can be overridden -entirely by setting the value *before* calling ``Py_ReadConfiguration``. The -provided value will then also be used in calculating any settings derived -from that value. +populated appropriately in the supplied configuration struct. The default +configuration can be overridden entirely by setting the value *before* calling ``Py_ReadConfiguration``. The provided value will then also be used in +calculating any other settings derived from that value. Alternatively, settings may be overridden *after* the ``Py_ReadConfiguration`` call (this can be useful if an embedding application wants to adjust a setting rather than replace it completely, such as removing ``sys.path[0]``). +Merely reading the configuration has no effect on the interpreter state: it +only modifies the passed in configuration struct. The settings are not +applied to the running interpreter until the ``Py_EndInitialization`` call +(see below). + Supported configuration settings -------------------------------- @@ -756,44 +772,44 @@ /* Note: if changing anything in Py_Config, also update Py_Config_INIT */ typedef struct { /* Argument processing */ - PyList *raw_argv; - PyList *argv; - PyList *warnoptions; /* -W switch, PYTHONWARNINGS */ - PyDict *xoptions; /* -X switch */ + PyListObject *raw_argv; + PyListObject *argv; + PyListObject *warnoptions; /* -W switch, PYTHONWARNINGS */ + PyDictObject *xoptions; /* -X switch */ /* Filesystem locations */ - PyUnicode *program_name; - PyUnicode *executable; - PyUnicode *prefix; /* PYTHONHOME */ - PyUnicode *exec_prefix; /* PYTHONHOME */ - PyUnicode *base_prefix; /* pyvenv.cfg */ - PyUnicode *base_exec_prefix; /* pyvenv.cfg */ + PyUnicodeObject *program_name; + PyUnicodeObject *executable; + PyUnicodeObject *prefix; /* PYTHONHOME */ + PyUnicodeObject *exec_prefix; /* PYTHONHOME */ + PyUnicodeObject *base_prefix; /* pyvenv.cfg */ + PyUnicodeObject *base_exec_prefix; /* pyvenv.cfg */ /* Site module */ - int no_site; /* -S switch */ - int no_user_site; /* -s switch, PYTHONNOUSERSITE */ + int enable_site_config; /* -S switch (inverted) */ + int no_user_site; /* -s switch, PYTHONNOUSERSITE */ /* Import configuration */ - int dont_write_bytecode; /* -B switch, PYTHONDONTWRITEBYTECODE */ - int ignore_module_case; /* PYTHONCASEOK */ - PyList *import_path; /* PYTHONPATH (etc) */ + int dont_write_bytecode; /* -B switch, PYTHONDONTWRITEBYTECODE */ + int ignore_module_case; /* PYTHONCASEOK */ + PyListObject *import_path; /* PYTHONPATH (etc) */ /* Standard streams */ - int use_unbuffered_io; /* -u switch, PYTHONUNBUFFEREDIO */ - PyUnicode *stdin_encoding; /* PYTHONIOENCODING */ - PyUnicode *stdin_errors; /* PYTHONIOENCODING */ - PyUnicode *stdout_encoding; /* PYTHONIOENCODING */ - PyUnicode *stdout_errors; /* PYTHONIOENCODING */ - PyUnicode *stderr_encoding; /* PYTHONIOENCODING */ - PyUnicode *stderr_errors; /* PYTHONIOENCODING */ + int use_unbuffered_io; /* -u switch, PYTHONUNBUFFEREDIO */ + PyUnicodeObject *stdin_encoding; /* PYTHONIOENCODING */ + PyUnicodeObject *stdin_errors; /* PYTHONIOENCODING */ + PyUnicodeObject *stdout_encoding; /* PYTHONIOENCODING */ + PyUnicodeObject *stdout_errors; /* PYTHONIOENCODING */ + PyUnicodeObject *stderr_encoding; /* PYTHONIOENCODING */ + PyUnicodeObject *stderr_errors; /* PYTHONIOENCODING */ /* Filesystem access */ - PyUnicode *fs_encoding; + PyUnicodeObject *fs_encoding; /* Interactive interpreter */ - int stdin_is_interactive; /* Force interactive behaviour */ - int inspect_main; /* -i switch, PYTHONINSPECT */ - PyUnicode *startup_file; /* PYTHONSTARTUP */ + int stdin_is_interactive; /* Force interactive behaviour */ + int inspect_main; /* -i switch, PYTHONINSPECT */ + PyUnicodeObject *startup_file; /* PYTHONSTARTUP */ /* Debugging output */ int debug_parser; /* -d switch, PYTHONDEBUG */ @@ -810,7 +826,7 @@ /* Struct initialization is pretty ugly in C89. Avoiding this mess would - * be the most attractive aspect of using a PyDict* instead... */ + * be the most attractive aspect of using a PyDictObject* instead... */ #define _Py_ArgConfig_INIT NULL, NULL, NULL, NULL #define _Py_LocationConfig_INIT NULL, NULL, NULL, NULL, NULL, NULL #define _Py_SiteConfig_INIT -1, -1 @@ -839,7 +855,7 @@ configuration settings into effect and finish bootstrapping the interpreter up to full operation:: - int Py_EndInitialization(const PyConfig *config); + int Py_EndInitialization(const Py_Config *config); Like Py_ReadConfiguration, this call will raise an exception and report an error return rather than exhibiting fatal errors if a problem is found with @@ -853,6 +869,10 @@ ``Py_IsInitialized()`` will become true. The caveats described above for the interpreter during the initialization phase will no longer hold. +Attempting to call ``Py_EndInitialization()`` again when +``Py_IsInitializing()`` is false or ``Py_IsInitialized()`` is true is an +error. + However, some metadata related to the ``__main__`` module may still be incomplete: @@ -866,6 +886,12 @@ * the metadata in the ``__main__`` module will still indicate it is a builtin module +This function will normally implicitly import site as its final operation +(after ``Py_IsInitialized()`` is already set). Clearing the +"enable_site_config" flag in the configuration settings will disable this +behaviour, as well as eliminating any side effects on global state if +``import site`` is later explicitly executed in the process. + Executing the main module ------------------------- @@ -896,6 +922,13 @@ ``sys.implementation``. Field names will match those in the configuration structs, exception for ``hash_seed``, which will be deliberately excluded. +An underscored attribute is chosen deliberately, as these configuration +settings are part of the CPython implementation, rather than part of the +Python language definition. If settings are needed to support +cross-implementation compatibility in the standard library, then those +should be agreed with the other implementations and exposed as new required +attributes on ``sys.implementation``, as described in PEP 421. + These are *snapshots* of the initial configuration settings. They are not consulted by the interpreter during runtime. @@ -908,14 +941,22 @@ than merely writing an extension. +Build time configuration +------------------------ + +This PEP makes no changes to the handling of build time configuration +settings, and thus has no effect on the contents of ``sys.implementation`` +or the result of ``sysconfig.get_config_vars()``. + + Backwards Compatibility ----------------------- Backwards compatibility will be preserved primarily by ensuring that -Py_ReadConfiguration() interrogates all the previously defined configuration -settings stored in global variables and environment variables, and that -Py_EndInitialization() writes affected settings back to the relevant -locations. +``Py_ReadConfiguration()`` interrogates all the previously defined +configuration settings stored in global variables and environment variables, +and that ``Py_EndInitialization()`` writes affected settings back to the +relevant locations. One acknowledged incompatiblity is that some environment variables which are currently read lazily may instead be read once during interpreter @@ -943,19 +984,6 @@ of the old style initialization API. (very much TBC) -Open Questions -============== - -* Is ``Py_IsRunningMain()`` worth keeping? -* Should the answers to ``Py_IsInitialized()`` and ``Py_RunningMain()`` be - exposed via the ``sys`` module? -* Is the ``Py_Config`` struct too unwieldy to be practical? Would a Python - dictionary be a better choice? -* Would it be better to manage the flag variables in ``Py_Config`` as - Python integers so the struct can be initialized with a simple - ``memset(&config, 0, sizeof(*config))``? - - A System Python Executable ========================== @@ -966,6 +994,11 @@ environment variables are trusted and that the directory containing the executed file is placed at the beginning of the import path. +Issue 16499 [6_] proposes adding a ``-I`` option to change the behaviour of +the normal CPython executable, but this is a hard to discover solution (and +adds yet another option to an already complex CLI). This PEP proposes to +instead add a separate ``pysystem`` executable + Currently, providing a separate executable with different default behaviour would be prohibitively hard to maintain. One of the goals of this PEP is to make it possible to replace much of the hard to maintain bootstrapping code @@ -985,6 +1018,30 @@ * execution from stdin (non-interactive) * interactive stdin +Actually implementing this may also reveal the need for some better +argument parsing infrastructure for use during the initializing phase. + + +Open Questions +============== + +* Error details for Py_ReadConfiguration and Py_EndInitialization (these + should become clear as the implementation progresses) +* Is ``Py_IsRunningMain()`` worth keeping? +* Should the answers to ``Py_IsInitialized()`` and ``Py_IsRunningMain()`` be + exposed via the ``sys`` module? +* Is the ``Py_Config`` struct too unwieldy to be practical? Would a Python + dictionary be a better choice? +* Would it be better to manage the flag variables in ``Py_Config`` as + Python integers or as "negative means false, positive means true, zero + means not set" so the struct can be initialized with a simple + ``memset(&config, 0, sizeof(*config))``, eliminating the need to update + both Py_Config and Py_Config_INIT when adding new fields? +* The name of the system Python executable is a bikeshed waiting to be + painted. The 3 options considered so far are ``spython``, ``pysystem`` + and ``python-minimal``. The PEP text reflects my current preferred choice + i.e. ``pysystem``. + Implementation ============== @@ -1011,6 +1068,24 @@ .. [5] Site module documentation (http://docs.python.org/3/library/site.html) +.. [6] Proposed CLI option for isolated mode + (http://bugs.python.org/issue16499) + +.. [7] Adding to sys.path on the command line + (http://mail.python.org/pipermail/python-ideas/2010-October/008299.html) + (http://mail.python.org/pipermail/python-ideas/2012-September/016128.html) + +.. [8] Control sys.path[0] initialisation + (http://bugs.python.org/issue13475) + +.. [9] Enabling code coverage in subprocesses when testing + (http://bugs.python.org/issue14803) + +.. [10] Problems with PYTHONIOENCODING in Blender + (http://bugs.python.org/issue16129) + + + Copyright =========== This document has been placed in the public domain. -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Mon Jan 7 05:57:58 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 07 Jan 2013 05:57:58 +0100 Subject: [Python-checkins] Daily reference leaks (b6284d2aaada): sum=0 Message-ID: results for b6284d2aaada on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogbVVu7C', '-x'] From python-checkins at python.org Mon Jan 7 15:19:29 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 7 Jan 2013 15:19:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2ODg0?= =?utf-8?q?=3A_updated_logging_documentation_to_include_lastResort_and_use?= Message-ID: <3YfzJ13yYbzS1q@mail.python.org> http://hg.python.org/cpython/rev/95a4ff8c540b changeset: 81307:95a4ff8c540b branch: 3.2 parent: 81303:02e2fa22f8b7 user: Vinay Sajip date: Mon Jan 07 14:16:52 2013 +0000 summary: Issue #16884: updated logging documentation to include lastResort and use 'note' directives where appropriate. files: Doc/howto/logging.rst | 15 +++++---- Doc/library/logging.rst | 43 +++++++++++++++++++--------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -780,13 +780,14 @@ libraries, then the logger name specified can be 'orgname.foo' rather than just 'foo'. -**PLEASE NOTE:** It is strongly advised that you *do not add any handlers other -than* :class:`~logging.NullHandler` *to your library's loggers*. This is -because the configuration of handlers is the prerogative of the application -developer who uses your library. The application developer knows their target -audience and what handlers are most appropriate for their application: if you -add handlers 'under the hood', you might well interfere with their ability to -carry out unit tests and deliver logs which suit their requirements. +.. note:: It is strongly advised that you *do not add any handlers other + than* :class:`~logging.NullHandler` *to your library's loggers*. This is + because the configuration of handlers is the prerogative of the application + developer who uses your library. The application developer knows their + target audience and what handlers are most appropriate for their + application: if you add handlers 'under the hood', you might well interfere + with their ability to carry out unit tests and deliver logs which suit their + requirements. Logging Levels diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -928,14 +928,14 @@ Logs a message with level *level* on the root logger. The other arguments are interpreted as for :func:`debug`. - PLEASE NOTE: The above module-level functions which delegate to the root - logger should *not* be used in threads, in versions of Python earlier than - 2.7.1 and 3.2, unless at least one handler has been added to the root - logger *before* the threads are started. These convenience functions call - :func:`basicConfig` to ensure that at least one handler is available; in - earlier versions of Python, this can (under rare circumstances) lead to - handlers being added multiple times to the root logger, which can in turn - lead to multiple messages for the same event. + .. note:: The above module-level functions which delegate to the root + logger should *not* be used in threads, in versions of Python earlier + than 2.7.1 and 3.2, unless at least one handler has been added to the + root logger *before* the threads are started. These convenience functions + call :func:`basicConfig` to ensure that at least one handler is + available; in earlier versions of Python, this can (under rare + circumstances) lead to handlers being added multiple times to the root + logger, which can in turn lead to multiple messages for the same event. .. function:: disable(lvl) @@ -991,12 +991,12 @@ This function does nothing if the root logger already has handlers configured for it. - PLEASE NOTE: This function should be called from the main thread - before other threads are started. In versions of Python prior to - 2.7.1 and 3.2, if this function is called from multiple threads, - it is possible (in rare circumstances) that a handler will be added - to the root logger more than once, leading to unexpected results - such as messages being duplicated in the log. + .. note:: This function should be called from the main thread + before other threads are started. In versions of Python prior to + 2.7.1 and 3.2, if this function is called from multiple threads, + it is possible (in rare circumstances) that a handler will be added + to the root logger more than once, leading to unexpected results + such as messages being duplicated in the log. The following keyword arguments are supported. @@ -1080,6 +1080,21 @@ :kwargs: Additional keyword arguments. +Module-Level Attributes +----------------------- + +.. attribute:: lastResort + + A "handler of last resort" is available through this attribute. This + is a :class:`StreamHandler` writing to ``sys.stderr`` with a level of + ``WARNING``, and is used to handle logging events in the absence of any + logging configuration. The end result is to just print the message to + ``sys.stderr``. This replaces the earlier error message saying that + "no handlers could be found for logger XYZ". If you need the earlier + behaviour for some reason, ``lastResort`` can be set to ``None``. + + .. versionadded:: 3.2 + Integration with the warnings module ------------------------------------ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 7 15:19:31 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 7 Jan 2013 15:19:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316884=3A_Merged_logging_documentation_fixes_from_3=2E?= =?utf-8?q?2=2E?= Message-ID: <3YfzJ30NDCzS1x@mail.python.org> http://hg.python.org/cpython/rev/3b5c4190e256 changeset: 81308:3b5c4190e256 branch: 3.3 parent: 81304:2ff547c165fd parent: 81307:95a4ff8c540b user: Vinay Sajip date: Mon Jan 07 14:18:19 2013 +0000 summary: Issue #16884: Merged logging documentation fixes from 3.2. files: Doc/howto/logging.rst | 15 +++++---- Doc/library/logging.rst | 43 +++++++++++++++++++--------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -780,13 +780,14 @@ libraries, then the logger name specified can be 'orgname.foo' rather than just 'foo'. -**PLEASE NOTE:** It is strongly advised that you *do not add any handlers other -than* :class:`~logging.NullHandler` *to your library's loggers*. This is -because the configuration of handlers is the prerogative of the application -developer who uses your library. The application developer knows their target -audience and what handlers are most appropriate for their application: if you -add handlers 'under the hood', you might well interfere with their ability to -carry out unit tests and deliver logs which suit their requirements. +.. note:: It is strongly advised that you *do not add any handlers other + than* :class:`~logging.NullHandler` *to your library's loggers*. This is + because the configuration of handlers is the prerogative of the application + developer who uses your library. The application developer knows their + target audience and what handlers are most appropriate for their + application: if you add handlers 'under the hood', you might well interfere + with their ability to carry out unit tests and deliver logs which suit their + requirements. Logging Levels diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -948,14 +948,14 @@ Logs a message with level *level* on the root logger. The other arguments are interpreted as for :func:`debug`. - PLEASE NOTE: The above module-level functions which delegate to the root - logger should *not* be used in threads, in versions of Python earlier than - 2.7.1 and 3.2, unless at least one handler has been added to the root - logger *before* the threads are started. These convenience functions call - :func:`basicConfig` to ensure that at least one handler is available; in - earlier versions of Python, this can (under rare circumstances) lead to - handlers being added multiple times to the root logger, which can in turn - lead to multiple messages for the same event. + .. note:: The above module-level functions which delegate to the root + logger should *not* be used in threads, in versions of Python earlier + than 2.7.1 and 3.2, unless at least one handler has been added to the + root logger *before* the threads are started. These convenience functions + call :func:`basicConfig` to ensure that at least one handler is + available; in earlier versions of Python, this can (under rare + circumstances) lead to handlers being added multiple times to the root + logger, which can in turn lead to multiple messages for the same event. .. function:: disable(lvl) @@ -1011,12 +1011,12 @@ This function does nothing if the root logger already has handlers configured for it. - PLEASE NOTE: This function should be called from the main thread - before other threads are started. In versions of Python prior to - 2.7.1 and 3.2, if this function is called from multiple threads, - it is possible (in rare circumstances) that a handler will be added - to the root logger more than once, leading to unexpected results - such as messages being duplicated in the log. + .. note:: This function should be called from the main thread + before other threads are started. In versions of Python prior to + 2.7.1 and 3.2, if this function is called from multiple threads, + it is possible (in rare circumstances) that a handler will be added + to the root logger more than once, leading to unexpected results + such as messages being duplicated in the log. The following keyword arguments are supported. @@ -1115,6 +1115,21 @@ :kwargs: Additional keyword arguments. +Module-Level Attributes +----------------------- + +.. attribute:: lastResort + + A "handler of last resort" is available through this attribute. This + is a :class:`StreamHandler` writing to ``sys.stderr`` with a level of + ``WARNING``, and is used to handle logging events in the absence of any + logging configuration. The end result is to just print the message to + ``sys.stderr``. This replaces the earlier error message saying that + "no handlers could be found for logger XYZ". If you need the earlier + behaviour for some reason, ``lastResort`` can be set to ``None``. + + .. versionadded:: 3.2 + Integration with the warnings module ------------------------------------ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 7 15:19:32 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 7 Jan 2013 15:19:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Closes_=2316884=3A_Merged_logging_documentation_fixes_fr?= =?utf-8?q?om_3=2E3=2E?= Message-ID: <3YfzJ43wQfzS1Q@mail.python.org> http://hg.python.org/cpython/rev/9009178e08d9 changeset: 81309:9009178e08d9 parent: 81305:b6284d2aaada parent: 81308:3b5c4190e256 user: Vinay Sajip date: Mon Jan 07 14:19:12 2013 +0000 summary: Closes #16884: Merged logging documentation fixes from 3.3. files: Doc/howto/logging.rst | 15 +++++---- Doc/library/logging.rst | 43 +++++++++++++++++++--------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -780,13 +780,14 @@ libraries, then the logger name specified can be 'orgname.foo' rather than just 'foo'. -**PLEASE NOTE:** It is strongly advised that you *do not add any handlers other -than* :class:`~logging.NullHandler` *to your library's loggers*. This is -because the configuration of handlers is the prerogative of the application -developer who uses your library. The application developer knows their target -audience and what handlers are most appropriate for their application: if you -add handlers 'under the hood', you might well interfere with their ability to -carry out unit tests and deliver logs which suit their requirements. +.. note:: It is strongly advised that you *do not add any handlers other + than* :class:`~logging.NullHandler` *to your library's loggers*. This is + because the configuration of handlers is the prerogative of the application + developer who uses your library. The application developer knows their + target audience and what handlers are most appropriate for their + application: if you add handlers 'under the hood', you might well interfere + with their ability to carry out unit tests and deliver logs which suit their + requirements. Logging Levels diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -948,14 +948,14 @@ Logs a message with level *level* on the root logger. The other arguments are interpreted as for :func:`debug`. - PLEASE NOTE: The above module-level functions which delegate to the root - logger should *not* be used in threads, in versions of Python earlier than - 2.7.1 and 3.2, unless at least one handler has been added to the root - logger *before* the threads are started. These convenience functions call - :func:`basicConfig` to ensure that at least one handler is available; in - earlier versions of Python, this can (under rare circumstances) lead to - handlers being added multiple times to the root logger, which can in turn - lead to multiple messages for the same event. + .. note:: The above module-level functions which delegate to the root + logger should *not* be used in threads, in versions of Python earlier + than 2.7.1 and 3.2, unless at least one handler has been added to the + root logger *before* the threads are started. These convenience functions + call :func:`basicConfig` to ensure that at least one handler is + available; in earlier versions of Python, this can (under rare + circumstances) lead to handlers being added multiple times to the root + logger, which can in turn lead to multiple messages for the same event. .. function:: disable(lvl) @@ -1011,12 +1011,12 @@ This function does nothing if the root logger already has handlers configured for it. - PLEASE NOTE: This function should be called from the main thread - before other threads are started. In versions of Python prior to - 2.7.1 and 3.2, if this function is called from multiple threads, - it is possible (in rare circumstances) that a handler will be added - to the root logger more than once, leading to unexpected results - such as messages being duplicated in the log. + .. note:: This function should be called from the main thread + before other threads are started. In versions of Python prior to + 2.7.1 and 3.2, if this function is called from multiple threads, + it is possible (in rare circumstances) that a handler will be added + to the root logger more than once, leading to unexpected results + such as messages being duplicated in the log. The following keyword arguments are supported. @@ -1115,6 +1115,21 @@ :kwargs: Additional keyword arguments. +Module-Level Attributes +----------------------- + +.. attribute:: lastResort + + A "handler of last resort" is available through this attribute. This + is a :class:`StreamHandler` writing to ``sys.stderr`` with a level of + ``WARNING``, and is used to handle logging events in the absence of any + logging configuration. The end result is to just print the message to + ``sys.stderr``. This replaces the earlier error message saying that + "no handlers could be found for logger XYZ". If you need the earlier + behaviour for some reason, ``lastResort`` can be set to ``None``. + + .. versionadded:: 3.2 + Integration with the warnings module ------------------------------------ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 7 21:24:29 2013 From: python-checkins at python.org (christian.heimes) Date: Mon, 7 Jan 2013 21:24:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Add_a_comment_about_*not*_?= =?utf-8?q?caching_the_hash_value=2E_Issue_=239685_suggested_to?= Message-ID: <3Yg7P92lJFzPGy@mail.python.org> http://hg.python.org/cpython/rev/17038de56fd4 changeset: 81310:17038de56fd4 user: Christian Heimes date: Mon Jan 07 21:24:18 2013 +0100 summary: Add a comment about *not* caching the hash value. Issue #9685 suggested to memorize the hash value, but the feature request was rejected because no speed ups were found. files: Objects/tupleobject.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -322,6 +322,9 @@ 1082527, 1165049, 1082531, 1165057, 1247581, 1330103, 1082533, 1330111, 1412633, 1165069, 1247599, 1495177, 1577699 + + Tests have shown that it's not worth to cache the hash value, see + issue #9685. */ static Py_hash_t -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 7 22:18:26 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 7 Jan 2013 22:18:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE1OTcy?= =?utf-8?q?=3A_Fix_error_messages_when_os_functions_expecting_a_file_name_?= =?utf-8?q?or?= Message-ID: <3Yg8bQ50ljzQ92@mail.python.org> http://hg.python.org/cpython/rev/1b68dc917321 changeset: 81311:1b68dc917321 branch: 3.3 parent: 81308:3b5c4190e256 user: Serhiy Storchaka date: Mon Jan 07 23:13:46 2013 +0200 summary: Issue #15972: Fix error messages when os functions expecting a file name or file descriptor receive the incorrect type. files: Lib/test/test_posix.py | 24 ++++++++++ Misc/NEWS | 3 + Modules/posixmodule.c | 66 +++++++++++++++-------------- 3 files changed, 62 insertions(+), 31 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -358,12 +358,28 @@ try: self.assertTrue(posix.fstat(fp.fileno())) self.assertTrue(posix.stat(fp.fileno())) + + self.assertRaisesRegex(TypeError, + 'should be string, bytes or integer, not', + posix.stat, float(fp.fileno())) finally: fp.close() def test_stat(self): if hasattr(posix, 'stat'): self.assertTrue(posix.stat(support.TESTFN)) + self.assertTrue(posix.stat(os.fsencode(support.TESTFN))) + self.assertTrue(posix.stat(bytearray(os.fsencode(support.TESTFN)))) + + self.assertRaisesRegex(TypeError, + 'can\'t specify None for path argument', + posix.stat, None) + self.assertRaisesRegex(TypeError, + 'should be string, bytes or integer, not', + posix.stat, list(support.TESTFN)) + self.assertRaisesRegex(TypeError, + 'should be string, bytes or integer, not', + posix.stat, list(os.fsencode(support.TESTFN))) @unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()") def test_mkfifo(self): @@ -714,6 +730,14 @@ s1 = posix.stat(support.TESTFN) s2 = posix.stat(support.TESTFN, dir_fd=f) self.assertEqual(s1, s2) + s2 = posix.stat(support.TESTFN, dir_fd=None) + self.assertEqual(s1, s2) + self.assertRaisesRegex(TypeError, 'should be integer, not', + posix.stat, support.TESTFN, dir_fd=posix.getcwd()) + self.assertRaisesRegex(TypeError, 'should be integer, not', + posix.stat, support.TESTFN, dir_fd=float(f)) + self.assertRaises(OverflowError, + posix.stat, support.TESTFN, dir_fd=10**20) finally: posix.close(f) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -136,6 +136,9 @@ Library ------- +- Issue #15972: Fix error messages when os functions expecting a file name or + file descriptor receive the incorrect type. + - Issue #16828: Fix error incorrectly raised by bz2.compress(b'') and bz2.BZ2Compressor.compress(b''). Initial patch by Martin Packman. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -427,26 +427,24 @@ #endif static int -_fd_converter(PyObject *o, int *p, int default_value) { - long long_value; - if (o == Py_None) { - *p = default_value; - return 1; - } - if (PyFloat_Check(o)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); +_fd_converter(PyObject *o, int *p, const char *allowed) +{ + int overflow; + long long_value = PyLong_AsLongAndOverflow(o, &overflow); + if (PyFloat_Check(o) || + (long_value == -1 && !overflow && PyErr_Occurred())) { + PyErr_Clear(); + PyErr_Format(PyExc_TypeError, + "argument should be %s, not %.200s", + allowed, Py_TYPE(o)->tp_name); return 0; } - long_value = PyLong_AsLong(o); - if (long_value == -1 && PyErr_Occurred()) - return 0; - if (long_value > INT_MAX) { + if (overflow > 0 || long_value > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "signed integer is greater than maximum"); return 0; } - if (long_value < INT_MIN) { + if (overflow < 0 || long_value < INT_MIN) { PyErr_SetString(PyExc_OverflowError, "signed integer is less than minimum"); return 0; @@ -456,8 +454,13 @@ } static int -dir_fd_converter(PyObject *o, void *p) { - return _fd_converter(o, (int *)p, DEFAULT_DIR_FD); +dir_fd_converter(PyObject *o, void *p) +{ + if (o == Py_None) { + *(int *)p = DEFAULT_DIR_FD; + return 1; + } + return _fd_converter(o, (int *)p, "integer"); } @@ -634,17 +637,16 @@ } else { PyErr_Clear(); - bytes = PyBytes_FromObject(o); + if (PyObject_CheckBuffer(o)) + bytes = PyBytes_FromObject(o); + else + bytes = NULL; if (!bytes) { PyErr_Clear(); if (path->allow_fd) { int fd; - /* - * note: _fd_converter always permits None. - * but we've already done our None check. - * so o cannot be None at this point. - */ - int result = _fd_converter(o, &fd, -1); + int result = _fd_converter(o, &fd, + "string, bytes or integer"); if (result) { path->wide = NULL; path->narrow = NULL; @@ -705,15 +707,17 @@ } static int -dir_fd_unavailable(PyObject *o, void *p) { - int *dir_fd = (int *)p; - int return_value = _fd_converter(o, dir_fd, DEFAULT_DIR_FD); - if (!return_value) +dir_fd_unavailable(PyObject *o, void *p) +{ + int dir_fd; + if (!dir_fd_converter(o, &dir_fd)) return 0; - if (*dir_fd == DEFAULT_DIR_FD) - return 1; - argument_unavailable_error(NULL, "dir_fd"); - return 0; + if (dir_fd != DEFAULT_DIR_FD) { + argument_unavailable_error(NULL, "dir_fd"); + return 0; + } + *(int *)p = dir_fd; + return 1; } static int -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 7 22:18:28 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 7 Jan 2013 22:18:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2315972=3A_Fix_error_messages_when_os_functions_e?= =?utf-8?q?xpecting_a_file_name_or?= Message-ID: <3Yg8bS1qpZzQrS@mail.python.org> http://hg.python.org/cpython/rev/71fb426ee972 changeset: 81312:71fb426ee972 parent: 81310:17038de56fd4 parent: 81311:1b68dc917321 user: Serhiy Storchaka date: Mon Jan 07 23:16:49 2013 +0200 summary: Issue #15972: Fix error messages when os functions expecting a file name or file descriptor receive the incorrect type. files: Lib/test/test_posix.py | 24 ++++++++++ Misc/NEWS | 3 + Modules/posixmodule.c | 66 +++++++++++++++-------------- 3 files changed, 62 insertions(+), 31 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -358,12 +358,28 @@ try: self.assertTrue(posix.fstat(fp.fileno())) self.assertTrue(posix.stat(fp.fileno())) + + self.assertRaisesRegex(TypeError, + 'should be string, bytes or integer, not', + posix.stat, float(fp.fileno())) finally: fp.close() def test_stat(self): if hasattr(posix, 'stat'): self.assertTrue(posix.stat(support.TESTFN)) + self.assertTrue(posix.stat(os.fsencode(support.TESTFN))) + self.assertTrue(posix.stat(bytearray(os.fsencode(support.TESTFN)))) + + self.assertRaisesRegex(TypeError, + 'can\'t specify None for path argument', + posix.stat, None) + self.assertRaisesRegex(TypeError, + 'should be string, bytes or integer, not', + posix.stat, list(support.TESTFN)) + self.assertRaisesRegex(TypeError, + 'should be string, bytes or integer, not', + posix.stat, list(os.fsencode(support.TESTFN))) @unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()") def test_mkfifo(self): @@ -714,6 +730,14 @@ s1 = posix.stat(support.TESTFN) s2 = posix.stat(support.TESTFN, dir_fd=f) self.assertEqual(s1, s2) + s2 = posix.stat(support.TESTFN, dir_fd=None) + self.assertEqual(s1, s2) + self.assertRaisesRegex(TypeError, 'should be integer, not', + posix.stat, support.TESTFN, dir_fd=posix.getcwd()) + self.assertRaisesRegex(TypeError, 'should be integer, not', + posix.stat, support.TESTFN, dir_fd=float(f)) + self.assertRaises(OverflowError, + posix.stat, support.TESTFN, dir_fd=10**20) finally: posix.close(f) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -206,6 +206,9 @@ Library ------- +- Issue #15972: Fix error messages when os functions expecting a file name or + file descriptor receive the incorrect type. + - Issue #8109: The ssl module now has support for server-side SNI, thanks to a :meth:`SSLContext.set_servername_callback` method. Patch by Daniel Black. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -396,26 +396,24 @@ #endif static int -_fd_converter(PyObject *o, int *p, int default_value) { - long long_value; - if (o == Py_None) { - *p = default_value; - return 1; - } - if (PyFloat_Check(o)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); +_fd_converter(PyObject *o, int *p, const char *allowed) +{ + int overflow; + long long_value = PyLong_AsLongAndOverflow(o, &overflow); + if (PyFloat_Check(o) || + (long_value == -1 && !overflow && PyErr_Occurred())) { + PyErr_Clear(); + PyErr_Format(PyExc_TypeError, + "argument should be %s, not %.200s", + allowed, Py_TYPE(o)->tp_name); return 0; } - long_value = PyLong_AsLong(o); - if (long_value == -1 && PyErr_Occurred()) - return 0; - if (long_value > INT_MAX) { + if (overflow > 0 || long_value > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "signed integer is greater than maximum"); return 0; } - if (long_value < INT_MIN) { + if (overflow < 0 || long_value < INT_MIN) { PyErr_SetString(PyExc_OverflowError, "signed integer is less than minimum"); return 0; @@ -425,8 +423,13 @@ } static int -dir_fd_converter(PyObject *o, void *p) { - return _fd_converter(o, (int *)p, DEFAULT_DIR_FD); +dir_fd_converter(PyObject *o, void *p) +{ + if (o == Py_None) { + *(int *)p = DEFAULT_DIR_FD; + return 1; + } + return _fd_converter(o, (int *)p, "integer"); } @@ -603,17 +606,16 @@ } else { PyErr_Clear(); - bytes = PyBytes_FromObject(o); + if (PyObject_CheckBuffer(o)) + bytes = PyBytes_FromObject(o); + else + bytes = NULL; if (!bytes) { PyErr_Clear(); if (path->allow_fd) { int fd; - /* - * note: _fd_converter always permits None. - * but we've already done our None check. - * so o cannot be None at this point. - */ - int result = _fd_converter(o, &fd, -1); + int result = _fd_converter(o, &fd, + "string, bytes or integer"); if (result) { path->wide = NULL; path->narrow = NULL; @@ -674,15 +676,17 @@ } static int -dir_fd_unavailable(PyObject *o, void *p) { - int *dir_fd = (int *)p; - int return_value = _fd_converter(o, dir_fd, DEFAULT_DIR_FD); - if (!return_value) +dir_fd_unavailable(PyObject *o, void *p) +{ + int dir_fd; + if (!dir_fd_converter(o, &dir_fd)) return 0; - if (*dir_fd == DEFAULT_DIR_FD) - return 1; - argument_unavailable_error(NULL, "dir_fd"); - return 0; + if (dir_fd != DEFAULT_DIR_FD) { + argument_unavailable_error(NULL, "dir_fd"); + return 0; + } + *(int *)p = dir_fd; + return 1; } static int -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 00:56:45 2013 From: python-checkins at python.org (victor.stinner) Date: Tue, 8 Jan 2013 00:56:45 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_fcntl=3A_add_F=5FDUPFD=5FC?= =?utf-8?q?LOEXEC_constant=2C_available_on_Linux_2=2E6=2E24+=2E?= Message-ID: <3YgD655bP7zNw3@mail.python.org> http://hg.python.org/cpython/rev/0afa7b323abb changeset: 81313:0afa7b323abb user: Victor Stinner date: Tue Jan 08 00:52:40 2013 +0100 summary: fcntl: add F_DUPFD_CLOEXEC constant, available on Linux 2.6.24+. files: Misc/NEWS | 2 ++ Modules/fcntlmodule.c | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -206,6 +206,8 @@ Library ------- +- fcntl: add F_DUPFD_CLOEXEC constant, available on Linux 2.6.24+. + - Issue #15972: Fix error messages when os functions expecting a file name or file descriptor receive the incorrect type. diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c --- a/Modules/fcntlmodule.c +++ b/Modules/fcntlmodule.c @@ -461,6 +461,9 @@ #ifdef F_DUPFD if (ins(d, "F_DUPFD", (long)F_DUPFD)) return -1; #endif +#ifdef F_DUPFD_CLOEXEC + if (ins(d, "F_DUPFD_CLOEXEC", (long)F_DUPFD_CLOEXEC)) return -1; +#endif #ifdef F_GETFD if (ins(d, "F_GETFD", (long)F_GETFD)) return -1; #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 02:10:40 2013 From: python-checkins at python.org (chris.jerdonek) Date: Tue, 8 Jan 2013 02:10:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316854=3A_Fix_regr?= =?utf-8?q?test=2Eusage=28=29_regression_introduced_in_6e2e5adc0400=2E?= Message-ID: <3YgFlN4gKFzRkl@mail.python.org> http://hg.python.org/cpython/rev/ce99559efa46 changeset: 81314:ce99559efa46 user: Chris Jerdonek date: Mon Jan 07 17:07:32 2013 -0800 summary: Issue #16854: Fix regrtest.usage() regression introduced in 6e2e5adc0400. This fixes a regression introduced in the commit for issue #15302, which switched regrtest from getopt to argparse. files: Lib/test/regrtest.py | 52 ++++++++++++++------------ Lib/test/test_regrtest.py | 8 +++- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -202,16 +202,20 @@ TEMPDIR = os.path.abspath(tempfile.gettempdir()) +class _ArgParser(argparse.ArgumentParser): + + def error(self, message): + super().error(message + "\nPass -h or --help for complete help.") + def _create_parser(): # Set prog to prevent the uninformative "__main__.py" from displaying in # error messages when using "python -m test ...". - parser = argparse.ArgumentParser(prog='regrtest.py', - usage=USAGE, - description=DESCRIPTION, - epilog=EPILOG, - add_help=False, - formatter_class= - argparse.RawDescriptionHelpFormatter) + parser = _ArgParser(prog='regrtest.py', + usage=USAGE, + description=DESCRIPTION, + epilog=EPILOG, + add_help=False, + formatter_class=argparse.RawDescriptionHelpFormatter) # Arguments with this clause added to its help are described further in # the epilog's "Additional option details" section. @@ -301,8 +305,18 @@ return parser +# TODO: remove this function as described in issue #16799, for example. +# We use this function since regrtest.main() was originally written to use +# getopt for parsing. def _convert_namespace_to_getopt(ns): - """Convert an argparse.Namespace object to a getopt-style (opts, args).""" + """Convert an argparse.Namespace object to a getopt-style opts list. + + The return value of this function mimics the first element of + getopt.getopt()'s (opts, args) return value. In addition, the (option, + value) pairs in the opts list are sorted by option and use the long + option string. The args part of (opts, args) can be mimicked by the + args attribute of the Namespace object we are using in regrtest. + """ opts = [] args_dict = vars(ns) for key in sorted(args_dict.keys()): @@ -319,21 +333,7 @@ # includes these with value '' in the opts list. val = '' opts.append(('--' + key, val)) - return opts, ns.args - -# This function has a getopt-style return value because regrtest.main() -# was originally written using getopt. -# TODO: switch this to return an argparse.Namespace instance. -def _parse_args(args=None): - """Parse arguments, and return a getopt-style (opts, args). - - This method mimics the return value of getopt.getopt(). In addition, - the (option, value) pairs in opts are sorted by option and use the long - option string. - """ - parser = _create_parser() - ns = parser.parse_args(args=args) - return _convert_namespace_to_getopt(ns) + return opts def main(tests=None, testdir=None, verbose=0, quiet=False, @@ -381,7 +381,11 @@ support.record_original_stdout(sys.stdout) - opts, args = _parse_args() + parser = _create_parser() + ns = parser.parse_args() + opts = _convert_namespace_to_getopt(ns) + args = ns.args + usage = parser.error # Defaults if random_seed is None: diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -23,10 +23,14 @@ class ParseArgsTestCase(unittest.TestCase): - """Test that regrtest._parse_args() matches the prior getopt behavior.""" + """Test that regrtest's parsing code matches the prior getopt behavior.""" def _parse_args(self, args): - return regrtest._parse_args(args=args) + # This is the same logic as that used in regrtest.main() + parser = regrtest._create_parser() + ns = parser.parse_args(args=args) + opts = regrtest._convert_namespace_to_getopt(ns) + return opts, ns.args def _check_args(self, args, expected=None): """ -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Tue Jan 8 05:58:52 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 08 Jan 2013 05:58:52 +0100 Subject: [Python-checkins] Daily reference leaks (ce99559efa46): sum=0 Message-ID: results for ce99559efa46 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogQsLOpl', '-x'] From python-checkins at python.org Tue Jan 8 10:41:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 10:41:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE1ODQ1?= =?utf-8?q?=3A_Fix_comparison_between_bytes_and_string=2E?= Message-ID: <3YgT4S0Gt3zR4h@mail.python.org> http://hg.python.org/cpython/rev/9458a516f769 changeset: 81315:9458a516f769 branch: 3.2 parent: 81307:95a4ff8c540b user: Serhiy Storchaka date: Tue Jan 08 11:32:58 2013 +0200 summary: Issue #15845: Fix comparison between bytes and string. files: Lib/os.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -146,7 +146,10 @@ # be happy if someone already created the path if e.errno != errno.EEXIST: raise - if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists + cdir = curdir + if isinstance(tail, bytes): + cdir = bytes(curdir, 'ASCII') + if tail == cdir: # xxx/newdir/. exists if xxx/newdir exists return try: mkdir(name, mode) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 10:41:13 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 10:41:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2315845=3A_Fix_comparison_between_bytes_and_string=2E?= Message-ID: <3YgT4T2xshzRkb@mail.python.org> http://hg.python.org/cpython/rev/f6cf2985348a changeset: 81316:f6cf2985348a branch: 3.3 parent: 81311:1b68dc917321 parent: 81315:9458a516f769 user: Serhiy Storchaka date: Tue Jan 08 11:36:54 2013 +0200 summary: Issue #15845: Fix comparison between bytes and string. files: Lib/os.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -260,7 +260,10 @@ # be happy if someone already created the path if e.errno != errno.EEXIST: raise - if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists + cdir = curdir + if isinstance(tail, bytes): + cdir = bytes(curdir, 'ASCII') + if tail == cdir: # xxx/newdir/. exists if xxx/newdir exists return try: mkdir(name, mode) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 10:41:14 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 10:41:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2315845=3A_Fix_comparison_between_bytes_and_strin?= =?utf-8?q?g=2E?= Message-ID: <3YgT4V5XsYzRm4@mail.python.org> http://hg.python.org/cpython/rev/51e60d9ee389 changeset: 81317:51e60d9ee389 parent: 81314:ce99559efa46 parent: 81316:f6cf2985348a user: Serhiy Storchaka date: Tue Jan 08 11:38:45 2013 +0200 summary: Issue #15845: Fix comparison between bytes and string. Patch by Alessandro Moura. files: Lib/os.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -236,7 +236,10 @@ # be happy if someone already created the path if e.errno != errno.EEXIST: raise - if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists + cdir = curdir + if isinstance(tail, bytes): + cdir = bytes(curdir, 'ASCII') + if tail == cdir: # xxx/newdir/. exists if xxx/newdir exists return try: mkdir(name, mode) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 12:20:23 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 8 Jan 2013 12:20:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2ODg0?= =?utf-8?q?=3A_Updated_docs_to_use_=27note=27_directives=2E?= Message-ID: <3YgWGv0CQwzRmP@mail.python.org> http://hg.python.org/cpython/rev/51138680b968 changeset: 81318:51138680b968 branch: 2.7 parent: 81306:58ac62bc3cd5 user: Vinay Sajip date: Tue Jan 08 11:18:42 2013 +0000 summary: Issue #16884: Updated docs to use 'note' directives. files: Doc/howto/logging.rst | 23 ++++++++++--------- Doc/library/logging.rst | 32 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -757,13 +757,14 @@ libraries, then the logger name specified can be 'orgname.foo' rather than just 'foo'. -**PLEASE NOTE:** It is strongly advised that you *do not add any handlers other -than* :class:`~logging.NullHandler` *to your library's loggers*. This is -because the configuration of handlers is the prerogative of the application -developer who uses your library. The application developer knows their target -audience and what handlers are most appropriate for their application: if you -add handlers 'under the hood', you might well interfere with their ability to -carry out unit tests and deliver logs which suit their requirements. +.. note:: It is strongly advised that you *do not add any handlers other + than* :class:`~logging.NullHandler` *to your library's loggers*. This is + because the configuration of handlers is the prerogative of the application + developer who uses your library. The application developer knows their + target audience and what handlers are most appropriate for their + application: if you add handlers 'under the hood', you might well interfere + with their ability to carry out unit tests and deliver logs which suit their + requirements. Logging Levels @@ -940,10 +941,10 @@ to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. -**Note:** The default value of :data:`raiseExceptions` is ``True``. This is because -during development, you typically want to be notified of any exceptions that -occur. It's advised that you set :data:`raiseExceptions` to ``False`` for production -usage. +.. note:: The default value of :data:`raiseExceptions` is ``True``. This is + because during development, you typically want to be notified of any + exceptions that occur. It's advised that you set :data:`raiseExceptions` to + ``False`` for production usage. .. currentmodule:: logging diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -800,14 +800,14 @@ Logs a message with level *level* on the root logger. The other arguments are interpreted as for :func:`debug`. - PLEASE NOTE: The above module-level functions which delegate to the root - logger should *not* be used in threads, in versions of Python earlier than - 2.7.1 and 3.2, unless at least one handler has been added to the root - logger *before* the threads are started. These convenience functions call - :func:`basicConfig` to ensure that at least one handler is available; in - earlier versions of Python, this can (under rare circumstances) lead to - handlers being added multiple times to the root logger, which can in turn - lead to multiple messages for the same event. + .. note:: The above module-level functions which delegate to the root + logger should *not* be used in threads, in versions of Python earlier + than 2.7.1 and 3.2, unless at least one handler has been added to the + root logger *before* the threads are started. These convenience functions + call :func:`basicConfig` to ensure that at least one handler is + available; in earlier versions of Python, this can (under rare + circumstances) lead to handlers being added multiple times to the root + logger, which can in turn lead to multiple messages for the same event. .. function:: disable(lvl) @@ -830,8 +830,8 @@ registered using this function, levels should be positive integers and they should increase in increasing order of severity. - NOTE: If you are thinking of defining your own levels, please see the section - on :ref:`custom-levels`. + .. note:: If you are thinking of defining your own levels, please see the + section on :ref:`custom-levels`. .. function:: getLevelName(lvl) @@ -866,12 +866,12 @@ .. versionchanged:: 2.4 Formerly, :func:`basicConfig` did not take any keyword arguments. - PLEASE NOTE: This function should be called from the main thread - before other threads are started. In versions of Python prior to - 2.7.1 and 3.2, if this function is called from multiple threads, - it is possible (in rare circumstances) that a handler will be added - to the root logger more than once, leading to unexpected results - such as messages being duplicated in the log. + .. note:: This function should be called from the main thread before other + threads are started. In versions of Python prior to 2.7.1 and 3.2, if + this function is called from multiple threads, it is possible (in rare + circumstances) that a handler will be added to the root logger more than + once, leading to unexpected results such as messages being duplicated in + the log. The following keyword arguments are supported. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 12:27:31 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 8 Jan 2013 12:27:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2ODg0?= =?utf-8?q?=3A_Updated_docs_to_use_=27note=27_directives_in_a_couple_of_pl?= =?utf-8?q?aces?= Message-ID: <3YgWR748YqzPMy@mail.python.org> http://hg.python.org/cpython/rev/50af862d0625 changeset: 81319:50af862d0625 branch: 3.2 parent: 81315:9458a516f769 user: Vinay Sajip date: Tue Jan 08 11:25:42 2013 +0000 summary: Issue #16884: Updated docs to use 'note' directives in a couple of places missed earlier. files: Doc/howto/logging.rst | 8 ++++---- Doc/library/logging.rst | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -970,10 +970,10 @@ to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. -**Note:** The default value of :data:`raiseExceptions` is ``True``. This is because -during development, you typically want to be notified of any exceptions that -occur. It's advised that you set :data:`raiseExceptions` to ``False`` for production -usage. +.. note:: The default value of :data:`raiseExceptions` is ``True``. This is + because during development, you typically want to be notified of any + exceptions that occur. It's advised that you set :data:`raiseExceptions` to + ``False`` for production usage. .. currentmodule:: logging diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -958,8 +958,8 @@ registered using this function, levels should be positive integers and they should increase in increasing order of severity. - NOTE: If you are thinking of defining your own levels, please see the section - on :ref:`custom-levels`. + .. note:: If you are thinking of defining your own levels, please see the + section on :ref:`custom-levels`. .. function:: getLevelName(lvl) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 12:27:32 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 8 Jan 2013 12:27:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316884=3A_Merged_doc_fix_from_3=2E2=2E?= Message-ID: <3YgWR86ncGzRn3@mail.python.org> http://hg.python.org/cpython/rev/b00c4a095b00 changeset: 81320:b00c4a095b00 branch: 3.3 parent: 81316:f6cf2985348a parent: 81319:50af862d0625 user: Vinay Sajip date: Tue Jan 08 11:26:30 2013 +0000 summary: Issue #16884: Merged doc fix from 3.2. files: Doc/howto/logging.rst | 8 ++++---- Doc/library/logging.rst | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -970,10 +970,10 @@ to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. -**Note:** The default value of :data:`raiseExceptions` is ``True``. This is because -during development, you typically want to be notified of any exceptions that -occur. It's advised that you set :data:`raiseExceptions` to ``False`` for production -usage. +.. note:: The default value of :data:`raiseExceptions` is ``True``. This is + because during development, you typically want to be notified of any + exceptions that occur. It's advised that you set :data:`raiseExceptions` to + ``False`` for production usage. .. currentmodule:: logging diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -978,8 +978,8 @@ registered using this function, levels should be positive integers and they should increase in increasing order of severity. - NOTE: If you are thinking of defining your own levels, please see the section - on :ref:`custom-levels`. + .. note:: If you are thinking of defining your own levels, please see the + section on :ref:`custom-levels`. .. function:: getLevelName(lvl) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 12:27:34 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 8 Jan 2013 12:27:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316884=3A_Merged_doc_fix_from_3=2E3=2E?= Message-ID: <3YgWRB2NWtzRph@mail.python.org> http://hg.python.org/cpython/rev/4617b7ac302a changeset: 81321:4617b7ac302a parent: 81317:51e60d9ee389 parent: 81320:b00c4a095b00 user: Vinay Sajip date: Tue Jan 08 11:27:18 2013 +0000 summary: Issue #16884: Merged doc fix from 3.3. files: Doc/howto/logging.rst | 8 ++++---- Doc/library/logging.rst | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -970,10 +970,10 @@ to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. -**Note:** The default value of :data:`raiseExceptions` is ``True``. This is because -during development, you typically want to be notified of any exceptions that -occur. It's advised that you set :data:`raiseExceptions` to ``False`` for production -usage. +.. note:: The default value of :data:`raiseExceptions` is ``True``. This is + because during development, you typically want to be notified of any + exceptions that occur. It's advised that you set :data:`raiseExceptions` to + ``False`` for production usage. .. currentmodule:: logging diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -978,8 +978,8 @@ registered using this function, levels should be positive integers and they should increase in increasing order of severity. - NOTE: If you are thinking of defining your own levels, please see the section - on :ref:`custom-levels`. + .. note:: If you are thinking of defining your own levels, please see the + section on :ref:`custom-levels`. .. function:: getLevelName(lvl) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 20:08:20 2013 From: python-checkins at python.org (charles-francois.natali) Date: Tue, 8 Jan 2013 20:08:20 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2ODM2?= =?utf-8?q?=3A_Enable_IPv6_support_even_if_IPv6_is_disabled_on_the_build_h?= =?utf-8?q?ost=2E?= Message-ID: <3Ygjfr12BczPCP@mail.python.org> http://hg.python.org/cpython/rev/1d8effd379c3 changeset: 81322:1d8effd379c3 branch: 2.7 parent: 81318:51138680b968 user: Charles-Fran?ois Natali date: Tue Jan 08 19:47:00 2013 +0100 summary: Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. files: Misc/NEWS | 2 + configure | 304 +++++++++++++++++++------------------- configure.ac | 16 +- 3 files changed, 159 insertions(+), 163 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -658,6 +658,8 @@ Build ----- +- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. + - Issue #15923: fix a mistake in asdl_c.py that resulted in a TypeError after 2801bf875a24 (see #15801). diff --git a/configure b/configure --- a/configure +++ b/configure @@ -1,14 +1,12 @@ #! /bin/sh # From configure.ac Revision. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for python 2.7. +# Generated by GNU Autoconf 2.69 for python 2.7. # # Report bugs to . # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -137,6 +135,31 @@ # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -170,7 +193,8 @@ else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -215,21 +239,25 @@ if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -332,6 +360,14 @@ } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -453,6 +489,10 @@ chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -487,16 +527,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -508,28 +548,8 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -1235,8 +1255,6 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1521,9 +1539,9 @@ if $ac_init_version; then cat <<\_ACEOF python configure 2.7 -generated by GNU Autoconf 2.68 - -Copyright (C) 2010 Free Software Foundation, Inc. +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1800,7 +1818,7 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1897,7 +1915,8 @@ main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1951,7 +1970,8 @@ main () { static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1967,7 +1987,8 @@ { static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2017,7 +2038,8 @@ main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2033,7 +2055,8 @@ main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2059,7 +2082,8 @@ main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2075,7 +2099,8 @@ main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2109,7 +2134,8 @@ main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2352,7 +2378,7 @@ running configure, to aid debugging if configure makes a mistake. It was created by python $as_me 2.7, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3296,7 +3322,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3336,7 +3362,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3389,7 +3415,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3430,7 +3456,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3488,7 +3514,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3532,7 +3558,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3978,8 +4004,7 @@ /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4122,7 +4147,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4163,7 +4188,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4212,7 +4237,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4413,7 +4438,7 @@ for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4479,7 +4504,7 @@ for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4686,8 +4711,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -5036,7 +5061,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5076,7 +5101,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5130,7 +5155,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5180,7 +5205,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_SVNVERSION="found" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5242,7 +5267,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_HAS_HG="found" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5349,7 +5374,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -5418,7 +5443,7 @@ test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -8426,7 +8451,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8469,7 +8494,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -9243,28 +9268,20 @@ esac else - if test "$cross_compiling" = yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ipv6=no - -else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* AF_INET6 available check */ #include #include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : +int +main () +{ +int domain = AF_INET6; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -9277,10 +9294,7 @@ ipv6=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ipv6" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if RFC2553 API is available" >&5 @@ -10130,7 +10144,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_TRUE="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11444,7 +11458,8 @@ main () { static int test_array [1 - 2 * !(((char) -1) < 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -11475,11 +11490,11 @@ int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -11496,8 +11511,9 @@ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -11513,10 +11529,10 @@ iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -14447,16 +14463,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -14516,28 +14532,16 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -14559,7 +14563,7 @@ # values after options handling. ac_log=" This file was extended by python $as_me 2.7, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -14621,10 +14625,10 @@ ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ python config.status 2.7 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -14714,7 +14718,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2517,25 +2517,15 @@ [ dnl the check does not work on cross compilation case... - AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */ #include -#include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} -]])],[ +#include ]], +[[int domain = AF_INET6;]])],[ AC_MSG_RESULT(yes) ipv6=yes ],[ AC_MSG_RESULT(no) ipv6=no -],[ - AC_MSG_RESULT(no) - ipv6=no ]) if test "$ipv6" = "yes"; then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 20:08:21 2013 From: python-checkins at python.org (charles-francois.natali) Date: Tue, 8 Jan 2013 20:08:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2ODM2?= =?utf-8?q?=3A_Enable_IPv6_support_even_if_IPv6_is_disabled_on_the_build_h?= =?utf-8?q?ost=2E?= Message-ID: <3Ygjfs4b36zPJ8@mail.python.org> http://hg.python.org/cpython/rev/d5df9ed118c5 changeset: 81323:d5df9ed118c5 branch: 3.2 parent: 81319:50af862d0625 user: Charles-Fran?ois Natali date: Tue Jan 08 19:49:42 2013 +0100 summary: Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. files: Misc/NEWS | 2 ++ configure | 31 ++++++++++--------------------- configure.ac | 16 +++------------- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -821,6 +821,8 @@ Build ----- +- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. + - Issue #16593: Have BSD 'make -s' do the right thing, thanks to Daniel Shahaf - Issue #16262: fix out-of-src-tree builds, if mercurial is not installed. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -9103,28 +9103,20 @@ esac else - if test "$cross_compiling" = yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ipv6=no - -else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* AF_INET6 available check */ #include #include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : +int +main () +{ +int domain = AF_INET6; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -9137,10 +9129,7 @@ ipv6=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ipv6" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if RFC2553 API is available" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2346,25 +2346,15 @@ [ dnl the check does not work on cross compilation case... - AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */ #include -#include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} -]])],[ +#include ]], +[[int domain = AF_INET6;]])],[ AC_MSG_RESULT(yes) ipv6=yes ],[ AC_MSG_RESULT(no) ipv6=no -],[ - AC_MSG_RESULT(no) - ipv6=no ]) if test "$ipv6" = "yes"; then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 20:08:23 2013 From: python-checkins at python.org (charles-francois.natali) Date: Tue, 8 Jan 2013 20:08:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316836=3A_Enable_IPv6_support_even_if_IPv6_is_disabled?= =?utf-8?q?_on_the_build_host=2E?= Message-ID: <3Ygjfv2kyVzPCP@mail.python.org> http://hg.python.org/cpython/rev/ebfd847bc15a changeset: 81324:ebfd847bc15a branch: 3.3 parent: 81320:b00c4a095b00 parent: 81323:d5df9ed118c5 user: Charles-Fran?ois Natali date: Tue Jan 08 19:51:56 2013 +0100 summary: Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. files: Misc/NEWS | 2 ++ configure | 31 ++++++++++--------------------- configure.ac | 16 +++------------- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -429,6 +429,8 @@ Build ----- +- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. + - Cross compiling needs host and build settings. configure no longer creates a broken PYTHON_FOR_BUILD variable when --build is missing. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -9795,28 +9795,20 @@ esac else - if test "$cross_compiling" = yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ipv6=no - -else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* AF_INET6 available check */ #include #include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : +int +main () +{ +int domain = AF_INET6; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -9829,10 +9821,7 @@ ipv6=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ipv6" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if RFC2553 API is available" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2501,25 +2501,15 @@ [ dnl the check does not work on cross compilation case... - AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */ #include -#include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} -]])],[ +#include ]], +[[int domain = AF_INET6;]])],[ AC_MSG_RESULT(yes) ipv6=yes ],[ AC_MSG_RESULT(no) ipv6=no -],[ - AC_MSG_RESULT(no) - ipv6=no ]) if test "$ipv6" = "yes"; then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 20:08:25 2013 From: python-checkins at python.org (charles-francois.natali) Date: Tue, 8 Jan 2013 20:08:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316836=3A_Enable_IPv6_support_even_if_IPv6_is_di?= =?utf-8?q?sabled_on_the_build_host=2E?= Message-ID: <3Ygjfx3800zRyM@mail.python.org> http://hg.python.org/cpython/rev/f7e563478349 changeset: 81325:f7e563478349 parent: 81321:4617b7ac302a parent: 81324:ebfd847bc15a user: Charles-Fran?ois Natali date: Tue Jan 08 20:03:07 2013 +0100 summary: Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. files: Misc/NEWS | 2 ++ configure | 31 ++++++++++--------------------- configure.ac | 16 +++------------- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -601,6 +601,8 @@ Tests ----- +- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. + - Issue #16748: test_heapq now works with unittest test discovery. - Issue #10646: Tests rearranged for os.samefile/samestat to check for not diff --git a/configure b/configure --- a/configure +++ b/configure @@ -9795,28 +9795,20 @@ esac else - if test "$cross_compiling" = yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ipv6=no - -else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* AF_INET6 available check */ #include #include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : +int +main () +{ +int domain = AF_INET6; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -9829,10 +9821,7 @@ ipv6=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ipv6" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if RFC2553 API is available" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2501,25 +2501,15 @@ [ dnl the check does not work on cross compilation case... - AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */ #include -#include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} -]])],[ +#include ]], +[[int domain = AF_INET6;]])],[ AC_MSG_RESULT(yes) ipv6=yes ],[ AC_MSG_RESULT(no) ipv6=no -],[ - AC_MSG_RESULT(no) - ipv6=no ]) if test "$ipv6" = "yes"; then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 21:47:18 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 21:47:18 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_out_of_bou?= =?utf-8?q?nd_read_in_UTF-32_decoder_on_=22narrow_Unicode=22_builds=2E?= Message-ID: <3Ygls22X8MzP57@mail.python.org> http://hg.python.org/cpython/rev/3570e04f4ea9 changeset: 81326:3570e04f4ea9 branch: 2.7 parent: 81322:1d8effd379c3 user: Serhiy Storchaka date: Tue Jan 08 22:43:18 2013 +0200 summary: Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds. files: Objects/unicodeobject.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2272,7 +2272,7 @@ /* On narrow builds we split characters outside the BMP into two codepoints => count how much extra space we need. */ #ifndef Py_UNICODE_WIDE - for (qq = q; qq < e; qq += 4) + for (qq = q; e - qq >= 4; qq += 4) if (qq[iorder[2]] != 0 || qq[iorder[3]] != 0) pairs++; #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 21:47:19 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 21:47:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_out_of_bou?= =?utf-8?q?nd_read_in_UTF-32_decoder_on_=22narrow_Unicode=22_builds=2E?= Message-ID: <3Ygls35cWJzRph@mail.python.org> http://hg.python.org/cpython/rev/bf347198fbaf changeset: 81327:bf347198fbaf branch: 3.2 parent: 81323:d5df9ed118c5 user: Serhiy Storchaka date: Tue Jan 08 22:45:42 2013 +0200 summary: Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds. files: Objects/unicodeobject.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3182,7 +3182,7 @@ /* On narrow builds we split characters outside the BMP into two codepoints => count how much extra space we need. */ #ifndef Py_UNICODE_WIDE - for (qq = q; qq < e; qq += 4) + for (qq = q; e - qq >= 4; qq += 4) if (qq[iorder[2]] != 0 || qq[iorder[3]] != 0) pairs++; #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 22:47:36 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 22:47:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzExNDYx?= =?utf-8?q?=3A_Fix_the_incremental_UTF-16_decoder=2E_Original_patch_by?= Message-ID: <3YgnBc5Z5wzMKB@mail.python.org> http://hg.python.org/cpython/rev/f2353e74b335 changeset: 81328:f2353e74b335 branch: 2.7 parent: 81326:3570e04f4ea9 user: Serhiy Storchaka date: Tue Jan 08 23:12:00 2013 +0200 summary: Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP characters. files: Lib/test/test_codecs.py | 48 ++++++++++++++++++++++++---- Misc/NEWS | 3 + Objects/unicodeobject.c | 5 ++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -281,7 +281,7 @@ def test_partial(self): self.check_partial( - u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", [ u"", # first byte of BOM read u"", # second byte of BOM read @@ -303,6 +303,10 @@ u"\x00\xff\u0100", u"\x00\xff\u0100", u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", ] ) @@ -331,7 +335,7 @@ def test_partial(self): self.check_partial( - u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", [ u"", u"", @@ -349,6 +353,10 @@ u"\x00\xff\u0100", u"\x00\xff\u0100", u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", ] ) @@ -371,7 +379,7 @@ def test_partial(self): self.check_partial( - u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", [ u"", u"", @@ -389,6 +397,10 @@ u"\x00\xff\u0100", u"\x00\xff\u0100", u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", ] ) @@ -439,7 +451,7 @@ def test_partial(self): self.check_partial( - u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", [ u"", # first byte of BOM read u"", # second byte of BOM read => byteorder known @@ -451,6 +463,10 @@ u"\x00\xff\u0100", u"\x00\xff\u0100", u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", ] ) @@ -481,7 +497,7 @@ def test_partial(self): self.check_partial( - u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", [ u"", u"\x00", @@ -491,6 +507,10 @@ u"\x00\xff\u0100", u"\x00\xff\u0100", u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", ] ) @@ -514,7 +534,7 @@ def test_partial(self): self.check_partial( - u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", [ u"", u"\x00", @@ -524,6 +544,10 @@ u"\x00\xff\u0100", u"\x00\xff\u0100", u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff", + u"\x00\xff\u0100\uffff\U00010000", ] ) @@ -547,7 +571,7 @@ def test_partial(self): self.check_partial( - u"\x00\xff\u07ff\u0800\uffff", + u"\x00\xff\u07ff\u0800\uffff\U00010000", [ u"\x00", u"\x00", @@ -560,6 +584,10 @@ u"\x00\xff\u07ff\u0800", u"\x00\xff\u07ff\u0800", u"\x00\xff\u07ff\u0800\uffff", + u"\x00\xff\u07ff\u0800\uffff", + u"\x00\xff\u07ff\u0800\uffff", + u"\x00\xff\u07ff\u0800\uffff", + u"\x00\xff\u07ff\u0800\uffff\U00010000", ] ) @@ -619,7 +647,7 @@ def test_partial(self): self.check_partial( - u"\ufeff\x00\xff\u07ff\u0800\uffff", + u"\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", [ u"", u"", @@ -638,6 +666,10 @@ u"\ufeff\x00\xff\u07ff\u0800", u"\ufeff\x00\xff\u07ff\u0800", u"\ufeff\x00\xff\u07ff\u0800\uffff", + u"\ufeff\x00\xff\u07ff\u0800\uffff", + u"\ufeff\x00\xff\u07ff\u0800\uffff", + u"\ufeff\x00\xff\u07ff\u0800\uffff", + u"\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", ] ) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,9 @@ Core and Builtins ----------------- +- Issue #11461: Fix the incremental UTF-16 decoder. Original patch by + Amaury Forgeot d'Arc. + - Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. - Issue #15516: Fix a bug in PyString_FromFormat where it failed to properly diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2565,8 +2565,11 @@ /* UTF-16 code pair: */ if (e - q < 2) { + q -= 2; + if (consumed) + break; errmsg = "unexpected end of data"; - startinpos = (((const char *)q)-2)-starts; + startinpos = ((const char *)q)-starts; endinpos = ((const char *)e)-starts; goto utf16Error; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 22:47:38 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 22:47:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzExNDYx?= =?utf-8?q?=3A_Fix_the_incremental_UTF-16_decoder=2E_Original_patch_by?= Message-ID: <3YgnBf3bjpzRwy@mail.python.org> http://hg.python.org/cpython/rev/4677c5f6fcf7 changeset: 81329:4677c5f6fcf7 branch: 3.2 parent: 81327:bf347198fbaf user: Serhiy Storchaka date: Tue Jan 08 23:14:24 2013 +0200 summary: Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP characters. files: Lib/test/test_codecs.py | 48 ++++++++++++++++++++++++---- Misc/NEWS | 3 + Objects/unicodeobject.c | 5 ++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -313,7 +313,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read @@ -335,6 +335,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -369,7 +373,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "", @@ -387,6 +391,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -409,7 +417,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "", @@ -427,6 +435,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -477,7 +489,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read => byteorder known @@ -489,6 +501,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -526,7 +542,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", @@ -536,6 +552,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -565,7 +585,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", @@ -575,6 +595,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -604,7 +628,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff\U00010000", [ "\x00", "\x00", @@ -617,6 +641,10 @@ "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff\U00010000", ] ) @@ -694,7 +722,7 @@ def test_partial(self): self.check_partial( - "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", [ "", "", @@ -713,6 +741,10 @@ "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", ] ) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #11461: Fix the incremental UTF-16 decoder. Original patch by + Amaury Forgeot d'Arc. + - Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. - Issue #16455: On FreeBSD and Solaris, if the locale is C, the diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3573,8 +3573,11 @@ /* UTF-16 code pair: */ if (e - q < 2) { + q -= 2; + if (consumed) + break; errmsg = "unexpected end of data"; - startinpos = (((const char *)q) - 2) - starts; + startinpos = ((const char *)q) - starts; endinpos = ((const char *)e) - starts; goto utf16Error; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 22:47:40 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 22:47:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null_merge?= Message-ID: <3YgnBh0C4XzP8h@mail.python.org> http://hg.python.org/cpython/rev/cd36e961e42c changeset: 81330:cd36e961e42c branch: 3.3 parent: 81324:ebfd847bc15a parent: 81327:bf347198fbaf user: Serhiy Storchaka date: Tue Jan 08 23:18:42 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 22:47:41 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 22:47:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3YgnBj2yhxzP8h@mail.python.org> http://hg.python.org/cpython/rev/6d019606d948 changeset: 81331:6d019606d948 parent: 81325:f7e563478349 parent: 81330:cd36e961e42c user: Serhiy Storchaka date: Tue Jan 08 23:19:42 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 22:47:43 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 22:47:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2311461=3A_Fix_the_incremental_UTF-16_decoder=2E_Origin?= =?utf-8?q?al_patch_by?= Message-ID: <3YgnBl0kgHzP34@mail.python.org> http://hg.python.org/cpython/rev/eed1883b1974 changeset: 81332:eed1883b1974 branch: 3.3 parent: 81330:cd36e961e42c parent: 81329:4677c5f6fcf7 user: Serhiy Storchaka date: Tue Jan 08 23:40:52 2013 +0200 summary: Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP characters. files: Lib/test/test_codecs.py | 48 ++++++++++++++++++++++++---- Misc/NEWS | 3 + Objects/unicodeobject.c | 5 ++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -330,7 +330,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read @@ -352,6 +352,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -386,7 +390,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "", @@ -404,6 +408,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -426,7 +434,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "", @@ -444,6 +452,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -494,7 +506,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read => byteorder known @@ -506,6 +518,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -543,7 +559,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", @@ -553,6 +569,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -582,7 +602,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", @@ -592,6 +612,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -621,7 +645,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff\U00010000", [ "\x00", "\x00", @@ -634,6 +658,10 @@ "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff\U00010000", ] ) @@ -816,7 +844,7 @@ def test_partial(self): self.check_partial( - "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", [ "", "", @@ -835,6 +863,10 @@ "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", ] ) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #11461: Fix the incremental UTF-16 decoder. Original patch by + Amaury Forgeot d'Arc. + - Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. - Issue #16856: Fix a segmentation fault from calling repr() on a dict with diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5284,8 +5284,11 @@ /* The remaining input chars are ignored if the callback chooses to skip the input */ case 1: + q -= 2; + if (consumed) + goto End; errmsg = "unexpected end of data"; - startinpos = ((const char *)q) - 2 - starts; + startinpos = ((const char *)q) - starts; endinpos = ((const char *)e) - starts; break; case 2: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 22:47:44 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 22:47:44 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2311461=3A_Fix_the_incremental_UTF-16_decoder=2E_?= =?utf-8?q?Original_patch_by?= Message-ID: <3YgnBm5bh5zQrS@mail.python.org> http://hg.python.org/cpython/rev/5e84d020d001 changeset: 81333:5e84d020d001 parent: 81331:6d019606d948 parent: 81332:eed1883b1974 user: Serhiy Storchaka date: Tue Jan 08 23:41:55 2013 +0200 summary: Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP characters. files: Lib/test/test_codecs.py | 48 ++++++++++++++++++++++++---- Misc/NEWS | 3 + Objects/unicodeobject.c | 5 ++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -330,7 +330,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read @@ -352,6 +352,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -386,7 +390,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "", @@ -404,6 +408,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -426,7 +434,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "", @@ -444,6 +452,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -494,7 +506,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", # first byte of BOM read "", # second byte of BOM read => byteorder known @@ -506,6 +518,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -543,7 +559,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", @@ -553,6 +569,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -582,7 +602,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", [ "", "\x00", @@ -592,6 +612,10 @@ "\x00\xff\u0100", "\x00\xff\u0100", "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff", + "\x00\xff\u0100\uffff\U00010000", ] ) @@ -621,7 +645,7 @@ def test_partial(self): self.check_partial( - "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff\U00010000", [ "\x00", "\x00", @@ -634,6 +658,10 @@ "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800", "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff", + "\x00\xff\u07ff\u0800\uffff\U00010000", ] ) @@ -816,7 +844,7 @@ def test_partial(self): self.check_partial( - "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", [ "", "", @@ -835,6 +863,10 @@ "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800", "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff", + "\ufeff\x00\xff\u07ff\u0800\uffff\U00010000", ] ) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #11461: Fix the incremental UTF-16 decoder. Original patch by + Amaury Forgeot d'Arc. + - Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. - Issue #16856: Fix a segmentation fault from calling repr() on a dict with diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5159,8 +5159,11 @@ /* The remaining input chars are ignored if the callback chooses to skip the input */ case 1: + q -= 2; + if (consumed) + goto End; errmsg = "unexpected end of data"; - startinpos = ((const char *)q) - 2 - starts; + startinpos = ((const char *)q) - starts; endinpos = ((const char *)e) - starts; break; case 2: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 23:16:08 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 23:16:08 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2ODQz?= =?utf-8?q?=3A_Make_concurrent_tests_for_sched_module_deterministic=2E?= Message-ID: <3YgnqX67QczPCZ@mail.python.org> http://hg.python.org/cpython/rev/ab36d3bb5996 changeset: 81334:ab36d3bb5996 branch: 3.3 parent: 81332:eed1883b1974 user: Serhiy Storchaka date: Wed Jan 09 00:13:38 2013 +0200 summary: Issue #16843: Make concurrent tests for sched module deterministic. files: Lib/test/test_sched.py | 106 +++++++++++++++++++++++----- 1 files changed, 85 insertions(+), 21 deletions(-) diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py --- a/Lib/test/test_sched.py +++ b/Lib/test/test_sched.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import queue import sched import time import unittest @@ -9,6 +10,37 @@ except ImportError: threading = None +TIMEOUT = 10 + + +class Timer: + def __init__(self): + self._cond = threading.Condition() + self._time = 0 + self._stop = 0 + + def time(self): + with self._cond: + return self._time + + # increase the time but not beyond the established limit + def sleep(self, t): + assert t >= 0 + with self._cond: + t += self._time + while self._stop < t: + self._time = self._stop + self._cond.wait() + self._time = t + + # advance time limit for user code + def advance(self, t): + assert t >= 0 + with self._cond: + self._stop += t + self._cond.notify_all() + + class TestCase(unittest.TestCase): def test_enter(self): @@ -31,17 +63,34 @@ @unittest.skipUnless(threading, 'Threading required for this test.') def test_enter_concurrent(self): - l = [] - fun = lambda x: l.append(x) - scheduler = sched.scheduler(time.time, time.sleep) - scheduler.enter(0.03, 1, fun, (0.03,)) + q = queue.Queue() + fun = q.put + timer = Timer() + scheduler = sched.scheduler(timer.time, timer.sleep) + scheduler.enter(1, 1, fun, (1,)) + scheduler.enter(3, 1, fun, (3,)) t = threading.Thread(target=scheduler.run) t.start() - for x in [0.05, 0.04, 0.02, 0.01]: - z = scheduler.enter(x, 1, fun, (x,)) - scheduler.run() - t.join() - self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05]) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 1) + self.assertTrue(q.empty()) + for x in [4, 5, 2]: + z = scheduler.enter(x - 1, 1, fun, (x,)) + timer.advance(2) + self.assertEqual(q.get(timeout=TIMEOUT), 2) + self.assertEqual(q.get(timeout=TIMEOUT), 3) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 4) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 5) + self.assertTrue(q.empty()) + timer.advance(1000) + t.join(timeout=TIMEOUT) + self.assertFalse(t.is_alive()) + self.assertTrue(q.empty()) + self.assertEqual(timer.time(), 5) def test_priority(self): l = [] @@ -69,21 +118,36 @@ @unittest.skipUnless(threading, 'Threading required for this test.') def test_cancel_concurrent(self): - l = [] - fun = lambda x: l.append(x) - scheduler = sched.scheduler(time.time, time.sleep) - now = time.time() - event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,)) - event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,)) - event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,)) - event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,)) - event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,)) + q = queue.Queue() + fun = q.put + timer = Timer() + scheduler = sched.scheduler(timer.time, timer.sleep) + now = timer.time() + event1 = scheduler.enterabs(now + 1, 1, fun, (1,)) + event2 = scheduler.enterabs(now + 2, 1, fun, (2,)) + event4 = scheduler.enterabs(now + 4, 1, fun, (4,)) + event5 = scheduler.enterabs(now + 5, 1, fun, (5,)) + event3 = scheduler.enterabs(now + 3, 1, fun, (3,)) t = threading.Thread(target=scheduler.run) t.start() - scheduler.cancel(event1) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 1) + self.assertTrue(q.empty()) + scheduler.cancel(event2) scheduler.cancel(event5) - t.join() - self.assertEqual(l, [0.02, 0.03, 0.04]) + timer.advance(1) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 3) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 4) + self.assertTrue(q.empty()) + timer.advance(1000) + t.join(timeout=TIMEOUT) + self.assertFalse(t.is_alive()) + self.assertTrue(q.empty()) + self.assertEqual(timer.time(), 4) def test_empty(self): l = [] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 8 23:16:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 8 Jan 2013 23:16:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316843=3A_Make_concurrent_tests_for_sched_module?= =?utf-8?q?_deterministic=2E?= Message-ID: <3YgnqZ36WhzR3l@mail.python.org> http://hg.python.org/cpython/rev/f65eae38f71e changeset: 81335:f65eae38f71e parent: 81333:5e84d020d001 parent: 81334:ab36d3bb5996 user: Serhiy Storchaka date: Wed Jan 09 00:15:14 2013 +0200 summary: Issue #16843: Make concurrent tests for sched module deterministic. files: Lib/test/test_sched.py | 106 +++++++++++++++++++++++----- 1 files changed, 85 insertions(+), 21 deletions(-) diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py --- a/Lib/test/test_sched.py +++ b/Lib/test/test_sched.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import queue import sched import time import unittest @@ -9,6 +10,37 @@ except ImportError: threading = None +TIMEOUT = 10 + + +class Timer: + def __init__(self): + self._cond = threading.Condition() + self._time = 0 + self._stop = 0 + + def time(self): + with self._cond: + return self._time + + # increase the time but not beyond the established limit + def sleep(self, t): + assert t >= 0 + with self._cond: + t += self._time + while self._stop < t: + self._time = self._stop + self._cond.wait() + self._time = t + + # advance time limit for user code + def advance(self, t): + assert t >= 0 + with self._cond: + self._stop += t + self._cond.notify_all() + + class TestCase(unittest.TestCase): def test_enter(self): @@ -31,17 +63,34 @@ @unittest.skipUnless(threading, 'Threading required for this test.') def test_enter_concurrent(self): - l = [] - fun = lambda x: l.append(x) - scheduler = sched.scheduler(time.time, time.sleep) - scheduler.enter(0.03, 1, fun, (0.03,)) + q = queue.Queue() + fun = q.put + timer = Timer() + scheduler = sched.scheduler(timer.time, timer.sleep) + scheduler.enter(1, 1, fun, (1,)) + scheduler.enter(3, 1, fun, (3,)) t = threading.Thread(target=scheduler.run) t.start() - for x in [0.05, 0.04, 0.02, 0.01]: - z = scheduler.enter(x, 1, fun, (x,)) - scheduler.run() - t.join() - self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05]) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 1) + self.assertTrue(q.empty()) + for x in [4, 5, 2]: + z = scheduler.enter(x - 1, 1, fun, (x,)) + timer.advance(2) + self.assertEqual(q.get(timeout=TIMEOUT), 2) + self.assertEqual(q.get(timeout=TIMEOUT), 3) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 4) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 5) + self.assertTrue(q.empty()) + timer.advance(1000) + t.join(timeout=TIMEOUT) + self.assertFalse(t.is_alive()) + self.assertTrue(q.empty()) + self.assertEqual(timer.time(), 5) def test_priority(self): l = [] @@ -69,21 +118,36 @@ @unittest.skipUnless(threading, 'Threading required for this test.') def test_cancel_concurrent(self): - l = [] - fun = lambda x: l.append(x) - scheduler = sched.scheduler(time.time, time.sleep) - now = time.time() - event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,)) - event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,)) - event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,)) - event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,)) - event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,)) + q = queue.Queue() + fun = q.put + timer = Timer() + scheduler = sched.scheduler(timer.time, timer.sleep) + now = timer.time() + event1 = scheduler.enterabs(now + 1, 1, fun, (1,)) + event2 = scheduler.enterabs(now + 2, 1, fun, (2,)) + event4 = scheduler.enterabs(now + 4, 1, fun, (4,)) + event5 = scheduler.enterabs(now + 5, 1, fun, (5,)) + event3 = scheduler.enterabs(now + 3, 1, fun, (3,)) t = threading.Thread(target=scheduler.run) t.start() - scheduler.cancel(event1) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 1) + self.assertTrue(q.empty()) + scheduler.cancel(event2) scheduler.cancel(event5) - t.join() - self.assertEqual(l, [0.02, 0.03, 0.04]) + timer.advance(1) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 3) + self.assertTrue(q.empty()) + timer.advance(1) + self.assertEqual(q.get(timeout=TIMEOUT), 4) + self.assertTrue(q.empty()) + timer.advance(1000) + t.join(timeout=TIMEOUT) + self.assertFalse(t.is_alive()) + self.assertTrue(q.empty()) + self.assertEqual(timer.time(), 4) def test_empty(self): l = [] -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Wed Jan 9 05:56:00 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 09 Jan 2013 05:56:00 +0100 Subject: [Python-checkins] Daily reference leaks (f65eae38f71e): sum=7 Message-ID: results for f65eae38f71e on branch "default" -------------------------------------------- test_dbm leaked [2, 0, 0] references, sum=2 test_dbm leaked [2, 2, 1] memory blocks, sum=5 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogvOIjCH', '-x'] From python-checkins at python.org Wed Jan 9 08:35:26 2013 From: python-checkins at python.org (ezio.melotti) Date: Wed, 9 Jan 2013 08:35:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_=2316868=3A_mention_that_?= =?utf-8?q?you_can_=22ping=22_issues_before_writing_to_python-dev=2E?= Message-ID: <3Yh2Dt0bp9zRxC@mail.python.org> http://hg.python.org/devguide/rev/3f2637a6fbfa changeset: 585:3f2637a6fbfa user: Ezio Melotti date: Wed Jan 09 09:35:00 2013 +0200 summary: #16868: mention that you can "ping" issues before writing to python-dev. files: patch.rst | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/patch.rst b/patch.rst --- a/patch.rst +++ b/patch.rst @@ -139,9 +139,11 @@ than there are people capable of reviewing your patch. Getting your patch reviewed requires a reviewer to have the spare time and motivation to look at your patch (we cannot force anyone to review patches). If your patch has -not received any notice from reviewers (i.e., no comment made) after a -substantial amount of time then you may -email python-dev at python.org asking for someone to take a look at your patch. +not received any notice from reviewers (i.e., no comment made) after one +month, first "ping" the issue on the `issue tracker`_ to remind the nosy list +that the patch needs a review. If you don't get a response within a few days +after pinging the issue, then you can try emailing python-dev at python.org asking +for someone to review your patch. When someone does manage to find the time to look at your patch they will most likely make comments about how it can be improved (don't worry, even core -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Wed Jan 9 11:29:25 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 9 Jan 2013 11:29:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2NDkx?= =?utf-8?q?=3A_IDLE_now_prints_chained_exception_tracebacks=2E?= Message-ID: <3Yh65d6jwWzR3q@mail.python.org> http://hg.python.org/cpython/rev/f28aff31900a changeset: 81336:f28aff31900a branch: 3.2 parent: 81329:4677c5f6fcf7 user: Serhiy Storchaka date: Wed Jan 09 12:21:57 2013 +0200 summary: Issue #16491: IDLE now prints chained exception tracebacks. files: Lib/idlelib/run.py | 35 +++++++++++++++++++++++++-------- Misc/NEWS | 2 + 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -158,15 +158,32 @@ efile = sys.stderr typ, val, tb = excinfo = sys.exc_info() sys.last_type, sys.last_value, sys.last_traceback = excinfo - tbe = traceback.extract_tb(tb) - print('Traceback (most recent call last):', file=efile) - exclude = ("run.py", "rpc.py", "threading.py", "queue.py", - "RemoteDebugger.py", "bdb.py") - cleanup_traceback(tbe, exclude) - traceback.print_list(tbe, file=efile) - lines = traceback.format_exception_only(typ, val) - for line in lines: - print(line, end='', file=efile) + seen = set() + + def print_exc(typ, exc, tb): + seen.add(exc) + context = exc.__context__ + cause = exc.__cause__ + if cause is not None and cause not in seen: + print_exc(type(cause), cause, cause.__traceback__) + print("\nThe above exception was the direct cause " + "of the following exception:\n", file=efile) + elif context is not None and context not in seen: + print_exc(type(context), context, context.__traceback__) + print("\nDuring handling of the above exception, " + "another exception occurred:\n", file=efile) + if tb: + tbe = traceback.extract_tb(tb) + print('Traceback (most recent call last):', file=efile) + exclude = ("run.py", "rpc.py", "threading.py", "queue.py", + "RemoteDebugger.py", "bdb.py") + cleanup_traceback(tbe, exclude) + traceback.print_list(tbe, file=efile) + lines = traceback.format_exception_only(typ, exc) + for line in lines: + print(line, end='', file=efile) + + print_exc(typ, val, tb) def cleanup_traceback(tb, exclude): "Remove excluded traces from beginning/end of tb; get cached lines" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -199,6 +199,8 @@ Library ------- +- Issue #16491: IDLE now prints chained exception tracebacks. + - Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by Martin Packman. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 9 11:29:27 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 9 Jan 2013 11:29:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316491=3A_IDLE_now_prints_chained_exception_tracebacks?= =?utf-8?q?=2E?= Message-ID: <3Yh65g30d9zS0Q@mail.python.org> http://hg.python.org/cpython/rev/3feead75c7a5 changeset: 81337:3feead75c7a5 branch: 3.3 parent: 81334:ab36d3bb5996 parent: 81336:f28aff31900a user: Serhiy Storchaka date: Wed Jan 09 12:24:48 2013 +0200 summary: Issue #16491: IDLE now prints chained exception tracebacks. files: Lib/idlelib/run.py | 37 +++++++++++++++++++++++++-------- Misc/NEWS | 2 + 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -171,15 +171,34 @@ efile = sys.stderr typ, val, tb = excinfo = sys.exc_info() sys.last_type, sys.last_value, sys.last_traceback = excinfo - tbe = traceback.extract_tb(tb) - print('Traceback (most recent call last):', file=efile) - exclude = ("run.py", "rpc.py", "threading.py", "queue.py", - "RemoteDebugger.py", "bdb.py") - cleanup_traceback(tbe, exclude) - traceback.print_list(tbe, file=efile) - lines = traceback.format_exception_only(typ, val) - for line in lines: - print(line, end='', file=efile) + seen = set() + + def print_exc(typ, exc, tb): + seen.add(exc) + context = exc.__context__ + cause = exc.__cause__ + if cause is not None and cause not in seen: + print_exc(type(cause), cause, cause.__traceback__) + print("\nThe above exception was the direct cause " + "of the following exception:\n", file=efile) + elif (context is not None and + not exc.__suppress_context__ and + context not in seen): + print_exc(type(context), context, context.__traceback__) + print("\nDuring handling of the above exception, " + "another exception occurred:\n", file=efile) + if tb: + tbe = traceback.extract_tb(tb) + print('Traceback (most recent call last):', file=efile) + exclude = ("run.py", "rpc.py", "threading.py", "queue.py", + "RemoteDebugger.py", "bdb.py") + cleanup_traceback(tbe, exclude) + traceback.print_list(tbe, file=efile) + lines = traceback.format_exception_only(typ, exc) + for line in lines: + print(line, end='', file=efile) + + print_exc(typ, val, tb) def cleanup_traceback(tb, exclude): "Remove excluded traces from beginning/end of tb; get cached lines" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -139,6 +139,8 @@ Library ------- +- Issue #16491: IDLE now prints chained exception tracebacks. + - Issue #15972: Fix error messages when os functions expecting a file name or file descriptor receive the incorrect type. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 9 11:29:28 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 9 Jan 2013 11:29:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316491=3A_IDLE_now_prints_chained_exception_trac?= =?utf-8?q?ebacks=2E?= Message-ID: <3Yh65h6Hq0zS0Q@mail.python.org> http://hg.python.org/cpython/rev/0793d68a0eba changeset: 81338:0793d68a0eba parent: 81335:f65eae38f71e parent: 81337:3feead75c7a5 user: Serhiy Storchaka date: Wed Jan 09 12:26:54 2013 +0200 summary: Issue #16491: IDLE now prints chained exception tracebacks. files: Lib/idlelib/run.py | 37 +++++++++++++++++++++++++-------- Misc/NEWS | 2 + 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -171,15 +171,34 @@ efile = sys.stderr typ, val, tb = excinfo = sys.exc_info() sys.last_type, sys.last_value, sys.last_traceback = excinfo - tbe = traceback.extract_tb(tb) - print('Traceback (most recent call last):', file=efile) - exclude = ("run.py", "rpc.py", "threading.py", "queue.py", - "RemoteDebugger.py", "bdb.py") - cleanup_traceback(tbe, exclude) - traceback.print_list(tbe, file=efile) - lines = traceback.format_exception_only(typ, val) - for line in lines: - print(line, end='', file=efile) + seen = set() + + def print_exc(typ, exc, tb): + seen.add(exc) + context = exc.__context__ + cause = exc.__cause__ + if cause is not None and cause not in seen: + print_exc(type(cause), cause, cause.__traceback__) + print("\nThe above exception was the direct cause " + "of the following exception:\n", file=efile) + elif (context is not None and + not exc.__suppress_context__ and + context not in seen): + print_exc(type(context), context, context.__traceback__) + print("\nDuring handling of the above exception, " + "another exception occurred:\n", file=efile) + if tb: + tbe = traceback.extract_tb(tb) + print('Traceback (most recent call last):', file=efile) + exclude = ("run.py", "rpc.py", "threading.py", "queue.py", + "RemoteDebugger.py", "bdb.py") + cleanup_traceback(tbe, exclude) + traceback.print_list(tbe, file=efile) + lines = traceback.format_exception_only(typ, exc) + for line in lines: + print(line, end='', file=efile) + + print_exc(typ, val, tb) def cleanup_traceback(tb, exclude): "Remove excluded traces from beginning/end of tb; get cached lines" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -209,6 +209,8 @@ Library ------- +- Issue #16491: IDLE now prints chained exception tracebacks. + - fcntl: add F_DUPFD_CLOEXEC constant, available on Linux 2.6.24+. - Issue #15972: Fix error messages when os functions expecting a file name or -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 9 16:52:36 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 9 Jan 2013 16:52:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_correct_static?= =?utf-8?q?_string_clearing_loop_=28closes_=2316906=29?= Message-ID: <3YhFGX5MzJzS1p@mail.python.org> http://hg.python.org/cpython/rev/3e18ccaa537e changeset: 81339:3e18ccaa537e branch: 3.3 parent: 81337:3feead75c7a5 user: Benjamin Peterson date: Wed Jan 09 09:52:01 2013 -0600 summary: correct static string clearing loop (closes #16906) files: Misc/NEWS | 3 +++ Objects/unicodeobject.c | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #16906: Fix a logic error that prevented most static strings from being + cleared. + - Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1826,12 +1826,15 @@ void _PyUnicode_ClearStaticStrings() { - _Py_Identifier *i; - for (i = static_strings; i; i = i->next) { - Py_DECREF(i->object); - i->object = NULL; - i->next = NULL; - } + _Py_Identifier *tmp, *s = static_strings; + while (s) { + Py_DECREF(s->object); + s->object = NULL; + tmp = s->next; + s->next = NULL; + s = tmp; + } + static_strings = NULL; } /* Internal function, doesn't check maximum character */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 9 16:52:38 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 9 Jan 2013 16:52:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4zICgjMTY5MDYp?= Message-ID: <3YhFGZ0vPPzP9G@mail.python.org> http://hg.python.org/cpython/rev/0c04ed40eeaf changeset: 81340:0c04ed40eeaf parent: 81338:0793d68a0eba parent: 81339:3e18ccaa537e user: Benjamin Peterson date: Wed Jan 09 09:52:22 2013 -0600 summary: merge 3.3 (#16906) files: Misc/NEWS | 3 +++ Objects/unicodeobject.c | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #16906: Fix a logic error that prevented most static strings from being + cleared. + - Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1822,12 +1822,15 @@ void _PyUnicode_ClearStaticStrings() { - _Py_Identifier *i; - for (i = static_strings; i; i = i->next) { - Py_DECREF(i->object); - i->object = NULL; - i->next = NULL; - } + _Py_Identifier *tmp, *s = static_strings; + while (s) { + Py_DECREF(s->object); + s->object = NULL; + tmp = s->next; + s->next = NULL; + s = tmp; + } + static_strings = NULL; } /* Internal function, doesn't check maximum character */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 9 18:18:55 2013 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 9 Jan 2013 18:18:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Specify_signal_handling_API?= =?utf-8?q?=2E?= Message-ID: <3YhHB76kLzzPCZ@mail.python.org> http://hg.python.org/peps/rev/a77060a3664e changeset: 4659:a77060a3664e user: Guido van Rossum date: Tue Jan 08 11:21:53 2013 -0800 summary: Specify signal handling API. files: pep-3156.txt | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -223,9 +223,28 @@ ``call_soon(callback, *args)``, but when called from another thread while the event loop is blocked waiting for I/O, unblocks the event loop. This is the *only* method that is safe to call from another - thread or from a signal handler. (To schedule a callback for a + thread. (To schedule a callback for a later time in a threadsafe manner, you can use ``ev.call_soon_threadsafe(ev.call_later, when, callback, *args)``.) + This is not safe to call from a signal handler (since it may use + locks). + +- ``add_signal_handler(sig, callback, *args). Whenever signal ``sig`` + is received, arrange for ``callback(*args)`` to be called. Returns + a ``Handler`` which can be used to cancel the signal callback. + Specifying another callback for the same signal replaces the + previous handler (only one handler can be active per signal). The + ``sig`` must be a valid sigal number defined in the ``signal`` + module. If the signal cannot be handled this raises an exception: + ValueError if it is not a valid signal or if it is an uncatchable + signale (e.g. ``SIGKILL``), RuntimeError if this particular event + loop instance cannot handle signals (since signals are global per + process, only an event loop associated with the main thread can + handle signals). + +- ``remove_signal_handler(sig)``. Removes the handler for signal + ``sig``, if one is set. Raises the same exceptions as + ``add_signal_handler()``. - TBD: A way to register a callback that is already wrapped in a ``Handler``. Maybe ``call_soon()`` could just check @@ -900,15 +919,6 @@ Finally, do we need support for unconnected datagram protocols? (That would mean wrappers for ``sendto()`` and ``recvfrom()``.) -- Signal handling. This is pretty UNIX-specific, but sometimes an - application needs to intercept signals. It may be handy to have a - standard interface for this in the event loop, so everyone doesn't - have to reinvent this same wheel (with the same bugs). It's - possible that this can be a thin wrapper on top of - ``call_soon_threadsafe()`` (assuming its implementation doesn't use - locks -- if it does, something different is needed, since a signal - handler may run while the thread is already holding a lock). - - We may need APIs to control various timeouts. E.g. we may want to limit the time spent in DNS resolution, connecting, ssl handshake, idle connection, close/shutdown, even per session. Possibly it's -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 9 18:18:57 2013 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 9 Jan 2013 18:18:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Instead_of_init=5Fevent=5Floo?= =?utf-8?b?cCgpLCBkZWZpbmUgbmV3X2V2ZW50X2xvb3AoKS4=?= Message-ID: <3YhHB9260hzPCZ@mail.python.org> http://hg.python.org/peps/rev/2eca3f5be871 changeset: 4660:2eca3f5be871 user: Guido van Rossum date: Tue Jan 08 15:45:25 2013 -0800 summary: Instead of init_event_loop(), define new_event_loop(). files: pep-3156.txt | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -126,16 +126,16 @@ ``get_event_loop()``. For the benefit of unit tests and other special cases there's a third -policy function: ``init_event_loop()``, which creates a new EventLoop -instance and calls ``set_event_loop()`` with it. TBD: Maybe we should -have a ``create_default_event_loop_instance()`` function instead? +policy function: ``new_event_loop()``, which creates and returns a new +EventLoop instance according to the policy's default rules. To make +this the current event loop, you must call ``set_event_loop()``. To change the way the above three functions work (including their notion of context), call ``set_event_loop_policy(policy)``, where ``policy`` is an event loop policy object. The policy object can be any object that has methods ``get_event_loop()``, ``set_event_loop(event_loop)`` -and ``init_event_loop()`` behaving like +and ``new_event_loop()`` behaving like the functions described above. The default event loop policy is an instance of the class ``DefaultEventLoopPolicy``. The current event loop policy object can be retrieved by calling ``get_event_loop_policy()``. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 9 18:18:58 2013 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 9 Jan 2013 18:18:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Allow_Handlers_as_callbacks?= =?utf-8?b?LiBBZGQgRXZlbnRMb29wLmNsb3NlKCku?= Message-ID: <3YhHBB63FrzS2p@mail.python.org> http://hg.python.org/peps/rev/d30c3d0eeea2 changeset: 4661:d30c3d0eeea2 user: Guido van Rossum date: Tue Jan 08 19:39:28 2013 -0800 summary: Allow Handlers as callbacks. Add EventLoop.close(). files: pep-3156.txt | 62 +++++++++++++++++++++++---------------- 1 files changed, 37 insertions(+), 25 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -148,10 +148,18 @@ Event Loop Interface -------------------- -(A note about times: as usual in Python, all timeouts, intervals and +A note about times: as usual in Python, all timeouts, intervals and delays are measured in seconds, and may be ints or floats. The accuracy and precision of the clock are up to the implementation; the -default implementation uses ``time.monotonic()``.) +default implementation uses ``time.monotonic()``. + +A note about callbacks and Handlers: any function that takes a +callback and a variable number of arguments for it can also be given a +Handler object instead of the callback. Then no arguments should be +given, and the Handler should represent an immediate callback (as +returned from ``call_soon()``), not a delayed callback (as returned +from ``call_later()``). If the Handler is already cancelled, the +call is a no-op. A conforming event loop object has the following methods: @@ -173,15 +181,6 @@ TBD: How many variants of this do we really need? -- ``stop()``. Stops the event loop as soon as it is convenient. It - is fine to restart the loop with ``run()`` (or one of its variants) - subsequently. - - Note: How soon exactly is up to the implementation. All immediate - callbacks that were already scheduled to run before ``stop()`` is - called must still be run, but callbacks scheduled after it is called - (or scheduled to be run later) will not be run. - - ``run_forever()``. Runs the event loop until ``stop()`` is called. - ``run_until_complete(future, timeout=None)``. Runs the event loop @@ -205,6 +204,20 @@ ``call_soon()``, causing an infinite loop, ``run_once()`` should still return. +- ``stop()``. Stops the event loop as soon as it is convenient. It + is fine to restart the loop with ``run()`` (or one of its variants) + subsequently. + + Note: How soon exactly is up to the implementation. All immediate + callbacks that were already scheduled to run before ``stop()`` is + called must still be run, but callbacks scheduled after it is called + (or scheduled to be run later) will not be run. + +- ``close()``. Closes the event loop, releasing any resources it may + hold, such as the file descriptor used by ``epoll()`` or + ``kqueue()``. This should not be called while the event loop is + running. It may be called multiple times. + - ``call_later(delay, callback, *args)``. Arrange for ``callback(*args)`` to be called approximately ``delay`` seconds in the future, once, unless cancelled. Returns @@ -232,24 +245,25 @@ - ``add_signal_handler(sig, callback, *args). Whenever signal ``sig`` is received, arrange for ``callback(*args)`` to be called. Returns a ``Handler`` which can be used to cancel the signal callback. + (Cancelling the handler causes ``remove_signal_handler()`` to be + called the next time the signal arrives. Explicitly calling + ``remove_signal_handler()`` is preferred.) Specifying another callback for the same signal replaces the previous handler (only one handler can be active per signal). The ``sig`` must be a valid sigal number defined in the ``signal`` module. If the signal cannot be handled this raises an exception: - ValueError if it is not a valid signal or if it is an uncatchable - signale (e.g. ``SIGKILL``), RuntimeError if this particular event + ``ValueError`` if it is not a valid signal or if it is an uncatchable + signale (e.g. ``SIGKILL``), ``RuntimeError`` if this particular event loop instance cannot handle signals (since signals are global per process, only an event loop associated with the main thread can handle signals). - ``remove_signal_handler(sig)``. Removes the handler for signal ``sig``, if one is set. Raises the same exceptions as - ``add_signal_handler()``. - -- TBD: A way to register a callback that is already wrapped in a - ``Handler``. Maybe ``call_soon()`` could just check - ``isinstance(callback, Handler)``? It should silently skip - a cancelled callback. + ``add_signal_handler()`` (except that it may return ``False`` + instead raising ``RuntimeError`` for uncatchable signals). Returns + ``True``e\ if a handler was removed successfully, ``False`` if no + handler was set. Some methods in the standard conforming interface return Futures: @@ -257,15 +271,13 @@ instance of ``concurrent.futures.Future``) and returns a Future compatible with the event loop (i.e., a ``tulip.Future`` instance). -- ``run_in_executor(executor, function, *args)``. Arrange to call - ``function(*args)`` in an executor (see PEP 3148). Returns a Future +- ``run_in_executor(executor, callback, *args)``. Arrange to call + ``callback(*args)`` in an executor (see PEP 3148). Returns a Future whose result on success is the return value that call. This is - equivalent to ``wrap_future(executor.submit(function, *args))``. If + equivalent to ``wrap_future(executor.submit(callback, *args))``. If ``executor`` is ``None``, a default ``ThreadPoolExecutor`` with 5 threads is used. (TBD: Should the default executor be shared - between different event loops? Should we even have a default - executor? Should be be able to set its thread count? Shoul we even - have this method?) + between different event loops?) - ``set_default_executor(executor)``. Set the default executor used by ``run_in_executor()``. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 9 19:00:55 2013 From: python-checkins at python.org (charles-francois.natali) Date: Wed, 9 Jan 2013 19:00:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316876=3A_Optimize?= =?utf-8?q?_epoll=2Epoll=28=29_by_keeping_a_per-instance_epoll_events?= Message-ID: <3YhJ6b2ZtkzRyX@mail.python.org> http://hg.python.org/cpython/rev/be8e6b81284e changeset: 81341:be8e6b81284e user: Charles-Fran?ois Natali date: Wed Jan 09 19:00:26 2013 +0100 summary: Issue #16876: Optimize epoll.poll() by keeping a per-instance epoll events buffer instead of allocating a new one at each poll(). files: Misc/NEWS | 3 ++ Modules/selectmodule.c | 45 +++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -212,6 +212,9 @@ Library ------- +- Issue #16876: Optimize epoll.poll() by keeping a per-instance epoll events + buffer instead of allocating a new one at each poll(). + - Issue #16491: IDLE now prints chained exception tracebacks. - fcntl: add F_DUPFD_CLOEXEC constant, available on Linux 2.6.24+. diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1056,9 +1056,14 @@ #include #endif +/* default maximum number of events returned by epoll_wait() */ +#define EPOLL_DEFAULT_MAXEVENTS (FD_SETSIZE) + typedef struct { PyObject_HEAD - SOCKET epfd; /* epoll control file descriptor */ + SOCKET epfd; /* epoll control file descriptor */ + int maxevents; /* maximum number of epoll events */ + struct epoll_event *evs; /* epoll events buffer */ } pyEpoll_Object; static PyTypeObject pyEpoll_Type; @@ -1114,6 +1119,15 @@ PyErr_SetFromErrno(PyExc_OSError); return NULL; } + + self->maxevents = EPOLL_DEFAULT_MAXEVENTS; + self->evs = PyMem_New(struct epoll_event, self->maxevents); + if (!self->evs) { + Py_DECREF(self); + PyErr_NoMemory(); + return NULL; + } + return (PyObject *)self; } @@ -1140,6 +1154,10 @@ pyepoll_dealloc(pyEpoll_Object *self) { (void)pyepoll_internal_close(self); + if (self->evs) { + PyMem_Free(self->evs); + self->evs = NULL; + } Py_TYPE(self)->tp_free(self); } @@ -1320,7 +1338,6 @@ int maxevents = -1; int nfds, i; PyObject *elist = NULL, *etuple = NULL; - struct epoll_event *evs = NULL; static char *kwlist[] = {"timeout", "maxevents", NULL}; if (self->epfd < 0) @@ -1344,24 +1361,27 @@ } if (maxevents == -1) { - maxevents = FD_SETSIZE-1; - } - else if (maxevents < 1) { + maxevents = EPOLL_DEFAULT_MAXEVENTS; + } else if (maxevents < 1) { PyErr_Format(PyExc_ValueError, "maxevents must be greater than 0, got %d", maxevents); return NULL; } + if (maxevents > self->maxevents) { + struct epoll_event *orig_evs = self->evs; - evs = PyMem_New(struct epoll_event, maxevents); - if (evs == NULL) { - Py_DECREF(self); - PyErr_NoMemory(); - return NULL; + PyMem_RESIZE(self->evs, struct epoll_event, maxevents); + if (!self->evs) { + self->evs = orig_evs; + PyErr_NoMemory(); + return NULL; + } + self->maxevents = maxevents; } Py_BEGIN_ALLOW_THREADS - nfds = epoll_wait(self->epfd, evs, maxevents, timeout); + nfds = epoll_wait(self->epfd, self->evs, self->maxevents, timeout); Py_END_ALLOW_THREADS if (nfds < 0) { PyErr_SetFromErrno(PyExc_OSError); @@ -1374,7 +1394,7 @@ } for (i = 0; i < nfds; i++) { - etuple = Py_BuildValue("iI", evs[i].data.fd, evs[i].events); + etuple = Py_BuildValue("iI", self->evs[i].data.fd, self->evs[i].events); if (etuple == NULL) { Py_CLEAR(elist); goto error; @@ -1383,7 +1403,6 @@ } error: - PyMem_Free(evs); return elist; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 9 20:22:20 2013 From: python-checkins at python.org (chris.jerdonek) Date: Wed, 9 Jan 2013 20:22:20 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_Document_that_the_=22Crea?= =?utf-8?q?te_Patch=22_button_works_only_for_CPython_repositories=2E?= Message-ID: <3YhKwX4w5KzS2V@mail.python.org> http://hg.python.org/devguide/rev/a566e3bd064b changeset: 586:a566e3bd064b user: Chris Jerdonek date: Wed Jan 09 11:21:44 2013 -0800 summary: Document that the "Create Patch" button works only for CPython repositories. files: triaging.rst | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/triaging.rst b/triaging.rst --- a/triaging.rst +++ b/triaging.rst @@ -256,11 +256,12 @@ Mercurial Repository '''''''''''''''''''' HTTP link to a Mercurial repository that contains a patch for the issue. -The `Create Patch` button will then compute a diff for the head revision -of the remote branch, and attach the diff to the issue. +A :guilabel:`Create Patch` button will appear that computes a diff for the +head revision of the remote branch and attaches it to the issue. The button +supports only CPython_ patches. -If you don't indicate a remote branch, ``default`` is used. You can -indicate a remote branch adding ``#BRANCH`` at the end of the URL. +If you don't indicate a remote branch, ``default`` is used. You can +indicate a remote branch by adding ``#BRANCH`` to the end of the URL. Generating Special Links in a Comment ------------------------------------- @@ -290,6 +291,7 @@ the Devguide, this page, and this section respectively. +.. _CPython: http://hg.python.org/cpython/file/default/ .. _Doc: http://hg.python.org/cpython/file/default/Doc/ .. _Grammar: http://hg.python.org/cpython/file/default/Grammar/ .. _Lib: http://hg.python.org/cpython/file/default/Lib/ -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Wed Jan 9 20:58:54 2013 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 9 Jan 2013 20:58:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Spec_out_Future_better=2E?= Message-ID: <3YhLkk4cRzzP6K@mail.python.org> http://hg.python.org/peps/rev/2fc65f2161ca changeset: 4662:2fc65f2161ca user: Guido van Rossum date: Wed Jan 09 11:58:51 2013 -0800 summary: Spec out Future better. files: pep-3156.txt | 90 ++++++++++++++++++++++++++++------------ 1 files changed, 63 insertions(+), 27 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -276,8 +276,7 @@ whose result on success is the return value that call. This is equivalent to ``wrap_future(executor.submit(callback, *args))``. If ``executor`` is ``None``, a default ``ThreadPoolExecutor`` with 5 - threads is used. (TBD: Should the default executor be shared - between different event loops?) + threads is used. - ``set_default_executor(executor)``. Set the default executor used by ``run_in_executor()``. @@ -515,39 +514,76 @@ The ``tulip.Future`` class here is intentionally similar to the ``concurrent.futures.Future`` class specified by PEP 3148, but there -are slight differences. The supported public API is as follows, -indicating the differences with PEP 3148: +are slight differences. Whenever this PEP talks about Futures or +futures this should be understood to refer to ``tulip.Future`` unless +``concurrent.futures.Future`` is explicitly mentioned. The supported +public API is as follows, indicating the differences with PEP 3148: -- ``cancel()``. - TBD: Exact specification. +- ``cancel()``. If the Future is already done (or cancelled), return + ``False``. Otherwise, change the Future's state to cancelled (this + implies done), schedule the callbacks, and return ``True``. -- ``cancelled()``. +- ``cancelled()``. Returns ``True`` if the Future was cancelled. -- ``running()``. Note that the meaning of this method is essentially - "cannot be cancelled and isn't done yet". (TBD: Would be nice if - this could be set *and* cleared in some cases, e.g. sock_recv().) +- ``running()``. Always returns ``False``. Difference with PEP 3148: + there is no "running" state. -- ``done()``. +- ``done()``. Returns ``True`` if the Future is done. Note that a + cancelled Future is considered done too (here and everywhere). -- ``result()``. Difference with PEP 3148: This has no timeout - argument and does *not* wait; if the future is not yet done, it - raises an exception. +- ``result()``. Returns the result set with ``set_result()``, or + raises the exception set with ``set_exception()``. Raises + ``CancelledError`` if cancelled. Difference with PEP 3148: This has + no timeout argument and does *not* wait; if the future is not yet + done, it raises an exception. -- ``exception()``. Difference with PEP 3148: This has no timeout - argument and does *not* wait; if the future is not yet done, it - raises an exception. +- ``exception()``. Returns the exception if set with + ``set_exception()``, or ``None`` if a result was set with + ``set_result()``. Raises ``CancelledError`` if cancelled. + Difference with PEP 3148: This has no timeout argument and does + *not* wait; if the future is not yet done, it raises an exception. -- ``add_done_callback(fn)``. Difference with PEP 3148: The callback - is never called immediately, and always in the context of the - caller. (Typically, a context is a thread.) You can think of this - as calling the callback through ``call_soon_threadsafe()``. Note - that the callback (unlike all other callbacks defined in this PEP, - and ignoring the convention from the section "Callback Style" below) - is always called with a single argument, the Future object. +- ``add_done_callback(fn)``. Add a callback to be run when the Future + becomes done (or is cancelled). If the Future is already done (or + cancelled), schedules the callback to using ``call_soon()``. + Difference with PEP 3148: The callback is never called immediately, + and always in the context of the caller. (Typically, a context is a + thread.) You can think of this as calling the callback through + ``call_soon()``. Note that the callback (unlike all other callbacks + defined in this PEP, and ignoring the convention from the section + "Callback Style" below) is always called with a single argument, the + Future object, and should not be a Handler object. -The internal methods defined in PEP 3148 are not supported. (TBD: -Maybe we do need to support these, in order to make it easy to write -user code that returns a Future?) +- ``set_result(result)``. The Future must not be done (nor cancelled) + already. This makes the Future done and schedules the callbacks. + Difference with PEP 3148: This is a public API. + +- ``set_exception(exception)``. The Future must not be done (nor + cancelled) already. This makes the Future done and schedules the + callbacks. Difference with PEP 3148: This is a public API. + +The internal method ``set_running_or_notify_cancel()`` is not +supported; there is no way to set the running state. + +The following exceptions are defined: + +- ``InvalidStateError``. Raised whenever the Future is not in a state + acceptable to the method being called (e.g. calling ``set_result()`` + on a Future that is already done, or calling ``result()`` on a Future + that is not yet done). + +- ``InvalidTimeoutError``. Raised by ``result()`` and ``exception()`` + when a nonzero ``timeout`` argument is given. + +- ``CancelledError``. An alias for + ``concurrent.futures.CancelledError``. Raised when ``result()`` or + ``exception()`` is called on a Future that is cancelled. + +- ``TimeoutError``. An alias for ``concurrent.futures.TimeoutError``. + May be raised by ``EventLoop.run_until_complete()``. + +A Future is associated with the default event loop when it is created. +(TBD: Optionally pass in an alternative event loop instance?) A ``tulip.Future`` object is not acceptable to the ``wait()`` and ``as_completed()`` functions in the ``concurrent.futures`` package. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 10 02:07:44 2013 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 10 Jan 2013 02:07:44 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Specify_wait=28=29_and_as=5Fc?= =?utf-8?q?ompleted=28=29_with_less_reliance_on_PEP_3148=2E?= Message-ID: <3YhTb418DRzS10@mail.python.org> http://hg.python.org/peps/rev/ec1c74a6bcef changeset: 4663:ec1c74a6bcef user: Guido van Rossum date: Wed Jan 09 17:07:40 2013 -0800 summary: Specify wait() and as_completed() with less reliance on PEP 3148. files: pep-3156.txt | 77 ++++++++++++++++++++++++--------------- 1 files changed, 47 insertions(+), 30 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -833,45 +833,62 @@ - ``raise exception`` -- raise an exception in the coroutine that is waiting for this one using ``yield from``. -To wait for multiple coroutines, two APIs similar to the ``wait()`` -and ``as_completed()`` APIs in the ``concurrent.futures`` package are -provided: - -- ``tulip.wait(fs, ...)``. Wait for the Futures or coroutines given - by ``fs`` to complete. Coroutine arguments will be wrapped in Tasks - (see below). The result is a tuple of two sets of Futures, ``(done, - not_done)``. Optional arguments ``timeout`` and ``return_when`` - have the same meaning and defaults as for - ``concurrent.futures.wait()``. The constants ``FIRST_COMPLETED``, - ``FIRST_EXCEPTION``, ``ALL_COMPLETED`` are defined with the same - values and the same meanings as in PEP 3148. - -- ``as_completed(fs, ...)``. Return an iterator whose values are - coroutines; waiting for successive values waits until the next - Future or coroutine from the set ``fs`` completes, and returns its - result (or raises its exception). The optional argument ``timeout`` - has the same meaning and default as it does for - ``concurrent.futures.wait()``; if the timeout is reached, the next - coroutine will raise ``concurrent.futures.TimeoutError`` when waited - for. Example of use:: - - for f in as_completed(fs): - result = yield from f - -(TBD: should ``as_completed()`` return an iterator of coroutines or an -iterator of Futures? For ``wait()`` it's clear that the sets should -only contain Futures; but less so for ``as_completed()``.) - Calling a coroutine does not start its code running -- it is just a generator, and the coroutine object returned by the call is really a generator object, which doesn't do anything until you iterate over it. In the case of a coroutine object, there are two basic ways to start it running: call ``yield from coroutine`` from another coroutine (assuming the other coroutine is already running!), or convert it to a -Task. +Task (see below). Coroutines can only run when the event loop is running. +Waiting for Multiple Coroutines +------------------------------- + +To wait for multiple coroutines or Futures, two APIs similar to the +``wait()`` and ``as_completed()`` APIs in the ``concurrent.futures`` +package are provided: + +- ``tulip.wait(fs, timeout=None, return_when=ALL_COMPLETED)``. This + is a coroutine that waits for the Futures or coroutines given by + ``fs`` to complete. Coroutine arguments will be wrapped in Tasks + (see below). This returns a Future whose result on success is a + tuple of two sets of Futures, ``(done, pending)``, where ``done`` is + the set of original Futures (or wrapped coroutines) that are done + (or cancelled), and ``pending`` is the rest, i.e. those that are + still not done (nor cancelled). Optional arguments ``timeout`` and + ``return_when`` have the same meaning and defaults as for + ``concurrent.futures.wait()``: ``timeout``, if not ``None``, + specifies a timeout for the overall operation; ``return_when``, + specifies when to stop. The constants ``FIRST_COMPLETED``, + ``FIRST_EXCEPTION``, ``ALL_COMPLETED`` are defined with the same + values and the same meanings as in PEP 3148: + + - ``ALL_COMPLETED`` (default): Wait until all Futures are done or + completed (or until the timeout occurs). + + - ``FIRST_COMPLETED``: Wait until at least one Future is done or + cancelled (or until the timeout occurs). + + - ``FIRST_EXCEPTION``: Wait until at least one Future is done (not + cancelled) with an exception set. (The exclusion of cancelled + Futures from the filter is surprising, but PEP 3148 does it this + way.) + +- ``tulip.as_completed(fs, timeout=None)``. Returns an iterator whose + values are Futures; waiting for successive values waits until the + next Future or coroutine from the set ``fs`` completes, and returns + its result (or raises its exception). The optional argument + ``timeout`` has the same meaning and default as it does for + ``concurrent.futures.wait()``: when the timeout occurs, the next + Future returned by the iterator will raise ``TimeoutError`` when + waited for. Example of use:: + + for f in as_completed(fs): + result = yield from f # May raise an exception. + # Use result. + Tasks ----- -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 10 02:30:04 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 02:30:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2ODUyOiB0ZXN0?= =?utf-8?q?=5Fgenericpath=2C_test=5Fposixpath=2C_test=5Fntpath=2C_and_test?= =?utf-8?q?=5Fmacpath_now?= Message-ID: <3YhV4r0ppdzLpw@mail.python.org> http://hg.python.org/cpython/rev/6f71e6aa9041 changeset: 81342:6f71e6aa9041 branch: 3.3 parent: 81339:3e18ccaa537e user: Ezio Melotti date: Thu Jan 10 03:12:50 2013 +0200 summary: #16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath now work with unittest test discovery. Patch by Zachary Ware. files: Lib/test/test_genericpath.py | 17 +++++++---------- Lib/test/test_macpath.py | 8 ++------ Lib/test/test_ntpath.py | 6 +----- Lib/test/test_posixpath.py | 8 ++------ Misc/NEWS | 3 +++ 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -17,9 +17,7 @@ pass -class GenericTest(unittest.TestCase): - # The path module to be tested - pathmodule = genericpath +class GenericTest: common_attributes = ['commonprefix', 'getsize', 'getatime', 'getctime', 'getmtime', 'exists', 'isdir', 'isfile'] attributes = [] @@ -190,13 +188,16 @@ support.unlink(support.TESTFN) safe_rmdir(support.TESTFN) +class TestGenericTest(GenericTest, unittest.TestCase): + # Issue 16852: GenericTest can't inherit from unittest.TestCase + # for test discovery purposes; CommonTest inherits from GenericTest + # and is only meant to be inherited by others. + pathmodule = genericpath # Following TestCase is not supposed to be run from test_genericpath. # It is inherited by other test modules (macpath, ntpath, posixpath). class CommonTest(GenericTest): - # The path module to be tested - pathmodule = None common_attributes = GenericTest.common_attributes + [ # Properties 'curdir', 'pardir', 'extsep', 'sep', @@ -328,9 +329,5 @@ self.test_abspath() -def test_main(): - support.run_unittest(GenericTest) - - if __name__=="__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py --- a/Lib/test/test_macpath.py +++ b/Lib/test/test_macpath.py @@ -115,13 +115,9 @@ self.assertEqual(normpath(b"a:b:"), b"a:b") -class MacCommonTest(test_genericpath.CommonTest): +class MacCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = macpath -def test_main(): - support.run_unittest(MacPathTestCase, MacCommonTest) - - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -257,14 +257,10 @@ ntpath.sameopenfile(-1, -1) -class NtCommonTest(test_genericpath.CommonTest): +class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = ntpath attributes = ['relpath', 'splitunc'] -def test_main(): - support.run_unittest(TestNtpath, NtCommonTest) - - if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -524,14 +524,10 @@ self.assertTrue(posixpath.sameopenfile(a.fileno(), b.fileno())) -class PosixCommonTest(test_genericpath.CommonTest): +class PosixCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = posixpath attributes = ['relpath', 'samefile', 'sameopenfile', 'samestat'] -def test_main(): - support.run_unittest(PosixPathTest, PosixCommonTest) - - if __name__=="__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -408,6 +408,9 @@ Tests ----- +- Issue #16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath + now work with unittest test discovery. Patch by Zachary Ware. + - Issue #16748: test_heapq now works with unittest test discovery. - Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 02:30:05 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 02:30:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2ODUyOiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YhV4s4l15zP8X@mail.python.org> http://hg.python.org/cpython/rev/3a7cd8efc19f changeset: 81343:3a7cd8efc19f parent: 81341:be8e6b81284e parent: 81342:6f71e6aa9041 user: Ezio Melotti date: Thu Jan 10 03:29:45 2013 +0200 summary: #16852: merge with 3.3. files: Lib/test/test_genericpath.py | 18 ++++++++---------- Lib/test/test_macpath.py | 8 ++------ Lib/test/test_ntpath.py | 6 +----- Lib/test/test_posixpath.py | 8 ++------ Misc/NEWS | 3 +++ 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -17,9 +17,7 @@ pass -class GenericTest(unittest.TestCase): - # The path module to be tested - pathmodule = genericpath +class GenericTest: common_attributes = ['commonprefix', 'getsize', 'getatime', 'getctime', 'getmtime', 'exists', 'isdir', 'isfile'] attributes = [] @@ -270,13 +268,17 @@ self.assertTrue(self.pathmodule.sameopenfile( a.fileno(), b.fileno())) +class TestGenericTest(GenericTest, unittest.TestCase): + # Issue 16852: GenericTest can't inherit from unittest.TestCase + # for test discovery purposes; CommonTest inherits from GenericTest + # and is only meant to be inherited by others. + pathmodule = genericpath + # Following TestCase is not supposed to be run from test_genericpath. # It is inherited by other test modules (macpath, ntpath, posixpath). class CommonTest(GenericTest): - # The path module to be tested - pathmodule = None common_attributes = GenericTest.common_attributes + [ # Properties 'curdir', 'pardir', 'extsep', 'sep', @@ -407,9 +409,5 @@ self.test_abspath() -def test_main(): - support.run_unittest(GenericTest) - - if __name__=="__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py --- a/Lib/test/test_macpath.py +++ b/Lib/test/test_macpath.py @@ -115,13 +115,9 @@ self.assertEqual(normpath(b"a:b:"), b"a:b") -class MacCommonTest(test_genericpath.CommonTest): +class MacCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = macpath -def test_main(): - support.run_unittest(MacPathTestCase, MacCommonTest) - - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -257,14 +257,10 @@ ntpath.sameopenfile(-1, -1) -class NtCommonTest(test_genericpath.CommonTest): +class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = ntpath attributes = ['relpath', 'splitunc'] -def test_main(): - support.run_unittest(TestNtpath, NtCommonTest) - - if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -462,14 +462,10 @@ os.getcwdb = real_getcwdb -class PosixCommonTest(test_genericpath.CommonTest): +class PosixCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = posixpath attributes = ['relpath', 'samefile', 'sameopenfile', 'samestat'] -def test_main(): - support.run_unittest(PosixPathTest, PosixCommonTest) - - if __name__=="__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -614,6 +614,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath + now work with unittest test discovery. Patch by Zachary Ware. + - Issue #16748: test_heapq now works with unittest test discovery. - Issue #10646: Tests rearranged for os.samefile/samestat to check for not -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 02:44:16 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 02:44:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Use_correct_me?= =?utf-8?q?thods_in_unittest=2Emock_examples=2E?= Message-ID: <3YhVPD2YJPzRwZ@mail.python.org> http://hg.python.org/cpython/rev/dfe06b30569c changeset: 81344:dfe06b30569c branch: 3.3 parent: 81342:6f71e6aa9041 user: Ezio Melotti date: Thu Jan 10 03:43:33 2013 +0200 summary: Use correct methods in unittest.mock examples. files: Doc/library/unittest.mock-examples.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst --- a/Doc/library/unittest.mock-examples.rst +++ b/Doc/library/unittest.mock-examples.rst @@ -372,8 +372,8 @@ ... @patch('package.module.ClassName1') ... @patch('package.module.ClassName2') ... def test_something(self, MockClass2, MockClass1): - ... self.assertTrue(package.module.ClassName1 is MockClass1) - ... self.assertTrue(package.module.ClassName2 is MockClass2) + ... self.assertIs(package.module.ClassName1, MockClass1) + ... self.assertIs(package.module.ClassName2, MockClass2) ... >>> MyTest('test_something').test_something() @@ -595,10 +595,10 @@ ... class MyTest(TestCase): ... ... def test_one(self, MockSomeClass): - ... self.assertTrue(mymodule.SomeClass is MockSomeClass) + ... self.assertIs(mymodule.SomeClass, MockSomeClass) ... ... def test_two(self, MockSomeClass): - ... self.assertTrue(mymodule.SomeClass is MockSomeClass) + ... self.assertIs(mymodule.SomeClass, MockSomeClass) ... ... def not_a_test(self): ... return 'something' @@ -617,7 +617,7 @@ ... self.mock_foo = self.patcher.start() ... ... def test_foo(self): - ... self.assertTrue(mymodule.foo is self.mock_foo) + ... self.assertIs(mymodule.foo, self.mock_foo) ... ... def tearDown(self): ... self.patcher.stop() @@ -636,7 +636,7 @@ ... self.mock_foo = patcher.start() ... ... def test_foo(self): - ... self.assertTrue(mymodule.foo is self.mock_foo) + ... self.assertIs(mymodule.foo, self.mock_foo) ... >>> MyTest('test_foo').run() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 02:44:17 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 02:44:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_unittest=2Emock_examples_fixes=2E?= Message-ID: <3YhVPF5MvBzS0m@mail.python.org> http://hg.python.org/cpython/rev/05183ce544be changeset: 81345:05183ce544be parent: 81343:3a7cd8efc19f parent: 81344:dfe06b30569c user: Ezio Melotti date: Thu Jan 10 03:44:00 2013 +0200 summary: Merge unittest.mock examples fixes. files: Doc/library/unittest.mock-examples.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst --- a/Doc/library/unittest.mock-examples.rst +++ b/Doc/library/unittest.mock-examples.rst @@ -372,8 +372,8 @@ ... @patch('package.module.ClassName1') ... @patch('package.module.ClassName2') ... def test_something(self, MockClass2, MockClass1): - ... self.assertTrue(package.module.ClassName1 is MockClass1) - ... self.assertTrue(package.module.ClassName2 is MockClass2) + ... self.assertIs(package.module.ClassName1, MockClass1) + ... self.assertIs(package.module.ClassName2, MockClass2) ... >>> MyTest('test_something').test_something() @@ -595,10 +595,10 @@ ... class MyTest(TestCase): ... ... def test_one(self, MockSomeClass): - ... self.assertTrue(mymodule.SomeClass is MockSomeClass) + ... self.assertIs(mymodule.SomeClass, MockSomeClass) ... ... def test_two(self, MockSomeClass): - ... self.assertTrue(mymodule.SomeClass is MockSomeClass) + ... self.assertIs(mymodule.SomeClass, MockSomeClass) ... ... def not_a_test(self): ... return 'something' @@ -617,7 +617,7 @@ ... self.mock_foo = self.patcher.start() ... ... def test_foo(self): - ... self.assertTrue(mymodule.foo is self.mock_foo) + ... self.assertIs(mymodule.foo, self.mock_foo) ... ... def tearDown(self): ... self.patcher.stop() @@ -636,7 +636,7 @@ ... self.mock_foo = patcher.start() ... ... def test_foo(self): - ... self.assertTrue(mymodule.foo is self.mock_foo) + ... self.assertIs(mymodule.foo, self.mock_foo) ... >>> MyTest('test_foo').run() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 03:33:37 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 03:33:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2ODk3OiB0ZXN0?= =?utf-8?q?=5Fbisect_now_works_with_unittest_test_discovery=2E__Initial_pa?= =?utf-8?q?tch_by?= Message-ID: <3YhWV95mC8zQwm@mail.python.org> http://hg.python.org/cpython/rev/f32cb5389a4b changeset: 81346:f32cb5389a4b branch: 3.3 parent: 81344:dfe06b30569c user: Ezio Melotti date: Thu Jan 10 04:32:01 2013 +0200 summary: #16897: test_bisect now works with unittest test discovery. Initial patch by Zachary Ware. files: Lib/test/test_bisect.py | 108 ++++++++------------------- Misc/NEWS | 3 + 2 files changed, 36 insertions(+), 75 deletions(-) diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py --- a/Lib/test/test_bisect.py +++ b/Lib/test/test_bisect.py @@ -3,25 +3,8 @@ from test import support from collections import UserList -# We do a bit of trickery here to be able to test both the C implementation -# and the Python implementation of the module. - -# Make it impossible to import the C implementation anymore. -sys.modules['_bisect'] = 0 -# We must also handle the case that bisect was imported before. -if 'bisect' in sys.modules: - del sys.modules['bisect'] - -# Now we can import the module and get the pure Python implementation. -import bisect as py_bisect - -# Restore everything to normal. -del sys.modules['_bisect'] -del sys.modules['bisect'] - -# This is now the module with the C implementation. -import bisect as c_bisect - +py_bisect = support.import_fresh_module('bisect', blocked=['_bisect']) +c_bisect = support.import_fresh_module('bisect', fresh=['_bisect']) class Range(object): """A trivial range()-like object without any integer width limitations.""" @@ -45,9 +28,7 @@ self.last_insert = idx, item -class TestBisect(unittest.TestCase): - module = None - +class TestBisect: def setUp(self): self.precomputedCases = [ (self.module.bisect_right, [], 1, 0), @@ -218,17 +199,15 @@ self.module.insort(a=data, x=25, lo=1, hi=3) self.assertEqual(data, [10, 20, 25, 25, 25, 30, 40, 50]) -class TestBisectPython(TestBisect): +class TestBisectPython(TestBisect, unittest.TestCase): module = py_bisect -class TestBisectC(TestBisect): +class TestBisectC(TestBisect, unittest.TestCase): module = c_bisect #============================================================================== -class TestInsort(unittest.TestCase): - module = None - +class TestInsort: def test_vsBuiltinSort(self, n=500): from random import choice for insorted in (list(), UserList()): @@ -255,15 +234,14 @@ self.module.insort_right(lst, 5) self.assertEqual([5, 10], lst.data) -class TestInsortPython(TestInsort): +class TestInsortPython(TestInsort, unittest.TestCase): module = py_bisect -class TestInsortC(TestInsort): +class TestInsortC(TestInsort, unittest.TestCase): module = c_bisect #============================================================================== - class LenOnly: "Dummy sequence class defining __len__ but not __getitem__." def __len__(self): @@ -284,9 +262,7 @@ __eq__ = __lt__ __ne__ = __lt__ -class TestErrorHandling(unittest.TestCase): - module = None - +class TestErrorHandling: def test_non_sequence(self): for f in (self.module.bisect_left, self.module.bisect_right, self.module.insort_left, self.module.insort_right): @@ -313,58 +289,40 @@ self.module.insort_left, self.module.insort_right): self.assertRaises(TypeError, f, 10) -class TestErrorHandlingPython(TestErrorHandling): +class TestErrorHandlingPython(TestErrorHandling, unittest.TestCase): module = py_bisect -class TestErrorHandlingC(TestErrorHandling): +class TestErrorHandlingC(TestErrorHandling, unittest.TestCase): module = c_bisect #============================================================================== -libreftest = """ -Example from the Library Reference: Doc/library/bisect.rst +class TestDocExample: + def test_grades(self): + def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'): + i = self.module.bisect(breakpoints, score) + return grades[i] -The bisect() function is generally useful for categorizing numeric data. -This example uses bisect() to look up a letter grade for an exam total -(say) based on a set of ordered numeric breakpoints: 85 and up is an `A', -75..84 is a `B', etc. + result = [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]] + self.assertEqual(result, ['F', 'A', 'C', 'C', 'B', 'A', 'A']) - >>> grades = "FEDCBA" - >>> breakpoints = [30, 44, 66, 75, 85] - >>> from bisect import bisect - >>> def grade(total): - ... return grades[bisect(breakpoints, total)] - ... - >>> grade(66) - 'C' - >>> list(map(grade, [33, 99, 77, 44, 12, 88])) - ['E', 'A', 'B', 'D', 'F', 'A'] + def test_colors(self): + data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)] + data.sort(key=lambda r: r[1]) + keys = [r[1] for r in data] + bisect_left = self.module.bisect_left + self.assertEqual(data[bisect_left(keys, 0)], ('black', 0)) + self.assertEqual(data[bisect_left(keys, 1)], ('blue', 1)) + self.assertEqual(data[bisect_left(keys, 5)], ('red', 5)) + self.assertEqual(data[bisect_left(keys, 8)], ('yellow', 8)) -""" +class TestDocExamplePython(TestDocExample, unittest.TestCase): + module = py_bisect + +class TestDocExampleC(TestDocExample, unittest.TestCase): + module = c_bisect #------------------------------------------------------------------------------ -__test__ = {'libreftest' : libreftest} - -def test_main(verbose=None): - from test import test_bisect - - test_classes = [TestBisectPython, TestBisectC, - TestInsortPython, TestInsortC, - TestErrorHandlingPython, TestErrorHandlingC] - - support.run_unittest(*test_classes) - support.run_doctest(test_bisect, verbose) - - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_unittest(*test_classes) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) - if __name__ == "__main__": - test_main(verbose=True) + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -408,6 +408,9 @@ Tests ----- +- Issue #16897: test_bisect now works with unittest test discovery. + Initial patch by Zachary Ware. + - Issue #16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath now work with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 03:33:39 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 03:33:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2ODk3OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YhWVC2DWdzS3Y@mail.python.org> http://hg.python.org/cpython/rev/cfd8d99ae645 changeset: 81347:cfd8d99ae645 parent: 81345:05183ce544be parent: 81346:f32cb5389a4b user: Ezio Melotti date: Thu Jan 10 04:33:17 2013 +0200 summary: #16897: merge with 3.3. files: Lib/test/test_bisect.py | 108 ++++++++------------------- Misc/NEWS | 3 + 2 files changed, 36 insertions(+), 75 deletions(-) diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py --- a/Lib/test/test_bisect.py +++ b/Lib/test/test_bisect.py @@ -3,25 +3,8 @@ from test import support from collections import UserList -# We do a bit of trickery here to be able to test both the C implementation -# and the Python implementation of the module. - -# Make it impossible to import the C implementation anymore. -sys.modules['_bisect'] = 0 -# We must also handle the case that bisect was imported before. -if 'bisect' in sys.modules: - del sys.modules['bisect'] - -# Now we can import the module and get the pure Python implementation. -import bisect as py_bisect - -# Restore everything to normal. -del sys.modules['_bisect'] -del sys.modules['bisect'] - -# This is now the module with the C implementation. -import bisect as c_bisect - +py_bisect = support.import_fresh_module('bisect', blocked=['_bisect']) +c_bisect = support.import_fresh_module('bisect', fresh=['_bisect']) class Range(object): """A trivial range()-like object without any integer width limitations.""" @@ -45,9 +28,7 @@ self.last_insert = idx, item -class TestBisect(unittest.TestCase): - module = None - +class TestBisect: def setUp(self): self.precomputedCases = [ (self.module.bisect_right, [], 1, 0), @@ -218,17 +199,15 @@ self.module.insort(a=data, x=25, lo=1, hi=3) self.assertEqual(data, [10, 20, 25, 25, 25, 30, 40, 50]) -class TestBisectPython(TestBisect): +class TestBisectPython(TestBisect, unittest.TestCase): module = py_bisect -class TestBisectC(TestBisect): +class TestBisectC(TestBisect, unittest.TestCase): module = c_bisect #============================================================================== -class TestInsort(unittest.TestCase): - module = None - +class TestInsort: def test_vsBuiltinSort(self, n=500): from random import choice for insorted in (list(), UserList()): @@ -255,15 +234,14 @@ self.module.insort_right(lst, 5) self.assertEqual([5, 10], lst.data) -class TestInsortPython(TestInsort): +class TestInsortPython(TestInsort, unittest.TestCase): module = py_bisect -class TestInsortC(TestInsort): +class TestInsortC(TestInsort, unittest.TestCase): module = c_bisect #============================================================================== - class LenOnly: "Dummy sequence class defining __len__ but not __getitem__." def __len__(self): @@ -284,9 +262,7 @@ __eq__ = __lt__ __ne__ = __lt__ -class TestErrorHandling(unittest.TestCase): - module = None - +class TestErrorHandling: def test_non_sequence(self): for f in (self.module.bisect_left, self.module.bisect_right, self.module.insort_left, self.module.insort_right): @@ -313,58 +289,40 @@ self.module.insort_left, self.module.insort_right): self.assertRaises(TypeError, f, 10) -class TestErrorHandlingPython(TestErrorHandling): +class TestErrorHandlingPython(TestErrorHandling, unittest.TestCase): module = py_bisect -class TestErrorHandlingC(TestErrorHandling): +class TestErrorHandlingC(TestErrorHandling, unittest.TestCase): module = c_bisect #============================================================================== -libreftest = """ -Example from the Library Reference: Doc/library/bisect.rst +class TestDocExample: + def test_grades(self): + def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'): + i = self.module.bisect(breakpoints, score) + return grades[i] -The bisect() function is generally useful for categorizing numeric data. -This example uses bisect() to look up a letter grade for an exam total -(say) based on a set of ordered numeric breakpoints: 85 and up is an `A', -75..84 is a `B', etc. + result = [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]] + self.assertEqual(result, ['F', 'A', 'C', 'C', 'B', 'A', 'A']) - >>> grades = "FEDCBA" - >>> breakpoints = [30, 44, 66, 75, 85] - >>> from bisect import bisect - >>> def grade(total): - ... return grades[bisect(breakpoints, total)] - ... - >>> grade(66) - 'C' - >>> list(map(grade, [33, 99, 77, 44, 12, 88])) - ['E', 'A', 'B', 'D', 'F', 'A'] + def test_colors(self): + data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)] + data.sort(key=lambda r: r[1]) + keys = [r[1] for r in data] + bisect_left = self.module.bisect_left + self.assertEqual(data[bisect_left(keys, 0)], ('black', 0)) + self.assertEqual(data[bisect_left(keys, 1)], ('blue', 1)) + self.assertEqual(data[bisect_left(keys, 5)], ('red', 5)) + self.assertEqual(data[bisect_left(keys, 8)], ('yellow', 8)) -""" +class TestDocExamplePython(TestDocExample, unittest.TestCase): + module = py_bisect + +class TestDocExampleC(TestDocExample, unittest.TestCase): + module = c_bisect #------------------------------------------------------------------------------ -__test__ = {'libreftest' : libreftest} - -def test_main(verbose=None): - from test import test_bisect - - test_classes = [TestBisectPython, TestBisectC, - TestInsortPython, TestInsortC, - TestErrorHandlingPython, TestErrorHandlingC] - - support.run_unittest(*test_classes) - support.run_doctest(test_bisect, verbose) - - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_unittest(*test_classes) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) - if __name__ == "__main__": - test_main(verbose=True) + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -614,6 +614,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16897: test_bisect now works with unittest test discovery. + Initial patch by Zachary Ware. + - Issue #16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath now work with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 04:29:54 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 04:29:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2ODk2OiB0ZXN0?= =?utf-8?q?=5Fasyncore_now_works_with_unittest_test_discovery=2E__Patch_by?= =?utf-8?q?_Zachary?= Message-ID: <3YhXl60VnbzS3n@mail.python.org> http://hg.python.org/cpython/rev/4976bf1d751c changeset: 81348:4976bf1d751c branch: 3.3 parent: 81346:f32cb5389a4b user: Ezio Melotti date: Thu Jan 10 05:28:52 2013 +0200 summary: #16896: test_asyncore now works with unittest test discovery. Patch by Zachary Ware. files: Lib/test/test_asyncore.py | 24 ++++++++---------------- Misc/NEWS | 3 +++ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -513,7 +513,7 @@ pass -class BaseTestAPI(unittest.TestCase): +class BaseTestAPI: def tearDown(self): asyncore.close_all() @@ -821,34 +821,26 @@ unlink(self.addr) BaseTestAPI.tearDown(self) -class TestAPI_UseIPv4Select(TestAPI_UseIPv4Sockets): +class TestAPI_UseIPv4Select(TestAPI_UseIPv4Sockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') -class TestAPI_UseIPv4Poll(TestAPI_UseIPv4Sockets): +class TestAPI_UseIPv4Poll(TestAPI_UseIPv4Sockets, unittest.TestCase): use_poll = True -class TestAPI_UseIPv6Select(TestAPI_UseIPv6Sockets): +class TestAPI_UseIPv6Select(TestAPI_UseIPv6Sockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') -class TestAPI_UseIPv6Poll(TestAPI_UseIPv6Sockets): +class TestAPI_UseIPv6Poll(TestAPI_UseIPv6Sockets, unittest.TestCase): use_poll = True -class TestAPI_UseUnixSocketsSelect(TestAPI_UseUnixSockets): +class TestAPI_UseUnixSocketsSelect(TestAPI_UseUnixSockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') -class TestAPI_UseUnixSocketsPoll(TestAPI_UseUnixSockets): +class TestAPI_UseUnixSocketsPoll(TestAPI_UseUnixSockets, unittest.TestCase): use_poll = True -def test_main(): - tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests, - DispatcherWithSendTests_UsePoll, FileWrapperTest, - TestAPI_UseIPv4Select, TestAPI_UseIPv4Poll, TestAPI_UseIPv6Select, - TestAPI_UseIPv6Poll, TestAPI_UseUnixSocketsSelect, - TestAPI_UseUnixSocketsPoll] - run_unittest(*tests) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -408,6 +408,9 @@ Tests ----- +- Issue #16896: test_asyncore now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16897: test_bisect now works with unittest test discovery. Initial patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 04:29:55 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 04:29:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2ODk2OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YhXl737BFzS3n@mail.python.org> http://hg.python.org/cpython/rev/e7a965a075f5 changeset: 81349:e7a965a075f5 parent: 81347:cfd8d99ae645 parent: 81348:4976bf1d751c user: Ezio Melotti date: Thu Jan 10 05:29:33 2013 +0200 summary: #16896: merge with 3.3. files: Lib/test/test_asyncore.py | 24 ++++++++---------------- Misc/NEWS | 3 +++ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -513,7 +513,7 @@ pass -class BaseTestAPI(unittest.TestCase): +class BaseTestAPI: def tearDown(self): asyncore.close_all() @@ -821,34 +821,26 @@ unlink(self.addr) BaseTestAPI.tearDown(self) -class TestAPI_UseIPv4Select(TestAPI_UseIPv4Sockets): +class TestAPI_UseIPv4Select(TestAPI_UseIPv4Sockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') -class TestAPI_UseIPv4Poll(TestAPI_UseIPv4Sockets): +class TestAPI_UseIPv4Poll(TestAPI_UseIPv4Sockets, unittest.TestCase): use_poll = True -class TestAPI_UseIPv6Select(TestAPI_UseIPv6Sockets): +class TestAPI_UseIPv6Select(TestAPI_UseIPv6Sockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') -class TestAPI_UseIPv6Poll(TestAPI_UseIPv6Sockets): +class TestAPI_UseIPv6Poll(TestAPI_UseIPv6Sockets, unittest.TestCase): use_poll = True -class TestAPI_UseUnixSocketsSelect(TestAPI_UseUnixSockets): +class TestAPI_UseUnixSocketsSelect(TestAPI_UseUnixSockets, unittest.TestCase): use_poll = False @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required') -class TestAPI_UseUnixSocketsPoll(TestAPI_UseUnixSockets): +class TestAPI_UseUnixSocketsPoll(TestAPI_UseUnixSockets, unittest.TestCase): use_poll = True -def test_main(): - tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests, - DispatcherWithSendTests_UsePoll, FileWrapperTest, - TestAPI_UseIPv4Select, TestAPI_UseIPv4Poll, TestAPI_UseIPv6Select, - TestAPI_UseIPv6Poll, TestAPI_UseUnixSocketsSelect, - TestAPI_UseUnixSocketsPoll] - run_unittest(*tests) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -614,6 +614,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16896: test_asyncore now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16897: test_bisect now works with unittest test discovery. Initial patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 05:06:54 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 05:06:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2ODg4OiB0ZXN0?= =?utf-8?q?=5Farray_now_works_with_unittest_test_discovery=2E__Patch_by_Za?= =?utf-8?q?chary?= Message-ID: <3YhYYp1J6mzS1W@mail.python.org> http://hg.python.org/cpython/rev/1538307c06c0 changeset: 81350:1538307c06c0 branch: 3.3 parent: 81348:4976bf1d751c user: Ezio Melotti date: Thu Jan 10 06:04:50 2013 +0200 summary: #16888: test_array now works with unittest test discovery. Patch by Zachary Ware. files: Lib/test/test_array.py | 64 +++++++---------------------- Misc/NEWS | 3 + 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -31,7 +31,6 @@ def __init__(self, typecode, newarg=None): array.array.__init__(self) -tests = [] # list to accumulate all tests typecodes = "ubBhHiIlLfd" if have_long_long: typecodes += 'qQ' @@ -44,7 +43,6 @@ self.assertRaises(TypeError, array.array, 'xx') self.assertRaises(ValueError, array.array, 'x') -tests.append(BadConstructorTest) # Machine format codes. # @@ -174,10 +172,7 @@ msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase)) -tests.append(ArrayReconstructorTest) - - -class BaseTest(unittest.TestCase): +class BaseTest: # Required class attributes (provided by subclasses # typecode: the typecode to test # example: an initializer usable in the constructor for this type @@ -1036,7 +1031,7 @@ a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2]) -class UnicodeTest(StringTest): +class UnicodeTest(StringTest, unittest.TestCase): typecode = 'u' example = '\x01\u263a\x00\ufeff' smallerexample = '\x01\u263a\x00\ufefe' @@ -1074,8 +1069,6 @@ self.assertRaises(TypeError, a.fromunicode) -tests.append(UnicodeTest) - class NumberTest(BaseTest): def test_extslice(self): @@ -1216,57 +1209,47 @@ ) -class ByteTest(SignedNumberTest): +class ByteTest(SignedNumberTest, unittest.TestCase): typecode = 'b' minitemsize = 1 -tests.append(ByteTest) -class UnsignedByteTest(UnsignedNumberTest): +class UnsignedByteTest(UnsignedNumberTest, unittest.TestCase): typecode = 'B' minitemsize = 1 -tests.append(UnsignedByteTest) -class ShortTest(SignedNumberTest): +class ShortTest(SignedNumberTest, unittest.TestCase): typecode = 'h' minitemsize = 2 -tests.append(ShortTest) -class UnsignedShortTest(UnsignedNumberTest): +class UnsignedShortTest(UnsignedNumberTest, unittest.TestCase): typecode = 'H' minitemsize = 2 -tests.append(UnsignedShortTest) -class IntTest(SignedNumberTest): +class IntTest(SignedNumberTest, unittest.TestCase): typecode = 'i' minitemsize = 2 -tests.append(IntTest) -class UnsignedIntTest(UnsignedNumberTest): +class UnsignedIntTest(UnsignedNumberTest, unittest.TestCase): typecode = 'I' minitemsize = 2 -tests.append(UnsignedIntTest) -class LongTest(SignedNumberTest): +class LongTest(SignedNumberTest, unittest.TestCase): typecode = 'l' minitemsize = 4 -tests.append(LongTest) -class UnsignedLongTest(UnsignedNumberTest): +class UnsignedLongTest(UnsignedNumberTest, unittest.TestCase): typecode = 'L' minitemsize = 4 -tests.append(UnsignedLongTest) @unittest.skipIf(not have_long_long, 'need long long support') -class LongLongTest(SignedNumberTest): +class LongLongTest(SignedNumberTest, unittest.TestCase): typecode = 'q' minitemsize = 8 -tests.append(LongLongTest) @unittest.skipIf(not have_long_long, 'need long long support') -class UnsignedLongLongTest(UnsignedNumberTest): +class UnsignedLongLongTest(UnsignedNumberTest, unittest.TestCase): typecode = 'Q' minitemsize = 8 -tests.append(UnsignedLongLongTest) class FPTest(NumberTest): example = [-42.0, 0, 42, 1e5, -1e10] @@ -1293,12 +1276,11 @@ b.byteswap() self.assertEqual(a, b) -class FloatTest(FPTest): +class FloatTest(FPTest, unittest.TestCase): typecode = 'f' minitemsize = 4 -tests.append(FloatTest) -class DoubleTest(FPTest): +class DoubleTest(FPTest, unittest.TestCase): typecode = 'd' minitemsize = 8 @@ -1319,22 +1301,6 @@ else: self.fail("Array of size > maxsize created - MemoryError expected") -tests.append(DoubleTest) - -def test_main(verbose=None): - import sys - - support.run_unittest(*tests) - - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_unittest(*tests) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) if __name__ == "__main__": - test_main(verbose=True) + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -408,6 +408,9 @@ Tests ----- +- Issue #16888: test_array now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16896: test_asyncore now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 05:06:55 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 05:06:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2ODg4OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YhYYq5rCbzS47@mail.python.org> http://hg.python.org/cpython/rev/16c58eeca0f8 changeset: 81351:16c58eeca0f8 parent: 81349:e7a965a075f5 parent: 81350:1538307c06c0 user: Ezio Melotti date: Thu Jan 10 06:06:31 2013 +0200 summary: #16888: merge with 3.3. files: Lib/test/test_array.py | 64 +++++++---------------------- Misc/NEWS | 3 + 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -31,7 +31,6 @@ def __init__(self, typecode, newarg=None): array.array.__init__(self) -tests = [] # list to accumulate all tests typecodes = "ubBhHiIlLfd" if have_long_long: typecodes += 'qQ' @@ -44,7 +43,6 @@ self.assertRaises(TypeError, array.array, 'xx') self.assertRaises(ValueError, array.array, 'x') -tests.append(BadConstructorTest) # Machine format codes. # @@ -174,10 +172,7 @@ msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase)) -tests.append(ArrayReconstructorTest) - - -class BaseTest(unittest.TestCase): +class BaseTest: # Required class attributes (provided by subclasses # typecode: the typecode to test # example: an initializer usable in the constructor for this type @@ -1036,7 +1031,7 @@ a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2]) -class UnicodeTest(StringTest): +class UnicodeTest(StringTest, unittest.TestCase): typecode = 'u' example = '\x01\u263a\x00\ufeff' smallerexample = '\x01\u263a\x00\ufefe' @@ -1074,8 +1069,6 @@ self.assertRaises(TypeError, a.fromunicode) -tests.append(UnicodeTest) - class NumberTest(BaseTest): def test_extslice(self): @@ -1216,57 +1209,47 @@ ) -class ByteTest(SignedNumberTest): +class ByteTest(SignedNumberTest, unittest.TestCase): typecode = 'b' minitemsize = 1 -tests.append(ByteTest) -class UnsignedByteTest(UnsignedNumberTest): +class UnsignedByteTest(UnsignedNumberTest, unittest.TestCase): typecode = 'B' minitemsize = 1 -tests.append(UnsignedByteTest) -class ShortTest(SignedNumberTest): +class ShortTest(SignedNumberTest, unittest.TestCase): typecode = 'h' minitemsize = 2 -tests.append(ShortTest) -class UnsignedShortTest(UnsignedNumberTest): +class UnsignedShortTest(UnsignedNumberTest, unittest.TestCase): typecode = 'H' minitemsize = 2 -tests.append(UnsignedShortTest) -class IntTest(SignedNumberTest): +class IntTest(SignedNumberTest, unittest.TestCase): typecode = 'i' minitemsize = 2 -tests.append(IntTest) -class UnsignedIntTest(UnsignedNumberTest): +class UnsignedIntTest(UnsignedNumberTest, unittest.TestCase): typecode = 'I' minitemsize = 2 -tests.append(UnsignedIntTest) -class LongTest(SignedNumberTest): +class LongTest(SignedNumberTest, unittest.TestCase): typecode = 'l' minitemsize = 4 -tests.append(LongTest) -class UnsignedLongTest(UnsignedNumberTest): +class UnsignedLongTest(UnsignedNumberTest, unittest.TestCase): typecode = 'L' minitemsize = 4 -tests.append(UnsignedLongTest) @unittest.skipIf(not have_long_long, 'need long long support') -class LongLongTest(SignedNumberTest): +class LongLongTest(SignedNumberTest, unittest.TestCase): typecode = 'q' minitemsize = 8 -tests.append(LongLongTest) @unittest.skipIf(not have_long_long, 'need long long support') -class UnsignedLongLongTest(UnsignedNumberTest): +class UnsignedLongLongTest(UnsignedNumberTest, unittest.TestCase): typecode = 'Q' minitemsize = 8 -tests.append(UnsignedLongLongTest) class FPTest(NumberTest): example = [-42.0, 0, 42, 1e5, -1e10] @@ -1293,12 +1276,11 @@ b.byteswap() self.assertEqual(a, b) -class FloatTest(FPTest): +class FloatTest(FPTest, unittest.TestCase): typecode = 'f' minitemsize = 4 -tests.append(FloatTest) -class DoubleTest(FPTest): +class DoubleTest(FPTest, unittest.TestCase): typecode = 'd' minitemsize = 8 @@ -1319,22 +1301,6 @@ else: self.fail("Array of size > maxsize created - MemoryError expected") -tests.append(DoubleTest) - -def test_main(verbose=None): - import sys - - support.run_unittest(*tests) - - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_unittest(*tests) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) if __name__ == "__main__": - test_main(verbose=True) + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -614,6 +614,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16888: test_array now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16896: test_asyncore now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 05:13:02 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 05:13:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2ODk4OiB0ZXN0?= =?utf-8?q?=5Fbufio_now_works_with_unittest_test_discovery=2E__Patch_by_Za?= =?utf-8?q?chary?= Message-ID: <3YhYht1TGLzS1T@mail.python.org> http://hg.python.org/cpython/rev/09d4b690b504 changeset: 81352:09d4b690b504 branch: 3.3 parent: 81350:1538307c06c0 user: Ezio Melotti date: Thu Jan 10 06:11:34 2013 +0200 summary: #16898: test_bufio now works with unittest test discovery. Patch by Zachary Ware. files: Lib/test/test_bufio.py | 11 ++++------- Misc/NEWS | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_bufio.py b/Lib/test/test_bufio.py --- a/Lib/test/test_bufio.py +++ b/Lib/test/test_bufio.py @@ -11,7 +11,7 @@ lengths = list(range(1, 257)) + [512, 1000, 1024, 2048, 4096, 8192, 10000, 16384, 32768, 65536, 1000000] -class BufferSizeTest(unittest.TestCase): +class BufferSizeTest: def try_one(self, s): # Write s + "\n" + s to file, then open it and ensure that successive # .readline()s deliver what we wrote. @@ -62,15 +62,12 @@ self.drive_one(bytes(1000)) -class CBufferSizeTest(BufferSizeTest): +class CBufferSizeTest(BufferSizeTest, unittest.TestCase): open = io.open -class PyBufferSizeTest(BufferSizeTest): +class PyBufferSizeTest(BufferSizeTest, unittest.TestCase): open = staticmethod(pyio.open) -def test_main(): - support.run_unittest(CBufferSizeTest, PyBufferSizeTest) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -408,6 +408,9 @@ Tests ----- +- Issue #16898: test_bufio now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16888: test_array now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 05:13:03 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 05:13:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2ODk4OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YhYhv4YrzzS41@mail.python.org> http://hg.python.org/cpython/rev/9a6e28350645 changeset: 81353:9a6e28350645 parent: 81351:16c58eeca0f8 parent: 81352:09d4b690b504 user: Ezio Melotti date: Thu Jan 10 06:12:43 2013 +0200 summary: #16898: merge with 3.3. files: Lib/test/test_bufio.py | 11 ++++------- Misc/NEWS | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_bufio.py b/Lib/test/test_bufio.py --- a/Lib/test/test_bufio.py +++ b/Lib/test/test_bufio.py @@ -11,7 +11,7 @@ lengths = list(range(1, 257)) + [512, 1000, 1024, 2048, 4096, 8192, 10000, 16384, 32768, 65536, 1000000] -class BufferSizeTest(unittest.TestCase): +class BufferSizeTest: def try_one(self, s): # Write s + "\n" + s to file, then open it and ensure that successive # .readline()s deliver what we wrote. @@ -62,15 +62,12 @@ self.drive_one(bytes(1000)) -class CBufferSizeTest(BufferSizeTest): +class CBufferSizeTest(BufferSizeTest, unittest.TestCase): open = io.open -class PyBufferSizeTest(BufferSizeTest): +class PyBufferSizeTest(BufferSizeTest, unittest.TestCase): open = staticmethod(pyio.open) -def test_main(): - support.run_unittest(CBufferSizeTest, PyBufferSizeTest) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -614,6 +614,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16898: test_bufio now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16888: test_array now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 05:55:13 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 05:55:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2OTA1OiB0ZXN0?= =?utf-8?q?=5Fbufio_now_works_with_unittest_test_discovery=2E__Initial_pat?= =?utf-8?q?ch_by?= Message-ID: <3YhZdY0cvdzS0J@mail.python.org> http://hg.python.org/cpython/rev/20e44464eb86 changeset: 81354:20e44464eb86 branch: 3.3 parent: 81352:09d4b690b504 user: Ezio Melotti date: Thu Jan 10 06:52:23 2013 +0200 summary: #16905: test_bufio now works with unittest test discovery. Initial patch by Berker Peksag. files: Lib/test/test_warnings.py | 52 +++++++++++--------------- Misc/NEWS | 3 + 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -40,7 +40,7 @@ module.filters = original_filters -class BaseTest(unittest.TestCase): +class BaseTest: """Basic bookkeeping required for testing.""" @@ -63,7 +63,7 @@ super(BaseTest, self).tearDown() -class FilterTests(object): +class FilterTests(BaseTest): """Testing the filtering functionality.""" @@ -186,14 +186,14 @@ self.assertEqual(str(w[-1].message), text) self.assertTrue(w[-1].category is UserWarning) -class CFilterTests(BaseTest, FilterTests): +class CFilterTests(FilterTests, unittest.TestCase): module = c_warnings -class PyFilterTests(BaseTest, FilterTests): +class PyFilterTests(FilterTests, unittest.TestCase): module = py_warnings -class WarnTests(unittest.TestCase): +class WarnTests(BaseTest): """Test warnings.warn() and warnings.warn_explicit().""" @@ -360,7 +360,7 @@ self.module.warn(BadStrWarning()) -class CWarnTests(BaseTest, WarnTests): +class CWarnTests(WarnTests, unittest.TestCase): module = c_warnings # As an early adopter, we sanity check the @@ -369,7 +369,7 @@ self.assertFalse(original_warnings is self.module) self.assertFalse(hasattr(self.module.warn, '__code__')) -class PyWarnTests(BaseTest, WarnTests): +class PyWarnTests(WarnTests, unittest.TestCase): module = py_warnings # As an early adopter, we sanity check the @@ -379,7 +379,7 @@ self.assertTrue(hasattr(self.module.warn, '__code__')) -class WCmdLineTests(unittest.TestCase): +class WCmdLineTests(BaseTest): def test_improper_input(self): # Uses the private _setoption() function to test the parsing @@ -410,14 +410,14 @@ self.assertFalse(out.strip()) self.assertNotIn(b'RuntimeWarning', err) -class CWCmdLineTests(BaseTest, WCmdLineTests): +class CWCmdLineTests(WCmdLineTests, unittest.TestCase): module = c_warnings -class PyWCmdLineTests(BaseTest, WCmdLineTests): +class PyWCmdLineTests(WCmdLineTests, unittest.TestCase): module = py_warnings -class _WarningsTests(BaseTest): +class _WarningsTests(BaseTest, unittest.TestCase): """Tests specific to the _warnings module.""" @@ -557,7 +557,7 @@ globals_dict['__file__'] = oldfile -class WarningsDisplayTests(unittest.TestCase): +class WarningsDisplayTests(BaseTest): """Test the displaying of warnings and the ability to overload functions related to displaying warnings.""" @@ -601,10 +601,10 @@ file_object, expected_file_line) self.assertEqual(expect, file_object.getvalue()) -class CWarningsDisplayTests(BaseTest, WarningsDisplayTests): +class CWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase): module = c_warnings -class PyWarningsDisplayTests(BaseTest, WarningsDisplayTests): +class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase): module = py_warnings @@ -710,10 +710,10 @@ with support.check_warnings(('foo', RuntimeWarning)): wmod.warn("foo") -class CCatchWarningTests(CatchWarningTests): +class CCatchWarningTests(CatchWarningTests, unittest.TestCase): module = c_warnings -class PyCatchWarningTests(CatchWarningTests): +class PyCatchWarningTests(CatchWarningTests, unittest.TestCase): module = py_warnings @@ -762,10 +762,10 @@ "['ignore:Deprecaci?nWarning']".encode('utf-8')) self.assertEqual(p.wait(), 0) -class CEnvironmentVariableTests(EnvironmentVariableTests): +class CEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase): module = c_warnings -class PyEnvironmentVariableTests(EnvironmentVariableTests): +class PyEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase): module = py_warnings @@ -788,20 +788,12 @@ env=env) self.assertEqual(retcode, 0) -def test_main(): + +def setUpModule(): py_warnings.onceregistry.clear() c_warnings.onceregistry.clear() - support.run_unittest( - CFilterTests, PyFilterTests, - CWarnTests, PyWarnTests, - CWCmdLineTests, PyWCmdLineTests, - _WarningsTests, - CWarningsDisplayTests, PyWarningsDisplayTests, - CCatchWarningTests, PyCatchWarningTests, - CEnvironmentVariableTests, PyEnvironmentVariableTests, - BootstrapTest, - ) +tearDownModule = setUpModule if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -408,6 +408,9 @@ Tests ----- +- Issue #16905: test_warnings now works with unittest test discovery. + Initial patch by Berker Peksag. + - Issue #16898: test_bufio now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 05:55:14 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 05:55:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2OTA1OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YhZdZ4wDLzS0m@mail.python.org> http://hg.python.org/cpython/rev/6ee721029fd5 changeset: 81355:6ee721029fd5 parent: 81353:9a6e28350645 parent: 81354:20e44464eb86 user: Ezio Melotti date: Thu Jan 10 06:53:34 2013 +0200 summary: #16905: merge with 3.3. files: Lib/test/test_warnings.py | 52 +++++++++++--------------- Misc/NEWS | 3 + 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -40,7 +40,7 @@ module.filters = original_filters -class BaseTest(unittest.TestCase): +class BaseTest: """Basic bookkeeping required for testing.""" @@ -63,7 +63,7 @@ super(BaseTest, self).tearDown() -class FilterTests(object): +class FilterTests(BaseTest): """Testing the filtering functionality.""" @@ -186,14 +186,14 @@ self.assertEqual(str(w[-1].message), text) self.assertTrue(w[-1].category is UserWarning) -class CFilterTests(BaseTest, FilterTests): +class CFilterTests(FilterTests, unittest.TestCase): module = c_warnings -class PyFilterTests(BaseTest, FilterTests): +class PyFilterTests(FilterTests, unittest.TestCase): module = py_warnings -class WarnTests(unittest.TestCase): +class WarnTests(BaseTest): """Test warnings.warn() and warnings.warn_explicit().""" @@ -360,7 +360,7 @@ self.module.warn(BadStrWarning()) -class CWarnTests(BaseTest, WarnTests): +class CWarnTests(WarnTests, unittest.TestCase): module = c_warnings # As an early adopter, we sanity check the @@ -369,7 +369,7 @@ self.assertFalse(original_warnings is self.module) self.assertFalse(hasattr(self.module.warn, '__code__')) -class PyWarnTests(BaseTest, WarnTests): +class PyWarnTests(WarnTests, unittest.TestCase): module = py_warnings # As an early adopter, we sanity check the @@ -379,7 +379,7 @@ self.assertTrue(hasattr(self.module.warn, '__code__')) -class WCmdLineTests(unittest.TestCase): +class WCmdLineTests(BaseTest): def test_improper_input(self): # Uses the private _setoption() function to test the parsing @@ -410,14 +410,14 @@ self.assertFalse(out.strip()) self.assertNotIn(b'RuntimeWarning', err) -class CWCmdLineTests(BaseTest, WCmdLineTests): +class CWCmdLineTests(WCmdLineTests, unittest.TestCase): module = c_warnings -class PyWCmdLineTests(BaseTest, WCmdLineTests): +class PyWCmdLineTests(WCmdLineTests, unittest.TestCase): module = py_warnings -class _WarningsTests(BaseTest): +class _WarningsTests(BaseTest, unittest.TestCase): """Tests specific to the _warnings module.""" @@ -557,7 +557,7 @@ globals_dict['__file__'] = oldfile -class WarningsDisplayTests(unittest.TestCase): +class WarningsDisplayTests(BaseTest): """Test the displaying of warnings and the ability to overload functions related to displaying warnings.""" @@ -601,10 +601,10 @@ file_object, expected_file_line) self.assertEqual(expect, file_object.getvalue()) -class CWarningsDisplayTests(BaseTest, WarningsDisplayTests): +class CWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase): module = c_warnings -class PyWarningsDisplayTests(BaseTest, WarningsDisplayTests): +class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase): module = py_warnings @@ -710,10 +710,10 @@ with support.check_warnings(('foo', RuntimeWarning)): wmod.warn("foo") -class CCatchWarningTests(CatchWarningTests): +class CCatchWarningTests(CatchWarningTests, unittest.TestCase): module = c_warnings -class PyCatchWarningTests(CatchWarningTests): +class PyCatchWarningTests(CatchWarningTests, unittest.TestCase): module = py_warnings @@ -762,10 +762,10 @@ "['ignore:Deprecaci?nWarning']".encode('utf-8')) self.assertEqual(p.wait(), 0) -class CEnvironmentVariableTests(EnvironmentVariableTests): +class CEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase): module = c_warnings -class PyEnvironmentVariableTests(EnvironmentVariableTests): +class PyEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase): module = py_warnings @@ -788,20 +788,12 @@ env=env) self.assertEqual(retcode, 0) -def test_main(): + +def setUpModule(): py_warnings.onceregistry.clear() c_warnings.onceregistry.clear() - support.run_unittest( - CFilterTests, PyFilterTests, - CWarnTests, PyWarnTests, - CWCmdLineTests, PyWCmdLineTests, - _WarningsTests, - CWarningsDisplayTests, PyWarningsDisplayTests, - CCatchWarningTests, PyCatchWarningTests, - CEnvironmentVariableTests, PyEnvironmentVariableTests, - BootstrapTest, - ) +tearDownModule = setUpModule if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -614,6 +614,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16905: test_warnings now works with unittest test discovery. + Initial patch by Berker Peksag. + - Issue #16898: test_bufio now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Thu Jan 10 05:57:18 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 10 Jan 2013 05:57:18 +0100 Subject: [Python-checkins] Daily reference leaks (05183ce544be): sum=0 Message-ID: results for 05183ce544be on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflog7S3gf7', '-x'] From python-checkins at python.org Thu Jan 10 06:46:49 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 06:46:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2OTEwOiB0ZXN0?= =?utf-8?q?=5Fbytes=2C_test=5Funicode=2C_and_test=5Fuserstring_now_work_wi?= =?utf-8?q?th_unittest?= Message-ID: <3Yhbn50BMyzS2f@mail.python.org> http://hg.python.org/cpython/rev/55383912c225 changeset: 81356:55383912c225 branch: 3.3 parent: 81354:20e44464eb86 user: Ezio Melotti date: Thu Jan 10 07:43:26 2013 +0200 summary: #16910: test_bytes, test_unicode, and test_userstring now work with unittest test discovery. Patch by Zachary Ware. files: Lib/test/string_tests.py | 2 +- Lib/test/test_bytes.py | 24 +++++++++--------------- Lib/test/test_unicode.py | 8 +++----- Lib/test/test_userstring.py | 7 +++---- Misc/NEWS | 3 +++ 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -19,7 +19,7 @@ def __init__(self): self.seq = ['a', 'b', 'c'] def __len__(self): return 8 -class BaseTest(unittest.TestCase): +class BaseTest: # These tests are for buffers of values (bytes) and not # specific to character interpretation, used for bytes objects # and various string implementations diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -38,7 +38,7 @@ return self.value -class BaseBytesTest(unittest.TestCase): +class BaseBytesTest: def test_basics(self): b = self.type2test() @@ -682,7 +682,7 @@ x, None, None, None) -class BytesTest(BaseBytesTest): +class BytesTest(BaseBytesTest, unittest.TestCase): type2test = bytes def test_buffer_is_readonly(self): @@ -730,7 +730,7 @@ b's:cstr') -class ByteArrayTest(BaseBytesTest): +class ByteArrayTest(BaseBytesTest, unittest.TestCase): type2test = bytearray def test_nohash(self): @@ -1293,16 +1293,16 @@ def test_lower(self): pass -class ByteArrayAsStringTest(FixedStringTest): +class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase): type2test = bytearray contains_bytes = True -class BytesAsStringTest(FixedStringTest): +class BytesAsStringTest(FixedStringTest, unittest.TestCase): type2test = bytes contains_bytes = True -class SubclassTest(unittest.TestCase): +class SubclassTest: def test_basic(self): self.assertTrue(issubclass(self.subclass2test, self.type2test)) @@ -1374,7 +1374,7 @@ class BytesSubclass(bytes): pass -class ByteArraySubclassTest(SubclassTest): +class ByteArraySubclassTest(SubclassTest, unittest.TestCase): type2test = bytearray subclass2test = ByteArraySubclass @@ -1389,16 +1389,10 @@ self.assertEqual(x, b"abcd") -class BytesSubclassTest(SubclassTest): +class BytesSubclassTest(SubclassTest, unittest.TestCase): type2test = bytes subclass2test = BytesSubclass -def test_main(): - test.support.run_unittest( - BytesTest, AssortedBytesTest, BytesAsStringTest, - ByteArrayTest, ByteArrayAsStringTest, BytesSubclassTest, - ByteArraySubclassTest, BytearrayPEP3137Test) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -33,7 +33,8 @@ class UnicodeTest(string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, - string_tests.MixinStrUnicodeTest): + string_tests.MixinStrUnicodeTest, + unittest.TestCase): type2test = str @@ -2218,8 +2219,5 @@ self.assertRaises(TypeError, _string.formatter_field_name_split, 1) -def test_main(): - support.run_unittest(__name__) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -3,6 +3,7 @@ # UserString instances should behave similar to builtin string objects. import string +import unittest from test import support, string_tests from collections import UserString @@ -10,6 +11,7 @@ class UserStringTest( string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, + unittest.TestCase ): type2test = UserString @@ -42,8 +44,5 @@ getattr(object, methodname)(*args) -def test_main(): - support.run_unittest(UserStringTest) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -408,6 +408,9 @@ Tests ----- +- Issue #16910: test_bytes, test_unicode, and test_userstring now work with + unittest test discovery. Patch by Zachary Ware. + - Issue #16905: test_warnings now works with unittest test discovery. Initial patch by Berker Peksag. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 06:46:50 2013 From: python-checkins at python.org (ezio.melotti) Date: Thu, 10 Jan 2013 06:46:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2OTEwOiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3Yhbn64VK5zS4D@mail.python.org> http://hg.python.org/cpython/rev/6478c4259ce3 changeset: 81357:6478c4259ce3 parent: 81355:6ee721029fd5 parent: 81356:55383912c225 user: Ezio Melotti date: Thu Jan 10 07:46:29 2013 +0200 summary: #16910: merge with 3.3. files: Lib/test/string_tests.py | 2 +- Lib/test/test_bytes.py | 24 +++++++++--------------- Lib/test/test_unicode.py | 8 +++----- Lib/test/test_userstring.py | 7 +++---- Misc/NEWS | 3 +++ 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -19,7 +19,7 @@ def __init__(self): self.seq = ['a', 'b', 'c'] def __len__(self): return 8 -class BaseTest(unittest.TestCase): +class BaseTest: # These tests are for buffers of values (bytes) and not # specific to character interpretation, used for bytes objects # and various string implementations diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -38,7 +38,7 @@ return self.value -class BaseBytesTest(unittest.TestCase): +class BaseBytesTest: def test_basics(self): b = self.type2test() @@ -696,7 +696,7 @@ x, None, None, None) -class BytesTest(BaseBytesTest): +class BytesTest(BaseBytesTest, unittest.TestCase): type2test = bytes def test_buffer_is_readonly(self): @@ -744,7 +744,7 @@ b's:cstr') -class ByteArrayTest(BaseBytesTest): +class ByteArrayTest(BaseBytesTest, unittest.TestCase): type2test = bytearray def test_nohash(self): @@ -1312,16 +1312,16 @@ def test_lower(self): pass -class ByteArrayAsStringTest(FixedStringTest): +class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase): type2test = bytearray contains_bytes = True -class BytesAsStringTest(FixedStringTest): +class BytesAsStringTest(FixedStringTest, unittest.TestCase): type2test = bytes contains_bytes = True -class SubclassTest(unittest.TestCase): +class SubclassTest: def test_basic(self): self.assertTrue(issubclass(self.subclass2test, self.type2test)) @@ -1393,7 +1393,7 @@ class BytesSubclass(bytes): pass -class ByteArraySubclassTest(SubclassTest): +class ByteArraySubclassTest(SubclassTest, unittest.TestCase): type2test = bytearray subclass2test = ByteArraySubclass @@ -1408,16 +1408,10 @@ self.assertEqual(x, b"abcd") -class BytesSubclassTest(SubclassTest): +class BytesSubclassTest(SubclassTest, unittest.TestCase): type2test = bytes subclass2test = BytesSubclass -def test_main(): - test.support.run_unittest( - BytesTest, AssortedBytesTest, BytesAsStringTest, - ByteArrayTest, ByteArrayAsStringTest, BytesSubclassTest, - ByteArraySubclassTest, BytearrayPEP3137Test) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -33,7 +33,8 @@ class UnicodeTest(string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, - string_tests.MixinStrUnicodeTest): + string_tests.MixinStrUnicodeTest, + unittest.TestCase): type2test = str @@ -2242,8 +2243,5 @@ self.assertRaises(TypeError, _string.formatter_field_name_split, 1) -def test_main(): - support.run_unittest(__name__) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -3,6 +3,7 @@ # UserString instances should behave similar to builtin string objects. import string +import unittest from test import support, string_tests from collections import UserString @@ -10,6 +11,7 @@ class UserStringTest( string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, + unittest.TestCase ): type2test = UserString @@ -42,8 +44,5 @@ getattr(object, methodname)(*args) -def test_main(): - support.run_unittest(UserStringTest) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -614,6 +614,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16910: test_bytes, test_unicode, and test_userstring now work with + unittest test discovery. Patch by Zachary Ware. + - Issue #16905: test_warnings now works with unittest test discovery. Initial patch by Berker Peksag. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 07:05:26 2013 From: python-checkins at python.org (ned.deily) Date: Thu, 10 Jan 2013 07:05:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE1Nzgy?= =?utf-8?q?=3A_Prevent_compile_errors_of_OS_X_Carbon_modules_=5FFm=2C_=5FQ?= =?utf-8?q?d=2C_and?= Message-ID: <3YhcBZ0Y7yzPCF@mail.python.org> http://hg.python.org/cpython/rev/ae1d34142a2a changeset: 81358:ae1d34142a2a branch: 2.7 parent: 81328:f2353e74b335 user: Ned Deily date: Wed Jan 09 22:04:35 2013 -0800 summary: Issue #15782: Prevent compile errors of OS X Carbon modules _Fm, _Qd, and _Qdoffs when compiling with an SDK of 10.7 or later. The OS X APIs they wrap have long been deprecated and have now been removed with 10.7. These modules were already empty for 64-bit builds and have been removed in Python 3. (Original patch by Ronald Oussoren.) files: Doc/library/carbon.rst | 7 +++++-- Doc/library/mac.rst | 5 ++++- Mac/Modules/fm/_Fmmodule.c | 8 ++++---- Mac/Modules/qd/_Qdmodule.c | 14 +++++++------- Mac/Modules/qdoffs/_Qdoffsmodule.c | 10 +++++----- Misc/NEWS | 6 ++++++ 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/Doc/library/carbon.rst b/Doc/library/carbon.rst --- a/Doc/library/carbon.rst +++ b/Doc/library/carbon.rst @@ -5,7 +5,7 @@ Mac OS Toolbox Modules ********************** -There are a set of modules that provide interfaces to various Mac OS toolboxes. +These are a set of modules that provide interfaces to various legacy Mac OS toolboxes. If applicable the module will define a number of Python objects for the various structures declared by the toolbox, and operations will be implemented as methods of the object. Other operations will be implemented as functions in the @@ -24,7 +24,10 @@ .. note:: - The Carbon modules have been removed in Python 3. + Most of the OS X APIs that these modules use are deprecated or removed + in recent versions of OS X. Many are not available when Python is + executing in 64-bit mode. The Carbon modules have been removed in + Python 3. You should avoid using them in Python 2. :mod:`Carbon.AE` --- Apple Events diff --git a/Doc/library/mac.rst b/Doc/library/mac.rst --- a/Doc/library/mac.rst +++ b/Doc/library/mac.rst @@ -12,7 +12,10 @@ .. note:: - These modules are deprecated and have been removed in Python 3.x. + Most of the OS X APIs that these modules use are deprecated or removed + in recent versions of OS X. Many are not available when Python is + executing in 64-bit mode. These modules have been removed in + Python 3. You should avoid using them in Python 2. .. toctree:: diff --git a/Mac/Modules/fm/_Fmmodule.c b/Mac/Modules/fm/_Fmmodule.c --- a/Mac/Modules/fm/_Fmmodule.c +++ b/Mac/Modules/fm/_Fmmodule.c @@ -2,8 +2,9 @@ /* =========================== Module _Fm =========================== */ #include "Python.h" +#include -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) #include "pymactoolbox.h" @@ -16,7 +17,6 @@ }} while(0) -#include /* @@ -347,7 +347,7 @@ void init_Fm(void) { PyObject *m; -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) PyObject *d; #endif /* __LP64__ */ @@ -355,7 +355,7 @@ m = Py_InitModule("_Fm", Fm_methods); -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) d = PyModule_GetDict(m); Fm_Error = PyMac_GetOSErrException(); if (Fm_Error == NULL || diff --git a/Mac/Modules/qd/_Qdmodule.c b/Mac/Modules/qd/_Qdmodule.c --- a/Mac/Modules/qd/_Qdmodule.c +++ b/Mac/Modules/qd/_Qdmodule.c @@ -3,8 +3,9 @@ #include "Python.h" - -#ifndef __LP64__ +#include + +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) #include "pymactoolbox.h" @@ -16,7 +17,6 @@ }} while(0) -#include #ifdef USE_TOOLBOX_OBJECT_GLUE extern PyObject *_GrafObj_New(GrafPtr); @@ -6548,7 +6548,7 @@ #endif /* __LP64__ */ static PyMethodDef Qd_methods[] = { -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) {"GetPort", (PyCFunction)Qd_GetPort, 1, PyDoc_STR("() -> (GrafPtr port)")}, {"GrafDevice", (PyCFunction)Qd_GrafDevice, 1, @@ -7088,7 +7088,7 @@ }; -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) /* Like BMObj_New, but the original bitmap data structure is copied (and ** released when the object is released) @@ -7112,7 +7112,7 @@ void init_Qd(void) { PyObject *m; -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) PyObject *d; @@ -7127,7 +7127,7 @@ #endif /* __LP64__ */ m = Py_InitModule("_Qd", Qd_methods); -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) d = PyModule_GetDict(m); Qd_Error = PyMac_GetOSErrException(); if (Qd_Error == NULL || diff --git a/Mac/Modules/qdoffs/_Qdoffsmodule.c b/Mac/Modules/qdoffs/_Qdoffsmodule.c --- a/Mac/Modules/qdoffs/_Qdoffsmodule.c +++ b/Mac/Modules/qdoffs/_Qdoffsmodule.c @@ -4,7 +4,8 @@ #include "Python.h" -#ifndef __LP64__ +#include +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) #include "pymactoolbox.h" @@ -16,7 +17,6 @@ }} while(0) -#include #ifdef USE_TOOLBOX_OBJECT_GLUE extern PyObject *_GWorldObj_New(GWorldPtr); @@ -634,7 +634,7 @@ #endif /* __LP64__ */ static PyMethodDef Qdoffs_methods[] = { -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) {"NewGWorld", (PyCFunction)Qdoffs_NewGWorld, 1, PyDoc_STR("(short PixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldPtr offscreenGWorld)")}, {"LockPixels", (PyCFunction)Qdoffs_LockPixels, 1, @@ -691,7 +691,7 @@ void init_Qdoffs(void) { PyObject *m; -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) PyObject *d; @@ -702,7 +702,7 @@ #endif /* __LP64__ */ m = Py_InitModule("_Qdoffs", Qdoffs_methods); -#ifndef __LP64__ +#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) d = PyModule_GetDict(m); Qdoffs_Error = PyMac_GetOSErrException(); if (Qdoffs_Error == NULL || diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -600,6 +600,12 @@ - Issue #16441: Avoid excessive memory usage working with large gzip files using the gzip module. +- Issue #15782: Prevent compile errors of OS X Carbon modules _Fm, _Qd, and + _Qdoffs when compiling with an SDK of 10.7 or later. The OS X APIs they + wrap have long been deprecated and have now been removed with 10.7. + These modules were already empty for 64-bit builds and have been removed + in Python 3. + Extension Modules ----------------- -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:07:34 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:07:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2MDc2?= =?utf-8?q?=3A_make_=5Felementtree=2EElement_pickle-able_in_a_way_that_is_?= =?utf-8?q?compatible?= Message-ID: <3Yhptt48x5zRnC@mail.python.org> http://hg.python.org/cpython/rev/8d6dadfecf22 changeset: 81359:8d6dadfecf22 branch: 3.3 parent: 81356:55383912c225 user: Eli Bendersky date: Thu Jan 10 06:01:06 2013 -0800 summary: Issue #16076: make _elementtree.Element pickle-able in a way that is compatible with the Python version of the class. Patch by Daniel Shahaf. files: Lib/test/test_xml_etree.py | 81 ++++++++-- Misc/ACKS | 1 + Modules/_elementtree.c | 180 ++++++++++++++++++++++++- 3 files changed, 239 insertions(+), 23 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -16,14 +16,20 @@ import html import io +import operator import pickle import sys import unittest import weakref +from itertools import product from test import support from test.support import TESTFN, findfile, unlink, import_fresh_module, gc_collect +# pyET is the pure-Python implementation. +# +# ET is pyET in test_xml_etree and is the C accelerated version in +# test_xml_etree_c. pyET = None ET = None @@ -171,6 +177,38 @@ for elem in element: check_element(elem) +class ElementTestCase: + @classmethod + def setUpClass(cls): + cls.modules = {pyET, ET} + + def pickleRoundTrip(self, obj, name, dumper, loader): + save_m = sys.modules[name] + try: + sys.modules[name] = dumper + temp = pickle.dumps(obj) + sys.modules[name] = loader + result = pickle.loads(temp) + except pickle.PicklingError as pe: + # pyET must be second, because pyET may be (equal to) ET. + human = dict([(ET, "cET"), (pyET, "pyET")]) + raise support.TestFailed("Failed to round-trip %r from %r to %r" + % (obj, + human.get(dumper, dumper), + human.get(loader, loader))) from pe + finally: + sys.modules[name] = save_m + return result + + def assertEqualElements(self, alice, bob): + self.assertIsInstance(alice, (ET.Element, pyET.Element)) + self.assertIsInstance(bob, (ET.Element, pyET.Element)) + self.assertEqual(len(list(alice)), len(list(bob))) + for x, y in zip(alice, bob): + self.assertEqualElements(x, y) + properties = operator.attrgetter('tag', 'tail', 'text', 'attrib') + self.assertEqual(properties(alice), properties(bob)) + # -------------------------------------------------------------------- # element tree tests @@ -1715,7 +1753,7 @@ # -------------------------------------------------------------------- -class BasicElementTest(unittest.TestCase): +class BasicElementTest(ElementTestCase, unittest.TestCase): def test_augmentation_type_errors(self): e = ET.Element('joe') self.assertRaises(TypeError, e.append, 'b') @@ -1775,19 +1813,22 @@ self.assertEqual(e1.get('w', default=7), 7) def test_pickle(self): - # For now this test only works for the Python version of ET, - # so set sys.modules accordingly because pickle uses __import__ - # to load the __module__ of the class. - if pyET: - sys.modules['xml.etree.ElementTree'] = pyET - else: - raise unittest.SkipTest('only for the Python version') - e1 = ET.Element('foo', bar=42) - s = pickle.dumps(e1) - e2 = pickle.loads(s) - self.assertEqual(e2.tag, 'foo') - self.assertEqual(e2.attrib['bar'], 42) - + # issue #16076: the C implementation wasn't pickleable. + for dumper, loader in product(self.modules, repeat=2): + e = dumper.Element('foo', bar=42) + e.text = "text goes here" + e.tail = "opposite of head" + dumper.SubElement(e, 'child').append(dumper.Element('grandchild')) + e.append(dumper.Element('child')) + e.findall('.//grandchild')[0].set('attr', 'other value') + + e2 = self.pickleRoundTrip(e, 'xml.etree.ElementTree', + dumper, loader) + + self.assertEqual(e2.tag, 'foo') + self.assertEqual(e2.attrib['bar'], 42) + self.assertEqual(len(e2), 2) + self.assertEqualElements(e, e2) class ElementTreeTest(unittest.TestCase): def test_istype(self): @@ -2433,7 +2474,7 @@ class NoAcceleratorTest(unittest.TestCase): def setUp(self): if not pyET: - raise SkipTest('only for the Python version') + raise unittest.SkipTest('only for the Python version') # Test that the C accelerator was not imported for pyET def test_correct_import_pyET(self): @@ -2486,10 +2527,10 @@ def test_main(module=None): # When invoked without a module, runs the Python ET tests by loading pyET. # Otherwise, uses the given module as the ET. + global pyET + pyET = import_fresh_module('xml.etree.ElementTree', + blocked=['_elementtree']) if module is None: - global pyET - pyET = import_fresh_module('xml.etree.ElementTree', - blocked=['_elementtree']) module = pyET global ET @@ -2509,7 +2550,7 @@ # These tests will only run for the pure-Python version that doesn't import # _elementtree. We can't use skipUnless here, because pyET is filled in only # after the module is loaded. - if pyET: + if pyET is not ET: test_classes.extend([ NoAcceleratorTest, ]) @@ -2518,7 +2559,7 @@ support.run_unittest(*test_classes) # XXX the C module should give the same warnings as the Python module - with CleanContext(quiet=(module is not pyET)): + with CleanContext(quiet=(pyET is not ET)): support.run_doctest(sys.modules[__name__], verbosity=True) finally: # don't interfere with subsequent tests diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1080,6 +1080,7 @@ Pete Sevander Denis Severson Ian Seyer +Daniel Shahaf Ha Shao Mark Shannon Richard Shapiro diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -814,6 +814,176 @@ return PyLong_FromSsize_t(result); } +/* dict keys for getstate/setstate. */ +#define PICKLED_TAG "tag" +#define PICKLED_CHILDREN "_children" +#define PICKLED_ATTRIB "attrib" +#define PICKLED_TAIL "tail" +#define PICKLED_TEXT "text" + +/* __getstate__ returns a fabricated instance dict as in the pure-Python + * Element implementation, for interoperability/interchangeability. This + * makes the pure-Python implementation details an API, but (a) there aren't + * any unnecessary structures there; and (b) it buys compatibility with 3.2 + * pickles. See issue #16076. + */ +static PyObject * +element_getstate(ElementObject *self) +{ + int i, noattrib; + PyObject *instancedict = NULL, *children; + + /* Build a list of children. */ + children = PyList_New(self->extra ? self->extra->length : 0); + if (!children) + return NULL; + for (i = 0; i < PyList_GET_SIZE(children); i++) { + PyObject *child = self->extra->children[i]; + Py_INCREF(child); + PyList_SET_ITEM(children, i, child); + } + + /* Construct the state object. */ + noattrib = (self->extra == NULL || self->extra->attrib == Py_None); + if (noattrib) + instancedict = Py_BuildValue("{sOsOs{}sOsO}", + PICKLED_TAG, self->tag, + PICKLED_CHILDREN, children, + PICKLED_ATTRIB, + PICKLED_TEXT, self->text, + PICKLED_TAIL, self->tail); + else + instancedict = Py_BuildValue("{sOsOsOsOsO}", + PICKLED_TAG, self->tag, + PICKLED_CHILDREN, children, + PICKLED_ATTRIB, self->extra->attrib, + PICKLED_TEXT, self->text, + PICKLED_TAIL, self->tail); + if (instancedict) + return instancedict; + else { + for (i = 0; i < PyList_GET_SIZE(children); i++) + Py_DECREF(PyList_GET_ITEM(children, i)); + Py_DECREF(children); + + return NULL; + } +} + +static PyObject * +element_setstate_from_attributes(ElementObject *self, + PyObject *tag, + PyObject *attrib, + PyObject *text, + PyObject *tail, + PyObject *children) +{ + Py_ssize_t i, nchildren; + + if (!tag) { + PyErr_SetString(PyExc_TypeError, "tag may not be NULL"); + return NULL; + } + if (!text) { + Py_INCREF(Py_None); + text = Py_None; + } + if (!tail) { + Py_INCREF(Py_None); + tail = Py_None; + } + + Py_CLEAR(self->tag); + self->tag = tag; + Py_INCREF(self->tag); + + Py_CLEAR(self->text); + self->text = text; + Py_INCREF(self->text); + + Py_CLEAR(self->tail); + self->tail = tail; + Py_INCREF(self->tail); + + /* Handle ATTRIB and CHILDREN. */ + if (!children && !attrib) + Py_RETURN_NONE; + + /* Compute 'nchildren'. */ + if (children) { + if (!PyList_Check(children)) { + PyErr_SetString(PyExc_TypeError, "'_children' is not a list"); + return NULL; + } + nchildren = PyList_Size(children); + } + else { + nchildren = 0; + } + + /* Allocate 'extra'. */ + if (element_resize(self, nchildren)) { + return NULL; + } + assert(self->extra && self->extra->allocated >= nchildren); + + /* Copy children */ + for (i = 0; i < nchildren; i++) { + self->extra->children[i] = PyList_GET_ITEM(children, i); + Py_INCREF(self->extra->children[i]); + } + + self->extra->length = nchildren; + self->extra->allocated = nchildren; + + /* Stash attrib. */ + if (attrib) { + Py_CLEAR(self->extra->attrib); + self->extra->attrib = attrib; + Py_INCREF(attrib); + } + + Py_RETURN_NONE; +} + +/* __setstate__ for Element instance from the Python implementation. + * 'state' should be the instance dict. + */ +static PyObject * +element_setstate_from_Python(ElementObject *self, PyObject *state) +{ + static char *kwlist[] = {PICKLED_TAG, PICKLED_ATTRIB, PICKLED_TEXT, + PICKLED_TAIL, PICKLED_CHILDREN, 0}; + PyObject *args; + PyObject *tag, *attrib, *text, *tail, *children; + int error; + + /* More instance dict members than we know to handle? */ + tag = attrib = text = tail = children = NULL; + args = PyTuple_New(0); + error = ! PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag, + &attrib, &text, &tail, &children); + Py_DECREF(args); + if (error) + return NULL; + else + return element_setstate_from_attributes(self, tag, attrib, text, + tail, children); +} + +static PyObject * +element_setstate(ElementObject *self, PyObject *state) +{ + if (!PyDict_CheckExact(state)) { + PyErr_Format(PyExc_TypeError, + "Don't know how to unpickle \"%.200R\" as an Element", + state); + return NULL; + } + else + return element_setstate_from_Python(self, state); +} + LOCAL(int) checkpath(PyObject* tag) { @@ -1587,6 +1757,8 @@ {"__copy__", (PyCFunction) element_copy, METH_VARARGS}, {"__deepcopy__", (PyCFunction) element_deepcopy, METH_VARARGS}, {"__sizeof__", element_sizeof, METH_NOARGS}, + {"__getstate__", (PyCFunction)element_getstate, METH_NOARGS}, + {"__setstate__", (PyCFunction)element_setstate, METH_O}, {NULL, NULL} }; @@ -1691,7 +1863,7 @@ static PyTypeObject Element_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "Element", sizeof(ElementObject), 0, + "xml.etree.ElementTree.Element", sizeof(ElementObject), 0, /* methods */ (destructor)element_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -1913,6 +2085,8 @@ static PyTypeObject ElementIter_Type = { PyVarObject_HEAD_INIT(NULL, 0) + /* Using the module's name since the pure-Python implementation does not + have such a type. */ "_elementtree._element_iterator", /* tp_name */ sizeof(ElementIterObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2458,7 +2632,7 @@ static PyTypeObject TreeBuilder_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "TreeBuilder", sizeof(TreeBuilderObject), 0, + "xml.etree.ElementTree.TreeBuilder", sizeof(TreeBuilderObject), 0, /* methods */ (destructor)treebuilder_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -3420,7 +3594,7 @@ static PyTypeObject XMLParser_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "XMLParser", sizeof(XMLParserObject), 0, + "xml.etree.ElementTree.XMLParser", sizeof(XMLParserObject), 0, /* methods */ (destructor)xmlparser_dealloc, /* tp_dealloc */ 0, /* tp_print */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:07:36 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:07:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316076=3A_make_=5Felementtree=2EElement_pickle-a?= =?utf-8?q?ble_in_a_way_that_is_compatible?= Message-ID: <3Yhptw12bhzRqs@mail.python.org> http://hg.python.org/cpython/rev/4c268b7c86e6 changeset: 81360:4c268b7c86e6 parent: 81357:6478c4259ce3 parent: 81359:8d6dadfecf22 user: Eli Bendersky date: Thu Jan 10 06:06:01 2013 -0800 summary: Issue #16076: make _elementtree.Element pickle-able in a way that is compatible with the Python version of the class. Patch by Daniel Shahaf. files: Lib/test/test_xml_etree.py | 81 ++++++++-- Modules/_elementtree.c | 180 ++++++++++++++++++++++++- 2 files changed, 238 insertions(+), 23 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -16,14 +16,20 @@ import html import io +import operator import pickle import sys import unittest import weakref +from itertools import product from test import support from test.support import TESTFN, findfile, unlink, import_fresh_module, gc_collect +# pyET is the pure-Python implementation. +# +# ET is pyET in test_xml_etree and is the C accelerated version in +# test_xml_etree_c. pyET = None ET = None @@ -171,6 +177,38 @@ for elem in element: check_element(elem) +class ElementTestCase: + @classmethod + def setUpClass(cls): + cls.modules = {pyET, ET} + + def pickleRoundTrip(self, obj, name, dumper, loader): + save_m = sys.modules[name] + try: + sys.modules[name] = dumper + temp = pickle.dumps(obj) + sys.modules[name] = loader + result = pickle.loads(temp) + except pickle.PicklingError as pe: + # pyET must be second, because pyET may be (equal to) ET. + human = dict([(ET, "cET"), (pyET, "pyET")]) + raise support.TestFailed("Failed to round-trip %r from %r to %r" + % (obj, + human.get(dumper, dumper), + human.get(loader, loader))) from pe + finally: + sys.modules[name] = save_m + return result + + def assertEqualElements(self, alice, bob): + self.assertIsInstance(alice, (ET.Element, pyET.Element)) + self.assertIsInstance(bob, (ET.Element, pyET.Element)) + self.assertEqual(len(list(alice)), len(list(bob))) + for x, y in zip(alice, bob): + self.assertEqualElements(x, y) + properties = operator.attrgetter('tag', 'tail', 'text', 'attrib') + self.assertEqual(properties(alice), properties(bob)) + # -------------------------------------------------------------------- # element tree tests @@ -1715,7 +1753,7 @@ # -------------------------------------------------------------------- -class BasicElementTest(unittest.TestCase): +class BasicElementTest(ElementTestCase, unittest.TestCase): def test_augmentation_type_errors(self): e = ET.Element('joe') self.assertRaises(TypeError, e.append, 'b') @@ -1775,19 +1813,22 @@ self.assertEqual(e1.get('w', default=7), 7) def test_pickle(self): - # For now this test only works for the Python version of ET, - # so set sys.modules accordingly because pickle uses __import__ - # to load the __module__ of the class. - if pyET: - sys.modules['xml.etree.ElementTree'] = pyET - else: - raise unittest.SkipTest('only for the Python version') - e1 = ET.Element('foo', bar=42) - s = pickle.dumps(e1) - e2 = pickle.loads(s) - self.assertEqual(e2.tag, 'foo') - self.assertEqual(e2.attrib['bar'], 42) - + # issue #16076: the C implementation wasn't pickleable. + for dumper, loader in product(self.modules, repeat=2): + e = dumper.Element('foo', bar=42) + e.text = "text goes here" + e.tail = "opposite of head" + dumper.SubElement(e, 'child').append(dumper.Element('grandchild')) + e.append(dumper.Element('child')) + e.findall('.//grandchild')[0].set('attr', 'other value') + + e2 = self.pickleRoundTrip(e, 'xml.etree.ElementTree', + dumper, loader) + + self.assertEqual(e2.tag, 'foo') + self.assertEqual(e2.attrib['bar'], 42) + self.assertEqual(len(e2), 2) + self.assertEqualElements(e, e2) class ElementTreeTest(unittest.TestCase): def test_istype(self): @@ -2433,7 +2474,7 @@ class NoAcceleratorTest(unittest.TestCase): def setUp(self): if not pyET: - raise SkipTest('only for the Python version') + raise unittest.SkipTest('only for the Python version') # Test that the C accelerator was not imported for pyET def test_correct_import_pyET(self): @@ -2486,10 +2527,10 @@ def test_main(module=None): # When invoked without a module, runs the Python ET tests by loading pyET. # Otherwise, uses the given module as the ET. + global pyET + pyET = import_fresh_module('xml.etree.ElementTree', + blocked=['_elementtree']) if module is None: - global pyET - pyET = import_fresh_module('xml.etree.ElementTree', - blocked=['_elementtree']) module = pyET global ET @@ -2509,7 +2550,7 @@ # These tests will only run for the pure-Python version that doesn't import # _elementtree. We can't use skipUnless here, because pyET is filled in only # after the module is loaded. - if pyET: + if pyET is not ET: test_classes.extend([ NoAcceleratorTest, ]) @@ -2518,7 +2559,7 @@ support.run_unittest(*test_classes) # XXX the C module should give the same warnings as the Python module - with CleanContext(quiet=(module is not pyET)): + with CleanContext(quiet=(pyET is not ET)): support.run_doctest(sys.modules[__name__], verbosity=True) finally: # don't interfere with subsequent tests diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -814,6 +814,176 @@ return PyLong_FromSsize_t(result); } +/* dict keys for getstate/setstate. */ +#define PICKLED_TAG "tag" +#define PICKLED_CHILDREN "_children" +#define PICKLED_ATTRIB "attrib" +#define PICKLED_TAIL "tail" +#define PICKLED_TEXT "text" + +/* __getstate__ returns a fabricated instance dict as in the pure-Python + * Element implementation, for interoperability/interchangeability. This + * makes the pure-Python implementation details an API, but (a) there aren't + * any unnecessary structures there; and (b) it buys compatibility with 3.2 + * pickles. See issue #16076. + */ +static PyObject * +element_getstate(ElementObject *self) +{ + int i, noattrib; + PyObject *instancedict = NULL, *children; + + /* Build a list of children. */ + children = PyList_New(self->extra ? self->extra->length : 0); + if (!children) + return NULL; + for (i = 0; i < PyList_GET_SIZE(children); i++) { + PyObject *child = self->extra->children[i]; + Py_INCREF(child); + PyList_SET_ITEM(children, i, child); + } + + /* Construct the state object. */ + noattrib = (self->extra == NULL || self->extra->attrib == Py_None); + if (noattrib) + instancedict = Py_BuildValue("{sOsOs{}sOsO}", + PICKLED_TAG, self->tag, + PICKLED_CHILDREN, children, + PICKLED_ATTRIB, + PICKLED_TEXT, self->text, + PICKLED_TAIL, self->tail); + else + instancedict = Py_BuildValue("{sOsOsOsOsO}", + PICKLED_TAG, self->tag, + PICKLED_CHILDREN, children, + PICKLED_ATTRIB, self->extra->attrib, + PICKLED_TEXT, self->text, + PICKLED_TAIL, self->tail); + if (instancedict) + return instancedict; + else { + for (i = 0; i < PyList_GET_SIZE(children); i++) + Py_DECREF(PyList_GET_ITEM(children, i)); + Py_DECREF(children); + + return NULL; + } +} + +static PyObject * +element_setstate_from_attributes(ElementObject *self, + PyObject *tag, + PyObject *attrib, + PyObject *text, + PyObject *tail, + PyObject *children) +{ + Py_ssize_t i, nchildren; + + if (!tag) { + PyErr_SetString(PyExc_TypeError, "tag may not be NULL"); + return NULL; + } + if (!text) { + Py_INCREF(Py_None); + text = Py_None; + } + if (!tail) { + Py_INCREF(Py_None); + tail = Py_None; + } + + Py_CLEAR(self->tag); + self->tag = tag; + Py_INCREF(self->tag); + + Py_CLEAR(self->text); + self->text = text; + Py_INCREF(self->text); + + Py_CLEAR(self->tail); + self->tail = tail; + Py_INCREF(self->tail); + + /* Handle ATTRIB and CHILDREN. */ + if (!children && !attrib) + Py_RETURN_NONE; + + /* Compute 'nchildren'. */ + if (children) { + if (!PyList_Check(children)) { + PyErr_SetString(PyExc_TypeError, "'_children' is not a list"); + return NULL; + } + nchildren = PyList_Size(children); + } + else { + nchildren = 0; + } + + /* Allocate 'extra'. */ + if (element_resize(self, nchildren)) { + return NULL; + } + assert(self->extra && self->extra->allocated >= nchildren); + + /* Copy children */ + for (i = 0; i < nchildren; i++) { + self->extra->children[i] = PyList_GET_ITEM(children, i); + Py_INCREF(self->extra->children[i]); + } + + self->extra->length = nchildren; + self->extra->allocated = nchildren; + + /* Stash attrib. */ + if (attrib) { + Py_CLEAR(self->extra->attrib); + self->extra->attrib = attrib; + Py_INCREF(attrib); + } + + Py_RETURN_NONE; +} + +/* __setstate__ for Element instance from the Python implementation. + * 'state' should be the instance dict. + */ +static PyObject * +element_setstate_from_Python(ElementObject *self, PyObject *state) +{ + static char *kwlist[] = {PICKLED_TAG, PICKLED_ATTRIB, PICKLED_TEXT, + PICKLED_TAIL, PICKLED_CHILDREN, 0}; + PyObject *args; + PyObject *tag, *attrib, *text, *tail, *children; + int error; + + /* More instance dict members than we know to handle? */ + tag = attrib = text = tail = children = NULL; + args = PyTuple_New(0); + error = ! PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag, + &attrib, &text, &tail, &children); + Py_DECREF(args); + if (error) + return NULL; + else + return element_setstate_from_attributes(self, tag, attrib, text, + tail, children); +} + +static PyObject * +element_setstate(ElementObject *self, PyObject *state) +{ + if (!PyDict_CheckExact(state)) { + PyErr_Format(PyExc_TypeError, + "Don't know how to unpickle \"%.200R\" as an Element", + state); + return NULL; + } + else + return element_setstate_from_Python(self, state); +} + LOCAL(int) checkpath(PyObject* tag) { @@ -1587,6 +1757,8 @@ {"__copy__", (PyCFunction) element_copy, METH_VARARGS}, {"__deepcopy__", (PyCFunction) element_deepcopy, METH_VARARGS}, {"__sizeof__", element_sizeof, METH_NOARGS}, + {"__getstate__", (PyCFunction)element_getstate, METH_NOARGS}, + {"__setstate__", (PyCFunction)element_setstate, METH_O}, {NULL, NULL} }; @@ -1691,7 +1863,7 @@ static PyTypeObject Element_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "Element", sizeof(ElementObject), 0, + "xml.etree.ElementTree.Element", sizeof(ElementObject), 0, /* methods */ (destructor)element_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -1913,6 +2085,8 @@ static PyTypeObject ElementIter_Type = { PyVarObject_HEAD_INIT(NULL, 0) + /* Using the module's name since the pure-Python implementation does not + have such a type. */ "_elementtree._element_iterator", /* tp_name */ sizeof(ElementIterObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2458,7 +2632,7 @@ static PyTypeObject TreeBuilder_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "TreeBuilder", sizeof(TreeBuilderObject), 0, + "xml.etree.ElementTree.TreeBuilder", sizeof(TreeBuilderObject), 0, /* methods */ (destructor)treebuilder_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -3420,7 +3594,7 @@ static PyTypeObject XMLParser_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "XMLParser", sizeof(XMLParserObject), 0, + "xml.etree.ElementTree.XMLParser", sizeof(XMLParserObject), 0, /* methods */ (destructor)xmlparser_dealloc, /* tp_dealloc */ 0, /* tp_print */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:07:37 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:07:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_normalize_whit?= =?utf-8?q?espace?= Message-ID: <3Yhptx3jTNzR2R@mail.python.org> http://hg.python.org/cpython/rev/fe4f334056bd changeset: 81361:fe4f334056bd branch: 3.3 parent: 81359:8d6dadfecf22 user: Eli Bendersky date: Thu Jan 10 06:07:00 2013 -0800 summary: normalize whitespace files: Lib/test/test_xml_etree.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -27,7 +27,7 @@ from test.support import TESTFN, findfile, unlink, import_fresh_module, gc_collect # pyET is the pure-Python implementation. -# +# # ET is pyET in test_xml_etree and is the C accelerated version in # test_xml_etree_c. pyET = None -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:07:38 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:07:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_normalize_whitespace?= Message-ID: <3Yhpty6PpYzRv7@mail.python.org> http://hg.python.org/cpython/rev/b2ccb6c98b6f changeset: 81362:b2ccb6c98b6f parent: 81360:4c268b7c86e6 parent: 81361:fe4f334056bd user: Eli Bendersky date: Thu Jan 10 06:07:14 2013 -0800 summary: normalize whitespace files: Lib/test/test_xml_etree.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -27,7 +27,7 @@ from test.support import TESTFN, findfile, unlink, import_fresh_module, gc_collect # pyET is the pure-Python implementation. -# +# # ET is pyET in test_xml_etree and is the C accelerated version in # test_xml_etree_c. pyET = None -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:31:24 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:31:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTEz?= =?utf-8?q?=3A_Fix_Element=2Eitertext=28=29=27s_handling_of_text_with_XML_?= =?utf-8?q?entities=2E?= Message-ID: <3YhqQN65z4zR77@mail.python.org> http://hg.python.org/cpython/rev/d965ff47cf94 changeset: 81363:d965ff47cf94 branch: 3.3 parent: 81361:fe4f334056bd user: Eli Bendersky date: Thu Jan 10 06:27:53 2013 -0800 summary: Issue #16913: Fix Element.itertext()'s handling of text with XML entities. Patch by Serhiy Storchaka files: Lib/test/test_xml_etree.py | 4 ++++ Misc/NEWS | 2 ++ Modules/_elementtree.c | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1904,6 +1904,10 @@ tree = ET.ElementTree(None) self.assertRaises(AttributeError, tree.iter) + # Issue #16913 + doc = ET.XML("a&b&c&") + self.assertEqual(''.join(doc.itertext()), 'a&b&c&') + def test_corners(self): # single root, no subelements a = ET.Element('a') diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -348,6 +348,8 @@ - Issue #16089: Allow ElementTree.TreeBuilder to work again with a non-Element element_factory (fixes a regression in SimpleTAL). +- Issue #16913: Fix Element.itertext()'s handling of text with XML entities. + - Issue #16034: Fix performance regressions in the new `bz2.BZ2File` implementation. Initial patch by Serhiy Storchaka. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2017,7 +2017,9 @@ PyObject_RichCompareBool(it->root_element->tag, it->sought_tag, Py_EQ) == 1) { if (it->gettext) { - PyObject *text = JOIN_OBJ(it->root_element->text); + PyObject *text = element_get_text(it->root_element); + if (!text) + return NULL; if (PyObject_IsTrue(text)) { Py_INCREF(text); return text; @@ -2047,7 +2049,9 @@ } if (it->gettext) { - PyObject *text = JOIN_OBJ(child->text); + PyObject *text = element_get_text(child); + if (!text) + return NULL; if (PyObject_IsTrue(text)) { Py_INCREF(text); return text; @@ -2062,8 +2066,15 @@ continue; } else { - PyObject *tail = it->gettext ? JOIN_OBJ(cur_parent->tail) : Py_None; + PyObject *tail; ParentLocator *next = it->parent_stack->next; + if (it->gettext) { + tail = element_get_tail(cur_parent); + if (!tail) + return NULL; + } + else + tail = Py_None; Py_XDECREF(it->parent_stack->parent); PyObject_Free(it->parent_stack); it->parent_stack = next; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:31:26 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:31:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316913=3A_Fix_Element=2Eitertext=28=29=27s_handl?= =?utf-8?q?ing_of_text_with_XML_entities=2E?= Message-ID: <3YhqQQ1rDszQwX@mail.python.org> http://hg.python.org/cpython/rev/9ab8632e7213 changeset: 81364:9ab8632e7213 parent: 81362:b2ccb6c98b6f parent: 81363:d965ff47cf94 user: Eli Bendersky date: Thu Jan 10 06:31:05 2013 -0800 summary: Issue #16913: Fix Element.itertext()'s handling of text with XML entities. Patch by Serhiy Storchaka files: Lib/test/test_xml_etree.py | 4 ++++ Modules/_elementtree.c | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1904,6 +1904,10 @@ tree = ET.ElementTree(None) self.assertRaises(AttributeError, tree.iter) + # Issue #16913 + doc = ET.XML("a&b&c&") + self.assertEqual(''.join(doc.itertext()), 'a&b&c&') + def test_corners(self): # single root, no subelements a = ET.Element('a') diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2017,7 +2017,9 @@ PyObject_RichCompareBool(it->root_element->tag, it->sought_tag, Py_EQ) == 1) { if (it->gettext) { - PyObject *text = JOIN_OBJ(it->root_element->text); + PyObject *text = element_get_text(it->root_element); + if (!text) + return NULL; if (PyObject_IsTrue(text)) { Py_INCREF(text); return text; @@ -2047,7 +2049,9 @@ } if (it->gettext) { - PyObject *text = JOIN_OBJ(child->text); + PyObject *text = element_get_text(child); + if (!text) + return NULL; if (PyObject_IsTrue(text)) { Py_INCREF(text); return text; @@ -2062,8 +2066,15 @@ continue; } else { - PyObject *tail = it->gettext ? JOIN_OBJ(cur_parent->tail) : Py_None; + PyObject *tail; ParentLocator *next = it->parent_stack->next; + if (it->gettext) { + tail = element_get_tail(cur_parent); + if (!tail) + return NULL; + } + else + tail = Py_None; Py_XDECREF(it->parent_stack->parent); PyObject_Free(it->parent_stack); it->parent_stack = next; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:36:26 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:36:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Update_Misc/NE?= =?utf-8?q?WS_for_issue_=2316076?= Message-ID: <3YhqXB3Y9LzQlT@mail.python.org> http://hg.python.org/cpython/rev/c46054b49b6c changeset: 81365:c46054b49b6c branch: 3.3 parent: 81363:d965ff47cf94 user: Eli Bendersky date: Thu Jan 10 06:35:18 2013 -0800 summary: Update Misc/NEWS for issue #16076 files: Misc/NEWS | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -345,10 +345,15 @@ - Issue #16169: Fix ctypes.WinError()'s confusion between errno and winerror. +- Issue #16076: Made _elementtree.Element pickleable in a way that is compatible + with the Python Element. Pickling/unpickling of xml.etree.ElementTree.Element + works again - this was a temporary regression from 3.2 where the by-default + imported _elementtree had no pickling capability. + - Issue #16089: Allow ElementTree.TreeBuilder to work again with a non-Element element_factory (fixes a regression in SimpleTAL). -- Issue #16913: Fix Element.itertext()'s handling of text with XML entities. +- Issue #16913: Fix Element.itertext()'s handling of text with XML entities., - Issue #16034: Fix performance regressions in the new `bz2.BZ2File` implementation. Initial patch by Serhiy Storchaka. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 15:36:28 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 10 Jan 2013 15:36:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4z?= Message-ID: <3YhqXD0HhMzRxj@mail.python.org> http://hg.python.org/cpython/rev/6da90e44c6a0 changeset: 81366:6da90e44c6a0 parent: 81364:9ab8632e7213 parent: 81365:c46054b49b6c user: Eli Bendersky date: Thu Jan 10 06:36:07 2013 -0800 summary: Merge 3.3 files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 17:31:32 2013 From: python-checkins at python.org (r.david.murray) Date: Thu, 10 Jan 2013 17:31:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE1NTQ1OiBmaXgg?= =?utf-8?q?sqlite3=2Eiterdump_regression_on_unsortable_row=5Ffactory_objec?= =?utf-8?b?dHMu?= Message-ID: <3Yht5008fDzRyf@mail.python.org> http://hg.python.org/cpython/rev/2cdb599172ab changeset: 81367:2cdb599172ab branch: 3.2 parent: 81336:f28aff31900a user: R David Murray date: Thu Jan 10 11:04:09 2013 -0500 summary: #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. The fix for issue 9750 introduced a regression by sorting the row objects returned by fetchall. But if a row_factory such as sqlite3.Row is used, the rows may not be sortable (in Python3), which leads to an exception. The sorting is still a nice idea, so the patch moves the sort into the sql. Fix and test by Peter Otten. files: Lib/sqlite3/dump.py | 3 ++- Lib/sqlite3/test/dump.py | 21 +++++++++++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py --- a/Lib/sqlite3/dump.py +++ b/Lib/sqlite3/dump.py @@ -25,9 +25,10 @@ FROM "sqlite_master" WHERE "sql" NOT NULL AND "type" == 'table' + ORDER BY "name" """ schema_res = cu.execute(q) - for table_name, type, sql in sorted(schema_res.fetchall()): + for table_name, type, sql in schema_res.fetchall(): if table_name == 'sqlite_sequence': yield('DELETE FROM "sqlite_sequence";') elif table_name == 'sqlite_stat1': diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py --- a/Lib/sqlite3/test/dump.py +++ b/Lib/sqlite3/test/dump.py @@ -49,6 +49,27 @@ [self.assertEqual(expected_sqls[i], actual_sqls[i]) for i in range(len(expected_sqls))] + def CheckUnorderableRow(self): + # iterdump() should be able to cope with unorderable row types (issue #15545) + class UnorderableRow: + def __init__(self, cursor, row): + self.row = row + def __getitem__(self, index): + return self.row[index] + self.cx.row_factory = UnorderableRow + CREATE_ALPHA = """CREATE TABLE "alpha" ("one");""" + CREATE_BETA = """CREATE TABLE "beta" ("two");""" + expected = [ + "BEGIN TRANSACTION;", + CREATE_ALPHA, + CREATE_BETA, + "COMMIT;" + ] + self.cu.execute(CREATE_BETA) + self.cu.execute(CREATE_ALPHA) + got = list(self.cx.iterdump()) + self.assertEqual(expected, got) + def suite(): return unittest.TestSuite(unittest.makeSuite(DumpTests, "Check")) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -199,6 +199,10 @@ Library ------- +- Issue #15545: Fix regression in sqlite3's iterdump method where it was + failing if the connection used a row factory (such as sqlite3.Row) that + produced unsortable objects. (Regression was introduced by fix for 9750). + - Issue #16491: IDLE now prints chained exception tracebacks. - Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 17:31:33 2013 From: python-checkins at python.org (r.david.murray) Date: Thu, 10 Jan 2013 17:31:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_merge_=2315545=3A_fix_sqlite3=2Eiterdump_regression_on_unsorta?= =?utf-8?q?ble_row=5Ffactory_objects=2E?= Message-ID: <3Yht514Gl1zRhJ@mail.python.org> http://hg.python.org/cpython/rev/6a85894c428f changeset: 81368:6a85894c428f branch: 3.3 parent: 81365:c46054b49b6c parent: 81367:2cdb599172ab user: R David Murray date: Thu Jan 10 11:13:34 2013 -0500 summary: merge #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. The fix for issue 9750 introduced a regression by sorting the row objects returned by fetchall. But if a row_factory such as sqlite3.Row is used, the rows may not be sortable (in Python3), which leads to an exception. The sorting is still a nice idea, so the patch moves the sort into the sql. Fix and test by Peter Otten. files: Lib/sqlite3/dump.py | 3 ++- Lib/sqlite3/test/dump.py | 21 +++++++++++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py --- a/Lib/sqlite3/dump.py +++ b/Lib/sqlite3/dump.py @@ -25,9 +25,10 @@ FROM "sqlite_master" WHERE "sql" NOT NULL AND "type" == 'table' + ORDER BY "name" """ schema_res = cu.execute(q) - for table_name, type, sql in sorted(schema_res.fetchall()): + for table_name, type, sql in schema_res.fetchall(): if table_name == 'sqlite_sequence': yield('DELETE FROM "sqlite_sequence";') elif table_name == 'sqlite_stat1': diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py --- a/Lib/sqlite3/test/dump.py +++ b/Lib/sqlite3/test/dump.py @@ -49,6 +49,27 @@ [self.assertEqual(expected_sqls[i], actual_sqls[i]) for i in range(len(expected_sqls))] + def CheckUnorderableRow(self): + # iterdump() should be able to cope with unorderable row types (issue #15545) + class UnorderableRow: + def __init__(self, cursor, row): + self.row = row + def __getitem__(self, index): + return self.row[index] + self.cx.row_factory = UnorderableRow + CREATE_ALPHA = """CREATE TABLE "alpha" ("one");""" + CREATE_BETA = """CREATE TABLE "beta" ("two");""" + expected = [ + "BEGIN TRANSACTION;", + CREATE_ALPHA, + CREATE_BETA, + "COMMIT;" + ] + self.cu.execute(CREATE_BETA) + self.cu.execute(CREATE_ALPHA) + got = list(self.cx.iterdump()) + self.assertEqual(expected, got) + def suite(): return unittest.TestSuite(unittest.makeSuite(DumpTests, "Check")) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -142,6 +142,10 @@ Library ------- +- Issue #15545: Fix regression in sqlite3's iterdump method where it was + failing if the connection used a row factory (such as sqlite3.Row) that + produced unsortable objects. (Regression was introduced by fix for 9750). + - Issue #16491: IDLE now prints chained exception tracebacks. - Issue #15972: Fix error messages when os functions expecting a file name or -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 17:31:35 2013 From: python-checkins at python.org (r.david.murray) Date: Thu, 10 Jan 2013 17:31:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_=2315545=3A_fix_sqlite3=2Eiterdump_regression_on_u?= =?utf-8?q?nsortable_row=5Ffactory_objects=2E?= Message-ID: <3Yht531GVWzS04@mail.python.org> http://hg.python.org/cpython/rev/7a62b5ee32ec changeset: 81369:7a62b5ee32ec parent: 81366:6da90e44c6a0 parent: 81368:6a85894c428f user: R David Murray date: Thu Jan 10 11:15:57 2013 -0500 summary: merge #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. The fix for issue 9750 introduced a regression by sorting the row objects returned by fetchall. But if a row_factory such as sqlite3.Row is used, the rows may not be sortable (in Python3), which leads to an exception. The sorting is still a nice idea, so the patch moves the sort into the sql. Fix and test by Peter Otten. files: Lib/sqlite3/dump.py | 3 ++- Lib/sqlite3/test/dump.py | 21 +++++++++++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py --- a/Lib/sqlite3/dump.py +++ b/Lib/sqlite3/dump.py @@ -25,9 +25,10 @@ FROM "sqlite_master" WHERE "sql" NOT NULL AND "type" == 'table' + ORDER BY "name" """ schema_res = cu.execute(q) - for table_name, type, sql in sorted(schema_res.fetchall()): + for table_name, type, sql in schema_res.fetchall(): if table_name == 'sqlite_sequence': yield('DELETE FROM "sqlite_sequence";') elif table_name == 'sqlite_stat1': diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py --- a/Lib/sqlite3/test/dump.py +++ b/Lib/sqlite3/test/dump.py @@ -49,6 +49,27 @@ [self.assertEqual(expected_sqls[i], actual_sqls[i]) for i in range(len(expected_sqls))] + def CheckUnorderableRow(self): + # iterdump() should be able to cope with unorderable row types (issue #15545) + class UnorderableRow: + def __init__(self, cursor, row): + self.row = row + def __getitem__(self, index): + return self.row[index] + self.cx.row_factory = UnorderableRow + CREATE_ALPHA = """CREATE TABLE "alpha" ("one");""" + CREATE_BETA = """CREATE TABLE "beta" ("two");""" + expected = [ + "BEGIN TRANSACTION;", + CREATE_ALPHA, + CREATE_BETA, + "COMMIT;" + ] + self.cu.execute(CREATE_BETA) + self.cu.execute(CREATE_ALPHA) + got = list(self.cx.iterdump()) + self.assertEqual(expected, got) + def suite(): return unittest.TestSuite(unittest.makeSuite(DumpTests, "Check")) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -212,6 +212,10 @@ Library ------- +- Issue #15545: Fix regression in sqlite3's iterdump method where it was + failing if the connection used a row factory (such as sqlite3.Row) that + produced unsortable objects. (Regression was introduced by fix for 9750). + - Issue #16876: Optimize epoll.poll() by keeping a per-instance epoll events buffer instead of allocating a new one at each poll(). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 17:31:36 2013 From: python-checkins at python.org (r.david.murray) Date: Thu, 10 Jan 2013 17:31:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE1NTQ1OiBzb3J0?= =?utf-8?q?_iterdump_via_SQL_instead_of_in_python_code?= Message-ID: <3Yht545WLkzS0Q@mail.python.org> http://hg.python.org/cpython/rev/bb4e4f0cec2e changeset: 81370:bb4e4f0cec2e branch: 2.7 parent: 81358:ae1d34142a2a user: R David Murray date: Thu Jan 10 11:30:51 2013 -0500 summary: #15545: sort iterdump via SQL instead of in python code Although there is not a regression in Python2, we make the same update here to keep the code bases in sync. (The fix for issue 9750 introduced a regression in Python 3 by sorting the row objects returned by fetchall. But if a row_factory such as sqlite3.Row is used, the rows may not be sortable (in Python3), which leads to an exception. The sorting is still a nice idea, so the patch moves the sort into the sql.) Fix and test by Peter Otten. files: Lib/sqlite3/dump.py | 3 ++- Lib/sqlite3/test/dump.py | 21 +++++++++++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py --- a/Lib/sqlite3/dump.py +++ b/Lib/sqlite3/dump.py @@ -25,9 +25,10 @@ FROM "sqlite_master" WHERE "sql" NOT NULL AND "type" == 'table' + ORDER BY "name" """ schema_res = cu.execute(q) - for table_name, type, sql in sorted(schema_res.fetchall()): + for table_name, type, sql in schema_res.fetchall(): if table_name == 'sqlite_sequence': yield('DELETE FROM "sqlite_sequence";') elif table_name == 'sqlite_stat1': diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py --- a/Lib/sqlite3/test/dump.py +++ b/Lib/sqlite3/test/dump.py @@ -49,6 +49,27 @@ [self.assertEqual(expected_sqls[i], actual_sqls[i]) for i in xrange(len(expected_sqls))] + def CheckUnorderableRow(self): + # iterdump() should be able to cope with unorderable row types (issue #15545) + class UnorderableRow: + def __init__(self, cursor, row): + self.row = row + def __getitem__(self, index): + return self.row[index] + self.cx.row_factory = UnorderableRow + CREATE_ALPHA = """CREATE TABLE "alpha" ("one");""" + CREATE_BETA = """CREATE TABLE "beta" ("two");""" + expected = [ + "BEGIN TRANSACTION;", + CREATE_ALPHA, + CREATE_BETA, + "COMMIT;" + ] + self.cu.execute(CREATE_BETA) + self.cu.execute(CREATE_ALPHA) + got = list(self.cx.iterdump()) + self.assertEqual(expected, got) + def suite(): return unittest.TestSuite(unittest.makeSuite(DumpTests, "Check")) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,6 +186,10 @@ Library ------- +- Issue #15545: Fix regression in sqlite3's iterdump method where it was + failing if the connection used a row factory (such as sqlite3.Row) that + produced unsortable objects. (Regression was introduced by fix for 9750). + - Issue #16828: Fix error incorrectly raised by bz2.compress(''). Patch by Martin Packman. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 17:37:58 2013 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 10 Jan 2013 17:37:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogdXNlIFB5SW50X0Zy?= =?utf-8?q?omSsize=5Ft_instead_of_PyLong=5FFromSsize=5Ft_=28=2310182=29?= Message-ID: <3YhtDQ3GS4zP1y@mail.python.org> http://hg.python.org/cpython/rev/0f5067d9e1d8 changeset: 81371:0f5067d9e1d8 branch: 2.7 user: Benjamin Peterson date: Thu Jan 10 10:37:47 2013 -0600 summary: use PyInt_FromSsize_t instead of PyLong_FromSsize_t (#10182) files: Modules/_sre.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1636,7 +1636,7 @@ static PyObject * sre_codesize(PyObject* self, PyObject *unused) { - return PyLong_FromSize_t(sizeof(SRE_CODE)); + return PyInt_FromSize_t(sizeof(SRE_CODE)); } static PyObject * @@ -3389,7 +3389,7 @@ } /* mark is -1 if group is undefined */ - return PyLong_FromSsize_t(self->mark[index*2]); + return PyInt_FromSsize_t(self->mark[index*2]); } static PyObject* @@ -3412,7 +3412,7 @@ } /* mark is -1 if group is undefined */ - return PyLong_FromSsize_t(self->mark[index*2+1]); + return PyInt_FromSsize_t(self->mark[index*2+1]); } LOCAL(PyObject*) @@ -3602,7 +3602,7 @@ match_lastindex_get(MatchObject *self) { if (self->lastindex >= 0) - return PyLong_FromSsize_t(self->lastindex); + return PyInt_FromSsize_t(self->lastindex); Py_INCREF(Py_None); return Py_None; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 21:17:00 2013 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 10 Jan 2013 21:17:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogcmVtb3ZlIF9fZGVs?= =?utf-8?q?=5F=5F_because_it=27s_evil_and_also_prevents_the_ResourceWarnin?= =?utf-8?q?g_on_the?= Message-ID: <3Yhz585lbNzS7v@mail.python.org> http://hg.python.org/cpython/rev/c8105251cc1f changeset: 81372:c8105251cc1f branch: 3.3 parent: 81368:6a85894c428f user: Benjamin Peterson date: Thu Jan 10 14:16:20 2013 -0600 summary: remove __del__ because it's evil and also prevents the ResourceWarning on the socket from happening (closes #16900) files: Lib/ssl.py | 4 ---- Lib/test/test_ssl.py | 8 ++++++++ Misc/NEWS | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/ssl.py b/Lib/ssl.py --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -574,10 +574,6 @@ return None return self._sslobj.tls_unique_cb() - def __del__(self): - # sys.stderr.write("__del__ on %s\n" % repr(self)) - self._real_close() - def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -374,6 +374,14 @@ ss = ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) self.assertIsNone(ss.get_channel_binding("tls-unique")) + def test_dealloc_warn(self): + ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) + r = repr(ss) + with self.assertWarns(ResourceWarning) as cm: + ss = None + support.gc_collect() + self.assertIn(r, str(cm.warning.args[0])) + class ContextTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -142,6 +142,8 @@ Library ------- +- Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed. + - Issue #15545: Fix regression in sqlite3's iterdump method where it was failing if the connection used a row factory (such as sqlite3.Row) that produced unsortable objects. (Regression was introduced by fix for 9750). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 10 21:17:02 2013 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 10 Jan 2013 21:17:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4zICgjMTY5MDAp?= Message-ID: <3Yhz5B2D4SzS75@mail.python.org> http://hg.python.org/cpython/rev/e23d51f17cce changeset: 81373:e23d51f17cce parent: 81369:7a62b5ee32ec parent: 81372:c8105251cc1f user: Benjamin Peterson date: Thu Jan 10 14:16:42 2013 -0600 summary: merge 3.3 (#16900) files: Lib/ssl.py | 4 ---- Lib/test/test_ssl.py | 8 ++++++++ Misc/NEWS | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/ssl.py b/Lib/ssl.py --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -604,10 +604,6 @@ return None return self._sslobj.tls_unique_cb() - def __del__(self): - # sys.stderr.write("__del__ on %s\n" % repr(self)) - self._real_close() - def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -383,6 +383,14 @@ ss = ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) self.assertIsNone(ss.get_channel_binding("tls-unique")) + def test_dealloc_warn(self): + ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) + r = repr(ss) + with self.assertWarns(ResourceWarning) as cm: + ss = None + support.gc_collect() + self.assertIn(r, str(cm.warning.args[0])) + class ContextTests(unittest.TestCase): @skip_if_broken_ubuntu_ssl diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -212,6 +212,8 @@ Library ------- +- Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed. + - Issue #15545: Fix regression in sqlite3's iterdump method where it was failing if the connection used a row factory (such as sqlite3.Row) that produced unsortable objects. (Regression was introduced by fix for 9750). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 02:23:14 2013 From: python-checkins at python.org (r.david.murray) Date: Fri, 11 Jan 2013 02:23:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzEzOTM0OiBkb2N1?= =?utf-8?q?ment_sqlite_version_strings=2C_use_correct_one_in_test=2E?= Message-ID: <3Yj5tV5cPmzR0b@mail.python.org> http://hg.python.org/cpython/rev/b8b26feb3e1a changeset: 81374:b8b26feb3e1a branch: 3.2 parent: 81367:2cdb599172ab user: R David Murray date: Thu Jan 10 20:18:21 2013 -0500 summary: #13934: document sqlite version strings, use correct one in test. files: Doc/library/sqlite3.rst | 22 ++++++++++++++++++++++ Lib/sqlite3/test/hooks.py | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -109,6 +109,28 @@ ------------------------------ +.. data:: version + + The version number of this module, as a string. This is not the version of + the SQLite library. + + +.. data:: version_info + + The version number of this module, as a tuple of integers. This is not the + version of the SQLite library. + + +.. data:: sqlite_version + + The version number of the run-time SQLite library, as a string. + + +.. data:: sqlite_version_info + + The version number of the run-time SQLite library, as a tuple of integers. + + .. data:: PARSE_DECLTYPES This constant is meant to be used with the *detect_types* parameter of the diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -47,9 +47,9 @@ except sqlite.ProgrammingError as e: pass + @unittest.skipIf(sqlite.sqlite_version_info < (3, 2, 1), + 'old SQLite versions crash on this test') def CheckCollationIsUsed(self): - if sqlite.version_info < (3, 2, 1): # old SQLite versions crash on this test - return def mycoll(x, y): # reverse order return -((x > y) - (x < y)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 02:23:16 2013 From: python-checkins at python.org (r.david.murray) Date: Fri, 11 Jan 2013 02:23:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_merge_=2313934=3A_document_sqlite_version_strings=2C_use_corre?= =?utf-8?q?ct_one_in_test=2E?= Message-ID: <3Yj5tX1NyVzRD7@mail.python.org> http://hg.python.org/cpython/rev/cdf9142a0c84 changeset: 81375:cdf9142a0c84 branch: 3.3 parent: 81372:c8105251cc1f parent: 81374:b8b26feb3e1a user: R David Murray date: Thu Jan 10 20:19:35 2013 -0500 summary: merge #13934: document sqlite version strings, use correct one in test. files: Doc/library/sqlite3.rst | 22 ++++++++++++++++++++++ Lib/sqlite3/test/hooks.py | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -109,6 +109,28 @@ ------------------------------ +.. data:: version + + The version number of this module, as a string. This is not the version of + the SQLite library. + + +.. data:: version_info + + The version number of this module, as a tuple of integers. This is not the + version of the SQLite library. + + +.. data:: sqlite_version + + The version number of the run-time SQLite library, as a string. + + +.. data:: sqlite_version_info + + The version number of the run-time SQLite library, as a tuple of integers. + + .. data:: PARSE_DECLTYPES This constant is meant to be used with the *detect_types* parameter of the diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -47,9 +47,9 @@ except sqlite.ProgrammingError as e: pass + @unittest.skipIf(sqlite.sqlite_version_info < (3, 2, 1), + 'old SQLite versions crash on this test') def CheckCollationIsUsed(self): - if sqlite.version_info < (3, 2, 1): # old SQLite versions crash on this test - return def mycoll(x, y): # reverse order return -((x > y) - (x < y)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 02:23:17 2013 From: python-checkins at python.org (r.david.murray) Date: Fri, 11 Jan 2013 02:23:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_=2313934=3A_document_sqlite_version_strings=2C_use?= =?utf-8?q?_correct_one_in_test=2E?= Message-ID: <3Yj5tY40F6zS3j@mail.python.org> http://hg.python.org/cpython/rev/aef7db0d3893 changeset: 81376:aef7db0d3893 parent: 81373:e23d51f17cce parent: 81375:cdf9142a0c84 user: R David Murray date: Thu Jan 10 20:20:19 2013 -0500 summary: merge #13934: document sqlite version strings, use correct one in test. files: Doc/library/sqlite3.rst | 22 ++++++++++++++++++++++ Lib/sqlite3/test/hooks.py | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -109,6 +109,28 @@ ------------------------------ +.. data:: version + + The version number of this module, as a string. This is not the version of + the SQLite library. + + +.. data:: version_info + + The version number of this module, as a tuple of integers. This is not the + version of the SQLite library. + + +.. data:: sqlite_version + + The version number of the run-time SQLite library, as a string. + + +.. data:: sqlite_version_info + + The version number of the run-time SQLite library, as a tuple of integers. + + .. data:: PARSE_DECLTYPES This constant is meant to be used with the *detect_types* parameter of the diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -47,9 +47,9 @@ except sqlite.ProgrammingError as e: pass + @unittest.skipIf(sqlite.sqlite_version_info < (3, 2, 1), + 'old SQLite versions crash on this test') def CheckCollationIsUsed(self): - if sqlite.version_info < (3, 2, 1): # old SQLite versions crash on this test - return def mycoll(x, y): # reverse order return -((x > y) - (x < y)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 02:23:18 2013 From: python-checkins at python.org (r.david.murray) Date: Fri, 11 Jan 2013 02:23:18 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzEzOTM0OiBkb2N1?= =?utf-8?q?ment_sqlite_version_strings=2E?= Message-ID: <3Yj5tZ6W5DzR7g@mail.python.org> http://hg.python.org/cpython/rev/315949b1842e changeset: 81377:315949b1842e branch: 2.7 parent: 81371:0f5067d9e1d8 user: R David Murray date: Thu Jan 10 20:22:57 2013 -0500 summary: #13934: document sqlite version strings. files: Doc/library/sqlite3.rst | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -118,6 +118,24 @@ ------------------------------ +.. data:: version + + The version number of this module, as a string. This is not the version of + the SQLite library. + +.. data:: version_info + + The version number of this module, as a tuple of integers. This is not the + version of the SQLite library. + +.. data:: sqlite_version + + The version number of the run-time SQLite library, as a string. + +.. data:: sqlite_version_info + + The version number of the run-time SQLite library, as a tuple of integers. + .. data:: PARSE_DECLTYPES This constant is meant to be used with the *detect_types* parameter of the -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 03:12:17 2013 From: python-checkins at python.org (r.david.murray) Date: Fri, 11 Jan 2013 03:12:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE1MTA5OiByZXZl?= =?utf-8?q?rt_=27=25=27-=3E=27format=27_changes_in_4b105d328fe7_to_fix_reg?= =?utf-8?q?ression=2E?= Message-ID: <3Yj6z56ZmdzR5h@mail.python.org> http://hg.python.org/cpython/rev/2a417ad8bfbf changeset: 81378:2a417ad8bfbf branch: 2.7 user: R David Murray date: Thu Jan 10 21:10:40 2013 -0500 summary: #15109: revert '%'->'format' changes in 4b105d328fe7 to fix regression. With '%', non-ascii worked because the '%' automatically got promoted to unicode. With format that doesn't happen, which led to encoding errors. This fix goes back to using %, and adds a test to make sure non-ascii string values work in iterdump. files: Lib/sqlite3/dump.py | 6 +++--- Lib/sqlite3/test/dump.py | 2 ++ Misc/NEWS | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py --- a/Lib/sqlite3/dump.py +++ b/Lib/sqlite3/dump.py @@ -43,7 +43,7 @@ # qtable, # sql.replace("''"))) else: - yield('{0};'.format(sql)) + yield('%s;' % sql) # Build the insert statement for each row of the current table table_name_ident = table_name.replace('"', '""') @@ -54,7 +54,7 @@ ",".join("""'||quote("{0}")||'""".format(col.replace('"', '""')) for col in column_names)) query_res = cu.execute(q) for row in query_res: - yield("{0};".format(row[0])) + yield("%s;" % row[0]) # Now when the type is 'index', 'trigger', or 'view' q = """ @@ -65,6 +65,6 @@ """ schema_res = cu.execute(q) for name, type, sql in schema_res.fetchall(): - yield('{0};'.format(sql)) + yield('%s;' % sql) yield('COMMIT;') diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py --- a/Lib/sqlite3/test/dump.py +++ b/Lib/sqlite3/test/dump.py @@ -29,6 +29,8 @@ , "INSERT INTO \"t1\" VALUES(2,'foo2',30,30);" , + u"INSERT INTO \"t1\" VALUES(3,'f\xc3\xb6',40,10);" + , "CREATE TABLE t2(id integer, t2_i1 integer, " \ "t2_i2 integer, primary key (id)," \ "foreign key(t2_i1) references t1(t1_i1));" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,6 +186,10 @@ Library ------- +- Issue #15109: Fix regression in sqlite3's iterdump method where it would + die with an encoding error if the database contained string values + containing non-ASCII. (Regression was introduced by fix for 9750). + - Issue #15545: Fix regression in sqlite3's iterdump method where it was failing if the connection used a row factory (such as sqlite3.Row) that produced unsortable objects. (Regression was introduced by fix for 9750). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 04:20:21 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 04:20:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2OTE5OiB0ZXN0?= =?utf-8?q?=5Fcrypt_now_works_with_unittest_test_discovery=2E_Patch_by_Zac?= =?utf-8?q?hary?= Message-ID: <3Yj8Td4X49zR5K@mail.python.org> http://hg.python.org/cpython/rev/15ddd683c321 changeset: 81379:15ddd683c321 branch: 3.3 parent: 81375:cdf9142a0c84 user: Ezio Melotti date: Fri Jan 11 05:18:45 2013 +0200 summary: #16919: test_crypt now works with unittest test discovery. Patch by Zachary Ware. files: Lib/test/test_crypt.py | 11 ++++++----- Misc/NEWS | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,7 +1,11 @@ from test import support import unittest -crypt = support.import_module('crypt') +def setUpModule(): + # this import will raise unittest.SkipTest if _crypt doesn't exist, + # so it has to be done in setUpModule for test discovery to work + global crypt + crypt = support.import_module('crypt') class CryptTestCase(unittest.TestCase): @@ -29,8 +33,5 @@ self.assertTrue(len(crypt.methods) >= 1) self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1]) -def test_main(): - support.run_unittest(CryptTestCase) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -421,6 +421,9 @@ Tests ----- +- Issue #16919: test_crypt now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16910: test_bytes, test_unicode, and test_userstring now work with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 04:20:23 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 04:20:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2OTE5OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3Yj8Tg0NhtzR5K@mail.python.org> http://hg.python.org/cpython/rev/5345f515e03b changeset: 81380:5345f515e03b parent: 81376:aef7db0d3893 parent: 81379:15ddd683c321 user: Ezio Melotti date: Fri Jan 11 05:20:01 2013 +0200 summary: #16919: merge with 3.3. files: Lib/test/test_crypt.py | 11 ++++++----- Misc/NEWS | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,7 +1,11 @@ from test import support import unittest -crypt = support.import_module('crypt') +def setUpModule(): + # this import will raise unittest.SkipTest if _crypt doesn't exist, + # so it has to be done in setUpModule for test discovery to work + global crypt + crypt = support.import_module('crypt') class CryptTestCase(unittest.TestCase): @@ -29,8 +33,5 @@ self.assertTrue(len(crypt.methods) >= 1) self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1]) -def test_main(): - support.run_unittest(CryptTestCase) - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -620,6 +620,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16919: test_crypt now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16910: test_bytes, test_unicode, and test_userstring now work with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 05:06:12 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 05:06:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Enable_a_broke?= =?utf-8?q?n_test_and_fix_it=2E?= Message-ID: <3Yj9VX4MxXzR5r@mail.python.org> http://hg.python.org/cpython/rev/65e55d86f2e6 changeset: 81381:65e55d86f2e6 branch: 3.2 parent: 81374:b8b26feb3e1a user: Ezio Melotti date: Fri Jan 11 05:54:57 2013 +0200 summary: Enable a broken test and fix it. files: Lib/test/test_codecs.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -803,7 +803,7 @@ class EscapeDecodeTest(unittest.TestCase): def test_empty(self): - self.assertEqual(codecs.escape_decode(""), ("", 0)) + self.assertEqual(codecs.escape_decode(""), (b"", 0)) class RecodingTest(unittest.TestCase): def test_recoding(self): @@ -1905,6 +1905,7 @@ UTF16BETest, UTF8Test, UTF8SigTest, + EscapeDecodeTest, UTF7Test, UTF16ExTest, ReadBufferTest, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 05:06:13 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 05:06:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge_fix_for_broken/disabled_test=2E?= Message-ID: <3Yj9VY72jRzR8Q@mail.python.org> http://hg.python.org/cpython/rev/b259b5302229 changeset: 81382:b259b5302229 branch: 3.3 parent: 81379:15ddd683c321 parent: 81381:65e55d86f2e6 user: Ezio Melotti date: Fri Jan 11 05:57:58 2013 +0200 summary: Merge fix for broken/disabled test. files: Lib/test/test_codecs.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -925,7 +925,7 @@ class EscapeDecodeTest(unittest.TestCase): def test_empty(self): - self.assertEqual(codecs.escape_decode(""), ("", 0)) + self.assertEqual(codecs.escape_decode(""), (b"", 0)) class RecodingTest(unittest.TestCase): def test_recoding(self): @@ -2217,6 +2217,7 @@ UTF16BETest, UTF8Test, UTF8SigTest, + EscapeDecodeTest, CP65001Test, UTF7Test, UTF16ExTest, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 05:06:15 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 05:06:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2OTE4OiB0ZXN0?= =?utf-8?q?=5Fcodecs_now_works_with_unittest_test_discovery=2E_Patch_by_Za?= =?utf-8?q?chary?= Message-ID: <3Yj9Vb44JtzS0T@mail.python.org> http://hg.python.org/cpython/rev/11e7d0936fa2 changeset: 81383:11e7d0936fa2 branch: 3.3 user: Ezio Melotti date: Fri Jan 11 06:02:07 2013 +0200 summary: #16918: test_codecs now works with unittest test discovery. Patch by Zachary Ware. files: Lib/test/test_codecs.py | 58 ++++++----------------------- Misc/NEWS | 3 + 2 files changed, 15 insertions(+), 46 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -74,7 +74,7 @@ part2 = d.encode(u[i:], True) self.assertEqual(s, part1+part2) -class ReadTest(unittest.TestCase, MixInCheckStateHandling): +class ReadTest(MixInCheckStateHandling): def check_partial(self, input, partialresults): # get a StreamReader for the encoding and feed the bytestring version # of input to the reader byte by byte. Read everything available from @@ -294,7 +294,7 @@ self.assertEqual(reader.readline(), s5) self.assertEqual(reader.readline(), "") -class UTF32Test(ReadTest): +class UTF32Test(ReadTest, unittest.TestCase): encoding = "utf-32" spamle = (b'\xff\xfe\x00\x00' @@ -385,7 +385,7 @@ self.assertEqual('\U00010000' * 1024, codecs.utf_32_decode(encoded_be)[0]) -class UTF32LETest(ReadTest): +class UTF32LETest(ReadTest, unittest.TestCase): encoding = "utf-32-le" def test_partial(self): @@ -429,7 +429,7 @@ self.assertEqual('\U00010000' * 1024, codecs.utf_32_le_decode(encoded)[0]) -class UTF32BETest(ReadTest): +class UTF32BETest(ReadTest, unittest.TestCase): encoding = "utf-32-be" def test_partial(self): @@ -474,7 +474,7 @@ codecs.utf_32_be_decode(encoded)[0]) -class UTF16Test(ReadTest): +class UTF16Test(ReadTest, unittest.TestCase): encoding = "utf-16" spamle = b'\xff\xfes\x00p\x00a\x00m\x00s\x00p\x00a\x00m\x00' @@ -554,7 +554,7 @@ with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader: self.assertEqual(reader.read(), s1) -class UTF16LETest(ReadTest): +class UTF16LETest(ReadTest, unittest.TestCase): encoding = "utf-16-le" def test_partial(self): @@ -597,7 +597,7 @@ self.assertEqual(b'\x00\xd8\x03\xde'.decode(self.encoding), "\U00010203") -class UTF16BETest(ReadTest): +class UTF16BETest(ReadTest, unittest.TestCase): encoding = "utf-16-be" def test_partial(self): @@ -640,7 +640,7 @@ self.assertEqual(b'\xd8\x00\xde\x03'.decode(self.encoding), "\U00010203") -class UTF8Test(ReadTest): +class UTF8Test(ReadTest, unittest.TestCase): encoding = "utf-8" def test_partial(self): @@ -701,7 +701,7 @@ @unittest.skipUnless(sys.platform == 'win32', 'cp65001 is a Windows-only codec') -class CP65001Test(ReadTest): +class CP65001Test(ReadTest, unittest.TestCase): encoding = "cp65001" def test_encode(self): @@ -800,7 +800,7 @@ -class UTF7Test(ReadTest): +class UTF7Test(ReadTest, unittest.TestCase): encoding = "utf-7" def test_partial(self): @@ -839,7 +839,7 @@ self.assertRaises(TypeError, codecs.readbuffer_encode) self.assertRaises(TypeError, codecs.readbuffer_encode, 42) -class UTF8SigTest(ReadTest): +class UTF8SigTest(ReadTest, unittest.TestCase): encoding = "utf-8-sig" def test_partial(self): @@ -2207,39 +2207,5 @@ self.assertEqual(decoded, ('abc', 3)) -def test_main(): - support.run_unittest( - UTF32Test, - UTF32LETest, - UTF32BETest, - UTF16Test, - UTF16LETest, - UTF16BETest, - UTF8Test, - UTF8SigTest, - EscapeDecodeTest, - CP65001Test, - UTF7Test, - UTF16ExTest, - ReadBufferTest, - RecodingTest, - PunycodeTest, - UnicodeInternalTest, - NameprepTest, - IDNACodecTest, - CodecsModuleTest, - StreamReaderTest, - EncodedFileTest, - BasicUnicodeTest, - CharmapTest, - WithStmtTest, - TypesTest, - SurrogateEscapeTest, - BomTest, - TransformCodecTest, - CodePageTest, - ) - - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -421,6 +421,9 @@ Tests ----- +- Issue #16918: test_codecs now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16919: test_crypt now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 05:06:17 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 05:06:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2OTE4OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3Yj9Vd0wgnzS0T@mail.python.org> http://hg.python.org/cpython/rev/02180599a99f changeset: 81384:02180599a99f parent: 81380:5345f515e03b parent: 81383:11e7d0936fa2 user: Ezio Melotti date: Fri Jan 11 06:05:51 2013 +0200 summary: #16918: merge with 3.3. files: Lib/test/test_codecs.py | 59 ++++++---------------------- Misc/NEWS | 3 + 2 files changed, 16 insertions(+), 46 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -74,7 +74,7 @@ part2 = d.encode(u[i:], True) self.assertEqual(s, part1+part2) -class ReadTest(unittest.TestCase, MixInCheckStateHandling): +class ReadTest(MixInCheckStateHandling): def check_partial(self, input, partialresults): # get a StreamReader for the encoding and feed the bytestring version # of input to the reader byte by byte. Read everything available from @@ -294,7 +294,7 @@ self.assertEqual(reader.readline(), s5) self.assertEqual(reader.readline(), "") -class UTF32Test(ReadTest): +class UTF32Test(ReadTest, unittest.TestCase): encoding = "utf-32" spamle = (b'\xff\xfe\x00\x00' @@ -385,7 +385,7 @@ self.assertEqual('\U00010000' * 1024, codecs.utf_32_decode(encoded_be)[0]) -class UTF32LETest(ReadTest): +class UTF32LETest(ReadTest, unittest.TestCase): encoding = "utf-32-le" def test_partial(self): @@ -429,7 +429,7 @@ self.assertEqual('\U00010000' * 1024, codecs.utf_32_le_decode(encoded)[0]) -class UTF32BETest(ReadTest): +class UTF32BETest(ReadTest, unittest.TestCase): encoding = "utf-32-be" def test_partial(self): @@ -474,7 +474,7 @@ codecs.utf_32_be_decode(encoded)[0]) -class UTF16Test(ReadTest): +class UTF16Test(ReadTest, unittest.TestCase): encoding = "utf-16" spamle = b'\xff\xfes\x00p\x00a\x00m\x00s\x00p\x00a\x00m\x00' @@ -554,7 +554,7 @@ with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader: self.assertEqual(reader.read(), s1) -class UTF16LETest(ReadTest): +class UTF16LETest(ReadTest, unittest.TestCase): encoding = "utf-16-le" def test_partial(self): @@ -597,7 +597,7 @@ self.assertEqual(b'\x00\xd8\x03\xde'.decode(self.encoding), "\U00010203") -class UTF16BETest(ReadTest): +class UTF16BETest(ReadTest, unittest.TestCase): encoding = "utf-16-be" def test_partial(self): @@ -640,7 +640,7 @@ self.assertEqual(b'\xd8\x00\xde\x03'.decode(self.encoding), "\U00010203") -class UTF8Test(ReadTest): +class UTF8Test(ReadTest, unittest.TestCase): encoding = "utf-8" def test_partial(self): @@ -701,7 +701,7 @@ @unittest.skipUnless(sys.platform == 'win32', 'cp65001 is a Windows-only codec') -class CP65001Test(ReadTest): +class CP65001Test(ReadTest, unittest.TestCase): encoding = "cp65001" def test_encode(self): @@ -800,7 +800,7 @@ -class UTF7Test(ReadTest): +class UTF7Test(ReadTest, unittest.TestCase): encoding = "utf-7" def test_partial(self): @@ -839,7 +839,7 @@ self.assertRaises(TypeError, codecs.readbuffer_encode) self.assertRaises(TypeError, codecs.readbuffer_encode, 42) -class UTF8SigTest(ReadTest): +class UTF8SigTest(ReadTest, unittest.TestCase): encoding = "utf-8-sig" def test_partial(self): @@ -925,7 +925,7 @@ class EscapeDecodeTest(unittest.TestCase): def test_empty(self): - self.assertEqual(codecs.escape_decode(""), ("", 0)) + self.assertEqual(codecs.escape_decode(""), (b"", 0)) class RecodingTest(unittest.TestCase): def test_recoding(self): @@ -2207,38 +2207,5 @@ self.assertEqual(decoded, ('abc', 3)) -def test_main(): - support.run_unittest( - UTF32Test, - UTF32LETest, - UTF32BETest, - UTF16Test, - UTF16LETest, - UTF16BETest, - UTF8Test, - UTF8SigTest, - CP65001Test, - UTF7Test, - UTF16ExTest, - ReadBufferTest, - RecodingTest, - PunycodeTest, - UnicodeInternalTest, - NameprepTest, - IDNACodecTest, - CodecsModuleTest, - StreamReaderTest, - EncodedFileTest, - BasicUnicodeTest, - CharmapTest, - WithStmtTest, - TypesTest, - SurrogateEscapeTest, - BomTest, - TransformCodecTest, - CodePageTest, - ) - - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -620,6 +620,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16918: test_codecs now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16919: test_crypt now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 05:32:26 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 05:32:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2OTI1OiB0ZXN0?= =?utf-8?q?=5Fconfigparser_now_works_with_unittest_test_discovery=2E_Patch?= =?utf-8?q?_by?= Message-ID: <3YjB4p2YBJzR6s@mail.python.org> http://hg.python.org/cpython/rev/7dbdd7204d0a changeset: 81385:7dbdd7204d0a branch: 3.3 parent: 81383:11e7d0936fa2 user: Ezio Melotti date: Fri Jan 11 06:30:57 2013 +0200 summary: #16925: test_configparser now works with unittest test discovery. Patch by Zachary Ware. files: Lib/test/test_configparser.py | 48 ++++++---------------- Misc/NEWS | 3 + 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -32,7 +32,7 @@ __iter__ = iterkeys -class CfgParserTestCaseClass(unittest.TestCase): +class CfgParserTestCaseClass: allow_no_value = False delimiters = ('=', ':') comment_prefixes = (';', '#') @@ -830,12 +830,12 @@ self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) -class StrictTestCase(BasicTestCase): +class StrictTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.RawConfigParser strict = True -class ConfigParserTestCase(BasicTestCase): +class ConfigParserTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser def test_interpolation(self): @@ -924,7 +924,7 @@ self.assertRaises(ValueError, cf.add_section, self.default_section) -class ConfigParserTestCaseNoInterpolation(BasicTestCase): +class ConfigParserTestCaseNoInterpolation(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser interpolation = None ini = textwrap.dedent(""" @@ -989,7 +989,7 @@ class ConfigParserTestCaseNonStandardDefaultSection(ConfigParserTestCase): default_section = 'general' -class MultilineValuesTestCase(BasicTestCase): +class MultilineValuesTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser wonderful_spam = ("I'm having spam spam spam spam " "spam spam spam beaked beans spam " @@ -1017,7 +1017,7 @@ self.assertEqual(cf_from_file.get('section8', 'lovely_spam4'), self.wonderful_spam.replace('\t\n', '\n')) -class RawConfigParserTestCase(BasicTestCase): +class RawConfigParserTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.RawConfigParser def test_interpolation(self): @@ -1064,7 +1064,7 @@ comment_prefixes = ('//', '"') inline_comment_prefixes = ('//', '"') -class RawConfigParserTestSambaConf(CfgParserTestCaseClass): +class RawConfigParserTestSambaConf(CfgParserTestCaseClass, unittest.TestCase): config_class = configparser.RawConfigParser comment_prefixes = ('#', ';', '----') inline_comment_prefixes = ('//',) @@ -1084,7 +1084,7 @@ self.assertEqual(cf.get("global", "hosts allow"), "127.") self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s") -class ConfigParserTestCaseExtendedInterpolation(BasicTestCase): +class ConfigParserTestCaseExtendedInterpolation(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser interpolation = configparser.ExtendedInterpolation() default_section = 'common' @@ -1258,7 +1258,7 @@ class ConfigParserTestCaseNoValue(ConfigParserTestCase): allow_no_value = True -class ConfigParserTestCaseTrickyFile(CfgParserTestCaseClass): +class ConfigParserTestCaseTrickyFile(CfgParserTestCaseClass, unittest.TestCase): config_class = configparser.ConfigParser delimiters = {'='} comment_prefixes = {'#'} @@ -1355,7 +1355,7 @@ "o4 = 1\n\n") -class CompatibleTestCase(CfgParserTestCaseClass): +class CompatibleTestCase(CfgParserTestCaseClass, unittest.TestCase): config_class = configparser.RawConfigParser comment_prefixes = '#;' inline_comment_prefixes = ';' @@ -1377,7 +1377,7 @@ self.assertEqual(cf.get('Commented Bar', 'quirk'), 'this;is not a comment') -class CopyTestCase(BasicTestCase): +class CopyTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser def fromstring(self, string, defaults=None): @@ -1713,27 +1713,5 @@ self.assertEqual(s['k3'], 'v3;#//still v3# and still v3') -def test_main(): - support.run_unittest( - ConfigParserTestCase, - ConfigParserTestCaseNonStandardDelimiters, - ConfigParserTestCaseNoValue, - ConfigParserTestCaseExtendedInterpolation, - ConfigParserTestCaseLegacyInterpolation, - ConfigParserTestCaseNoInterpolation, - ConfigParserTestCaseTrickyFile, - MultilineValuesTestCase, - RawConfigParserTestCase, - RawConfigParserTestCaseNonStandardDelimiters, - RawConfigParserTestSambaConf, - SortedTestCase, - Issue7005TestCase, - StrictTestCase, - CompatibleTestCase, - CopyTestCase, - ConfigParserTestCaseNonStandardDefaultSection, - ReadFileTestCase, - CoverageOneHundredTestCase, - ExceptionPicklingTestCase, - InlineCommentStrippingTestCase, - ) +if __name__ == '__main__': + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -421,6 +421,9 @@ Tests ----- +- Issue #16925: test_configparser now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16918: test_codecs now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 05:32:27 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 05:32:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2OTI1OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YjB4q6bb2zRv7@mail.python.org> http://hg.python.org/cpython/rev/680a855ec91e changeset: 81386:680a855ec91e parent: 81384:02180599a99f parent: 81385:7dbdd7204d0a user: Ezio Melotti date: Fri Jan 11 06:32:06 2013 +0200 summary: #16925: merge with 3.3. files: Lib/test/test_configparser.py | 48 ++++++---------------- Misc/NEWS | 3 + 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -32,7 +32,7 @@ __iter__ = iterkeys -class CfgParserTestCaseClass(unittest.TestCase): +class CfgParserTestCaseClass: allow_no_value = False delimiters = ('=', ':') comment_prefixes = (';', '#') @@ -830,12 +830,12 @@ self.assertEqual(cf.sections(), ['section1', 'section2', 'section3']) -class StrictTestCase(BasicTestCase): +class StrictTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.RawConfigParser strict = True -class ConfigParserTestCase(BasicTestCase): +class ConfigParserTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser def test_interpolation(self): @@ -924,7 +924,7 @@ self.assertRaises(ValueError, cf.add_section, self.default_section) -class ConfigParserTestCaseNoInterpolation(BasicTestCase): +class ConfigParserTestCaseNoInterpolation(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser interpolation = None ini = textwrap.dedent(""" @@ -989,7 +989,7 @@ class ConfigParserTestCaseNonStandardDefaultSection(ConfigParserTestCase): default_section = 'general' -class MultilineValuesTestCase(BasicTestCase): +class MultilineValuesTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser wonderful_spam = ("I'm having spam spam spam spam " "spam spam spam beaked beans spam " @@ -1017,7 +1017,7 @@ self.assertEqual(cf_from_file.get('section8', 'lovely_spam4'), self.wonderful_spam.replace('\t\n', '\n')) -class RawConfigParserTestCase(BasicTestCase): +class RawConfigParserTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.RawConfigParser def test_interpolation(self): @@ -1064,7 +1064,7 @@ comment_prefixes = ('//', '"') inline_comment_prefixes = ('//', '"') -class RawConfigParserTestSambaConf(CfgParserTestCaseClass): +class RawConfigParserTestSambaConf(CfgParserTestCaseClass, unittest.TestCase): config_class = configparser.RawConfigParser comment_prefixes = ('#', ';', '----') inline_comment_prefixes = ('//',) @@ -1084,7 +1084,7 @@ self.assertEqual(cf.get("global", "hosts allow"), "127.") self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s") -class ConfigParserTestCaseExtendedInterpolation(BasicTestCase): +class ConfigParserTestCaseExtendedInterpolation(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser interpolation = configparser.ExtendedInterpolation() default_section = 'common' @@ -1258,7 +1258,7 @@ class ConfigParserTestCaseNoValue(ConfigParserTestCase): allow_no_value = True -class ConfigParserTestCaseTrickyFile(CfgParserTestCaseClass): +class ConfigParserTestCaseTrickyFile(CfgParserTestCaseClass, unittest.TestCase): config_class = configparser.ConfigParser delimiters = {'='} comment_prefixes = {'#'} @@ -1355,7 +1355,7 @@ "o4 = 1\n\n") -class CompatibleTestCase(CfgParserTestCaseClass): +class CompatibleTestCase(CfgParserTestCaseClass, unittest.TestCase): config_class = configparser.RawConfigParser comment_prefixes = '#;' inline_comment_prefixes = ';' @@ -1377,7 +1377,7 @@ self.assertEqual(cf.get('Commented Bar', 'quirk'), 'this;is not a comment') -class CopyTestCase(BasicTestCase): +class CopyTestCase(BasicTestCase, unittest.TestCase): config_class = configparser.ConfigParser def fromstring(self, string, defaults=None): @@ -1713,27 +1713,5 @@ self.assertEqual(s['k3'], 'v3;#//still v3# and still v3') -def test_main(): - support.run_unittest( - ConfigParserTestCase, - ConfigParserTestCaseNonStandardDelimiters, - ConfigParserTestCaseNoValue, - ConfigParserTestCaseExtendedInterpolation, - ConfigParserTestCaseLegacyInterpolation, - ConfigParserTestCaseNoInterpolation, - ConfigParserTestCaseTrickyFile, - MultilineValuesTestCase, - RawConfigParserTestCase, - RawConfigParserTestCaseNonStandardDelimiters, - RawConfigParserTestSambaConf, - SortedTestCase, - Issue7005TestCase, - StrictTestCase, - CompatibleTestCase, - CopyTestCase, - ConfigParserTestCaseNonStandardDefaultSection, - ReadFileTestCase, - CoverageOneHundredTestCase, - ExceptionPicklingTestCase, - InlineCommentStrippingTestCase, - ) +if __name__ == '__main__': + unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -620,6 +620,9 @@ - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. +- Issue #16925: test_configparser now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #16918: test_codecs now works with unittest test discovery. Patch by Zachary Ware. -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Fri Jan 11 05:57:50 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 11 Jan 2013 05:57:50 +0100 Subject: [Python-checkins] Daily reference leaks (aef7db0d3893): sum=287 Message-ID: results for aef7db0d3893 on branch "default" -------------------------------------------- test_dbm leaked [2, 0, 0] references, sum=2 test_dbm leaked [2, 2, 1] memory blocks, sum=5 test_xml_etree_c leaked [56, 56, 56] references, sum=168 test_xml_etree_c leaked [36, 38, 38] memory blocks, sum=112 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogang3f6', '-x'] From ncoghlan at gmail.com Fri Jan 11 07:09:52 2013 From: ncoghlan at gmail.com (Nick Coghlan) Date: Fri, 11 Jan 2013 16:09:52 +1000 Subject: [Python-checkins] Daily reference leaks (aef7db0d3893): sum=287 In-Reply-To: References: Message-ID: On Fri, Jan 11, 2013 at 2:57 PM, wrote: > results for aef7db0d3893 on branch "default" > -------------------------------------------- > > test_dbm leaked [2, 0, 0] references, sum=2 > test_dbm leaked [2, 2, 1] memory blocks, sum=5 Hmm, I'm starting to wonder if there's something to this one - it seems to be popping up a bit lately. > test_xml_etree_c leaked [56, 56, 56] references, sum=168 > test_xml_etree_c leaked [36, 38, 38] memory blocks, sum=112 I'm gonna take a wild guess and suggest there may be a problem with the recent pickling fix in the C extension :) Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia From python-checkins at python.org Fri Jan 11 07:44:48 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 07:44:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzEzODk5OiBcQSwg?= =?utf-8?q?=5CZ=2C_and_=5CB_now_correctly_match_the_A=2C_Z=2C_and_B_litera?= =?utf-8?q?ls_when_used?= Message-ID: <3YjF1X5hQfzS0T@mail.python.org> http://hg.python.org/cpython/rev/2bc04449fd8c changeset: 81387:2bc04449fd8c branch: 2.7 parent: 81378:2a417ad8bfbf user: Ezio Melotti date: Fri Jan 11 08:32:01 2013 +0200 summary: #13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used inside character classes (e.g. [A]). Patch by Matthew Barnett. files: Lib/sre_parse.py | 2 +- Lib/test/test_re.py | 6 ++++++ Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 11 insertions(+), 1 deletions(-) diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -228,7 +228,7 @@ if code: return code code = CATEGORIES.get(escape) - if code: + if code and code[0] == IN: return code try: c = escape[1:2] diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -821,6 +821,12 @@ # Test behaviour when not given a string or pattern as parameter self.assertRaises(TypeError, re.compile, 0) + def test_bug_13899(self): + # Issue #13899: re pattern r"[\A]" should work like "A" but matches + # nothing. Ditto B and Z. + self.assertEqual(re.findall(r'[\A\B\b\C\Z]', 'AB\bCZ'), + ['A', 'B', '\b', 'C', 'Z']) + @precisionbigmemtest(size=_2G, memuse=1) def test_large_search(self, size): # Issue #10182: indices were 32-bit-truncated. diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -58,6 +58,7 @@ Anton Barkovsky Nick Barnes Quentin Barnes +Matthew Barnett Richard Barran Cesar Eduardo Barros Des Barry diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,6 +186,9 @@ Library ------- +- Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals + when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. + - Issue #15109: Fix regression in sqlite3's iterdump method where it would die with an encoding error if the database contained string values containing non-ASCII. (Regression was introduced by fix for 9750). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 07:44:50 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 07:44:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzEzODk5OiBcQSwg?= =?utf-8?q?=5CZ=2C_and_=5CB_now_correctly_match_the_A=2C_Z=2C_and_B_litera?= =?utf-8?q?ls_when_used?= Message-ID: <3YjF1Z1MYhzS3J@mail.python.org> http://hg.python.org/cpython/rev/081db241ccda changeset: 81388:081db241ccda branch: 3.2 parent: 81381:65e55d86f2e6 user: Ezio Melotti date: Fri Jan 11 08:32:01 2013 +0200 summary: #13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used inside character classes (e.g. [A]). Patch by Matthew Barnett. files: Lib/sre_parse.py | 2 +- Lib/test/test_re.py | 6 ++++++ Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 11 insertions(+), 1 deletions(-) diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -235,7 +235,7 @@ if code: return code code = CATEGORIES.get(escape) - if code: + if code and code[0] == IN: return code try: c = escape[1:2] diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -857,6 +857,12 @@ # Test behaviour when not given a string or pattern as parameter self.assertRaises(TypeError, re.compile, 0) + def test_bug_13899(self): + # Issue #13899: re pattern r"[\A]" should work like "A" but matches + # nothing. Ditto B and Z. + self.assertEqual(re.findall(r'[\A\B\b\C\Z]', 'AB\bCZ'), + ['A', 'B', '\b', 'C', 'Z']) + @bigmemtest(size=_2G, memuse=character_size) def test_large_search(self, size): # Issue #10182: indices were 32-bit-truncated. diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -65,6 +65,7 @@ Anton Barkovsky Nick Barnes Quentin Barnes +Matthew Barnett Richard Barran Cesar Eduardo Barros Des Barry diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -199,6 +199,9 @@ Library ------- +- Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals + when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. + - Issue #15545: Fix regression in sqlite3's iterdump method where it was failing if the connection used a row factory (such as sqlite3.Row) that produced unsortable objects. (Regression was introduced by fix for 9750). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 07:44:51 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 07:44:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2313899=3A_merge_with_3=2E2=2E?= Message-ID: <3YjF1b49zYzS4D@mail.python.org> http://hg.python.org/cpython/rev/17b1eb4a8144 changeset: 81389:17b1eb4a8144 branch: 3.3 parent: 81385:7dbdd7204d0a parent: 81388:081db241ccda user: Ezio Melotti date: Fri Jan 11 08:43:53 2013 +0200 summary: #13899: merge with 3.2. files: Lib/sre_parse.py | 2 +- Lib/test/test_re.py | 6 ++++++ Misc/NEWS | 3 +++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -245,7 +245,7 @@ if code: return code code = CATEGORIES.get(escape) - if code: + if code and code[0] == IN: return code try: c = escape[1:2] diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -949,6 +949,12 @@ # Test behaviour when not given a string or pattern as parameter self.assertRaises(TypeError, re.compile, 0) + def test_bug_13899(self): + # Issue #13899: re pattern r"[\A]" should work like "A" but matches + # nothing. Ditto B and Z. + self.assertEqual(re.findall(r'[\A\B\b\C\Z]', 'AB\bCZ'), + ['A', 'B', '\b', 'C', 'Z']) + @bigmemtest(size=_2G, memuse=1) def test_large_search(self, size): # Issue #10182: indices were 32-bit-truncated. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -144,6 +144,9 @@ - Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed. +- Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals + when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. + - Issue #15545: Fix regression in sqlite3's iterdump method where it was failing if the connection used a row factory (such as sqlite3.Row) that produced unsortable objects. (Regression was introduced by fix for 9750). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 07:44:52 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 07:44:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzEzODk5OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YjF1c6y25zS4N@mail.python.org> http://hg.python.org/cpython/rev/35ece2465936 changeset: 81390:35ece2465936 parent: 81386:680a855ec91e parent: 81389:17b1eb4a8144 user: Ezio Melotti date: Fri Jan 11 08:44:25 2013 +0200 summary: #13899: merge with 3.3. files: Lib/sre_parse.py | 2 +- Lib/test/test_re.py | 6 ++++++ Misc/NEWS | 3 +++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -245,7 +245,7 @@ if code: return code code = CATEGORIES.get(escape) - if code: + if code and code[0] == IN: return code try: c = escape[1:2] diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -949,6 +949,12 @@ # Test behaviour when not given a string or pattern as parameter self.assertRaises(TypeError, re.compile, 0) + def test_bug_13899(self): + # Issue #13899: re pattern r"[\A]" should work like "A" but matches + # nothing. Ditto B and Z. + self.assertEqual(re.findall(r'[\A\B\b\C\Z]', 'AB\bCZ'), + ['A', 'B', '\b', 'C', 'Z']) + @bigmemtest(size=_2G, memuse=1) def test_large_search(self, size): # Issue #10182: indices were 32-bit-truncated. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -214,6 +214,9 @@ - Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed. +- Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals + when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. + - Issue #15545: Fix regression in sqlite3's iterdump method where it was failing if the connection used a row factory (such as sqlite3.Row) that produced unsortable objects. (Regression was introduced by fix for 9750). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:05:24 2013 From: python-checkins at python.org (chris.jerdonek) Date: Fri, 11 Jan 2013 08:05:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2ODc0?= =?utf-8?q?=3A_fix_formatting_of_setup=2Epy_upload_options_in_documentatio?= =?utf-8?q?n=2E?= Message-ID: <3YjFTJ23SszR7g@mail.python.org> http://hg.python.org/cpython/rev/a30c36fbefcf changeset: 81391:a30c36fbefcf branch: 2.7 parent: 81387:2bc04449fd8c user: Chris Jerdonek date: Thu Jan 10 22:50:40 2013 -0800 summary: Issue #16874: fix formatting of setup.py upload options in documentation. files: Doc/distutils/uploading.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/distutils/uploading.rst b/Doc/distutils/uploading.rst --- a/Doc/distutils/uploading.rst +++ b/Doc/distutils/uploading.rst @@ -27,21 +27,21 @@ entered password. This is useful if you do not want to store a clear text password in the :file:`$HOME/.pypirc` file. -You can specify another PyPI server with the :option:`--repository=*url*` option:: +You can specify another PyPI server with the ``--repository=url`` option:: python setup.py sdist bdist_wininst upload -r http://example.com/pypi See section :ref:`pypirc` for more on defining several servers. -You can use the :option:`--sign` option to tell :command:`upload` to sign each +You can use the ``--sign`` option to tell :command:`upload` to sign each uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must be available for execution on the system :envvar:`PATH`. You can also specify -which key to use for signing using the :option:`--identity=*name*` option. +which key to use for signing using the ``--identity=name`` option. -Other :command:`upload` options include :option:`--repository=` or -:option:`--repository=
` where *url* is the url of the server and +Other :command:`upload` options include ``--repository=url`` or +``--repository=section`` where *url* is the url of the server and *section* the name of the section in :file:`$HOME/.pypirc`, and -:option:`--show-response` (which displays the full response text from the PyPI +``--show-response`` (which displays the full response text from the PyPI server for help in debugging upload problems). PyPI package display -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:05:25 2013 From: python-checkins at python.org (chris.jerdonek) Date: Fri, 11 Jan 2013 08:05:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2ODc0?= =?utf-8?q?_=28forward-port_from_2=2E7=29=3A_fix_some_documentation_format?= =?utf-8?q?ting=2E?= Message-ID: <3YjFTK5CH8zS1q@mail.python.org> http://hg.python.org/cpython/rev/dcb645b9de4c changeset: 81392:dcb645b9de4c branch: 3.2 parent: 81388:081db241ccda user: Chris Jerdonek date: Thu Jan 10 23:01:27 2013 -0800 summary: Issue #16874 (forward-port from 2.7): fix some documentation formatting. files: Doc/distutils/uploading.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/distutils/uploading.rst b/Doc/distutils/uploading.rst --- a/Doc/distutils/uploading.rst +++ b/Doc/distutils/uploading.rst @@ -25,21 +25,21 @@ entered password. This is useful if you do not want to store a clear text password in the :file:`$HOME/.pypirc` file. -You can specify another PyPI server with the :option:`--repository=*url*` option:: +You can specify another PyPI server with the ``--repository=url`` option:: python setup.py sdist bdist_wininst upload -r http://example.com/pypi See section :ref:`pypirc` for more on defining several servers. -You can use the :option:`--sign` option to tell :command:`upload` to sign each +You can use the ``--sign`` option to tell :command:`upload` to sign each uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must be available for execution on the system :envvar:`PATH`. You can also specify -which key to use for signing using the :option:`--identity=*name*` option. +which key to use for signing using the ``--identity=name`` option. -Other :command:`upload` options include :option:`--repository=` or -:option:`--repository=
` where *url* is the url of the server and +Other :command:`upload` options include ``--repository=url`` or +``--repository=section`` where *url* is the url of the server and *section* the name of the section in :file:`$HOME/.pypirc`, and -:option:`--show-response` (which displays the full response text from the PyPI +``--show-response`` (which displays the full response text from the PyPI server for help in debugging upload problems). PyPI package display -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:05:27 2013 From: python-checkins at python.org (chris.jerdonek) Date: Fri, 11 Jan 2013 08:05:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316874_=28merge_from_3=2E2=29=3A_fix_some_documentatio?= =?utf-8?q?n_formatting=2E?= Message-ID: <3YjFTM1K8zzS3j@mail.python.org> http://hg.python.org/cpython/rev/63fff55a167f changeset: 81393:63fff55a167f branch: 3.3 parent: 81389:17b1eb4a8144 parent: 81392:dcb645b9de4c user: Chris Jerdonek date: Thu Jan 10 23:03:42 2013 -0800 summary: Issue #16874 (merge from 3.2): fix some documentation formatting. files: Doc/distutils/uploading.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/distutils/uploading.rst b/Doc/distutils/uploading.rst --- a/Doc/distutils/uploading.rst +++ b/Doc/distutils/uploading.rst @@ -25,21 +25,21 @@ entered password. This is useful if you do not want to store a clear text password in the :file:`$HOME/.pypirc` file. -You can specify another PyPI server with the :option:`--repository=*url*` option:: +You can specify another PyPI server with the ``--repository=url`` option:: python setup.py sdist bdist_wininst upload -r http://example.com/pypi See section :ref:`pypirc` for more on defining several servers. -You can use the :option:`--sign` option to tell :command:`upload` to sign each +You can use the ``--sign`` option to tell :command:`upload` to sign each uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must be available for execution on the system :envvar:`PATH`. You can also specify -which key to use for signing using the :option:`--identity=*name*` option. +which key to use for signing using the ``--identity=name`` option. -Other :command:`upload` options include :option:`--repository=` or -:option:`--repository=
` where *url* is the url of the server and +Other :command:`upload` options include ``--repository=url`` or +``--repository=section`` where *url* is the url of the server and *section* the name of the section in :file:`$HOME/.pypirc`, and -:option:`--show-response` (which displays the full response text from the PyPI +``--show-response`` (which displays the full response text from the PyPI server for help in debugging upload problems). PyPI package display -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:05:28 2013 From: python-checkins at python.org (chris.jerdonek) Date: Fri, 11 Jan 2013 08:05:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316874_=28merge_from_3=2E3=29=3A_fix_some_docume?= =?utf-8?q?ntation_formatting=2E?= Message-ID: <3YjFTN4MLJzR7g@mail.python.org> http://hg.python.org/cpython/rev/860a2f6282c4 changeset: 81394:860a2f6282c4 parent: 81390:35ece2465936 parent: 81393:63fff55a167f user: Chris Jerdonek date: Thu Jan 10 23:04:44 2013 -0800 summary: Issue #16874 (merge from 3.3): fix some documentation formatting. files: Doc/distutils/uploading.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/distutils/uploading.rst b/Doc/distutils/uploading.rst --- a/Doc/distutils/uploading.rst +++ b/Doc/distutils/uploading.rst @@ -25,21 +25,21 @@ entered password. This is useful if you do not want to store a clear text password in the :file:`$HOME/.pypirc` file. -You can specify another PyPI server with the :option:`--repository=*url*` option:: +You can specify another PyPI server with the ``--repository=url`` option:: python setup.py sdist bdist_wininst upload -r http://example.com/pypi See section :ref:`pypirc` for more on defining several servers. -You can use the :option:`--sign` option to tell :command:`upload` to sign each +You can use the ``--sign`` option to tell :command:`upload` to sign each uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must be available for execution on the system :envvar:`PATH`. You can also specify -which key to use for signing using the :option:`--identity=*name*` option. +which key to use for signing using the ``--identity=name`` option. -Other :command:`upload` options include :option:`--repository=` or -:option:`--repository=
` where *url* is the url of the server and +Other :command:`upload` options include ``--repository=url`` or +``--repository=section`` where *url* is the url of the server and *section* the name of the section in :file:`$HOME/.pypirc`, and -:option:`--show-response` (which displays the full response text from the PyPI +``--show-response`` (which displays the full response text from the PyPI server for help in debugging upload problems). PyPI package display -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:13:11 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 08:13:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE2MTU0OiBmaXgg?= =?utf-8?q?some_doctests_in_Doc/library=2E__Patch_by_Ravi_Sinha=2E?= Message-ID: <3YjFfH17zzzQpP@mail.python.org> http://hg.python.org/cpython/rev/9b3d0bdb9256 changeset: 81395:9b3d0bdb9256 branch: 2.7 parent: 81387:2bc04449fd8c user: Ezio Melotti date: Fri Jan 11 08:53:10 2013 +0200 summary: #16154: fix some doctests in Doc/library. Patch by Ravi Sinha. files: Doc/library/colorsys.rst | 8 ++++---- Doc/library/filecmp.rst | 8 ++++---- Doc/library/math.rst | 2 ++ Doc/library/string.rst | 2 +- Misc/ACKS | 1 + 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -58,7 +58,7 @@ Example:: >>> import colorsys - >>> colorsys.rgb_to_hsv(.3, .4, .2) - (0.25, 0.5, 0.4) - >>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4) - (0.3, 0.4, 0.2) + >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4) + (0.5, 0.5, 0.4) + >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4) + (0.2, 0.4, 0.4) diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -54,9 +54,9 @@ Example:: >>> import filecmp - >>> filecmp.cmp('undoc.rst', 'undoc.rst') + >>> filecmp.cmp('undoc.rst', 'undoc.rst') # doctest: +SKIP True - >>> filecmp.cmp('undoc.rst', 'index.rst') + >>> filecmp.cmp('undoc.rst', 'index.rst') # doctest: +SKIP False @@ -190,6 +190,6 @@ ... for sub_dcmp in dcmp.subdirs.values(): ... print_diff_files(sub_dcmp) ... - >>> dcmp = dircmp('dir1', 'dir2') - >>> print_diff_files(dcmp) + >>> dcmp = dircmp('dir1', 'dir2') # doctest: +SKIP + >>> print_diff_files(dcmp) # doctest: +SKIP diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -82,6 +82,8 @@ .. function:: fsum(iterable) +.. testsetup:: + >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -717,7 +717,7 @@ >>> Template('Give $who $100').substitute(d) Traceback (most recent call last): [...] - ValueError: Invalid placeholder in string: line 1, col 10 + ValueError: Invalid placeholder in string: line 1, col 11 >>> Template('$who likes $what').substitute(d) Traceback (most recent call last): [...] diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -923,6 +923,7 @@ Ionel Simionescu Kirill Simonov Nathan Paul Simons +Ravi Sinha Janne Sinkkonen Ng Pheng Siong George Sipe -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:13:12 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 08:13:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_Merge_heads=2E?= Message-ID: <3YjFfJ4nPPzRxl@mail.python.org> http://hg.python.org/cpython/rev/66e2040c1756 changeset: 81396:66e2040c1756 branch: 2.7 parent: 81391:a30c36fbefcf parent: 81395:9b3d0bdb9256 user: Ezio Melotti date: Fri Jan 11 09:06:12 2013 +0200 summary: Merge heads. files: Doc/library/colorsys.rst | 8 ++++---- Doc/library/filecmp.rst | 8 ++++---- Doc/library/math.rst | 2 ++ Doc/library/string.rst | 2 +- Misc/ACKS | 1 + 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -58,7 +58,7 @@ Example:: >>> import colorsys - >>> colorsys.rgb_to_hsv(.3, .4, .2) - (0.25, 0.5, 0.4) - >>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4) - (0.3, 0.4, 0.2) + >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4) + (0.5, 0.5, 0.4) + >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4) + (0.2, 0.4, 0.4) diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -54,9 +54,9 @@ Example:: >>> import filecmp - >>> filecmp.cmp('undoc.rst', 'undoc.rst') + >>> filecmp.cmp('undoc.rst', 'undoc.rst') # doctest: +SKIP True - >>> filecmp.cmp('undoc.rst', 'index.rst') + >>> filecmp.cmp('undoc.rst', 'index.rst') # doctest: +SKIP False @@ -190,6 +190,6 @@ ... for sub_dcmp in dcmp.subdirs.values(): ... print_diff_files(sub_dcmp) ... - >>> dcmp = dircmp('dir1', 'dir2') - >>> print_diff_files(dcmp) + >>> dcmp = dircmp('dir1', 'dir2') # doctest: +SKIP + >>> print_diff_files(dcmp) # doctest: +SKIP diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -82,6 +82,8 @@ .. function:: fsum(iterable) +.. testsetup:: + >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -717,7 +717,7 @@ >>> Template('Give $who $100').substitute(d) Traceback (most recent call last): [...] - ValueError: Invalid placeholder in string: line 1, col 10 + ValueError: Invalid placeholder in string: line 1, col 11 >>> Template('$who likes $what').substitute(d) Traceback (most recent call last): [...] diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -923,6 +923,7 @@ Ionel Simionescu Kirill Simonov Nathan Paul Simons +Ravi Sinha Janne Sinkkonen Ng Pheng Siong George Sipe -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:13:14 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 08:13:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE2MTU0OiBmaXgg?= =?utf-8?q?some_doctests_in_Doc/library=2E__Patch_by_Ravi_Sinha=2E?= Message-ID: <3YjFfL11C5zS4w@mail.python.org> http://hg.python.org/cpython/rev/5b405df8518d changeset: 81397:5b405df8518d branch: 3.2 parent: 81392:dcb645b9de4c user: Ezio Melotti date: Fri Jan 11 09:09:07 2013 +0200 summary: #16154: fix some doctests in Doc/library. Patch by Ravi Sinha. files: Doc/library/colorsys.rst | 8 ++++---- Doc/library/filecmp.rst | 8 ++++---- Doc/library/math.rst | 2 ++ Doc/library/string.rst | 4 ++-- Misc/ACKS | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -58,7 +58,7 @@ Example:: >>> import colorsys - >>> colorsys.rgb_to_hsv(.3, .4, .2) - (0.25, 0.5, 0.4) - >>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4) - (0.3, 0.4, 0.2) + >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4) + (0.5, 0.5, 0.4) + >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4) + (0.2, 0.4, 0.4) diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -54,9 +54,9 @@ Example:: >>> import filecmp - >>> filecmp.cmp('undoc.rst', 'undoc.rst') + >>> filecmp.cmp('undoc.rst', 'undoc.rst') # doctest: +SKIP True - >>> filecmp.cmp('undoc.rst', 'index.rst') + >>> filecmp.cmp('undoc.rst', 'index.rst') # doctest: +SKIP False @@ -191,6 +191,6 @@ ... for sub_dcmp in dcmp.subdirs.values(): ... print_diff_files(sub_dcmp) ... - >>> dcmp = dircmp('dir1', 'dir2') - >>> print_diff_files(dcmp) + >>> dcmp = dircmp('dir1', 'dir2') # doctest: +SKIP + >>> print_diff_files(dcmp) # doctest: +SKIP diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -77,6 +77,8 @@ .. function:: fsum(iterable) +.. testsetup:: + >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -610,7 +610,7 @@ 3232235521 >>> >>> width = 5 - >>> for num in range(5,12): + >>> for num in range(5,12): #doctest: +NORMALIZE_WHITESPACE ... for base in 'dXob': ... print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ') ... print() @@ -698,7 +698,7 @@ >>> Template('Give $who $100').substitute(d) Traceback (most recent call last): [...] - ValueError: Invalid placeholder in string: line 1, col 10 + ValueError: Invalid placeholder in string: line 1, col 11 >>> Template('$who likes $what').substitute(d) Traceback (most recent call last): [...] diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -998,6 +998,7 @@ Ionel Simionescu Kirill Simonov Nathan Paul Simons +Ravi Sinha Janne Sinkkonen Ng Pheng Siong George Sipe -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:13:15 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 08:13:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2316154=3A_merge_with_3=2E2=2E?= Message-ID: <3YjFfM4HL4zS47@mail.python.org> http://hg.python.org/cpython/rev/3e884b3804b3 changeset: 81398:3e884b3804b3 branch: 3.3 parent: 81393:63fff55a167f parent: 81397:5b405df8518d user: Ezio Melotti date: Fri Jan 11 09:12:28 2013 +0200 summary: #16154: merge with 3.2. files: Doc/library/colorsys.rst | 8 ++++---- Doc/library/filecmp.rst | 4 ++-- Doc/library/math.rst | 2 ++ Doc/library/string.rst | 4 ++-- Misc/ACKS | 1 + 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -58,7 +58,7 @@ Example:: >>> import colorsys - >>> colorsys.rgb_to_hsv(.3, .4, .2) - (0.25, 0.5, 0.4) - >>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4) - (0.3, 0.4, 0.2) + >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4) + (0.5, 0.5, 0.4) + >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4) + (0.2, 0.4, 0.4) diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -176,6 +176,6 @@ ... for sub_dcmp in dcmp.subdirs.values(): ... print_diff_files(sub_dcmp) ... - >>> dcmp = dircmp('dir1', 'dir2') - >>> print_diff_files(dcmp) + >>> dcmp = dircmp('dir1', 'dir2') # doctest: +SKIP + >>> print_diff_files(dcmp) # doctest: +SKIP diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -77,6 +77,8 @@ .. function:: fsum(iterable) +.. testsetup:: + >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -610,7 +610,7 @@ 3232235521 >>> >>> width = 5 - >>> for num in range(5,12): + >>> for num in range(5,12): #doctest: +NORMALIZE_WHITESPACE ... for base in 'dXob': ... print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ') ... print() @@ -698,7 +698,7 @@ >>> Template('Give $who $100').substitute(d) Traceback (most recent call last): [...] - ValueError: Invalid placeholder in string: line 1, col 10 + ValueError: Invalid placeholder in string: line 1, col 11 >>> Template('$who likes $what').substitute(d) Traceback (most recent call last): [...] diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1103,6 +1103,7 @@ Kirill Simonov Nathan Paul Simons Adam Simpkins +Ravi Sinha Janne Sinkkonen Ng Pheng Siong George Sipe -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:13:17 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 08:13:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2MTU0OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YjFfP0QjGzS5g@mail.python.org> http://hg.python.org/cpython/rev/5ec8daab477a changeset: 81399:5ec8daab477a parent: 81394:860a2f6282c4 parent: 81398:3e884b3804b3 user: Ezio Melotti date: Fri Jan 11 09:12:49 2013 +0200 summary: #16154: merge with 3.3. files: Doc/library/colorsys.rst | 8 ++++---- Doc/library/filecmp.rst | 4 ++-- Doc/library/math.rst | 2 ++ Doc/library/string.rst | 4 ++-- Misc/ACKS | 1 + 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -58,7 +58,7 @@ Example:: >>> import colorsys - >>> colorsys.rgb_to_hsv(.3, .4, .2) - (0.25, 0.5, 0.4) - >>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4) - (0.3, 0.4, 0.2) + >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4) + (0.5, 0.5, 0.4) + >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4) + (0.2, 0.4, 0.4) diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -176,6 +176,6 @@ ... for sub_dcmp in dcmp.subdirs.values(): ... print_diff_files(sub_dcmp) ... - >>> dcmp = dircmp('dir1', 'dir2') - >>> print_diff_files(dcmp) + >>> dcmp = dircmp('dir1', 'dir2') # doctest: +SKIP + >>> print_diff_files(dcmp) # doctest: +SKIP diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -77,6 +77,8 @@ .. function:: fsum(iterable) +.. testsetup:: + >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -610,7 +610,7 @@ 3232235521 >>> >>> width = 5 - >>> for num in range(5,12): + >>> for num in range(5,12): #doctest: +NORMALIZE_WHITESPACE ... for base in 'dXob': ... print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ') ... print() @@ -698,7 +698,7 @@ >>> Template('Give $who $100').substitute(d) Traceback (most recent call last): [...] - ValueError: Invalid placeholder in string: line 1, col 10 + ValueError: Invalid placeholder in string: line 1, col 11 >>> Template('$who likes $what').substitute(d) Traceback (most recent call last): [...] diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1113,6 +1113,7 @@ Kirill Simonov Nathan Paul Simons Adam Simpkins +Ravi Sinha Janne Sinkkonen Ng Pheng Siong George Sipe -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 08:30:50 2013 From: python-checkins at python.org (chris.jerdonek) Date: Fri, 11 Jan 2013 08:30:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_Improve_and_make_more_con?= =?utf-8?q?cise_the_=22Building_the_documentation=22_section=2E?= Message-ID: <3YjG2f74RhzS69@mail.python.org> http://hg.python.org/devguide/rev/157066a204ab changeset: 587:157066a204ab user: Chris Jerdonek date: Thu Jan 10 23:29:47 2013 -0800 summary: Improve and make more concise the "Building the documentation" section. A couple of the changes include adding hyperlinks for each toolset component and moving the viewing instructions outside of the "Using make" section. files: documenting.rst | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) diff --git a/documenting.rst b/documenting.rst --- a/documenting.rst +++ b/documenting.rst @@ -18,8 +18,6 @@ :ref:`CPython Mercurial repository `. .. _reStructuredText: http://docutils.sf.net/rst.html -.. _docutils: http://docutils.sf.net/ -.. _Sphinx: http://sphinx-doc.org/ .. note:: @@ -1629,29 +1627,30 @@ Building the documentation ========================== -You need to have Python 2.4 or higher installed; the toolset used to build the -docs is written in Python. It is called *Sphinx*, it is not included in this -tree, but maintained separately. Also needed are the docutils, supplying the -base markup that Sphinx uses, Jinja, a templating engine, and optionally -Pygments, a code highlighter. +You need to have Python 2.4 or higher installed. The toolset used to build +the docs is written in Python and is called Sphinx_. Sphinx is maintained +separately and is not included in this tree. Also needed are docutils_, +supplying the base markup that Sphinx uses; Jinja_, a templating engine; and +optionally Pygments_, a code highlighter. + +To build the documentation, follow the instructions from one of the sections +below. You can view the documentation after building the HTML by pointing +a browser at the file :file:`Doc/build/html/index.html`. Using make ---------- -Luckily, a Makefile has been prepared so that on Unix, provided you have -installed Python and Subversion, you can just go to your :ref:`clone of the -CPython Mercurial repository ` and run :: +On Unix, if you have Subversion installed, run the following from the root of +your :ref:`repository clone `:: cd Doc make html -to check out the necessary toolset in the :file:`Doc/tools/` subdirectory and -build the HTML output files. To view the generated HTML, point your favorite -browser at the top-level index :file:`Doc/build/html/index.html` after running -:command:`make`. +This checks out the needed toolset in the :file:`Doc/tools/` directory and +builds the output as HTML. -Available make targets are: +Available :command:`make` targets are: * "html", which builds standalone HTML files for offline viewing. @@ -1721,3 +1720,8 @@ where `` is one of html, text, latex, or htmlhelp (for explanations see the make targets above). + +.. _docutils: http://docutils.sourceforge.net/ +.. _Jinja: http://jinja.pocoo.org/ +.. _Pygments: http://pygments.org/ +.. _Sphinx: http://sphinx-doc.org/ -- Repository URL: http://hg.python.org/devguide From root at python.org Fri Jan 11 08:35:08 2013 From: root at python.org (Cron Daemon) Date: Fri, 11 Jan 2013 08:35:08 +0100 Subject: [Python-checkins] Cron /home/docs/build-devguide Message-ID: /home/docs/devguide/documenting.rst:766: WARNING: term not in glossary: bytecode From python-checkins at python.org Fri Jan 11 09:16:57 2013 From: python-checkins at python.org (chris.jerdonek) Date: Fri, 11 Jan 2013 09:16:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_Issue_=2316814=3A_add_=22?= =?utf-8?q?make_-C_Doc_html=22_short-cut_to_documentation_instructions=2E?= Message-ID: <3YjH3s2HhvzS3j@mail.python.org> http://hg.python.org/devguide/rev/5f24a77e7beb changeset: 588:5f24a77e7beb user: Chris Jerdonek date: Fri Jan 11 00:10:09 2013 -0800 summary: Issue #16814: add "make -C Doc html" short-cut to documentation instructions. files: documenting.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documenting.rst b/documenting.rst --- a/documenting.rst +++ b/documenting.rst @@ -1647,8 +1647,8 @@ cd Doc make html -This checks out the needed toolset in the :file:`Doc/tools/` directory and -builds the output as HTML. +or alternatively ``make -C Doc html``. This checks out the needed toolset +in the :file:`Doc/tools/` directory and builds the output as HTML. Available :command:`make` targets are: -- Repository URL: http://hg.python.org/devguide From root at python.org Fri Jan 11 09:20:07 2013 From: root at python.org (Cron Daemon) Date: Fri, 11 Jan 2013 09:20:07 +0100 Subject: [Python-checkins] Cron /home/docs/build-devguide Message-ID: /home/docs/devguide/documenting.rst:766: WARNING: term not in glossary: bytecode From python-checkins at python.org Fri Jan 11 09:20:52 2013 From: python-checkins at python.org (georg.brandl) Date: Fri, 11 Jan 2013 09:20:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_Update_Py3k_doc_URL=2E?= Message-ID: <3YjH8N4f1xzS34@mail.python.org> http://hg.python.org/devguide/rev/5c8851aaf386 changeset: 589:5c8851aaf386 user: Georg Brandl date: Fri Jan 11 09:21:52 2013 +0100 summary: Update Py3k doc URL. files: conf.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/conf.py b/conf.py --- a/conf.py +++ b/conf.py @@ -26,7 +26,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo'] -intersphinx_mapping = {'python': ('http://docs.python.org/py3k', None)} +intersphinx_mapping = {'python': ('http://docs.python.org/3', None)} todo_include_todos = True # Add any paths that contain templates here, relative to this directory. -- Repository URL: http://hg.python.org/devguide From root at python.org Fri Jan 11 09:25:12 2013 From: root at python.org (Cron Daemon) Date: Fri, 11 Jan 2013 09:25:12 +0100 Subject: [Python-checkins] Cron /home/docs/build-devguide Message-ID: /home/docs/devguide/documenting.rst:766: WARNING: term not in glossary: bytecode From python-checkins at python.org Fri Jan 11 10:50:13 2013 From: python-checkins at python.org (sandro.tosi) Date: Fri, 11 Jan 2013 10:50:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_grammatical_fi?= =?utf-8?q?x=3B_thanks_to_Alex_Rudnick_from_docs=40?= Message-ID: <3YjK7T2YKtzS5v@mail.python.org> http://hg.python.org/cpython/rev/7555399134af changeset: 81400:7555399134af branch: 2.7 parent: 81396:66e2040c1756 user: Sandro Tosi date: Fri Jan 11 10:48:34 2013 +0100 summary: grammatical fix; thanks to Alex Rudnick from docs@ files: Doc/library/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1116,7 +1116,7 @@ metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it need some way to refer +When :class:`ArgumentParser` generates help messages, it needs some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 10:50:14 2013 From: python-checkins at python.org (sandro.tosi) Date: Fri, 11 Jan 2013 10:50:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_grammatical_fi?= =?utf-8?q?x=3B_thanks_to_Alex_Rudnick_from_docs=40?= Message-ID: <3YjK7V58Z3zS56@mail.python.org> http://hg.python.org/cpython/rev/64d1cbc0f813 changeset: 81401:64d1cbc0f813 branch: 3.2 parent: 81397:5b405df8518d user: Sandro Tosi date: Fri Jan 11 10:49:00 2013 +0100 summary: grammatical fix; thanks to Alex Rudnick from docs@ files: Doc/library/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1117,7 +1117,7 @@ metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it need some way to refer +When :class:`ArgumentParser` generates help messages, it needs some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 10:50:16 2013 From: python-checkins at python.org (sandro.tosi) Date: Fri, 11 Jan 2013 10:50:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_merge_with_3=2E2?= Message-ID: <3YjK7X0dcZzS4y@mail.python.org> http://hg.python.org/cpython/rev/ad806dac3ff3 changeset: 81402:ad806dac3ff3 branch: 3.3 parent: 81398:3e884b3804b3 parent: 81401:64d1cbc0f813 user: Sandro Tosi date: Fri Jan 11 10:49:28 2013 +0100 summary: merge with 3.2 files: Doc/library/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1136,7 +1136,7 @@ metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it need some way to refer +When :class:`ArgumentParser` generates help messages, it needs some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 10:50:17 2013 From: python-checkins at python.org (sandro.tosi) Date: Fri, 11 Jan 2013 10:50:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E3?= Message-ID: <3YjK7Y3BvmzS5r@mail.python.org> http://hg.python.org/cpython/rev/6eae84170536 changeset: 81403:6eae84170536 parent: 81399:5ec8daab477a parent: 81402:ad806dac3ff3 user: Sandro Tosi date: Fri Jan 11 10:49:43 2013 +0100 summary: merge with 3.3 files: Doc/library/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1136,7 +1136,7 @@ metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it need some way to refer +When :class:`ArgumentParser` generates help messages, it needs some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:07 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE1NTM5?= =?utf-8?q?=3A_Fix_a_number_of_bugs_in_Tools/scripts/pindent=2Epy=2E?= Message-ID: <3YjLF33x8jzP94@mail.python.org> http://hg.python.org/cpython/rev/f783db4a58ba changeset: 81404:f783db4a58ba branch: 2.7 parent: 81396:66e2040c1756 user: Serhiy Storchaka date: Fri Jan 11 11:59:59 2013 +0200 summary: Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now pindent.py works with a "with" statement. pindent.py no longer produces improper indentation. pindent.py now works with continued lines broken after "class" or "def" keywords and with continuations at the start of line. Added regression tests for pindent.py. Modernized pindent.py. files: Lib/test/test_tools.py | 334 ++++++++++++++++++++++++++- Misc/NEWS | 7 + Tools/scripts/pindent.py | 166 ++++-------- 3 files changed, 399 insertions(+), 108 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -5,10 +5,15 @@ """ import os +import sys import unittest +import shutil +import subprocess import sysconfig +import tempfile +import textwrap from test import test_support -from test.script_helper import assert_python_ok +from test.script_helper import assert_python_ok, temp_dir if not sysconfig.is_python_build(): # XXX some installers do contain the tools, should we detect that @@ -17,10 +22,11 @@ basepath = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'Tools') +scriptsdir = os.path.join(basepath, 'scripts') class ReindentTests(unittest.TestCase): - script = os.path.join(basepath, 'scripts', 'reindent.py') + script = os.path.join(scriptsdir, 'reindent.py') def test_noargs(self): assert_python_ok(self.script) @@ -31,8 +37,330 @@ self.assertGreater(err, b'') +class PindentTests(unittest.TestCase): + script = os.path.join(scriptsdir, 'pindent.py') + + def assertFileEqual(self, fn1, fn2): + with open(fn1) as f1, open(fn2) as f2: + self.assertEqual(f1.readlines(), f2.readlines()) + + def pindent(self, source, *args): + proc = subprocess.Popen( + (sys.executable, self.script) + args, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + universal_newlines=True) + out, err = proc.communicate(source) + self.assertIsNone(err) + return out + + def lstriplines(self, data): + return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' + + def test_selftest(self): + with temp_dir() as directory: + data_path = os.path.join(directory, '_test.py') + with open(self.script) as f: + closed = f.read() + with open(data_path, 'w') as f: + f.write(closed) + + rc, out, err = assert_python_ok(self.script, '-d', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + backup = data_path + '~' + self.assertTrue(os.path.exists(backup)) + with open(backup) as f: + self.assertEqual(f.read(), closed) + with open(data_path) as f: + clean = f.read() + compile(clean, '_test.py', 'exec') + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + rc, out, err = assert_python_ok(self.script, '-c', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), clean) + with open(data_path) as f: + self.assertEqual(f.read(), closed) + + broken = self.lstriplines(closed) + with open(data_path, 'w') as f: + f.write(broken) + rc, out, err = assert_python_ok(self.script, '-r', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), broken) + with open(data_path) as f: + indented = f.read() + compile(indented, '_test.py', 'exec') + self.assertEqual(self.pindent(broken, '-r'), indented) + + def pindent_test(self, clean, closed): + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '4'), closed) + + def test_statements(self): + clean = textwrap.dedent("""\ + if a: + pass + + if a: + pass + else: + pass + + if a: + pass + elif: + pass + else: + pass + + while a: + break + + while a: + break + else: + pass + + for i in a: + break + + for i in a: + break + else: + pass + + try: + pass + finally: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + + with a: + pass + + class A: + pass + + def f(): + pass + """) + + closed = textwrap.dedent("""\ + if a: + pass + # end if + + if a: + pass + else: + pass + # end if + + if a: + pass + elif: + pass + else: + pass + # end if + + while a: + break + # end while + + while a: + break + else: + pass + # end while + + for i in a: + break + # end for + + for i in a: + break + else: + pass + # end for + + try: + pass + finally: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + # end try + + with a: + pass + # end with + + class A: + pass + # end class A + + def f(): + pass + # end def f + """) + self.pindent_test(clean, closed) + + def test_multilevel(self): + clean = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + else: + print 'oops!' + """) + closed = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + # end if + else: + print 'oops!' + # end if + # end def foobar + """) + self.pindent_test(clean, closed) + + def test_preserve_indents(self): + clean = textwrap.dedent("""\ + if a: + if b: + pass + """) + closed = textwrap.dedent("""\ + if a: + if b: + pass + # end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '9'), closed) + clean = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + """) + closed = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + \t# end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r'), closed) + + def test_escaped_newline(self): + clean = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + """) + closed = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + # end def f + # end class A + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + def test_empty_line(self): + clean = textwrap.dedent("""\ + if a: + + pass + """) + closed = textwrap.dedent("""\ + if a: + + pass + # end if + """) + self.pindent_test(clean, closed) + + def test_oneline(self): + clean = textwrap.dedent("""\ + if a: pass + """) + closed = textwrap.dedent("""\ + if a: pass + # end if + """) + self.pindent_test(clean, closed) + + def test_main(): - test_support.run_unittest(ReindentTests) + test_support.run_unittest(*[obj for obj in globals().values() + if isinstance(obj, type)]) if __name__ == '__main__': diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -634,6 +634,8 @@ Tests ----- +- Issue #15539: Added regression tests for Tools/scripts/pindent.py. + - Issue #15324: Fix regrtest parsing of --fromfile and --randomize options. - Issue #16618: Add more regression tests for glob. @@ -709,6 +711,11 @@ Tools/Demos ----------- +- Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now + pindent.py works with a "with" statement. pindent.py no longer produces + improper indentation. pindent.py now works with continued lines broken after + "class" or "def" keywords and with continuations at the start of line. + - Issue #13301: use ast.literal_eval() instead of eval() in Tools/i18n/msgfmt.py Patch by Serhiy Storchaka. diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -79,8 +79,9 @@ # Defaults STEPSIZE = 8 TABSIZE = 8 -EXPANDTABS = 0 +EXPANDTABS = False +import io import re import sys @@ -89,7 +90,8 @@ next['while'] = next['for'] = 'else', 'end' next['try'] = 'except', 'finally' next['except'] = 'except', 'else', 'finally', 'end' -next['else'] = next['finally'] = next['def'] = next['class'] = 'end' +next['else'] = next['finally'] = next['with'] = \ + next['def'] = next['class'] = 'end' next['end'] = () start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' @@ -105,11 +107,11 @@ self.expandtabs = expandtabs self._write = fpo.write self.kwprog = re.compile( - r'^\s*(?P[a-z]+)' - r'(\s+(?P[a-zA-Z_]\w*))?' + r'^(?:\s|\\\n)*(?P[a-z]+)' + r'((?:\s|\\\n)+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.endprog = re.compile( - r'^\s*#?\s*end\s+(?P[a-z]+)' + r'^(?:\s|\\\n)*#?\s*end\s+(?P[a-z]+)' r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.wsprog = re.compile(r'^[ \t]*') @@ -125,7 +127,7 @@ def readline(self): line = self.fpi.readline() - if line: self.lineno = self.lineno + 1 + if line: self.lineno += 1 # end if return line # end def readline @@ -143,27 +145,24 @@ line2 = self.readline() if not line2: break # end if - line = line + line2 + line += line2 # end while return line # end def getline - def putline(self, line, indent = None): - if indent is None: - self.write(line) - return + def putline(self, line, indent): + tabs, spaces = divmod(indent*self.indentsize, self.tabsize) + i = self.wsprog.match(line).end() + line = line[i:] + if line[:1] not in ('\n', '\r', ''): + line = '\t'*tabs + ' '*spaces + line # end if - tabs, spaces = divmod(indent*self.indentsize, self.tabsize) - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if - self.write('\t'*tabs + ' '*spaces + line[i:]) + self.write(line) # end def putline def reformat(self): stack = [] - while 1: + while True: line = self.getline() if not line: break # EOF # end if @@ -173,10 +172,9 @@ kw2 = m.group('kw') if not stack: self.error('unexpected end') - elif stack[-1][0] != kw2: + elif stack.pop()[0] != kw2: self.error('unmatched end') # end if - del stack[-1:] self.putline(line, len(stack)) continue # end if @@ -208,23 +206,23 @@ def delete(self): begin_counter = 0 end_counter = 0 - while 1: + while True: line = self.getline() if not line: break # EOF # end if m = self.endprog.match(line) if m: - end_counter = end_counter + 1 + end_counter += 1 continue # end if m = self.kwprog.match(line) if m: kw = m.group('kw') if kw in start: - begin_counter = begin_counter + 1 + begin_counter += 1 # end if # end if - self.putline(line) + self.write(line) # end while if begin_counter - end_counter < 0: sys.stderr.write('Warning: input contained more end tags than expected\n') @@ -234,17 +232,12 @@ # end def delete def complete(self): - self.indentsize = 1 stack = [] todo = [] - thisid = '' - current, firstkw, lastkw, topid = 0, '', '', '' - while 1: + currentws = thisid = firstkw = lastkw = topid = '' + while True: line = self.getline() - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if + i = self.wsprog.match(line).end() m = self.endprog.match(line) if m: thiskw = 'end' @@ -269,7 +262,9 @@ thiskw = '' # end if # end if - indent = len(line[:i].expandtabs(self.tabsize)) + indentws = line[:i] + indent = len(indentws.expandtabs(self.tabsize)) + current = len(currentws.expandtabs(self.tabsize)) while indent < current: if firstkw: if topid: @@ -278,11 +273,11 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = '' # end if - current, firstkw, lastkw, topid = stack[-1] - del stack[-1] + currentws, firstkw, lastkw, topid = stack.pop() + current = len(currentws.expandtabs(self.tabsize)) # end while if indent == current and firstkw: if thiskw == 'end': @@ -297,18 +292,18 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = topid = '' # end if # end if if indent > current: - stack.append((current, firstkw, lastkw, topid)) + stack.append((currentws, firstkw, lastkw, topid)) if thiskw and thiskw not in start: # error thiskw = '' # end if - current, firstkw, lastkw, topid = \ - indent, thiskw, thiskw, thisid + currentws, firstkw, lastkw, topid = \ + indentws, thiskw, thiskw, thisid # end if if thiskw: if thiskw in start: @@ -326,7 +321,6 @@ self.write(line) # end while # end def complete - # end class PythonIndenter # Simplified user interface @@ -352,76 +346,34 @@ pi.reformat() # end def reformat_filter -class StringReader: - def __init__(self, buf): - self.buf = buf - self.pos = 0 - self.len = len(self.buf) - # end def __init__ - def read(self, n = 0): - if n <= 0: - n = self.len - self.pos - else: - n = min(n, self.len - self.pos) - # end if - r = self.buf[self.pos : self.pos + n] - self.pos = self.pos + n - return r - # end def read - def readline(self): - i = self.buf.find('\n', self.pos) - return self.read(i + 1 - self.pos) - # end def readline - def readlines(self): - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - # end while - return lines - # end def readlines - # seek/tell etc. are left as an exercise for the reader -# end class StringReader - -class StringWriter: - def __init__(self): - self.buf = '' - # end def __init__ - def write(self, s): - self.buf = self.buf + s - # end def write - def getvalue(self): - return self.buf - # end def getvalue -# end class StringWriter - def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.BytesIO(source) + output = io.BytesIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.complete() return output.getvalue() # end def complete_string def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.BytesIO(source) + output = io.BytesIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.delete() return output.getvalue() # end def delete_string def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.BytesIO(source) + output = io.BytesIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.reformat() return output.getvalue() # end def reformat_string def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -429,14 +381,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def complete_file def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -444,14 +398,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def delete_file def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -459,9 +415,9 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def reformat_file @@ -474,7 +430,7 @@ -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) --e : expand TABs into spaces (defailt OFF) +-e : expand TABs into spaces (default OFF) [file] ... : files are changed in place, with backups in file~ If no files are specified or a single - is given, the program acts as a filter (reads stdin, writes stdout). @@ -517,7 +473,7 @@ elif o == '-t': tabsize = int(a) elif o == '-e': - expandtabs = 1 + expandtabs = True # end if # end for if not action: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:09 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE1NTM5?= =?utf-8?q?=3A_Fix_a_number_of_bugs_in_Tools/scripts/pindent=2Epy=2E?= Message-ID: <3YjLF52FWdzR2Y@mail.python.org> http://hg.python.org/cpython/rev/9df6b707aef9 changeset: 81405:9df6b707aef9 branch: 3.2 parent: 81397:5b405df8518d user: Serhiy Storchaka date: Fri Jan 11 12:04:23 2013 +0200 summary: Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now pindent.py works with a "with" statement. pindent.py no longer produces improper indentation. pindent.py now works with continued lines broken after "class" or "def" keywords and with continuations at the start of line. Added regression tests for pindent.py. Modernized pindent.py. files: Lib/test/test_tools.py | 326 ++++++++++++++++++++++++++- Misc/NEWS | 7 + Tools/scripts/pindent.py | 166 +++++-------- 3 files changed, 393 insertions(+), 106 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -8,10 +8,13 @@ import sys import imp import unittest +import shutil +import subprocess import sysconfig import tempfile +import textwrap from test import support -from test.script_helper import assert_python_ok +from test.script_helper import assert_python_ok, temp_dir if not sysconfig.is_python_build(): # XXX some installers do contain the tools, should we detect that @@ -35,6 +38,327 @@ self.assertGreater(err, b'') +class PindentTests(unittest.TestCase): + script = os.path.join(scriptsdir, 'pindent.py') + + def assertFileEqual(self, fn1, fn2): + with open(fn1) as f1, open(fn2) as f2: + self.assertEqual(f1.readlines(), f2.readlines()) + + def pindent(self, source, *args): + with subprocess.Popen( + (sys.executable, self.script) + args, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + universal_newlines=True) as proc: + out, err = proc.communicate(source.encode()) + self.assertIsNone(err) + return out + + def lstriplines(self, data): + return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' + + def test_selftest(self): + with temp_dir() as directory: + data_path = os.path.join(directory, '_test.py') + with open(self.script) as f: + closed = f.read() + with open(data_path, 'w') as f: + f.write(closed) + + rc, out, err = assert_python_ok(self.script, '-d', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + backup = data_path + '~' + self.assertTrue(os.path.exists(backup)) + with open(backup) as f: + self.assertEqual(f.read(), closed) + with open(data_path) as f: + clean = f.read() + compile(clean, '_test.py', 'exec') + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + rc, out, err = assert_python_ok(self.script, '-c', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), clean) + with open(data_path) as f: + self.assertEqual(f.read(), closed) + + broken = self.lstriplines(closed) + with open(data_path, 'w') as f: + f.write(broken) + rc, out, err = assert_python_ok(self.script, '-r', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), broken) + with open(data_path) as f: + indented = f.read() + compile(indented, '_test.py', 'exec') + self.assertEqual(self.pindent(broken, '-r'), indented) + + def pindent_test(self, clean, closed): + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '4'), closed) + + def test_statements(self): + clean = textwrap.dedent("""\ + if a: + pass + + if a: + pass + else: + pass + + if a: + pass + elif: + pass + else: + pass + + while a: + break + + while a: + break + else: + pass + + for i in a: + break + + for i in a: + break + else: + pass + + try: + pass + finally: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + + with a: + pass + + class A: + pass + + def f(): + pass + """) + + closed = textwrap.dedent("""\ + if a: + pass + # end if + + if a: + pass + else: + pass + # end if + + if a: + pass + elif: + pass + else: + pass + # end if + + while a: + break + # end while + + while a: + break + else: + pass + # end while + + for i in a: + break + # end for + + for i in a: + break + else: + pass + # end for + + try: + pass + finally: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + # end try + + with a: + pass + # end with + + class A: + pass + # end class A + + def f(): + pass + # end def f + """) + self.pindent_test(clean, closed) + + def test_multilevel(self): + clean = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + else: + print 'oops!' + """) + closed = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + # end if + else: + print 'oops!' + # end if + # end def foobar + """) + self.pindent_test(clean, closed) + + def test_preserve_indents(self): + clean = textwrap.dedent("""\ + if a: + if b: + pass + """) + closed = textwrap.dedent("""\ + if a: + if b: + pass + # end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '9'), closed) + clean = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + """) + closed = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + \t# end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r'), closed) + + def test_escaped_newline(self): + clean = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + """) + closed = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + # end def f + # end class A + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + def test_empty_line(self): + clean = textwrap.dedent("""\ + if a: + + pass + """) + closed = textwrap.dedent("""\ + if a: + + pass + # end if + """) + self.pindent_test(clean, closed) + + def test_oneline(self): + clean = textwrap.dedent("""\ + if a: pass + """) + closed = textwrap.dedent("""\ + if a: pass + # end if + """) + self.pindent_test(clean, closed) + + class TestSundryScripts(unittest.TestCase): # At least make sure the rest don't have syntax errors. When tests are # added for a script it should be added to the whitelist below. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -770,6 +770,8 @@ Tests ----- +- Issue #15539: Added regression tests for Tools/scripts/pindent.py. + - Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize options. @@ -951,6 +953,11 @@ Tools/Demos ----------- +- Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now + pindent.py works with a "with" statement. pindent.py no longer produces + improper indentation. pindent.py now works with continued lines broken after + "class" or "def" keywords and with continuations at the start of line. + - Issue #15378: Fix Tools/unicode/comparecodecs.py. Patch by Serhiy Storchaka. - Issue #14695: Fix missing support for starred assignments in diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -79,8 +79,9 @@ # Defaults STEPSIZE = 8 TABSIZE = 8 -EXPANDTABS = 0 +EXPANDTABS = False +import io import re import sys @@ -89,7 +90,8 @@ next['while'] = next['for'] = 'else', 'end' next['try'] = 'except', 'finally' next['except'] = 'except', 'else', 'finally', 'end' -next['else'] = next['finally'] = next['def'] = next['class'] = 'end' +next['else'] = next['finally'] = next['with'] = \ + next['def'] = next['class'] = 'end' next['end'] = () start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' @@ -105,11 +107,11 @@ self.expandtabs = expandtabs self._write = fpo.write self.kwprog = re.compile( - r'^\s*(?P[a-z]+)' - r'(\s+(?P[a-zA-Z_]\w*))?' + r'^(?:\s|\\\n)*(?P[a-z]+)' + r'((?:\s|\\\n)+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.endprog = re.compile( - r'^\s*#?\s*end\s+(?P[a-z]+)' + r'^(?:\s|\\\n)*#?\s*end\s+(?P[a-z]+)' r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.wsprog = re.compile(r'^[ \t]*') @@ -125,7 +127,7 @@ def readline(self): line = self.fpi.readline() - if line: self.lineno = self.lineno + 1 + if line: self.lineno += 1 # end if return line # end def readline @@ -143,27 +145,24 @@ line2 = self.readline() if not line2: break # end if - line = line + line2 + line += line2 # end while return line # end def getline - def putline(self, line, indent = None): - if indent is None: - self.write(line) - return + def putline(self, line, indent): + tabs, spaces = divmod(indent*self.indentsize, self.tabsize) + i = self.wsprog.match(line).end() + line = line[i:] + if line[:1] not in ('\n', '\r', ''): + line = '\t'*tabs + ' '*spaces + line # end if - tabs, spaces = divmod(indent*self.indentsize, self.tabsize) - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if - self.write('\t'*tabs + ' '*spaces + line[i:]) + self.write(line) # end def putline def reformat(self): stack = [] - while 1: + while True: line = self.getline() if not line: break # EOF # end if @@ -173,10 +172,9 @@ kw2 = m.group('kw') if not stack: self.error('unexpected end') - elif stack[-1][0] != kw2: + elif stack.pop()[0] != kw2: self.error('unmatched end') # end if - del stack[-1:] self.putline(line, len(stack)) continue # end if @@ -208,23 +206,23 @@ def delete(self): begin_counter = 0 end_counter = 0 - while 1: + while True: line = self.getline() if not line: break # EOF # end if m = self.endprog.match(line) if m: - end_counter = end_counter + 1 + end_counter += 1 continue # end if m = self.kwprog.match(line) if m: kw = m.group('kw') if kw in start: - begin_counter = begin_counter + 1 + begin_counter += 1 # end if # end if - self.putline(line) + self.write(line) # end while if begin_counter - end_counter < 0: sys.stderr.write('Warning: input contained more end tags than expected\n') @@ -234,17 +232,12 @@ # end def delete def complete(self): - self.indentsize = 1 stack = [] todo = [] - thisid = '' - current, firstkw, lastkw, topid = 0, '', '', '' - while 1: + currentws = thisid = firstkw = lastkw = topid = '' + while True: line = self.getline() - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if + i = self.wsprog.match(line).end() m = self.endprog.match(line) if m: thiskw = 'end' @@ -269,7 +262,9 @@ thiskw = '' # end if # end if - indent = len(line[:i].expandtabs(self.tabsize)) + indentws = line[:i] + indent = len(indentws.expandtabs(self.tabsize)) + current = len(currentws.expandtabs(self.tabsize)) while indent < current: if firstkw: if topid: @@ -278,11 +273,11 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = '' # end if - current, firstkw, lastkw, topid = stack[-1] - del stack[-1] + currentws, firstkw, lastkw, topid = stack.pop() + current = len(currentws.expandtabs(self.tabsize)) # end while if indent == current and firstkw: if thiskw == 'end': @@ -297,18 +292,18 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = topid = '' # end if # end if if indent > current: - stack.append((current, firstkw, lastkw, topid)) + stack.append((currentws, firstkw, lastkw, topid)) if thiskw and thiskw not in start: # error thiskw = '' # end if - current, firstkw, lastkw, topid = \ - indent, thiskw, thiskw, thisid + currentws, firstkw, lastkw, topid = \ + indentws, thiskw, thiskw, thisid # end if if thiskw: if thiskw in start: @@ -326,7 +321,6 @@ self.write(line) # end while # end def complete - # end class PythonIndenter # Simplified user interface @@ -352,76 +346,34 @@ pi.reformat() # end def reformat_filter -class StringReader: - def __init__(self, buf): - self.buf = buf - self.pos = 0 - self.len = len(self.buf) - # end def __init__ - def read(self, n = 0): - if n <= 0: - n = self.len - self.pos - else: - n = min(n, self.len - self.pos) - # end if - r = self.buf[self.pos : self.pos + n] - self.pos = self.pos + n - return r - # end def read - def readline(self): - i = self.buf.find('\n', self.pos) - return self.read(i + 1 - self.pos) - # end def readline - def readlines(self): - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - # end while - return lines - # end def readlines - # seek/tell etc. are left as an exercise for the reader -# end class StringReader - -class StringWriter: - def __init__(self): - self.buf = '' - # end def __init__ - def write(self, s): - self.buf = self.buf + s - # end def write - def getvalue(self): - return self.buf - # end def getvalue -# end class StringWriter - def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.complete() return output.getvalue() # end def complete_string def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.delete() return output.getvalue() # end def delete_string def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.reformat() return output.getvalue() # end def reformat_string def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -429,14 +381,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def complete_file def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -444,14 +398,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def delete_file def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -459,9 +415,9 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def reformat_file @@ -474,7 +430,7 @@ -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) --e : expand TABs into spaces (defailt OFF) +-e : expand TABs into spaces (default OFF) [file] ... : files are changed in place, with backups in file~ If no files are specified or a single - is given, the program acts as a filter (reads stdin, writes stdout). @@ -517,7 +473,7 @@ elif o == '-t': tabsize = int(a) elif o == '-e': - expandtabs = 1 + expandtabs = True # end if # end for if not action: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:11 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2315539=3A_Fix_a_number_of_bugs_in_Tools/scripts/pinden?= =?utf-8?b?dC5weS4=?= Message-ID: <3YjLF70XwczRxl@mail.python.org> http://hg.python.org/cpython/rev/01df1f7841b2 changeset: 81406:01df1f7841b2 branch: 3.3 parent: 81398:3e884b3804b3 parent: 81405:9df6b707aef9 user: Serhiy Storchaka date: Fri Jan 11 12:10:57 2013 +0200 summary: Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now pindent.py works with a "with" statement. pindent.py no longer produces improper indentation. pindent.py now works with continued lines broken after "class" or "def" keywords and with continuations at the start of line. Added regression tests for pindent.py. Modernized pindent.py. files: Lib/test/test_tools.py | 326 ++++++++++++++++++++++++++- Misc/NEWS | 7 + Tools/scripts/pindent.py | 166 +++++-------- 3 files changed, 393 insertions(+), 106 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -9,10 +9,13 @@ import importlib.machinery import unittest from unittest import mock +import shutil +import subprocess import sysconfig import tempfile +import textwrap from test import support -from test.script_helper import assert_python_ok +from test.script_helper import assert_python_ok, temp_dir if not sysconfig.is_python_build(): # XXX some installers do contain the tools, should we detect that @@ -36,6 +39,327 @@ self.assertGreater(err, b'') +class PindentTests(unittest.TestCase): + script = os.path.join(scriptsdir, 'pindent.py') + + def assertFileEqual(self, fn1, fn2): + with open(fn1) as f1, open(fn2) as f2: + self.assertEqual(f1.readlines(), f2.readlines()) + + def pindent(self, source, *args): + with subprocess.Popen( + (sys.executable, self.script) + args, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + universal_newlines=True) as proc: + out, err = proc.communicate(source) + self.assertIsNone(err) + return out + + def lstriplines(self, data): + return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' + + def test_selftest(self): + with temp_dir() as directory: + data_path = os.path.join(directory, '_test.py') + with open(self.script) as f: + closed = f.read() + with open(data_path, 'w') as f: + f.write(closed) + + rc, out, err = assert_python_ok(self.script, '-d', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + backup = data_path + '~' + self.assertTrue(os.path.exists(backup)) + with open(backup) as f: + self.assertEqual(f.read(), closed) + with open(data_path) as f: + clean = f.read() + compile(clean, '_test.py', 'exec') + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + rc, out, err = assert_python_ok(self.script, '-c', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), clean) + with open(data_path) as f: + self.assertEqual(f.read(), closed) + + broken = self.lstriplines(closed) + with open(data_path, 'w') as f: + f.write(broken) + rc, out, err = assert_python_ok(self.script, '-r', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), broken) + with open(data_path) as f: + indented = f.read() + compile(indented, '_test.py', 'exec') + self.assertEqual(self.pindent(broken, '-r'), indented) + + def pindent_test(self, clean, closed): + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '4'), closed) + + def test_statements(self): + clean = textwrap.dedent("""\ + if a: + pass + + if a: + pass + else: + pass + + if a: + pass + elif: + pass + else: + pass + + while a: + break + + while a: + break + else: + pass + + for i in a: + break + + for i in a: + break + else: + pass + + try: + pass + finally: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + + with a: + pass + + class A: + pass + + def f(): + pass + """) + + closed = textwrap.dedent("""\ + if a: + pass + # end if + + if a: + pass + else: + pass + # end if + + if a: + pass + elif: + pass + else: + pass + # end if + + while a: + break + # end while + + while a: + break + else: + pass + # end while + + for i in a: + break + # end for + + for i in a: + break + else: + pass + # end for + + try: + pass + finally: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + # end try + + with a: + pass + # end with + + class A: + pass + # end class A + + def f(): + pass + # end def f + """) + self.pindent_test(clean, closed) + + def test_multilevel(self): + clean = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + else: + print 'oops!' + """) + closed = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + # end if + else: + print 'oops!' + # end if + # end def foobar + """) + self.pindent_test(clean, closed) + + def test_preserve_indents(self): + clean = textwrap.dedent("""\ + if a: + if b: + pass + """) + closed = textwrap.dedent("""\ + if a: + if b: + pass + # end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '9'), closed) + clean = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + """) + closed = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + \t# end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r'), closed) + + def test_escaped_newline(self): + clean = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + """) + closed = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + # end def f + # end class A + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + def test_empty_line(self): + clean = textwrap.dedent("""\ + if a: + + pass + """) + closed = textwrap.dedent("""\ + if a: + + pass + # end if + """) + self.pindent_test(clean, closed) + + def test_oneline(self): + clean = textwrap.dedent("""\ + if a: pass + """) + closed = textwrap.dedent("""\ + if a: pass + # end if + """) + self.pindent_test(clean, closed) + + class TestSundryScripts(unittest.TestCase): # At least make sure the rest don't have syntax errors. When tests are # added for a script it should be added to the whitelist below. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -424,6 +424,8 @@ Tests ----- +- Issue #15539: Added regression tests for Tools/scripts/pindent.py. + - Issue #16925: test_configparser now works with unittest test discovery. Patch by Zachary Ware. @@ -571,6 +573,11 @@ Tools/Demos ----------- +- Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now + pindent.py works with a "with" statement. pindent.py no longer produces + improper indentation. pindent.py now works with continued lines broken after + "class" or "def" keywords and with continuations at the start of line. + - Issue #15378: Fix Tools/unicode/comparecodecs.py. Patch by Serhiy Storchaka. diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -79,8 +79,9 @@ # Defaults STEPSIZE = 8 TABSIZE = 8 -EXPANDTABS = 0 +EXPANDTABS = False +import io import re import sys @@ -89,7 +90,8 @@ next['while'] = next['for'] = 'else', 'end' next['try'] = 'except', 'finally' next['except'] = 'except', 'else', 'finally', 'end' -next['else'] = next['finally'] = next['def'] = next['class'] = 'end' +next['else'] = next['finally'] = next['with'] = \ + next['def'] = next['class'] = 'end' next['end'] = () start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' @@ -105,11 +107,11 @@ self.expandtabs = expandtabs self._write = fpo.write self.kwprog = re.compile( - r'^\s*(?P[a-z]+)' - r'(\s+(?P[a-zA-Z_]\w*))?' + r'^(?:\s|\\\n)*(?P[a-z]+)' + r'((?:\s|\\\n)+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.endprog = re.compile( - r'^\s*#?\s*end\s+(?P[a-z]+)' + r'^(?:\s|\\\n)*#?\s*end\s+(?P[a-z]+)' r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.wsprog = re.compile(r'^[ \t]*') @@ -125,7 +127,7 @@ def readline(self): line = self.fpi.readline() - if line: self.lineno = self.lineno + 1 + if line: self.lineno += 1 # end if return line # end def readline @@ -143,27 +145,24 @@ line2 = self.readline() if not line2: break # end if - line = line + line2 + line += line2 # end while return line # end def getline - def putline(self, line, indent = None): - if indent is None: - self.write(line) - return + def putline(self, line, indent): + tabs, spaces = divmod(indent*self.indentsize, self.tabsize) + i = self.wsprog.match(line).end() + line = line[i:] + if line[:1] not in ('\n', '\r', ''): + line = '\t'*tabs + ' '*spaces + line # end if - tabs, spaces = divmod(indent*self.indentsize, self.tabsize) - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if - self.write('\t'*tabs + ' '*spaces + line[i:]) + self.write(line) # end def putline def reformat(self): stack = [] - while 1: + while True: line = self.getline() if not line: break # EOF # end if @@ -173,10 +172,9 @@ kw2 = m.group('kw') if not stack: self.error('unexpected end') - elif stack[-1][0] != kw2: + elif stack.pop()[0] != kw2: self.error('unmatched end') # end if - del stack[-1:] self.putline(line, len(stack)) continue # end if @@ -208,23 +206,23 @@ def delete(self): begin_counter = 0 end_counter = 0 - while 1: + while True: line = self.getline() if not line: break # EOF # end if m = self.endprog.match(line) if m: - end_counter = end_counter + 1 + end_counter += 1 continue # end if m = self.kwprog.match(line) if m: kw = m.group('kw') if kw in start: - begin_counter = begin_counter + 1 + begin_counter += 1 # end if # end if - self.putline(line) + self.write(line) # end while if begin_counter - end_counter < 0: sys.stderr.write('Warning: input contained more end tags than expected\n') @@ -234,17 +232,12 @@ # end def delete def complete(self): - self.indentsize = 1 stack = [] todo = [] - thisid = '' - current, firstkw, lastkw, topid = 0, '', '', '' - while 1: + currentws = thisid = firstkw = lastkw = topid = '' + while True: line = self.getline() - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if + i = self.wsprog.match(line).end() m = self.endprog.match(line) if m: thiskw = 'end' @@ -269,7 +262,9 @@ thiskw = '' # end if # end if - indent = len(line[:i].expandtabs(self.tabsize)) + indentws = line[:i] + indent = len(indentws.expandtabs(self.tabsize)) + current = len(currentws.expandtabs(self.tabsize)) while indent < current: if firstkw: if topid: @@ -278,11 +273,11 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = '' # end if - current, firstkw, lastkw, topid = stack[-1] - del stack[-1] + currentws, firstkw, lastkw, topid = stack.pop() + current = len(currentws.expandtabs(self.tabsize)) # end while if indent == current and firstkw: if thiskw == 'end': @@ -297,18 +292,18 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = topid = '' # end if # end if if indent > current: - stack.append((current, firstkw, lastkw, topid)) + stack.append((currentws, firstkw, lastkw, topid)) if thiskw and thiskw not in start: # error thiskw = '' # end if - current, firstkw, lastkw, topid = \ - indent, thiskw, thiskw, thisid + currentws, firstkw, lastkw, topid = \ + indentws, thiskw, thiskw, thisid # end if if thiskw: if thiskw in start: @@ -326,7 +321,6 @@ self.write(line) # end while # end def complete - # end class PythonIndenter # Simplified user interface @@ -352,76 +346,34 @@ pi.reformat() # end def reformat_filter -class StringReader: - def __init__(self, buf): - self.buf = buf - self.pos = 0 - self.len = len(self.buf) - # end def __init__ - def read(self, n = 0): - if n <= 0: - n = self.len - self.pos - else: - n = min(n, self.len - self.pos) - # end if - r = self.buf[self.pos : self.pos + n] - self.pos = self.pos + n - return r - # end def read - def readline(self): - i = self.buf.find('\n', self.pos) - return self.read(i + 1 - self.pos) - # end def readline - def readlines(self): - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - # end while - return lines - # end def readlines - # seek/tell etc. are left as an exercise for the reader -# end class StringReader - -class StringWriter: - def __init__(self): - self.buf = '' - # end def __init__ - def write(self, s): - self.buf = self.buf + s - # end def write - def getvalue(self): - return self.buf - # end def getvalue -# end class StringWriter - def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.complete() return output.getvalue() # end def complete_string def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.delete() return output.getvalue() # end def delete_string def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.reformat() return output.getvalue() # end def reformat_string def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -429,14 +381,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def complete_file def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -444,14 +398,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def delete_file def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -459,9 +415,9 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def reformat_file @@ -474,7 +430,7 @@ -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) --e : expand TABs into spaces (defailt OFF) +-e : expand TABs into spaces (default OFF) [file] ... : files are changed in place, with backups in file~ If no files are specified or a single - is given, the program acts as a filter (reads stdin, writes stdout). @@ -517,7 +473,7 @@ elif o == '-t': tabsize = int(a) elif o == '-e': - expandtabs = 1 + expandtabs = True # end if # end for if not action: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2315539=3A_Fix_a_number_of_bugs_in_Tools/scripts/?= =?utf-8?q?pindent=2Epy=2E?= Message-ID: <3YjLF866ftzS6g@mail.python.org> http://hg.python.org/cpython/rev/8452c23139c6 changeset: 81407:8452c23139c6 parent: 81399:5ec8daab477a parent: 81406:01df1f7841b2 user: Serhiy Storchaka date: Fri Jan 11 12:12:32 2013 +0200 summary: Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now pindent.py works with a "with" statement. pindent.py no longer produces improper indentation. pindent.py now works with continued lines broken after "class" or "def" keywords and with continuations at the start of line. Added regression tests for pindent.py. Modernized pindent.py. files: Lib/test/test_tools.py | 326 ++++++++++++++++++++++++++- Misc/NEWS | 7 + Tools/scripts/pindent.py | 166 +++++-------- 3 files changed, 393 insertions(+), 106 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -9,10 +9,13 @@ import importlib.machinery import unittest from unittest import mock +import shutil +import subprocess import sysconfig import tempfile +import textwrap from test import support -from test.script_helper import assert_python_ok +from test.script_helper import assert_python_ok, temp_dir if not sysconfig.is_python_build(): # XXX some installers do contain the tools, should we detect that @@ -36,6 +39,327 @@ self.assertGreater(err, b'') +class PindentTests(unittest.TestCase): + script = os.path.join(scriptsdir, 'pindent.py') + + def assertFileEqual(self, fn1, fn2): + with open(fn1) as f1, open(fn2) as f2: + self.assertEqual(f1.readlines(), f2.readlines()) + + def pindent(self, source, *args): + with subprocess.Popen( + (sys.executable, self.script) + args, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + universal_newlines=True) as proc: + out, err = proc.communicate(source) + self.assertIsNone(err) + return out + + def lstriplines(self, data): + return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' + + def test_selftest(self): + with temp_dir() as directory: + data_path = os.path.join(directory, '_test.py') + with open(self.script) as f: + closed = f.read() + with open(data_path, 'w') as f: + f.write(closed) + + rc, out, err = assert_python_ok(self.script, '-d', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + backup = data_path + '~' + self.assertTrue(os.path.exists(backup)) + with open(backup) as f: + self.assertEqual(f.read(), closed) + with open(data_path) as f: + clean = f.read() + compile(clean, '_test.py', 'exec') + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + rc, out, err = assert_python_ok(self.script, '-c', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), clean) + with open(data_path) as f: + self.assertEqual(f.read(), closed) + + broken = self.lstriplines(closed) + with open(data_path, 'w') as f: + f.write(broken) + rc, out, err = assert_python_ok(self.script, '-r', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), broken) + with open(data_path) as f: + indented = f.read() + compile(indented, '_test.py', 'exec') + self.assertEqual(self.pindent(broken, '-r'), indented) + + def pindent_test(self, clean, closed): + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '4'), closed) + + def test_statements(self): + clean = textwrap.dedent("""\ + if a: + pass + + if a: + pass + else: + pass + + if a: + pass + elif: + pass + else: + pass + + while a: + break + + while a: + break + else: + pass + + for i in a: + break + + for i in a: + break + else: + pass + + try: + pass + finally: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + + with a: + pass + + class A: + pass + + def f(): + pass + """) + + closed = textwrap.dedent("""\ + if a: + pass + # end if + + if a: + pass + else: + pass + # end if + + if a: + pass + elif: + pass + else: + pass + # end if + + while a: + break + # end while + + while a: + break + else: + pass + # end while + + for i in a: + break + # end for + + for i in a: + break + else: + pass + # end for + + try: + pass + finally: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + # end try + + with a: + pass + # end with + + class A: + pass + # end class A + + def f(): + pass + # end def f + """) + self.pindent_test(clean, closed) + + def test_multilevel(self): + clean = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + else: + print 'oops!' + """) + closed = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + # end if + else: + print 'oops!' + # end if + # end def foobar + """) + self.pindent_test(clean, closed) + + def test_preserve_indents(self): + clean = textwrap.dedent("""\ + if a: + if b: + pass + """) + closed = textwrap.dedent("""\ + if a: + if b: + pass + # end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '9'), closed) + clean = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + """) + closed = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + \t# end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r'), closed) + + def test_escaped_newline(self): + clean = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + """) + closed = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + # end def f + # end class A + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + def test_empty_line(self): + clean = textwrap.dedent("""\ + if a: + + pass + """) + closed = textwrap.dedent("""\ + if a: + + pass + # end if + """) + self.pindent_test(clean, closed) + + def test_oneline(self): + clean = textwrap.dedent("""\ + if a: pass + """) + closed = textwrap.dedent("""\ + if a: pass + # end if + """) + self.pindent_test(clean, closed) + + class TestSundryScripts(unittest.TestCase): # At least make sure the rest don't have syntax errors. When tests are # added for a script it should be added to the whitelist below. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -621,6 +621,8 @@ Tests ----- +- Issue #15539: Added regression tests for Tools/scripts/pindent.py. + - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. - Issue #16925: test_configparser now works with unittest test discovery. @@ -777,6 +779,11 @@ Tools/Demos ----------- +- Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now + pindent.py works with a "with" statement. pindent.py no longer produces + improper indentation. pindent.py now works with continued lines broken after + "class" or "def" keywords and with continuations at the start of line. + - Issue #11797: Add a 2to3 fixer that maps reload() to imp.reload(). - Issue #10966: Remove the concept of unexpected skipped tests. diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -79,8 +79,9 @@ # Defaults STEPSIZE = 8 TABSIZE = 8 -EXPANDTABS = 0 +EXPANDTABS = False +import io import re import sys @@ -89,7 +90,8 @@ next['while'] = next['for'] = 'else', 'end' next['try'] = 'except', 'finally' next['except'] = 'except', 'else', 'finally', 'end' -next['else'] = next['finally'] = next['def'] = next['class'] = 'end' +next['else'] = next['finally'] = next['with'] = \ + next['def'] = next['class'] = 'end' next['end'] = () start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' @@ -105,11 +107,11 @@ self.expandtabs = expandtabs self._write = fpo.write self.kwprog = re.compile( - r'^\s*(?P[a-z]+)' - r'(\s+(?P[a-zA-Z_]\w*))?' + r'^(?:\s|\\\n)*(?P[a-z]+)' + r'((?:\s|\\\n)+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.endprog = re.compile( - r'^\s*#?\s*end\s+(?P[a-z]+)' + r'^(?:\s|\\\n)*#?\s*end\s+(?P[a-z]+)' r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.wsprog = re.compile(r'^[ \t]*') @@ -125,7 +127,7 @@ def readline(self): line = self.fpi.readline() - if line: self.lineno = self.lineno + 1 + if line: self.lineno += 1 # end if return line # end def readline @@ -143,27 +145,24 @@ line2 = self.readline() if not line2: break # end if - line = line + line2 + line += line2 # end while return line # end def getline - def putline(self, line, indent = None): - if indent is None: - self.write(line) - return + def putline(self, line, indent): + tabs, spaces = divmod(indent*self.indentsize, self.tabsize) + i = self.wsprog.match(line).end() + line = line[i:] + if line[:1] not in ('\n', '\r', ''): + line = '\t'*tabs + ' '*spaces + line # end if - tabs, spaces = divmod(indent*self.indentsize, self.tabsize) - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if - self.write('\t'*tabs + ' '*spaces + line[i:]) + self.write(line) # end def putline def reformat(self): stack = [] - while 1: + while True: line = self.getline() if not line: break # EOF # end if @@ -173,10 +172,9 @@ kw2 = m.group('kw') if not stack: self.error('unexpected end') - elif stack[-1][0] != kw2: + elif stack.pop()[0] != kw2: self.error('unmatched end') # end if - del stack[-1:] self.putline(line, len(stack)) continue # end if @@ -208,23 +206,23 @@ def delete(self): begin_counter = 0 end_counter = 0 - while 1: + while True: line = self.getline() if not line: break # EOF # end if m = self.endprog.match(line) if m: - end_counter = end_counter + 1 + end_counter += 1 continue # end if m = self.kwprog.match(line) if m: kw = m.group('kw') if kw in start: - begin_counter = begin_counter + 1 + begin_counter += 1 # end if # end if - self.putline(line) + self.write(line) # end while if begin_counter - end_counter < 0: sys.stderr.write('Warning: input contained more end tags than expected\n') @@ -234,17 +232,12 @@ # end def delete def complete(self): - self.indentsize = 1 stack = [] todo = [] - thisid = '' - current, firstkw, lastkw, topid = 0, '', '', '' - while 1: + currentws = thisid = firstkw = lastkw = topid = '' + while True: line = self.getline() - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if + i = self.wsprog.match(line).end() m = self.endprog.match(line) if m: thiskw = 'end' @@ -269,7 +262,9 @@ thiskw = '' # end if # end if - indent = len(line[:i].expandtabs(self.tabsize)) + indentws = line[:i] + indent = len(indentws.expandtabs(self.tabsize)) + current = len(currentws.expandtabs(self.tabsize)) while indent < current: if firstkw: if topid: @@ -278,11 +273,11 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = '' # end if - current, firstkw, lastkw, topid = stack[-1] - del stack[-1] + currentws, firstkw, lastkw, topid = stack.pop() + current = len(currentws.expandtabs(self.tabsize)) # end while if indent == current and firstkw: if thiskw == 'end': @@ -297,18 +292,18 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = topid = '' # end if # end if if indent > current: - stack.append((current, firstkw, lastkw, topid)) + stack.append((currentws, firstkw, lastkw, topid)) if thiskw and thiskw not in start: # error thiskw = '' # end if - current, firstkw, lastkw, topid = \ - indent, thiskw, thiskw, thisid + currentws, firstkw, lastkw, topid = \ + indentws, thiskw, thiskw, thisid # end if if thiskw: if thiskw in start: @@ -326,7 +321,6 @@ self.write(line) # end while # end def complete - # end class PythonIndenter # Simplified user interface @@ -352,76 +346,34 @@ pi.reformat() # end def reformat_filter -class StringReader: - def __init__(self, buf): - self.buf = buf - self.pos = 0 - self.len = len(self.buf) - # end def __init__ - def read(self, n = 0): - if n <= 0: - n = self.len - self.pos - else: - n = min(n, self.len - self.pos) - # end if - r = self.buf[self.pos : self.pos + n] - self.pos = self.pos + n - return r - # end def read - def readline(self): - i = self.buf.find('\n', self.pos) - return self.read(i + 1 - self.pos) - # end def readline - def readlines(self): - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - # end while - return lines - # end def readlines - # seek/tell etc. are left as an exercise for the reader -# end class StringReader - -class StringWriter: - def __init__(self): - self.buf = '' - # end def __init__ - def write(self, s): - self.buf = self.buf + s - # end def write - def getvalue(self): - return self.buf - # end def getvalue -# end class StringWriter - def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.complete() return output.getvalue() # end def complete_string def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.delete() return output.getvalue() # end def delete_string def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.reformat() return output.getvalue() # end def reformat_string def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -429,14 +381,16 @@ try: os.rename(filename, filename + '~') except OSError: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def complete_file def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -444,14 +398,16 @@ try: os.rename(filename, filename + '~') except OSError: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def delete_file def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -459,9 +415,9 @@ try: os.rename(filename, filename + '~') except OSError: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def reformat_file @@ -474,7 +430,7 @@ -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) --e : expand TABs into spaces (defailt OFF) +-e : expand TABs into spaces (default OFF) [file] ... : files are changed in place, with backups in file~ If no files are specified or a single - is given, the program acts as a filter (reads stdin, writes stdout). @@ -517,7 +473,7 @@ elif o == '-t': tabsize = int(a) elif o == '-e': - expandtabs = 1 + expandtabs = True # end if # end for if not action: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:14 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YjLFB1hW7zR5K@mail.python.org> http://hg.python.org/cpython/rev/4a86efa5a97f changeset: 81408:4a86efa5a97f branch: 2.7 parent: 81404:f783db4a58ba parent: 81400:7555399134af user: Serhiy Storchaka date: Fri Jan 11 12:27:43 2013 +0200 summary: Merge heads files: Doc/library/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1116,7 +1116,7 @@ metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it need some way to refer +When :class:`ArgumentParser` generates help messages, it needs some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:15 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMik6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YjLFC4MGtzRxl@mail.python.org> http://hg.python.org/cpython/rev/973f3a253ab0 changeset: 81409:973f3a253ab0 branch: 3.2 parent: 81405:9df6b707aef9 parent: 81401:64d1cbc0f813 user: Serhiy Storchaka date: Fri Jan 11 12:28:53 2013 +0200 summary: Merge heads files: Doc/library/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1117,7 +1117,7 @@ metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it need some way to refer +When :class:`ArgumentParser` generates help messages, it needs some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:17 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YjLFF2TjvzS6J@mail.python.org> http://hg.python.org/cpython/rev/be350b08fc9c changeset: 81410:be350b08fc9c branch: 3.3 parent: 81402:ad806dac3ff3 parent: 81406:01df1f7841b2 user: Serhiy Storchaka date: Fri Jan 11 12:32:37 2013 +0200 summary: Merge heads files: Lib/test/test_tools.py | 326 ++++++++++++++++++++++++++- Misc/NEWS | 7 + Tools/scripts/pindent.py | 166 +++++-------- 3 files changed, 393 insertions(+), 106 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -9,10 +9,13 @@ import importlib.machinery import unittest from unittest import mock +import shutil +import subprocess import sysconfig import tempfile +import textwrap from test import support -from test.script_helper import assert_python_ok +from test.script_helper import assert_python_ok, temp_dir if not sysconfig.is_python_build(): # XXX some installers do contain the tools, should we detect that @@ -36,6 +39,327 @@ self.assertGreater(err, b'') +class PindentTests(unittest.TestCase): + script = os.path.join(scriptsdir, 'pindent.py') + + def assertFileEqual(self, fn1, fn2): + with open(fn1) as f1, open(fn2) as f2: + self.assertEqual(f1.readlines(), f2.readlines()) + + def pindent(self, source, *args): + with subprocess.Popen( + (sys.executable, self.script) + args, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + universal_newlines=True) as proc: + out, err = proc.communicate(source) + self.assertIsNone(err) + return out + + def lstriplines(self, data): + return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' + + def test_selftest(self): + with temp_dir() as directory: + data_path = os.path.join(directory, '_test.py') + with open(self.script) as f: + closed = f.read() + with open(data_path, 'w') as f: + f.write(closed) + + rc, out, err = assert_python_ok(self.script, '-d', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + backup = data_path + '~' + self.assertTrue(os.path.exists(backup)) + with open(backup) as f: + self.assertEqual(f.read(), closed) + with open(data_path) as f: + clean = f.read() + compile(clean, '_test.py', 'exec') + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + rc, out, err = assert_python_ok(self.script, '-c', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), clean) + with open(data_path) as f: + self.assertEqual(f.read(), closed) + + broken = self.lstriplines(closed) + with open(data_path, 'w') as f: + f.write(broken) + rc, out, err = assert_python_ok(self.script, '-r', data_path) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + with open(backup) as f: + self.assertEqual(f.read(), broken) + with open(data_path) as f: + indented = f.read() + compile(indented, '_test.py', 'exec') + self.assertEqual(self.pindent(broken, '-r'), indented) + + def pindent_test(self, clean, closed): + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '4'), closed) + + def test_statements(self): + clean = textwrap.dedent("""\ + if a: + pass + + if a: + pass + else: + pass + + if a: + pass + elif: + pass + else: + pass + + while a: + break + + while a: + break + else: + pass + + for i in a: + break + + for i in a: + break + else: + pass + + try: + pass + finally: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + + with a: + pass + + class A: + pass + + def f(): + pass + """) + + closed = textwrap.dedent("""\ + if a: + pass + # end if + + if a: + pass + else: + pass + # end if + + if a: + pass + elif: + pass + else: + pass + # end if + + while a: + break + # end while + + while a: + break + else: + pass + # end while + + for i in a: + break + # end for + + for i in a: + break + else: + pass + # end for + + try: + pass + finally: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + else: + pass + # end try + + try: + pass + except TypeError: + pass + except ValueError: + pass + finally: + pass + # end try + + with a: + pass + # end with + + class A: + pass + # end class A + + def f(): + pass + # end def f + """) + self.pindent_test(clean, closed) + + def test_multilevel(self): + clean = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + else: + print 'oops!' + """) + closed = textwrap.dedent("""\ + def foobar(a, b): + if a == b: + a = a+1 + elif a < b: + b = b-1 + if b > a: a = a-1 + # end if + else: + print 'oops!' + # end if + # end def foobar + """) + self.pindent_test(clean, closed) + + def test_preserve_indents(self): + clean = textwrap.dedent("""\ + if a: + if b: + pass + """) + closed = textwrap.dedent("""\ + if a: + if b: + pass + # end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '9'), closed) + clean = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + """) + closed = textwrap.dedent("""\ + if a: + \tif b: + \t\tpass + \t# end if + # end if + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + broken = self.lstriplines(closed) + self.assertEqual(self.pindent(broken, '-r'), closed) + + def test_escaped_newline(self): + clean = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + """) + closed = textwrap.dedent("""\ + class\\ + \\ + A: + def\ + \\ + f: + pass + # end def f + # end class A + """) + self.assertEqual(self.pindent(clean, '-c'), closed) + self.assertEqual(self.pindent(closed, '-d'), clean) + + def test_empty_line(self): + clean = textwrap.dedent("""\ + if a: + + pass + """) + closed = textwrap.dedent("""\ + if a: + + pass + # end if + """) + self.pindent_test(clean, closed) + + def test_oneline(self): + clean = textwrap.dedent("""\ + if a: pass + """) + closed = textwrap.dedent("""\ + if a: pass + # end if + """) + self.pindent_test(clean, closed) + + class TestSundryScripts(unittest.TestCase): # At least make sure the rest don't have syntax errors. When tests are # added for a script it should be added to the whitelist below. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -424,6 +424,8 @@ Tests ----- +- Issue #15539: Added regression tests for Tools/scripts/pindent.py. + - Issue #16925: test_configparser now works with unittest test discovery. Patch by Zachary Ware. @@ -571,6 +573,11 @@ Tools/Demos ----------- +- Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now + pindent.py works with a "with" statement. pindent.py no longer produces + improper indentation. pindent.py now works with continued lines broken after + "class" or "def" keywords and with continuations at the start of line. + - Issue #15378: Fix Tools/unicode/comparecodecs.py. Patch by Serhiy Storchaka. diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -79,8 +79,9 @@ # Defaults STEPSIZE = 8 TABSIZE = 8 -EXPANDTABS = 0 +EXPANDTABS = False +import io import re import sys @@ -89,7 +90,8 @@ next['while'] = next['for'] = 'else', 'end' next['try'] = 'except', 'finally' next['except'] = 'except', 'else', 'finally', 'end' -next['else'] = next['finally'] = next['def'] = next['class'] = 'end' +next['else'] = next['finally'] = next['with'] = \ + next['def'] = next['class'] = 'end' next['end'] = () start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' @@ -105,11 +107,11 @@ self.expandtabs = expandtabs self._write = fpo.write self.kwprog = re.compile( - r'^\s*(?P[a-z]+)' - r'(\s+(?P[a-zA-Z_]\w*))?' + r'^(?:\s|\\\n)*(?P[a-z]+)' + r'((?:\s|\\\n)+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.endprog = re.compile( - r'^\s*#?\s*end\s+(?P[a-z]+)' + r'^(?:\s|\\\n)*#?\s*end\s+(?P[a-z]+)' r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.wsprog = re.compile(r'^[ \t]*') @@ -125,7 +127,7 @@ def readline(self): line = self.fpi.readline() - if line: self.lineno = self.lineno + 1 + if line: self.lineno += 1 # end if return line # end def readline @@ -143,27 +145,24 @@ line2 = self.readline() if not line2: break # end if - line = line + line2 + line += line2 # end while return line # end def getline - def putline(self, line, indent = None): - if indent is None: - self.write(line) - return + def putline(self, line, indent): + tabs, spaces = divmod(indent*self.indentsize, self.tabsize) + i = self.wsprog.match(line).end() + line = line[i:] + if line[:1] not in ('\n', '\r', ''): + line = '\t'*tabs + ' '*spaces + line # end if - tabs, spaces = divmod(indent*self.indentsize, self.tabsize) - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if - self.write('\t'*tabs + ' '*spaces + line[i:]) + self.write(line) # end def putline def reformat(self): stack = [] - while 1: + while True: line = self.getline() if not line: break # EOF # end if @@ -173,10 +172,9 @@ kw2 = m.group('kw') if not stack: self.error('unexpected end') - elif stack[-1][0] != kw2: + elif stack.pop()[0] != kw2: self.error('unmatched end') # end if - del stack[-1:] self.putline(line, len(stack)) continue # end if @@ -208,23 +206,23 @@ def delete(self): begin_counter = 0 end_counter = 0 - while 1: + while True: line = self.getline() if not line: break # EOF # end if m = self.endprog.match(line) if m: - end_counter = end_counter + 1 + end_counter += 1 continue # end if m = self.kwprog.match(line) if m: kw = m.group('kw') if kw in start: - begin_counter = begin_counter + 1 + begin_counter += 1 # end if # end if - self.putline(line) + self.write(line) # end while if begin_counter - end_counter < 0: sys.stderr.write('Warning: input contained more end tags than expected\n') @@ -234,17 +232,12 @@ # end def delete def complete(self): - self.indentsize = 1 stack = [] todo = [] - thisid = '' - current, firstkw, lastkw, topid = 0, '', '', '' - while 1: + currentws = thisid = firstkw = lastkw = topid = '' + while True: line = self.getline() - i = 0 - m = self.wsprog.match(line) - if m: i = m.end() - # end if + i = self.wsprog.match(line).end() m = self.endprog.match(line) if m: thiskw = 'end' @@ -269,7 +262,9 @@ thiskw = '' # end if # end if - indent = len(line[:i].expandtabs(self.tabsize)) + indentws = line[:i] + indent = len(indentws.expandtabs(self.tabsize)) + current = len(currentws.expandtabs(self.tabsize)) while indent < current: if firstkw: if topid: @@ -278,11 +273,11 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = '' # end if - current, firstkw, lastkw, topid = stack[-1] - del stack[-1] + currentws, firstkw, lastkw, topid = stack.pop() + current = len(currentws.expandtabs(self.tabsize)) # end while if indent == current and firstkw: if thiskw == 'end': @@ -297,18 +292,18 @@ else: s = '# end %s\n' % firstkw # end if - self.putline(s, current) + self.write(currentws + s) firstkw = lastkw = topid = '' # end if # end if if indent > current: - stack.append((current, firstkw, lastkw, topid)) + stack.append((currentws, firstkw, lastkw, topid)) if thiskw and thiskw not in start: # error thiskw = '' # end if - current, firstkw, lastkw, topid = \ - indent, thiskw, thiskw, thisid + currentws, firstkw, lastkw, topid = \ + indentws, thiskw, thiskw, thisid # end if if thiskw: if thiskw in start: @@ -326,7 +321,6 @@ self.write(line) # end while # end def complete - # end class PythonIndenter # Simplified user interface @@ -352,76 +346,34 @@ pi.reformat() # end def reformat_filter -class StringReader: - def __init__(self, buf): - self.buf = buf - self.pos = 0 - self.len = len(self.buf) - # end def __init__ - def read(self, n = 0): - if n <= 0: - n = self.len - self.pos - else: - n = min(n, self.len - self.pos) - # end if - r = self.buf[self.pos : self.pos + n] - self.pos = self.pos + n - return r - # end def read - def readline(self): - i = self.buf.find('\n', self.pos) - return self.read(i + 1 - self.pos) - # end def readline - def readlines(self): - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - # end while - return lines - # end def readlines - # seek/tell etc. are left as an exercise for the reader -# end class StringReader - -class StringWriter: - def __init__(self): - self.buf = '' - # end def __init__ - def write(self, s): - self.buf = self.buf + s - # end def write - def getvalue(self): - return self.buf - # end def getvalue -# end class StringWriter - def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.complete() return output.getvalue() # end def complete_string def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.delete() return output.getvalue() # end def delete_string def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = StringReader(source) - output = StringWriter() + input = io.StringIO(source) + output = io.StringIO() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.reformat() return output.getvalue() # end def reformat_string def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -429,14 +381,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def complete_file def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -444,14 +398,16 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def delete_file def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - source = open(filename, 'r').read() + with open(filename, 'r') as f: + source = f.read() + # end with result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if @@ -459,9 +415,9 @@ try: os.rename(filename, filename + '~') except os.error: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def reformat_file @@ -474,7 +430,7 @@ -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) --e : expand TABs into spaces (defailt OFF) +-e : expand TABs into spaces (default OFF) [file] ... : files are changed in place, with backups in file~ If no files are specified or a single - is given, the program acts as a filter (reads stdin, writes stdout). @@ -517,7 +473,7 @@ elif o == '-t': tabsize = int(a) elif o == '-e': - expandtabs = 1 + expandtabs = True # end if # end for if not action: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:18 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:18 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge_heads?= Message-ID: <3YjLFG6CldzS6d@mail.python.org> http://hg.python.org/cpython/rev/479da8b0e36d changeset: 81411:479da8b0e36d parent: 81407:8452c23139c6 parent: 81403:6eae84170536 user: Serhiy Storchaka date: Fri Jan 11 12:33:10 2013 +0200 summary: Merge heads files: Doc/library/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1136,7 +1136,7 @@ metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it need some way to refer +When :class:`ArgumentParser` generates help messages, it needs some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:20 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:20 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null_merge?= Message-ID: <3YjLFJ3wgpzS6T@mail.python.org> http://hg.python.org/cpython/rev/086c6e8d0a24 changeset: 81412:086c6e8d0a24 branch: 3.3 parent: 81410:be350b08fc9c parent: 81409:973f3a253ab0 user: Serhiy Storchaka date: Fri Jan 11 12:34:21 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 11:40:21 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 11:40:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3YjLFK6QbGzS21@mail.python.org> http://hg.python.org/cpython/rev/59d9d970b2d0 changeset: 81413:59d9d970b2d0 parent: 81411:479da8b0e36d parent: 81412:086c6e8d0a24 user: Serhiy Storchaka date: Fri Jan 11 12:34:48 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 12:41:02 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 12:41:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_Add_a_paragraph_about_che?= =?utf-8?q?cking_for_refleaks=2E__Initial_patch_by_Daniel_Shahaf=2E?= Message-ID: <3YjMbL0mThzS41@mail.python.org> http://hg.python.org/devguide/rev/de93193d7a33 changeset: 590:de93193d7a33 user: Ezio Melotti date: Fri Jan 11 13:40:53 2013 +0200 summary: Add a paragraph about checking for refleaks. Initial patch by Daniel Shahaf. files: committing.rst | 1 + runtests.rst | 5 +++++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/committing.rst b/committing.rst --- a/committing.rst +++ b/committing.rst @@ -35,6 +35,7 @@ * Has ``configure`` been regenerated, if necessary? * Has ``pyconfig.h.in`` been regenerated, if necessary? * Has the test suite been run? +* Are there any reference leaks? Note that the automated patch check can't actually *answer* all of these questions, and even if it could, it still wouldn't know whether or not diff --git a/runtests.rst b/runtests.rst --- a/runtests.rst +++ b/runtests.rst @@ -71,6 +71,11 @@ The ``-uall`` flag allows the use of all available resources so as to not skip tests requiring, e.g., Internet access. +To check for reference leaks (only needed if you modified C code), use the +``-R`` flag. For example, ``-R 3:2`` will first run the test 3 times to settle +down the reference count, and then run it 2 more times to verify if there are +any leaks. + You can also execute the ``Tools/scripts/run_tests.py`` script as found in a CPython checkout. The script tries to balance speed with thoroughness. But if you want the most thorough tests you should use the strenuous approach shown -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Fri Jan 11 13:12:55 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 13:12:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Add_a_note_abo?= =?utf-8?q?ut_checking_refleaks_to_patchcheck=2E?= Message-ID: <3YjNJ71v55zP57@mail.python.org> http://hg.python.org/cpython/rev/1cfe0f50fd0c changeset: 81414:1cfe0f50fd0c branch: 2.7 parent: 81408:4a86efa5a97f user: Ezio Melotti date: Fri Jan 11 14:07:47 2013 +0200 summary: Add a note about checking refleaks to patchcheck. files: Tools/scripts/patchcheck.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -174,8 +174,9 @@ # Test suite run and passed. if python_files or c_files: + end = " and check for refleaks?" if c_files else "?" print - print "Did you run the test suite?" + print "Did you run the test suite" + end if __name__ == '__main__': -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 13:12:56 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 13:12:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Add_a_note_abo?= =?utf-8?q?ut_checking_refleaks_to_patchcheck=2E?= Message-ID: <3YjNJ84QyfzS6v@mail.python.org> http://hg.python.org/cpython/rev/0ed68fb13b3a changeset: 81415:0ed68fb13b3a branch: 3.2 parent: 81409:973f3a253ab0 user: Ezio Melotti date: Fri Jan 11 14:07:47 2013 +0200 summary: Add a note about checking refleaks to patchcheck. files: Tools/scripts/patchcheck.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -170,8 +170,9 @@ # Test suite run and passed. if python_files or c_files: + end = " and check for refleaks?" if c_files else "?" print() - print("Did you run the test suite?") + print("Did you run the test suite" + end) if __name__ == '__main__': -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 13:12:58 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 13:12:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge_patchcheck_changes_with_3=2E2?= Message-ID: <3YjNJB0Bq8zS6x@mail.python.org> http://hg.python.org/cpython/rev/d3374d393975 changeset: 81416:d3374d393975 branch: 3.3 parent: 81412:086c6e8d0a24 parent: 81415:0ed68fb13b3a user: Ezio Melotti date: Fri Jan 11 14:12:20 2013 +0200 summary: Merge patchcheck changes with 3.2 files: Tools/scripts/patchcheck.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -173,8 +173,9 @@ # Test suite run and passed. if python_files or c_files: + end = " and check for refleaks?" if c_files else "?" print() - print("Did you run the test suite?") + print("Did you run the test suite" + end) if __name__ == '__main__': -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 13:12:59 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 11 Jan 2013 13:12:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_patchcheck_changes_with_3=2E3?= Message-ID: <3YjNJC3LwFzS6x@mail.python.org> http://hg.python.org/cpython/rev/f9feb11130e7 changeset: 81417:f9feb11130e7 parent: 81413:59d9d970b2d0 parent: 81416:d3374d393975 user: Ezio Melotti date: Fri Jan 11 14:12:42 2013 +0200 summary: Merge patchcheck changes with 3.3 files: Tools/scripts/patchcheck.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -173,8 +173,9 @@ # Test suite run and passed. if python_files or c_files: + end = " and check for refleaks?" if c_files else "?" print() - print("Did you run the test suite?") + print("Did you run the test suite" + end) if __name__ == '__main__': -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 14:31:30 2013 From: python-checkins at python.org (tim.golden) Date: Fri, 11 Jan 2013 14:31:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_=2316921_Since_Win9x_is_no?= =?utf-8?q?_longer_supported=2C_CREATE=5FNEW=5FCONSOLE_is?= Message-ID: <3YjQ2p0KW5zS2B@mail.python.org> http://hg.python.org/cpython/rev/1aac333f320a changeset: 81418:1aac333f320a user: Tim Golden date: Fri Jan 11 13:28:31 2013 +0000 summary: #16921 Since Win9x is no longer supported, CREATE_NEW_CONSOLE is no longer implied by shell=True files: Doc/library/subprocess.rst | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -826,8 +826,6 @@ The new process has a new console, instead of inheriting its parent's console (the default). - This flag is always set when :class:`Popen` is created with ``shell=True``. - .. data:: CREATE_NEW_PROCESS_GROUP A :class:`Popen` ``creationflags`` parameter to specify that a new process -- Repository URL: http://hg.python.org/cpython From christian at python.org Fri Jan 11 17:08:30 2013 From: christian at python.org (Christian Heimes) Date: Fri, 11 Jan 2013 17:08:30 +0100 Subject: [Python-checkins] Daily reference leaks (aef7db0d3893): sum=287 In-Reply-To: References: Message-ID: <50F038FE.208@python.org> Am 11.01.2013 07:09, schrieb Nick Coghlan: > On Fri, Jan 11, 2013 at 2:57 PM, wrote: >> results for aef7db0d3893 on branch "default" >> -------------------------------------------- >> >> test_dbm leaked [2, 0, 0] references, sum=2 >> test_dbm leaked [2, 2, 1] memory blocks, sum=5 > > Hmm, I'm starting to wonder if there's something to this one - it > seems to be popping up a bit lately. > >> test_xml_etree_c leaked [56, 56, 56] references, sum=168 >> test_xml_etree_c leaked [36, 38, 38] memory blocks, sum=112 > > I'm gonna take a wild guess and suggest there may be a problem with > the recent pickling fix in the C extension :) It has more issues. Coverity has sent me some complains, see attachment. -------------- next part -------------- An embedded message was scrubbed... From: scan-admin at coverity.com Subject: New Defects reported by Coverity Scan for Python Date: Thu, 10 Jan 2013 16:35:29 -0800 Size: 4865 URL: From python-checkins at python.org Fri Jan 11 17:18:01 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 11 Jan 2013 17:18:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=233583=3A_mention_t?= =?utf-8?q?hat_testing_whether_a_bad_address_not_triggering?= Message-ID: <3YjTkx3ldXzPHs@mail.python.org> http://hg.python.org/cpython/rev/acce13a6e728 changeset: 81419:acce13a6e728 user: Brett Cannon date: Fri Jan 11 11:17:53 2013 -0500 summary: Issue #3583: mention that testing whether a bad address not triggering an OSError can mean a bad DNS server and not an actual bug. files: Lib/test/test_urllibnet.py | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -121,16 +121,15 @@ else: # This happens with some overzealous DNS providers such as OpenDNS self.skipTest("%r should not resolve for test to work" % bogus_domain) - self.assertRaises(OSError, - # SF patch 809915: In Sep 2003, VeriSign started - # highjacking invalid .com and .net addresses to - # boost traffic to their own site. This test - # started failing then. One hopes the .invalid - # domain will be spared to serve its defined - # purpose. - # urllib.urlopen, "http://www.sadflkjsasadf.com/") - urllib.request.urlopen, - "http://sadflkjsasf.i.nvali.d/") + failure_explanation = ('opening an invalid URL did not raise OSError; ' + 'can be caused by a broken DNS server ' + '(e.g. returns 404 or hijacks page)') + with self.assertRaises(OSError, msg=failure_explanation): + # SF patch 809915: In Sep 2003, VeriSign started highjacking + # invalid .com and .net addresses to boost traffic to their own + # site. This test started failing then. One hopes the .invalid + # domain will be spared to serve its defined purpose. + urllib.request.urlopen("http://sadflkjsasf.i.nvali.d/") class urlretrieveNetworkTests(unittest.TestCase): -- Repository URL: http://hg.python.org/cpython From brett at python.org Fri Jan 11 18:08:18 2013 From: brett at python.org (Brett Cannon) Date: Fri, 11 Jan 2013 12:08:18 -0500 Subject: [Python-checkins] cpython (merge 3.3 -> default): Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. In-Reply-To: <3YjLF866ftzS6g@mail.python.org> References: <3YjLF866ftzS6g@mail.python.org> Message-ID: This seems to have caused the Windows buildbots to fail. On Fri, Jan 11, 2013 at 5:40 AM, serhiy.storchaka wrote: > http://hg.python.org/cpython/rev/8452c23139c6 > changeset: 81407:8452c23139c6 > parent: 81399:5ec8daab477a > parent: 81406:01df1f7841b2 > user: Serhiy Storchaka > date: Fri Jan 11 12:12:32 2013 +0200 > summary: > Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. > Now pindent.py works with a "with" statement. pindent.py no longer produces > improper indentation. pindent.py now works with continued lines broken after > "class" or "def" keywords and with continuations at the start of line. Added > regression tests for pindent.py. Modernized pindent.py. > > files: > Lib/test/test_tools.py | 326 ++++++++++++++++++++++++++- > Misc/NEWS | 7 + > Tools/scripts/pindent.py | 166 +++++-------- > 3 files changed, 393 insertions(+), 106 deletions(-) > > > diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py > --- a/Lib/test/test_tools.py > +++ b/Lib/test/test_tools.py > @@ -9,10 +9,13 @@ > import importlib.machinery > import unittest > from unittest import mock > +import shutil > +import subprocess > import sysconfig > import tempfile > +import textwrap > from test import support > -from test.script_helper import assert_python_ok > +from test.script_helper import assert_python_ok, temp_dir > > if not sysconfig.is_python_build(): > # XXX some installers do contain the tools, should we detect that > @@ -36,6 +39,327 @@ > self.assertGreater(err, b'') > > > +class PindentTests(unittest.TestCase): > + script = os.path.join(scriptsdir, 'pindent.py') > + > + def assertFileEqual(self, fn1, fn2): > + with open(fn1) as f1, open(fn2) as f2: > + self.assertEqual(f1.readlines(), f2.readlines()) > + > + def pindent(self, source, *args): > + with subprocess.Popen( > + (sys.executable, self.script) + args, > + stdin=subprocess.PIPE, stdout=subprocess.PIPE, > + universal_newlines=True) as proc: > + out, err = proc.communicate(source) > + self.assertIsNone(err) > + return out > + > + def lstriplines(self, data): > + return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' > + > + def test_selftest(self): > + with temp_dir() as directory: > + data_path = os.path.join(directory, '_test.py') > + with open(self.script) as f: > + closed = f.read() > + with open(data_path, 'w') as f: > + f.write(closed) > + > + rc, out, err = assert_python_ok(self.script, '-d', data_path) > + self.assertEqual(out, b'') > + self.assertEqual(err, b'') > + backup = data_path + '~' > + self.assertTrue(os.path.exists(backup)) > + with open(backup) as f: > + self.assertEqual(f.read(), closed) > + with open(data_path) as f: > + clean = f.read() > + compile(clean, '_test.py', 'exec') > + self.assertEqual(self.pindent(clean, '-c'), closed) > + self.assertEqual(self.pindent(closed, '-d'), clean) > + > + rc, out, err = assert_python_ok(self.script, '-c', data_path) > + self.assertEqual(out, b'') > + self.assertEqual(err, b'') > + with open(backup) as f: > + self.assertEqual(f.read(), clean) > + with open(data_path) as f: > + self.assertEqual(f.read(), closed) > + > + broken = self.lstriplines(closed) > + with open(data_path, 'w') as f: > + f.write(broken) > + rc, out, err = assert_python_ok(self.script, '-r', data_path) > + self.assertEqual(out, b'') > + self.assertEqual(err, b'') > + with open(backup) as f: > + self.assertEqual(f.read(), broken) > + with open(data_path) as f: > + indented = f.read() > + compile(indented, '_test.py', 'exec') > + self.assertEqual(self.pindent(broken, '-r'), indented) > + > + def pindent_test(self, clean, closed): > + self.assertEqual(self.pindent(clean, '-c'), closed) > + self.assertEqual(self.pindent(closed, '-d'), clean) > + broken = self.lstriplines(closed) > + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '4'), closed) > + > + def test_statements(self): > + clean = textwrap.dedent("""\ > + if a: > + pass > + > + if a: > + pass > + else: > + pass > + > + if a: > + pass > + elif: > + pass > + else: > + pass > + > + while a: > + break > + > + while a: > + break > + else: > + pass > + > + for i in a: > + break > + > + for i in a: > + break > + else: > + pass > + > + try: > + pass > + finally: > + pass > + > + try: > + pass > + except TypeError: > + pass > + except ValueError: > + pass > + else: > + pass > + > + try: > + pass > + except TypeError: > + pass > + except ValueError: > + pass > + finally: > + pass > + > + with a: > + pass > + > + class A: > + pass > + > + def f(): > + pass > + """) > + > + closed = textwrap.dedent("""\ > + if a: > + pass > + # end if > + > + if a: > + pass > + else: > + pass > + # end if > + > + if a: > + pass > + elif: > + pass > + else: > + pass > + # end if > + > + while a: > + break > + # end while > + > + while a: > + break > + else: > + pass > + # end while > + > + for i in a: > + break > + # end for > + > + for i in a: > + break > + else: > + pass > + # end for > + > + try: > + pass > + finally: > + pass > + # end try > + > + try: > + pass > + except TypeError: > + pass > + except ValueError: > + pass > + else: > + pass > + # end try > + > + try: > + pass > + except TypeError: > + pass > + except ValueError: > + pass > + finally: > + pass > + # end try > + > + with a: > + pass > + # end with > + > + class A: > + pass > + # end class A > + > + def f(): > + pass > + # end def f > + """) > + self.pindent_test(clean, closed) > + > + def test_multilevel(self): > + clean = textwrap.dedent("""\ > + def foobar(a, b): > + if a == b: > + a = a+1 > + elif a < b: > + b = b-1 > + if b > a: a = a-1 > + else: > + print 'oops!' > + """) > + closed = textwrap.dedent("""\ > + def foobar(a, b): > + if a == b: > + a = a+1 > + elif a < b: > + b = b-1 > + if b > a: a = a-1 > + # end if > + else: > + print 'oops!' > + # end if > + # end def foobar > + """) > + self.pindent_test(clean, closed) > + > + def test_preserve_indents(self): > + clean = textwrap.dedent("""\ > + if a: > + if b: > + pass > + """) > + closed = textwrap.dedent("""\ > + if a: > + if b: > + pass > + # end if > + # end if > + """) > + self.assertEqual(self.pindent(clean, '-c'), closed) > + self.assertEqual(self.pindent(closed, '-d'), clean) > + broken = self.lstriplines(closed) > + self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '9'), closed) > + clean = textwrap.dedent("""\ > + if a: > + \tif b: > + \t\tpass > + """) > + closed = textwrap.dedent("""\ > + if a: > + \tif b: > + \t\tpass > + \t# end if > + # end if > + """) > + self.assertEqual(self.pindent(clean, '-c'), closed) > + self.assertEqual(self.pindent(closed, '-d'), clean) > + broken = self.lstriplines(closed) > + self.assertEqual(self.pindent(broken, '-r'), closed) > + > + def test_escaped_newline(self): > + clean = textwrap.dedent("""\ > + class\\ > + \\ > + A: > + def\ > + \\ > + f: > + pass > + """) > + closed = textwrap.dedent("""\ > + class\\ > + \\ > + A: > + def\ > + \\ > + f: > + pass > + # end def f > + # end class A > + """) > + self.assertEqual(self.pindent(clean, '-c'), closed) > + self.assertEqual(self.pindent(closed, '-d'), clean) > + > + def test_empty_line(self): > + clean = textwrap.dedent("""\ > + if a: > + > + pass > + """) > + closed = textwrap.dedent("""\ > + if a: > + > + pass > + # end if > + """) > + self.pindent_test(clean, closed) > + > + def test_oneline(self): > + clean = textwrap.dedent("""\ > + if a: pass > + """) > + closed = textwrap.dedent("""\ > + if a: pass > + # end if > + """) > + self.pindent_test(clean, closed) > + > + > class TestSundryScripts(unittest.TestCase): > # At least make sure the rest don't have syntax errors. When tests are > # added for a script it should be added to the whitelist below. > diff --git a/Misc/NEWS b/Misc/NEWS > --- a/Misc/NEWS > +++ b/Misc/NEWS > @@ -621,6 +621,8 @@ > Tests > ----- > > +- Issue #15539: Added regression tests for Tools/scripts/pindent.py. > + > - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. > > - Issue #16925: test_configparser now works with unittest test discovery. > @@ -777,6 +779,11 @@ > Tools/Demos > ----------- > > +- Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now > + pindent.py works with a "with" statement. pindent.py no longer produces > + improper indentation. pindent.py now works with continued lines broken after > + "class" or "def" keywords and with continuations at the start of line. > + > - Issue #11797: Add a 2to3 fixer that maps reload() to imp.reload(). > > - Issue #10966: Remove the concept of unexpected skipped tests. > diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py > --- a/Tools/scripts/pindent.py > +++ b/Tools/scripts/pindent.py > @@ -79,8 +79,9 @@ > # Defaults > STEPSIZE = 8 > TABSIZE = 8 > -EXPANDTABS = 0 > +EXPANDTABS = False > > +import io > import re > import sys > > @@ -89,7 +90,8 @@ > next['while'] = next['for'] = 'else', 'end' > next['try'] = 'except', 'finally' > next['except'] = 'except', 'else', 'finally', 'end' > -next['else'] = next['finally'] = next['def'] = next['class'] = 'end' > +next['else'] = next['finally'] = next['with'] = \ > + next['def'] = next['class'] = 'end' > next['end'] = () > start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' > > @@ -105,11 +107,11 @@ > self.expandtabs = expandtabs > self._write = fpo.write > self.kwprog = re.compile( > - r'^\s*(?P[a-z]+)' > - r'(\s+(?P[a-zA-Z_]\w*))?' > + r'^(?:\s|\\\n)*(?P[a-z]+)' > + r'((?:\s|\\\n)+(?P[a-zA-Z_]\w*))?' > r'[^\w]') > self.endprog = re.compile( > - r'^\s*#?\s*end\s+(?P[a-z]+)' > + r'^(?:\s|\\\n)*#?\s*end\s+(?P[a-z]+)' > r'(\s+(?P[a-zA-Z_]\w*))?' > r'[^\w]') > self.wsprog = re.compile(r'^[ \t]*') > @@ -125,7 +127,7 @@ > > def readline(self): > line = self.fpi.readline() > - if line: self.lineno = self.lineno + 1 > + if line: self.lineno += 1 > # end if > return line > # end def readline > @@ -143,27 +145,24 @@ > line2 = self.readline() > if not line2: break > # end if > - line = line + line2 > + line += line2 > # end while > return line > # end def getline > > - def putline(self, line, indent = None): > - if indent is None: > - self.write(line) > - return > + def putline(self, line, indent): > + tabs, spaces = divmod(indent*self.indentsize, self.tabsize) > + i = self.wsprog.match(line).end() > + line = line[i:] > + if line[:1] not in ('\n', '\r', ''): > + line = '\t'*tabs + ' '*spaces + line > # end if > - tabs, spaces = divmod(indent*self.indentsize, self.tabsize) > - i = 0 > - m = self.wsprog.match(line) > - if m: i = m.end() > - # end if > - self.write('\t'*tabs + ' '*spaces + line[i:]) > + self.write(line) > # end def putline > > def reformat(self): > stack = [] > - while 1: > + while True: > line = self.getline() > if not line: break # EOF > # end if > @@ -173,10 +172,9 @@ > kw2 = m.group('kw') > if not stack: > self.error('unexpected end') > - elif stack[-1][0] != kw2: > + elif stack.pop()[0] != kw2: > self.error('unmatched end') > # end if > - del stack[-1:] > self.putline(line, len(stack)) > continue > # end if > @@ -208,23 +206,23 @@ > def delete(self): > begin_counter = 0 > end_counter = 0 > - while 1: > + while True: > line = self.getline() > if not line: break # EOF > # end if > m = self.endprog.match(line) > if m: > - end_counter = end_counter + 1 > + end_counter += 1 > continue > # end if > m = self.kwprog.match(line) > if m: > kw = m.group('kw') > if kw in start: > - begin_counter = begin_counter + 1 > + begin_counter += 1 > # end if > # end if > - self.putline(line) > + self.write(line) > # end while > if begin_counter - end_counter < 0: > sys.stderr.write('Warning: input contained more end tags than expected\n') > @@ -234,17 +232,12 @@ > # end def delete > > def complete(self): > - self.indentsize = 1 > stack = [] > todo = [] > - thisid = '' > - current, firstkw, lastkw, topid = 0, '', '', '' > - while 1: > + currentws = thisid = firstkw = lastkw = topid = '' > + while True: > line = self.getline() > - i = 0 > - m = self.wsprog.match(line) > - if m: i = m.end() > - # end if > + i = self.wsprog.match(line).end() > m = self.endprog.match(line) > if m: > thiskw = 'end' > @@ -269,7 +262,9 @@ > thiskw = '' > # end if > # end if > - indent = len(line[:i].expandtabs(self.tabsize)) > + indentws = line[:i] > + indent = len(indentws.expandtabs(self.tabsize)) > + current = len(currentws.expandtabs(self.tabsize)) > while indent < current: > if firstkw: > if topid: > @@ -278,11 +273,11 @@ > else: > s = '# end %s\n' % firstkw > # end if > - self.putline(s, current) > + self.write(currentws + s) > firstkw = lastkw = '' > # end if > - current, firstkw, lastkw, topid = stack[-1] > - del stack[-1] > + currentws, firstkw, lastkw, topid = stack.pop() > + current = len(currentws.expandtabs(self.tabsize)) > # end while > if indent == current and firstkw: > if thiskw == 'end': > @@ -297,18 +292,18 @@ > else: > s = '# end %s\n' % firstkw > # end if > - self.putline(s, current) > + self.write(currentws + s) > firstkw = lastkw = topid = '' > # end if > # end if > if indent > current: > - stack.append((current, firstkw, lastkw, topid)) > + stack.append((currentws, firstkw, lastkw, topid)) > if thiskw and thiskw not in start: > # error > thiskw = '' > # end if > - current, firstkw, lastkw, topid = \ > - indent, thiskw, thiskw, thisid > + currentws, firstkw, lastkw, topid = \ > + indentws, thiskw, thiskw, thisid > # end if > if thiskw: > if thiskw in start: > @@ -326,7 +321,6 @@ > self.write(line) > # end while > # end def complete > - > # end class PythonIndenter > > # Simplified user interface > @@ -352,76 +346,34 @@ > pi.reformat() > # end def reformat_filter > > -class StringReader: > - def __init__(self, buf): > - self.buf = buf > - self.pos = 0 > - self.len = len(self.buf) > - # end def __init__ > - def read(self, n = 0): > - if n <= 0: > - n = self.len - self.pos > - else: > - n = min(n, self.len - self.pos) > - # end if > - r = self.buf[self.pos : self.pos + n] > - self.pos = self.pos + n > - return r > - # end def read > - def readline(self): > - i = self.buf.find('\n', self.pos) > - return self.read(i + 1 - self.pos) > - # end def readline > - def readlines(self): > - lines = [] > - line = self.readline() > - while line: > - lines.append(line) > - line = self.readline() > - # end while > - return lines > - # end def readlines > - # seek/tell etc. are left as an exercise for the reader > -# end class StringReader > - > -class StringWriter: > - def __init__(self): > - self.buf = '' > - # end def __init__ > - def write(self, s): > - self.buf = self.buf + s > - # end def write > - def getvalue(self): > - return self.buf > - # end def getvalue > -# end class StringWriter > - > def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): > - input = StringReader(source) > - output = StringWriter() > + input = io.StringIO(source) > + output = io.StringIO() > pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) > pi.complete() > return output.getvalue() > # end def complete_string > > def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): > - input = StringReader(source) > - output = StringWriter() > + input = io.StringIO(source) > + output = io.StringIO() > pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) > pi.delete() > return output.getvalue() > # end def delete_string > > def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): > - input = StringReader(source) > - output = StringWriter() > + input = io.StringIO(source) > + output = io.StringIO() > pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) > pi.reformat() > return output.getvalue() > # end def reformat_string > > def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): > - source = open(filename, 'r').read() > + with open(filename, 'r') as f: > + source = f.read() > + # end with > result = complete_string(source, stepsize, tabsize, expandtabs) > if source == result: return 0 > # end if > @@ -429,14 +381,16 @@ > try: os.rename(filename, filename + '~') > except OSError: pass > # end try > - f = open(filename, 'w') > - f.write(result) > - f.close() > + with open(filename, 'w') as f: > + f.write(result) > + # end with > return 1 > # end def complete_file > > def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): > - source = open(filename, 'r').read() > + with open(filename, 'r') as f: > + source = f.read() > + # end with > result = delete_string(source, stepsize, tabsize, expandtabs) > if source == result: return 0 > # end if > @@ -444,14 +398,16 @@ > try: os.rename(filename, filename + '~') > except OSError: pass > # end try > - f = open(filename, 'w') > - f.write(result) > - f.close() > + with open(filename, 'w') as f: > + f.write(result) > + # end with > return 1 > # end def delete_file > > def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): > - source = open(filename, 'r').read() > + with open(filename, 'r') as f: > + source = f.read() > + # end with > result = reformat_string(source, stepsize, tabsize, expandtabs) > if source == result: return 0 > # end if > @@ -459,9 +415,9 @@ > try: os.rename(filename, filename + '~') > except OSError: pass > # end try > - f = open(filename, 'w') > - f.write(result) > - f.close() > + with open(filename, 'w') as f: > + f.write(result) > + # end with > return 1 > # end def reformat_file > > @@ -474,7 +430,7 @@ > -r : reformat a completed program (use #end directives) > -s stepsize: indentation step (default %(STEPSIZE)d) > -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) > --e : expand TABs into spaces (defailt OFF) > +-e : expand TABs into spaces (default OFF) > [file] ... : files are changed in place, with backups in file~ > If no files are specified or a single - is given, > the program acts as a filter (reads stdin, writes stdout). > @@ -517,7 +473,7 @@ > elif o == '-t': > tabsize = int(a) > elif o == '-e': > - expandtabs = 1 > + expandtabs = True > # end if > # end for > if not action: > > -- > Repository URL: http://hg.python.org/cpython > > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From eliben at gmail.com Fri Jan 11 18:36:06 2013 From: eliben at gmail.com (Eli Bendersky) Date: Fri, 11 Jan 2013 09:36:06 -0800 Subject: [Python-checkins] Daily reference leaks (aef7db0d3893): sum=287 In-Reply-To: References: Message-ID: On Thu, Jan 10, 2013 at 10:09 PM, Nick Coghlan wrote: > On Fri, Jan 11, 2013 at 2:57 PM, wrote: > > results for aef7db0d3893 on branch "default" > > -------------------------------------------- > > > > test_dbm leaked [2, 0, 0] references, sum=2 > > test_dbm leaked [2, 2, 1] memory blocks, sum=5 > > Hmm, I'm starting to wonder if there's something to this one - it > seems to be popping up a bit lately. > > > test_xml_etree_c leaked [56, 56, 56] references, sum=168 > > test_xml_etree_c leaked [36, 38, 38] memory blocks, sum=112 > > I'm gonna take a wild guess and suggest there may be a problem with > the recent pickling fix in the C extension :) > Yep. We're on it :-) Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From christian at python.org Fri Jan 11 18:42:20 2013 From: christian at python.org (Christian Heimes) Date: Fri, 11 Jan 2013 18:42:20 +0100 Subject: [Python-checkins] Daily reference leaks (aef7db0d3893): sum=287 In-Reply-To: References: <50F038FE.208@python.org> Message-ID: <50F04EFC.80505@python.org> Am 11.01.2013 18:19, schrieb Andrea Griffini: > On Fri, Jan 11, 2013 at 5:08 PM, Christian Heimes wrote: >> It has more issues. Coverity has sent me some complains, see attachment. > > The second complaint seems a false positive; if self->extra is null > then children is set to 0 and following code is not executed. Yes, Coverity's results have lots of false positives. On the other hand it's able to detect hard to find resource leaks. You get used to the false positives and learn to appreciate the good stuff. :) From python-checkins at python.org Fri Jan 11 19:07:31 2013 From: python-checkins at python.org (georg.brandl) Date: Fri, 11 Jan 2013 19:07:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Closes_=2316916=3A_clarify_?= =?utf-8?q?=22slicing_equivalent_to_extended_unpacking=22_example=3A_the?= Message-ID: <3YjX9H2bqTzP5Y@mail.python.org> http://hg.python.org/peps/rev/a0077c1d201d changeset: 4664:a0077c1d201d user: Georg Brandl date: Fri Jan 11 19:08:14 2013 +0100 summary: Closes #16916: clarify "slicing equivalent to extended unpacking" example: the latter always creates a list. files: pep-3132.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-3132.txt b/pep-3132.txt --- a/pep-3132.txt +++ b/pep-3132.txt @@ -68,7 +68,7 @@ For example, if ``seq`` is a slicable sequence, all the following assignments are equivalent if ``seq`` has at least three elements:: - a, b, c = seq[0], seq[1:-1], seq[-1] + a, b, c = seq[0], list(seq[1:-1]), seq[-1] a, *b, c = seq [a, *b, c] = seq -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Fri Jan 11 20:26:01 2013 From: python-checkins at python.org (georg.brandl) Date: Fri, 11 Jan 2013 20:26:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogQ2xvc2VzICMxNjkz?= =?utf-8?q?6=3A_fix_duplicate/ambiguous_description_of_stat=2ES=5FIFMT_in_?= =?utf-8?q?the_docs=2E?= Message-ID: <3YjYvs4xLlzS9y@mail.python.org> http://hg.python.org/cpython/rev/0d7a8a4d6f30 changeset: 81420:0d7a8a4d6f30 branch: 2.7 parent: 81414:1cfe0f50fd0c user: Georg Brandl date: Fri Jan 11 20:25:54 2013 +0100 summary: Closes #16936: fix duplicate/ambiguous description of stat.S_IFMT in the docs. files: Doc/library/stat.rst | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -171,10 +171,6 @@ Use of the functions above is more portable than use of the first set of flags: -.. data:: S_IFMT - - Bit mask for the file type bit fields. - .. data:: S_IFSOCK Socket. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 20:26:03 2013 From: python-checkins at python.org (georg.brandl) Date: Fri, 11 Jan 2013 20:26:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogQ2xvc2VzICMxNjkz?= =?utf-8?q?6=3A_fix_duplicate/ambiguous_description_of_stat=2ES=5FIFMT_in_?= =?utf-8?q?the_docs=2E?= Message-ID: <3YjYvv0j8KzSBS@mail.python.org> http://hg.python.org/cpython/rev/3555391a9909 changeset: 81421:3555391a9909 branch: 3.3 parent: 81416:d3374d393975 user: Georg Brandl date: Fri Jan 11 20:25:54 2013 +0100 summary: Closes #16936: fix duplicate/ambiguous description of stat.S_IFMT in the docs. files: Doc/library/stat.rst | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -182,10 +182,6 @@ Use of the functions above is more portable than use of the first set of flags: -.. data:: S_IFMT - - Bit mask for the file type bit fields. - .. data:: S_IFSOCK Socket. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 20:26:04 2013 From: python-checkins at python.org (georg.brandl) Date: Fri, 11 Jan 2013 20:26:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E3?= Message-ID: <3YjYvw3kZ6zSCG@mail.python.org> http://hg.python.org/cpython/rev/21abd27ca9ed changeset: 81422:21abd27ca9ed parent: 81419:acce13a6e728 parent: 81421:3555391a9909 user: Georg Brandl date: Fri Jan 11 20:26:54 2013 +0100 summary: merge with 3.3 files: Doc/library/stat.rst | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -182,10 +182,6 @@ Use of the functions above is more portable than use of the first set of flags: -.. data:: S_IFMT - - Bit mask for the file type bit fields. - .. data:: S_IFSOCK Socket. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:23:43 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 21:23:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE1NTM5?= =?utf-8?q?=3A_Fix_backup_file_creation_in_pindent=2Epy_on_Windows?= Message-ID: <3YjbBR0mzmzS4V@mail.python.org> http://hg.python.org/cpython/rev/2d0c5f97af48 changeset: 81423:2d0c5f97af48 branch: 2.7 parent: 81420:0d7a8a4d6f30 user: Serhiy Storchaka date: Fri Jan 11 22:16:15 2013 +0200 summary: Issue #15539: Fix backup file creation in pindent.py on Windows files: Lib/test/test_tools.py | 1 + Tools/scripts/pindent.py | 34 ++++++++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -57,6 +57,7 @@ return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' def test_selftest(self): + self.maxDiff = None with temp_dir() as directory: data_path = os.path.join(directory, '_test.py') with open(self.script) as f: diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -76,6 +76,8 @@ # - realign comments # - optionally do much more thorough reformatting, a la C indent +from __future__ import print_function + # Defaults STEPSIZE = 8 TABSIZE = 8 @@ -370,6 +372,23 @@ return output.getvalue() # end def reformat_string +def make_backup(filename): + import os, os.path + backup = filename + '~' + if os.path.lexists(backup): + try: + os.remove(backup) + except os.error: + print("Can't remove backup %r" % (backup,), file=sys.stderr) + # end try + # end if + try: + os.rename(filename, backup) + except os.error: + print("Can't rename %r to %r" % (filename, backup), file=sys.stderr) + # end try +# end def make_backup + def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): with open(filename, 'r') as f: source = f.read() @@ -377,10 +396,7 @@ result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -394,10 +410,7 @@ result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -411,10 +424,7 @@ result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:23:44 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 21:23:44 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE1NTM5?= =?utf-8?q?=3A_Fix_a_backup_file_creation_in_pindent=2Epy_on_Windows=2E?= Message-ID: <3YjbBS3qBjzS8x@mail.python.org> http://hg.python.org/cpython/rev/a9990104f728 changeset: 81424:a9990104f728 branch: 3.2 parent: 81415:0ed68fb13b3a user: Serhiy Storchaka date: Fri Jan 11 22:18:17 2013 +0200 summary: Issue #15539: Fix a backup file creation in pindent.py on Windows. files: Lib/test/test_tools.py | 1 + Tools/scripts/pindent.py | 32 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -58,6 +58,7 @@ return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' def test_selftest(self): + self.maxDiff = None with temp_dir() as directory: data_path = os.path.join(directory, '_test.py') with open(self.script) as f: diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -370,6 +370,23 @@ return output.getvalue() # end def reformat_string +def make_backup(filename): + import os, os.path + backup = filename + '~' + if os.path.lexists(backup): + try: + os.remove(backup) + except os.error: + print("Can't remove backup %r" % (backup,), file=sys.stderr) + # end try + # end if + try: + os.rename(filename, backup) + except os.error: + print("Can't rename %r to %r" % (filename, backup), file=sys.stderr) + # end try +# end def make_backup + def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): with open(filename, 'r') as f: source = f.read() @@ -377,10 +394,7 @@ result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -394,10 +408,7 @@ result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -411,10 +422,7 @@ result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:23:45 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 21:23:45 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2315539=3A_Fix_a_backup_file_creation_in_pindent=2Epy_o?= =?utf-8?q?n_Windows=2E?= Message-ID: <3YjbBT6dkrzS9G@mail.python.org> http://hg.python.org/cpython/rev/735361e8709e changeset: 81425:735361e8709e branch: 3.3 parent: 81421:3555391a9909 parent: 81424:a9990104f728 user: Serhiy Storchaka date: Fri Jan 11 22:19:07 2013 +0200 summary: Issue #15539: Fix a backup file creation in pindent.py on Windows. files: Lib/test/test_tools.py | 1 + Tools/scripts/pindent.py | 32 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -59,6 +59,7 @@ return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' def test_selftest(self): + self.maxDiff = None with temp_dir() as directory: data_path = os.path.join(directory, '_test.py') with open(self.script) as f: diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -370,6 +370,23 @@ return output.getvalue() # end def reformat_string +def make_backup(filename): + import os, os.path + backup = filename + '~' + if os.path.lexists(backup): + try: + os.remove(backup) + except os.error: + print("Can't remove backup %r" % (backup,), file=sys.stderr) + # end try + # end if + try: + os.rename(filename, backup) + except os.error: + print("Can't rename %r to %r" % (filename, backup), file=sys.stderr) + # end try +# end def make_backup + def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): with open(filename, 'r') as f: source = f.read() @@ -377,10 +394,7 @@ result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -394,10 +408,7 @@ result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -411,10 +422,7 @@ result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:23:47 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 11 Jan 2013 21:23:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2315539=3A_Fix_a_backup_file_creation_in_pindent?= =?utf-8?q?=2Epy_on_Windows=2E?= Message-ID: <3YjbBW71tFzS95@mail.python.org> http://hg.python.org/cpython/rev/c46dec051819 changeset: 81426:c46dec051819 parent: 81422:21abd27ca9ed parent: 81425:735361e8709e user: Serhiy Storchaka date: Fri Jan 11 22:21:45 2013 +0200 summary: Issue #15539: Fix a backup file creation in pindent.py on Windows. files: Lib/test/test_tools.py | 1 + Tools/scripts/pindent.py | 32 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -59,6 +59,7 @@ return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' def test_selftest(self): + self.maxDiff = None with temp_dir() as directory: data_path = os.path.join(directory, '_test.py') with open(self.script) as f: diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -370,6 +370,23 @@ return output.getvalue() # end def reformat_string +def make_backup(filename): + import os, os.path + backup = filename + '~' + if os.path.lexists(backup): + try: + os.remove(backup) + except OSError: + print("Can't remove backup %r" % (backup,), file=sys.stderr) + # end try + # end if + try: + os.rename(filename, backup) + except OSError: + print("Can't rename %r to %r" % (filename, backup), file=sys.stderr) + # end try +# end def make_backup + def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): with open(filename, 'r') as f: source = f.read() @@ -377,10 +394,7 @@ result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except OSError: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -394,10 +408,7 @@ result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except OSError: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -411,10 +422,7 @@ result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except OSError: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:45:13 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 11 Jan 2013 21:45:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2NzMw?= =?utf-8?q?=3A_Don=27t_raise_an_exception_in?= Message-ID: <3YjbgF2cTqzS8m@mail.python.org> http://hg.python.org/cpython/rev/159967aa24a5 changeset: 81427:159967aa24a5 branch: 3.3 parent: 81416:d3374d393975 user: Brett Cannon date: Fri Jan 11 15:40:12 2013 -0500 summary: Issue #16730: Don't raise an exception in importlib.machinery.FileFinder when the directory has become unreadable or a file. This brings semantics in line with Python 3.2 import. Reported and diagnosed by David Pritchard. files: Lib/importlib/_bootstrap.py | 5 +- Lib/test/test_importlib/source/test_finder.py | 35 + Misc/NEWS | 5 + Python/importlib.h | 1901 +++++---- 4 files changed, 995 insertions(+), 951 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1395,8 +1395,9 @@ path = self.path try: contents = _os.listdir(path) - except FileNotFoundError: - # Directory has been removed since last import + except (FileNotFoundError, PermissionError, NotADirectoryError): + # Directory has either been removed, turned into a file, or made + # unreadable. contents = [] # We store two cached versions, to handle runtime changes of the # PYTHONCASEOK environment variable. diff --git a/Lib/test/test_importlib/source/test_finder.py b/Lib/test/test_importlib/source/test_finder.py --- a/Lib/test/test_importlib/source/test_finder.py +++ b/Lib/test/test_importlib/source/test_finder.py @@ -6,6 +6,9 @@ import imp import os import py_compile +import stat +import sys +import tempfile from test.support import make_legacy_pyc import unittest import warnings @@ -147,6 +150,38 @@ self.assertIsNotNone(finder.find_module(mod)) self.assertIsNone(finder.find_module(mod)) + @unittest.skipUnless(sys.platform != 'win32', + 'os.chmod() does not support the needed arguments under Windows') + def test_no_read_directory(self): + # Issue #16730 + tempdir = tempfile.TemporaryDirectory() + original_mode = os.stat(tempdir.name).st_mode + def cleanup(tempdir): + """Cleanup function for the temporary directory. + + Since we muck with the permissions, we want to set them back to + their original values to make sure the directory can be properly + cleaned up. + + """ + os.chmod(tempdir.name, original_mode) + # If this is not explicitly called then the __del__ method is used, + # but since already mucking around might as well explicitly clean + # up. + tempdir.__exit__(None, None, None) + self.addCleanup(cleanup, tempdir) + os.chmod(tempdir.name, stat.S_IWUSR | stat.S_IXUSR) + finder = self.get_finder(tempdir.name) + self.assertEqual((None, []), finder.find_loader('doesnotexist')) + + def test_ignore_file(self): + # If a directory got changed to a file from underneath us, then don't + # worry about looking for submodules. + with tempfile.NamedTemporaryFile() as file_obj: + finder = self.get_finder(file_obj.name) + self.assertEqual((None, []), finder.find_loader('doesnotexist')) + + def test_main(): from test.support import run_unittest run_unittest(FinderTests) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,11 @@ Core and Builtins ----------------- +- Issue #16730: importlib.machinery.FileFinder now no longers raises an + exception when trying to populate its cache and it finds out the directory is + unreadable or has turned into a file. Reported and diagnosed by + David Pritchard. + - Issue #16906: Fix a logic error that prevented most static strings from being cleared. diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:45:14 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 11 Jan 2013 21:45:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_from_3=2E3_for_fix_for_issue_=2316730?= Message-ID: <3YjbgG6rcZzS8w@mail.python.org> http://hg.python.org/cpython/rev/b94f308e9b47 changeset: 81428:b94f308e9b47 parent: 81419:acce13a6e728 parent: 81427:159967aa24a5 user: Brett Cannon date: Fri Jan 11 15:42:30 2013 -0500 summary: Merge from 3.3 for fix for issue #16730 files: Lib/importlib/_bootstrap.py | 5 +- Lib/test/test_importlib/source/test_finder.py | 35 + Misc/NEWS | 5 + Python/importlib.h | 1889 +++++---- 4 files changed, 989 insertions(+), 945 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1401,8 +1401,9 @@ path = self.path try: contents = _os.listdir(path) - except FileNotFoundError: - # Directory has been removed since last import + except (FileNotFoundError, PermissionError, NotADirectoryError): + # Directory has either been removed, turned into a file, or made + # unreadable. contents = [] # We store two cached versions, to handle runtime changes of the # PYTHONCASEOK environment variable. diff --git a/Lib/test/test_importlib/source/test_finder.py b/Lib/test/test_importlib/source/test_finder.py --- a/Lib/test/test_importlib/source/test_finder.py +++ b/Lib/test/test_importlib/source/test_finder.py @@ -6,6 +6,9 @@ import imp import os import py_compile +import stat +import sys +import tempfile from test.support import make_legacy_pyc import unittest import warnings @@ -147,6 +150,38 @@ self.assertIsNotNone(finder.find_module(mod)) self.assertIsNone(finder.find_module(mod)) + @unittest.skipUnless(sys.platform != 'win32', + 'os.chmod() does not support the needed arguments under Windows') + def test_no_read_directory(self): + # Issue #16730 + tempdir = tempfile.TemporaryDirectory() + original_mode = os.stat(tempdir.name).st_mode + def cleanup(tempdir): + """Cleanup function for the temporary directory. + + Since we muck with the permissions, we want to set them back to + their original values to make sure the directory can be properly + cleaned up. + + """ + os.chmod(tempdir.name, original_mode) + # If this is not explicitly called then the __del__ method is used, + # but since already mucking around might as well explicitly clean + # up. + tempdir.__exit__(None, None, None) + self.addCleanup(cleanup, tempdir) + os.chmod(tempdir.name, stat.S_IWUSR | stat.S_IXUSR) + finder = self.get_finder(tempdir.name) + self.assertEqual((None, []), finder.find_loader('doesnotexist')) + + def test_ignore_file(self): + # If a directory got changed to a file from underneath us, then don't + # worry about looking for submodules. + with tempfile.NamedTemporaryFile() as file_obj: + finder = self.get_finder(file_obj.name) + self.assertEqual((None, []), finder.find_loader('doesnotexist')) + + def test_main(): from test.support import run_unittest run_unittest(FinderTests) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ Core and Builtins ----------------- +- Issue #16730: importlib.machinery.FileFinder now no longers raises an + exception when trying to populate its cache and it finds out the directory is + unreadable or has turned into a file. Reported and diagnosed by + David Pritchard. + - Issue #16906: Fix a logic error that prevented most static strings from being cleared. diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:45:16 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 11 Jan 2013 21:45:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_merge?= Message-ID: <3YjbgJ31X2zS9M@mail.python.org> http://hg.python.org/cpython/rev/e3d47d5b9110 changeset: 81429:e3d47d5b9110 parent: 81428:b94f308e9b47 parent: 81426:c46dec051819 user: Brett Cannon date: Fri Jan 11 15:43:34 2013 -0500 summary: merge files: Doc/library/stat.rst | 4 --- Lib/test/test_tools.py | 1 + Tools/scripts/pindent.py | 32 +++++++++++++++++---------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -182,10 +182,6 @@ Use of the functions above is more portable than use of the first set of flags: -.. data:: S_IFMT - - Bit mask for the file type bit fields. - .. data:: S_IFSOCK Socket. diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -59,6 +59,7 @@ return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' def test_selftest(self): + self.maxDiff = None with temp_dir() as directory: data_path = os.path.join(directory, '_test.py') with open(self.script) as f: diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -370,6 +370,23 @@ return output.getvalue() # end def reformat_string +def make_backup(filename): + import os, os.path + backup = filename + '~' + if os.path.lexists(backup): + try: + os.remove(backup) + except OSError: + print("Can't remove backup %r" % (backup,), file=sys.stderr) + # end try + # end if + try: + os.rename(filename, backup) + except OSError: + print("Can't rename %r to %r" % (filename, backup), file=sys.stderr) + # end try +# end def make_backup + def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): with open(filename, 'r') as f: source = f.read() @@ -377,10 +394,7 @@ result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except OSError: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -394,10 +408,7 @@ result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except OSError: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -411,10 +422,7 @@ result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except OSError: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:45:17 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 11 Jan 2013 21:45:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_merge?= Message-ID: <3YjbgK5tPWzSBC@mail.python.org> http://hg.python.org/cpython/rev/9c695fddd10a changeset: 81430:9c695fddd10a branch: 3.3 parent: 81427:159967aa24a5 parent: 81425:735361e8709e user: Brett Cannon date: Fri Jan 11 15:44:00 2013 -0500 summary: merge files: Doc/library/stat.rst | 4 --- Lib/test/test_tools.py | 1 + Tools/scripts/pindent.py | 32 +++++++++++++++++---------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -182,10 +182,6 @@ Use of the functions above is more portable than use of the first set of flags: -.. data:: S_IFMT - - Bit mask for the file type bit fields. - .. data:: S_IFSOCK Socket. diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py --- a/Lib/test/test_tools.py +++ b/Lib/test/test_tools.py @@ -59,6 +59,7 @@ return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' def test_selftest(self): + self.maxDiff = None with temp_dir() as directory: data_path = os.path.join(directory, '_test.py') with open(self.script) as f: diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -370,6 +370,23 @@ return output.getvalue() # end def reformat_string +def make_backup(filename): + import os, os.path + backup = filename + '~' + if os.path.lexists(backup): + try: + os.remove(backup) + except os.error: + print("Can't remove backup %r" % (backup,), file=sys.stderr) + # end try + # end if + try: + os.rename(filename, backup) + except os.error: + print("Can't rename %r to %r" % (filename, backup), file=sys.stderr) + # end try +# end def make_backup + def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): with open(filename, 'r') as f: source = f.read() @@ -377,10 +394,7 @@ result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -394,10 +408,7 @@ result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with @@ -411,10 +422,7 @@ result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - import os - try: os.rename(filename, filename + '~') - except os.error: pass - # end try + make_backup(filename) with open(filename, 'w') as f: f.write(result) # end with -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 11 21:45:19 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 11 Jan 2013 21:45:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge?= Message-ID: <3YjbgM1PS9zS8p@mail.python.org> http://hg.python.org/cpython/rev/578d5ae1c8eb changeset: 81431:578d5ae1c8eb parent: 81429:e3d47d5b9110 parent: 81430:9c695fddd10a user: Brett Cannon date: Fri Jan 11 15:44:57 2013 -0500 summary: merge files: -- Repository URL: http://hg.python.org/cpython From agriff at tin.it Fri Jan 11 18:19:44 2013 From: agriff at tin.it (Andrea Griffini) Date: Fri, 11 Jan 2013 18:19:44 +0100 Subject: [Python-checkins] [Python-Dev] Daily reference leaks (aef7db0d3893): sum=287 In-Reply-To: <50F038FE.208@python.org> References: <50F038FE.208@python.org> Message-ID: On Fri, Jan 11, 2013 at 5:08 PM, Christian Heimes wrote: > It has more issues. Coverity has sent me some complains, see attachment. The second complaint seems a false positive; if self->extra is null then children is set to 0 and following code is not executed. From python-checkins at python.org Sat Jan 12 00:09:34 2013 From: python-checkins at python.org (brett.cannon) Date: Sat, 12 Jan 2013 00:09:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2315031=3A_Refactor?= =?utf-8?q?_some_code_in_importlib_pertaining_to_validating?= Message-ID: <3Yjfsp6PBWzSBY@mail.python.org> http://hg.python.org/cpython/rev/a4292889e942 changeset: 81432:a4292889e942 user: Brett Cannon date: Fri Jan 11 18:09:25 2013 -0500 summary: Issue #15031: Refactor some code in importlib pertaining to validating and compiling bytecode. Thanks to Ronan Lamy for pointing the redundancy and taking an initial stab at the refactor (as did Nick Coghlan). files: Lib/importlib/_bootstrap.py | 139 +- Misc/NEWS | 4 + Python/importlib.h | 8560 +++++++++++----------- 3 files changed, 4375 insertions(+), 4328 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -623,6 +623,71 @@ return loader +def _validate_bytecode_header(data, source_stats=None, name=None, path=None): + """Validate the header of the passed-in bytecode against source_stats (if + given) and returning the bytecode that can be compiled by compile(). + + All other arguments are used to enhance error reporting. + + ImportError is raised when the magic number is incorrect or the bytecode is + found to be stale. EOFError is raised when the data is found to be + truncated. + + """ + exc_details = {} + if name is not None: + exc_details['name'] = name + else: + # To prevent having to make all messages have a conditional name. + name = 'bytecode' + if path is not None: + exc_details['path'] = path + magic = data[:4] + raw_timestamp = data[4:8] + raw_size = data[8:12] + if magic != _MAGIC_BYTES: + msg = 'bad magic number in {!r}: {!r}'.format(name, magic) + raise ImportError(msg, **exc_details) + elif len(raw_timestamp) != 4: + message = 'bad timestamp in {!r}'.format(name) + _verbose_message(message) + raise EOFError(message) + elif len(raw_size) != 4: + message = 'bad size in {!r}'.format(name) + _verbose_message(message) + raise EOFError(message) + if source_stats is not None: + try: + source_mtime = int(source_stats['mtime']) + except KeyError: + pass + else: + if _r_long(raw_timestamp) != source_mtime: + message = 'bytecode is stale for {!r}'.format(name) + _verbose_message(message) + raise ImportError(message, **exc_details) + try: + source_size = source_stats['size'] & 0xFFFFFFFF + except KeyError: + pass + else: + if _r_long(raw_size) != source_size: + raise ImportError("bytecode is stale for {!r}".format(name), + **exc_details) + return data[12:] + + +def _compile_bytecode(data, name=None, bytecode_path=None, source_path=None): + """Compile bytecode as returned by _validate_bytecode_header().""" + code = marshal.loads(data) + if isinstance(code, _code_type): + _verbose_message('code object from {!r}', bytecode_path) + if source_path is not None: + _imp._fix_co_filename(code, source_path) + return code + else: + raise ImportError("Non-code object in {!r}".format(bytecode_path), + name=name, path=bytecode_path) # Loaders ##################################################################### @@ -801,51 +866,6 @@ tail_name = fullname.rpartition('.')[2] return filename_base == '__init__' and tail_name != '__init__' - def _bytes_from_bytecode(self, fullname, data, bytecode_path, source_stats): - """Return the marshalled bytes from bytecode, verifying the magic - number, timestamp and source size along the way. - - If source_stats is None then skip the timestamp check. - - """ - magic = data[:4] - raw_timestamp = data[4:8] - raw_size = data[8:12] - if magic != _MAGIC_BYTES: - msg = 'bad magic number in {!r}: {!r}'.format(fullname, magic) - raise ImportError(msg, name=fullname, path=bytecode_path) - elif len(raw_timestamp) != 4: - message = 'bad timestamp in {}'.format(fullname) - _verbose_message(message) - raise EOFError(message) - elif len(raw_size) != 4: - message = 'bad size in {}'.format(fullname) - _verbose_message(message) - raise EOFError(message) - if source_stats is not None: - try: - source_mtime = int(source_stats['mtime']) - except KeyError: - pass - else: - if _r_long(raw_timestamp) != source_mtime: - message = 'bytecode is stale for {}'.format(fullname) - _verbose_message(message) - raise ImportError(message, name=fullname, - path=bytecode_path) - try: - source_size = source_stats['size'] & 0xFFFFFFFF - except KeyError: - pass - else: - if _r_long(raw_size) != source_size: - raise ImportError( - "bytecode is stale for {}".format(fullname), - name=fullname, path=bytecode_path) - # Can't return the code object as errors from marshal loading need to - # propagate even when source is available. - return data[12:] - @module_for_loader def _load_module(self, module, *, sourceless=False): """Helper for load_module able to handle either source or sourceless @@ -965,24 +985,17 @@ pass else: try: - bytes_data = self._bytes_from_bytecode(fullname, data, - bytecode_path, - st) + bytes_data = _validate_bytecode_header(data, + source_stats=st, name=fullname, + path=bytecode_path) except (ImportError, EOFError): pass else: _verbose_message('{} matches {}', bytecode_path, source_path) - found = marshal.loads(bytes_data) - if isinstance(found, _code_type): - _imp._fix_co_filename(found, source_path) - _verbose_message('code object from {}', - bytecode_path) - return found - else: - msg = "Non-code object in {}" - raise ImportError(msg.format(bytecode_path), - name=fullname, path=bytecode_path) + return _compile_bytecode(bytes_data, name=fullname, + bytecode_path=bytecode_path, + source_path=source_path) source_bytes = self.get_data(source_path) code_object = self.source_to_code(source_bytes, source_path) _verbose_message('code object from {}', source_path) @@ -1098,14 +1111,8 @@ def get_code(self, fullname): path = self.get_filename(fullname) data = self.get_data(path) - bytes_data = self._bytes_from_bytecode(fullname, data, path, None) - found = marshal.loads(bytes_data) - if isinstance(found, _code_type): - _verbose_message('code object from {!r}', path) - return found - else: - raise ImportError("Non-code object in {}".format(path), - name=fullname, path=path) + bytes_data = _validate_bytecode_header(data, name=fullname, path=path) + return _compile_bytecode(bytes_data, name=fullname, bytecode_path=path) def get_source(self, fullname): """Return None as there is no source code.""" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -217,6 +217,10 @@ Library ------- +- Issue #15031: Refactor some .pyc management code to cut down on code + duplication. Thanks to Ronan Lamy for the report and taking an initial stab + at the problem. + - Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed. - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 00:40:07 2013 From: python-checkins at python.org (vinay.sajip) Date: Sat, 12 Jan 2013 00:40:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Closes_=2316613=3A_Added_o?= =?utf-8?q?ptional_mapping_argument_to_ChainMap=2Enew=5Fchild=2E?= Message-ID: <3YjgY358JQzS9N@mail.python.org> http://hg.python.org/cpython/rev/c0ddae67f4df changeset: 81433:c0ddae67f4df user: Vinay Sajip date: Fri Jan 11 23:39:53 2013 +0000 summary: Closes #16613: Added optional mapping argument to ChainMap.new_child. files: Doc/library/collections.rst | 13 ++++++--- Lib/collections/__init__.py | 11 ++++++-- Lib/test/test_collections.py | 32 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -76,14 +76,19 @@ be modified to change which mappings are searched. The list should always contain at least one mapping. - .. method:: new_child() + .. method:: new_child(m=None) - Returns a new :class:`ChainMap` containing a new :class:`dict` followed by - all of the maps in the current instance. A call to ``d.new_child()`` is - equivalent to: ``ChainMap({}, *d.maps)``. This method is used for + Returns a new :class:`ChainMap` containing a new map followed by + all of the maps in the current instance. If ``m`` is specified, + it becomes the new map at the front of the list of mappings; if not + specified, an empty dict is used, so that a call to ``d.new_child()`` + is equivalent to: ``ChainMap({}, *d.maps)``. This method is used for creating subcontexts that can be updated without altering values in any of the parent mappings. + .. versionchanged:: 3.4 + The optional ``m`` parameter was added. + .. attribute:: parents Property returning a new :class:`ChainMap` containing all of the maps in diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -821,9 +821,14 @@ __copy__ = copy - def new_child(self): # like Django's Context.push() - 'New ChainMap with a new dict followed by all previous maps.' - return self.__class__({}, *self.maps) + def new_child(self, m=None): # like Django's Context.push() + ''' + New ChainMap with a new map followed by all previous maps. If no + map is provided, an empty dict is used. + ''' + if m is None: + m = {} + return self.__class__(m, *self.maps) @property def parents(self): # like Django's Context.pop() diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -112,6 +112,38 @@ self.assertEqual(dict(d), dict(a=1, b=2, c=30)) self.assertEqual(dict(d.items()), dict(a=1, b=2, c=30)) + def test_new_child(self): + 'Tests for changes for issue #16613.' + c = ChainMap() + c['a'] = 1 + c['b'] = 2 + m = {'b':20, 'c': 30} + d = c.new_child(m) + self.assertEqual(d.maps, [{'b':20, 'c':30}, {'a':1, 'b':2}]) # check internal state + self.assertIs(m, d.maps[0]) + + # Use a different map than a dict + class lowerdict(dict): + def __getitem__(self, key): + if isinstance(key, str): + key = key.lower() + return dict.__getitem__(self, key) + def __contains__(self, key): + if isinstance(key, str): + key = key.lower() + return dict.__contains__(self, key) + + c = ChainMap() + c['a'] = 1 + c['b'] = 2 + m = lowerdict(b=20, c=30) + d = c.new_child(m) + self.assertIs(m, d.maps[0]) + for key in 'abc': # check contains + self.assertIn(key, d) + for k, v in dict(a=1, B=20, C=30, z=100).items(): # check get + self.assertEqual(d.get(k, 100), v) + ################################################################################ ### Named Tuples -- Repository URL: http://hg.python.org/cpython From ncoghlan at gmail.com Sat Jan 12 03:55:25 2013 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sat, 12 Jan 2013 12:55:25 +1000 Subject: [Python-checkins] cpython: Issue #15031: Refactor some code in importlib pertaining to validating In-Reply-To: <3Yjfsp6PBWzSBY@mail.python.org> References: <3Yjfsp6PBWzSBY@mail.python.org> Message-ID: Nice improvement. Just a couple of minor cleanup suggestions. On Sat, Jan 12, 2013 at 9:09 AM, brett.cannon wrote: > + else: > + # To prevent having to make all messages have a conditional name. > + name = 'bytecode' For consistency with other default/implied names, I suggest wrapping this in angle brackets: "") > + if path is not None: > + exc_details['path'] = path > + magic = data[:4] > + raw_timestamp = data[4:8] > + raw_size = data[8:12] > + if magic != _MAGIC_BYTES: > + msg = 'bad magic number in {!r}: {!r}'.format(name, magic) > + raise ImportError(msg, **exc_details) > + elif len(raw_timestamp) != 4: > + message = 'bad timestamp in {!r}'.format(name) > + _verbose_message(message) > + raise EOFError(message) > + elif len(raw_size) != 4: > + message = 'bad size in {!r}'.format(name) > + _verbose_message(message) > + raise EOFError(message) For timestamp and size "incomplete" would probably be a better word than "bad" in the error messages (since we're only checking the length rather than the value). Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia From python-checkins at python.org Sat Jan 12 04:31:13 2013 From: python-checkins at python.org (chris.jerdonek) Date: Sat, 12 Jan 2013 04:31:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2OTMz?= =?utf-8?q?=3A_Improve_choices_examples_in_argparse_documentation=2E?= Message-ID: <3Yjmgj20S3zSBM@mail.python.org> http://hg.python.org/cpython/rev/b2bb3219d36d changeset: 81434:b2bb3219d36d branch: 2.7 parent: 81423:2d0c5f97af48 user: Chris Jerdonek date: Fri Jan 11 19:25:28 2013 -0800 summary: Issue #16933: Improve choices examples in argparse documentation. files: Doc/library/argparse.rst | 41 ++++++++++++++------------- 1 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1005,32 +1005,33 @@ ^^^^^^^ Some command-line arguments should be selected from a restricted set of values. -These can be handled by passing a container object as the ``choices`` keyword +These can be handled by passing a container object as the *choices* keyword argument to :meth:`~ArgumentParser.add_argument`. When the command line is -parsed, argument values will be checked, and an error message will be displayed if -the argument was not one of the acceptable values:: +parsed, argument values will be checked, and an error message will be displayed +if the argument was not one of the acceptable values:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', choices='abc') - >>> parser.parse_args('c'.split()) - Namespace(foo='c') - >>> parser.parse_args('X'.split()) - usage: PROG [-h] {a,b,c} - PROG: error: argument foo: invalid choice: 'X' (choose from 'a', 'b', 'c') + >>> parser = argparse.ArgumentParser(prog='game.py') + >>> parser.add_argument('move', choices=['rock', 'paper', 'scissors']) + >>> parser.parse_args(['rock']) + Namespace(move='rock') + >>> parser.parse_args(['fire']) + usage: game.py [-h] {rock,paper,scissors} + game.py: error: argument move: invalid choice: 'fire' (choose from 'rock', + 'paper', 'scissors') -Note that inclusion in the ``choices`` container is checked after any type_ -conversions have been performed, so the type of the objects in the ``choices`` +Note that inclusion in the *choices* container is checked after any type_ +conversions have been performed, so the type of the objects in the *choices* container should match the type_ specified:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', type=complex, choices=[1, 1j]) - >>> parser.parse_args('1j'.split()) - Namespace(foo=1j) - >>> parser.parse_args('-- -4'.split()) - usage: PROG [-h] {1,1j} - PROG: error: argument foo: invalid choice: (-4+0j) (choose from 1, 1j) + >>> parser = argparse.ArgumentParser(prog='doors.py') + >>> parser.add_argument('door', type=int, choices=range(1, 4)) + >>> print(parser.parse_args(['3'])) + Namespace(door=3) + >>> parser.parse_args(['4']) + usage: doors.py [-h] {1,2,3} + doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3) -Any object that supports the ``in`` operator can be passed as the ``choices`` +Any object that supports the ``in`` operator can be passed as the *choices* value, so :class:`dict` objects, :class:`set` objects, custom containers, etc. are all supported. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 04:31:14 2013 From: python-checkins at python.org (chris.jerdonek) Date: Sat, 12 Jan 2013 04:31:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2OTMz?= =?utf-8?q?_=282=2E7_forward-port=29=3A_Improve_choices_examples_in_argpar?= =?utf-8?q?se_docs=2E?= Message-ID: <3Yjmgk4zhzzSBs@mail.python.org> http://hg.python.org/cpython/rev/eaa2a6074741 changeset: 81435:eaa2a6074741 branch: 3.2 parent: 81424:a9990104f728 user: Chris Jerdonek date: Fri Jan 11 19:26:44 2013 -0800 summary: Issue #16933 (2.7 forward-port): Improve choices examples in argparse docs. files: Doc/library/argparse.rst | 41 ++++++++++++++------------- 1 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1003,32 +1003,33 @@ ^^^^^^^ Some command-line arguments should be selected from a restricted set of values. -These can be handled by passing a container object as the ``choices`` keyword +These can be handled by passing a container object as the *choices* keyword argument to :meth:`~ArgumentParser.add_argument`. When the command line is -parsed, argument values will be checked, and an error message will be displayed if -the argument was not one of the acceptable values:: +parsed, argument values will be checked, and an error message will be displayed +if the argument was not one of the acceptable values:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', choices='abc') - >>> parser.parse_args('c'.split()) - Namespace(foo='c') - >>> parser.parse_args('X'.split()) - usage: PROG [-h] {a,b,c} - PROG: error: argument foo: invalid choice: 'X' (choose from 'a', 'b', 'c') + >>> parser = argparse.ArgumentParser(prog='game.py') + >>> parser.add_argument('move', choices=['rock', 'paper', 'scissors']) + >>> parser.parse_args(['rock']) + Namespace(move='rock') + >>> parser.parse_args(['fire']) + usage: game.py [-h] {rock,paper,scissors} + game.py: error: argument move: invalid choice: 'fire' (choose from 'rock', + 'paper', 'scissors') -Note that inclusion in the ``choices`` container is checked after any type_ -conversions have been performed, so the type of the objects in the ``choices`` +Note that inclusion in the *choices* container is checked after any type_ +conversions have been performed, so the type of the objects in the *choices* container should match the type_ specified:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', type=complex, choices=[1, 1j]) - >>> parser.parse_args('1j'.split()) - Namespace(foo=1j) - >>> parser.parse_args('-- -4'.split()) - usage: PROG [-h] {1,1j} - PROG: error: argument foo: invalid choice: (-4+0j) (choose from 1, 1j) + >>> parser = argparse.ArgumentParser(prog='doors.py') + >>> parser.add_argument('door', type=int, choices=range(1, 4)) + >>> print(parser.parse_args(['3'])) + Namespace(door=3) + >>> parser.parse_args(['4']) + usage: doors.py [-h] {1,2,3} + doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3) -Any object that supports the ``in`` operator can be passed as the ``choices`` +Any object that supports the ``in`` operator can be passed as the *choices* value, so :class:`dict` objects, :class:`set` objects, custom containers, etc. are all supported. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 04:31:16 2013 From: python-checkins at python.org (chris.jerdonek) Date: Sat, 12 Jan 2013 04:31:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316933_=28merge_from_3=2E2=29=3A_Improve_choices_examp?= =?utf-8?q?les_in_argparse_docs=2E?= Message-ID: <3Yjmgm0xB5zSBc@mail.python.org> http://hg.python.org/cpython/rev/de9eb3031f5a changeset: 81436:de9eb3031f5a branch: 3.3 parent: 81430:9c695fddd10a parent: 81435:eaa2a6074741 user: Chris Jerdonek date: Fri Jan 11 19:28:05 2013 -0800 summary: Issue #16933 (merge from 3.2): Improve choices examples in argparse docs. files: Doc/library/argparse.rst | 41 ++++++++++++++------------- 1 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1022,32 +1022,33 @@ ^^^^^^^ Some command-line arguments should be selected from a restricted set of values. -These can be handled by passing a container object as the ``choices`` keyword +These can be handled by passing a container object as the *choices* keyword argument to :meth:`~ArgumentParser.add_argument`. When the command line is -parsed, argument values will be checked, and an error message will be displayed if -the argument was not one of the acceptable values:: +parsed, argument values will be checked, and an error message will be displayed +if the argument was not one of the acceptable values:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', choices='abc') - >>> parser.parse_args('c'.split()) - Namespace(foo='c') - >>> parser.parse_args('X'.split()) - usage: PROG [-h] {a,b,c} - PROG: error: argument foo: invalid choice: 'X' (choose from 'a', 'b', 'c') + >>> parser = argparse.ArgumentParser(prog='game.py') + >>> parser.add_argument('move', choices=['rock', 'paper', 'scissors']) + >>> parser.parse_args(['rock']) + Namespace(move='rock') + >>> parser.parse_args(['fire']) + usage: game.py [-h] {rock,paper,scissors} + game.py: error: argument move: invalid choice: 'fire' (choose from 'rock', + 'paper', 'scissors') -Note that inclusion in the ``choices`` container is checked after any type_ -conversions have been performed, so the type of the objects in the ``choices`` +Note that inclusion in the *choices* container is checked after any type_ +conversions have been performed, so the type of the objects in the *choices* container should match the type_ specified:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', type=complex, choices=[1, 1j]) - >>> parser.parse_args('1j'.split()) - Namespace(foo=1j) - >>> parser.parse_args('-- -4'.split()) - usage: PROG [-h] {1,1j} - PROG: error: argument foo: invalid choice: (-4+0j) (choose from 1, 1j) + >>> parser = argparse.ArgumentParser(prog='doors.py') + >>> parser.add_argument('door', type=int, choices=range(1, 4)) + >>> print(parser.parse_args(['3'])) + Namespace(door=3) + >>> parser.parse_args(['4']) + usage: doors.py [-h] {1,2,3} + doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3) -Any object that supports the ``in`` operator can be passed as the ``choices`` +Any object that supports the ``in`` operator can be passed as the *choices* value, so :class:`dict` objects, :class:`set` objects, custom containers, etc. are all supported. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 04:31:17 2013 From: python-checkins at python.org (chris.jerdonek) Date: Sat, 12 Jan 2013 04:31:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316933_=28merge_from_3=2E3=29=3A_Improve_choices?= =?utf-8?q?_examples_in_argparse_docs=2E?= Message-ID: <3Yjmgn3X0tzSDC@mail.python.org> http://hg.python.org/cpython/rev/bddbaaf332d7 changeset: 81437:bddbaaf332d7 parent: 81433:c0ddae67f4df parent: 81436:de9eb3031f5a user: Chris Jerdonek date: Fri Jan 11 19:29:43 2013 -0800 summary: Issue #16933 (merge from 3.3): Improve choices examples in argparse docs. files: Doc/library/argparse.rst | 41 ++++++++++++++------------- 1 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1022,32 +1022,33 @@ ^^^^^^^ Some command-line arguments should be selected from a restricted set of values. -These can be handled by passing a container object as the ``choices`` keyword +These can be handled by passing a container object as the *choices* keyword argument to :meth:`~ArgumentParser.add_argument`. When the command line is -parsed, argument values will be checked, and an error message will be displayed if -the argument was not one of the acceptable values:: +parsed, argument values will be checked, and an error message will be displayed +if the argument was not one of the acceptable values:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', choices='abc') - >>> parser.parse_args('c'.split()) - Namespace(foo='c') - >>> parser.parse_args('X'.split()) - usage: PROG [-h] {a,b,c} - PROG: error: argument foo: invalid choice: 'X' (choose from 'a', 'b', 'c') + >>> parser = argparse.ArgumentParser(prog='game.py') + >>> parser.add_argument('move', choices=['rock', 'paper', 'scissors']) + >>> parser.parse_args(['rock']) + Namespace(move='rock') + >>> parser.parse_args(['fire']) + usage: game.py [-h] {rock,paper,scissors} + game.py: error: argument move: invalid choice: 'fire' (choose from 'rock', + 'paper', 'scissors') -Note that inclusion in the ``choices`` container is checked after any type_ -conversions have been performed, so the type of the objects in the ``choices`` +Note that inclusion in the *choices* container is checked after any type_ +conversions have been performed, so the type of the objects in the *choices* container should match the type_ specified:: - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('foo', type=complex, choices=[1, 1j]) - >>> parser.parse_args('1j'.split()) - Namespace(foo=1j) - >>> parser.parse_args('-- -4'.split()) - usage: PROG [-h] {1,1j} - PROG: error: argument foo: invalid choice: (-4+0j) (choose from 1, 1j) + >>> parser = argparse.ArgumentParser(prog='doors.py') + >>> parser.add_argument('door', type=int, choices=range(1, 4)) + >>> print(parser.parse_args(['3'])) + Namespace(door=3) + >>> parser.parse_args(['4']) + usage: doors.py [-h] {1,2,3} + doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3) -Any object that supports the ``in`` operator can be passed as the ``choices`` +Any object that supports the ``in`` operator can be passed as the *choices* value, so :class:`dict` objects, :class:`set` objects, custom containers, etc. are all supported. -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Sat Jan 12 05:58:35 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 12 Jan 2013 05:58:35 +0100 Subject: [Python-checkins] Daily reference leaks (c0ddae67f4df): sum=280 Message-ID: results for c0ddae67f4df on branch "default" -------------------------------------------- test_xml_etree_c leaked [56, 56, 56] references, sum=168 test_xml_etree_c leaked [36, 38, 38] memory blocks, sum=112 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogBm4Rxs', '-x'] From python-checkins at python.org Sat Jan 12 07:30:12 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 12 Jan 2013 07:30:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316398=3A_Optimize?= =?utf-8?b?IGRlcXVlLnJvdGF0ZSgp?= Message-ID: <3YjrfD1z9FzSCk@mail.python.org> http://hg.python.org/cpython/rev/9fb793b60e79 changeset: 81438:9fb793b60e79 user: Raymond Hettinger date: Fri Jan 11 22:29:50 2013 -0800 summary: Issue #16398: Optimize deque.rotate() files: Misc/NEWS | 3 + Modules/_collectionsmodule.c | 72 +++++++++++++++++++---- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -221,6 +221,9 @@ duplication. Thanks to Ronan Lamy for the report and taking an initial stab at the problem. +- Issue #16398: Optimize deque.rotate() so that it only moves pointers + and doesn't touch the underlying data with increfs and decrefs. + - Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed. - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -414,9 +414,10 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n) { Py_ssize_t i, len=deque->len, halflen=(len+1)>>1; - PyObject *item, *rv; + PyObject *item; + block *prevblock, *leftblock, *rightblock; - if (len == 0) + if (len <= 1) return 0; if (n > halflen || n < -halflen) { n %= len; @@ -426,23 +427,66 @@ n += len; } + assert(deque->len > 1); + deque->state++; + leftblock = deque->leftblock; + rightblock = deque->rightblock; for (i=0 ; idata[deque->rightindex]; assert (item != NULL); - rv = deque_appendleft(deque, item); - Py_DECREF(item); - if (rv == NULL) - return -1; - Py_DECREF(rv); + deque->rightindex--; + if (deque->rightindex == -1) { + assert(rightblock != NULL); + prevblock = rightblock->leftlink; + assert(leftblock != rightblock); + freeblock(rightblock); + prevblock->rightlink = NULL; + deque->rightblock = rightblock = prevblock; + deque->rightindex = BLOCKLEN - 1; + } + if (deque->leftindex == 0) { + block *b = newblock(NULL, leftblock, deque->len); + if (b == NULL) { + deque->len--; + Py_DECREF(item); + return -1; + } + assert(leftblock->leftlink == NULL); + leftblock->leftlink = b; + deque->leftblock = leftblock = b; + deque->leftindex = BLOCKLEN; + } + deque->leftindex--; + leftblock->data[deque->leftindex] = item; } for (i=0 ; i>n ; i--) { - item = deque_popleft(deque, NULL); + assert(leftblock != NULL); + item = leftblock->data[deque->leftindex]; assert (item != NULL); - rv = deque_append(deque, item); - Py_DECREF(item); - if (rv == NULL) - return -1; - Py_DECREF(rv); + deque->leftindex++; + if (deque->leftindex == BLOCKLEN) { + assert(leftblock != rightblock); + prevblock = leftblock->rightlink; + freeblock(leftblock); + assert(prevblock != NULL); + prevblock->leftlink = NULL; + deque->leftblock = leftblock = prevblock; + deque->leftindex = 0; + } + if (deque->rightindex == BLOCKLEN-1) { + block *b = newblock(rightblock, NULL, deque->len); + if (b == NULL) { + deque->len--; + Py_DECREF(item); + return -1; + } + assert(rightblock->rightlink == NULL); + rightblock->rightlink = b; + deque->rightblock = rightblock = b; + deque->rightindex = -1; + } + deque->rightindex++; + rightblock->data[deque->rightindex] = item; } return 0; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 09:05:16 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 12 Jan 2013 09:05:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2Mzk4?= =?utf-8?q?=3A_Optimize_deque=2Erotate=28=29?= Message-ID: <3Yjtlw6LyNzSCc@mail.python.org> http://hg.python.org/cpython/rev/0d81333bde78 changeset: 81439:0d81333bde78 branch: 2.7 parent: 81434:b2bb3219d36d user: Raymond Hettinger date: Sat Jan 12 00:05:00 2013 -0800 summary: Issue #16398: Optimize deque.rotate() files: Misc/NEWS | 3 + Modules/_collectionsmodule.c | 72 +++++++++++++++++++---- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,9 @@ - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. +- Issue #16398: Optimize deque.rotate() so that it only moves pointers + and doesn't touch the underlying data with increfs and decrefs. + - Issue #15109: Fix regression in sqlite3's iterdump method where it would die with an encoding error if the database contained string values containing non-ASCII. (Regression was introduced by fix for 9750). diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -414,9 +414,10 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n) { Py_ssize_t i, len=deque->len, halflen=(len+1)>>1; - PyObject *item, *rv; + PyObject *item; + block *prevblock, *leftblock, *rightblock; - if (len == 0) + if (len <= 1) return 0; if (n > halflen || n < -halflen) { n %= len; @@ -426,23 +427,66 @@ n += len; } + assert(deque->len > 1); + deque->state++; + leftblock = deque->leftblock; + rightblock = deque->rightblock; for (i=0 ; idata[deque->rightindex]; assert (item != NULL); - rv = deque_appendleft(deque, item); - Py_DECREF(item); - if (rv == NULL) - return -1; - Py_DECREF(rv); + deque->rightindex--; + if (deque->rightindex == -1) { + assert(rightblock != NULL); + prevblock = rightblock->leftlink; + assert(leftblock != rightblock); + freeblock(rightblock); + prevblock->rightlink = NULL; + deque->rightblock = rightblock = prevblock; + deque->rightindex = BLOCKLEN - 1; + } + if (deque->leftindex == 0) { + block *b = newblock(NULL, leftblock, deque->len); + if (b == NULL) { + deque->len--; + Py_DECREF(item); + return -1; + } + assert(leftblock->leftlink == NULL); + leftblock->leftlink = b; + deque->leftblock = leftblock = b; + deque->leftindex = BLOCKLEN; + } + deque->leftindex--; + leftblock->data[deque->leftindex] = item; } for (i=0 ; i>n ; i--) { - item = deque_popleft(deque, NULL); + assert(leftblock != NULL); + item = leftblock->data[deque->leftindex]; assert (item != NULL); - rv = deque_append(deque, item); - Py_DECREF(item); - if (rv == NULL) - return -1; - Py_DECREF(rv); + deque->leftindex++; + if (deque->leftindex == BLOCKLEN) { + assert(leftblock != rightblock); + prevblock = leftblock->rightlink; + freeblock(leftblock); + assert(prevblock != NULL); + prevblock->leftlink = NULL; + deque->leftblock = leftblock = prevblock; + deque->leftindex = 0; + } + if (deque->rightindex == BLOCKLEN-1) { + block *b = newblock(rightblock, NULL, deque->len); + if (b == NULL) { + deque->len--; + Py_DECREF(item); + return -1; + } + assert(rightblock->rightlink == NULL); + rightblock->rightlink = b; + deque->rightblock = rightblock = b; + deque->rightindex = -1; + } + deque->rightindex++; + rightblock->data[deque->rightindex] = item; } return 0; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 09:41:02 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 12 Jan 2013 09:41:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE2OTQwOiBmaXgg?= =?utf-8?q?indentation_in_example=2E?= Message-ID: <3YjvYB5QjdzSCx@mail.python.org> http://hg.python.org/cpython/rev/eae31f2b6f60 changeset: 81440:eae31f2b6f60 branch: 2.7 user: Ezio Melotti date: Sat Jan 12 10:39:45 2013 +0200 summary: #16940: fix indentation in example. files: Doc/library/argparse.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1486,8 +1486,8 @@ positional arguments: {a,b} sub-command help - a a help - b b help + a a help + b b help optional arguments: -h, --help show this help message and exit -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 09:41:04 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 12 Jan 2013 09:41:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE2OTQwOiBmaXgg?= =?utf-8?q?indentation_in_example=2E?= Message-ID: <3YjvYD0yG7zR1G@mail.python.org> http://hg.python.org/cpython/rev/3d54723c9be6 changeset: 81441:3d54723c9be6 branch: 3.2 parent: 81435:eaa2a6074741 user: Ezio Melotti date: Sat Jan 12 10:39:45 2013 +0200 summary: #16940: fix indentation in example. files: Doc/library/argparse.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1487,8 +1487,8 @@ positional arguments: {a,b} sub-command help - a a help - b b help + a a help + b b help optional arguments: -h, --help show this help message and exit -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 09:41:05 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 12 Jan 2013 09:41:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2316940=3A_merge_with_3=2E2=2E?= Message-ID: <3YjvYF3f0kzS8T@mail.python.org> http://hg.python.org/cpython/rev/b468f6c8eae5 changeset: 81442:b468f6c8eae5 branch: 3.3 parent: 81436:de9eb3031f5a parent: 81441:3d54723c9be6 user: Ezio Melotti date: Sat Jan 12 10:40:24 2013 +0200 summary: #16940: merge with 3.2. files: Doc/library/argparse.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1506,8 +1506,8 @@ positional arguments: {a,b} sub-command help - a a help - b b help + a a help + b b help optional arguments: -h, --help show this help message and exit -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 09:41:06 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 12 Jan 2013 09:41:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2OTQwOiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YjvYG6GkgzS8T@mail.python.org> http://hg.python.org/cpython/rev/6fe28afa6611 changeset: 81443:6fe28afa6611 parent: 81438:9fb793b60e79 parent: 81442:b468f6c8eae5 user: Ezio Melotti date: Sat Jan 12 10:40:49 2013 +0200 summary: #16940: merge with 3.3. files: Doc/library/argparse.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1506,8 +1506,8 @@ positional arguments: {a,b} sub-command help - a a help - b b help + a a help + b b help optional arguments: -h, --help show this help message and exit -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 12:32:52 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 12 Jan 2013 12:32:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316876=3A_Revert_b?= =?utf-8?q?e8e6b81284e=2C_which_wasn=27t_thread-safe=3A_wait_until_a?= Message-ID: <3YjzMS3C6nzSDp@mail.python.org> http://hg.python.org/cpython/rev/30eb98c8afef changeset: 81444:30eb98c8afef user: Charles-Fran?ois Natali date: Sat Jan 12 12:31:00 2013 +0100 summary: Issue #16876: Revert be8e6b81284e, which wasn't thread-safe: wait until a solution is found for poll(). files: Misc/NEWS | 3 -- Modules/selectmodule.c | 45 ++++++++--------------------- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -233,9 +233,6 @@ failing if the connection used a row factory (such as sqlite3.Row) that produced unsortable objects. (Regression was introduced by fix for 9750). -- Issue #16876: Optimize epoll.poll() by keeping a per-instance epoll events - buffer instead of allocating a new one at each poll(). - - Issue #16491: IDLE now prints chained exception tracebacks. - fcntl: add F_DUPFD_CLOEXEC constant, available on Linux 2.6.24+. diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1056,14 +1056,9 @@ #include #endif -/* default maximum number of events returned by epoll_wait() */ -#define EPOLL_DEFAULT_MAXEVENTS (FD_SETSIZE) - typedef struct { PyObject_HEAD - SOCKET epfd; /* epoll control file descriptor */ - int maxevents; /* maximum number of epoll events */ - struct epoll_event *evs; /* epoll events buffer */ + SOCKET epfd; /* epoll control file descriptor */ } pyEpoll_Object; static PyTypeObject pyEpoll_Type; @@ -1119,15 +1114,6 @@ PyErr_SetFromErrno(PyExc_OSError); return NULL; } - - self->maxevents = EPOLL_DEFAULT_MAXEVENTS; - self->evs = PyMem_New(struct epoll_event, self->maxevents); - if (!self->evs) { - Py_DECREF(self); - PyErr_NoMemory(); - return NULL; - } - return (PyObject *)self; } @@ -1154,10 +1140,6 @@ pyepoll_dealloc(pyEpoll_Object *self) { (void)pyepoll_internal_close(self); - if (self->evs) { - PyMem_Free(self->evs); - self->evs = NULL; - } Py_TYPE(self)->tp_free(self); } @@ -1338,6 +1320,7 @@ int maxevents = -1; int nfds, i; PyObject *elist = NULL, *etuple = NULL; + struct epoll_event *evs = NULL; static char *kwlist[] = {"timeout", "maxevents", NULL}; if (self->epfd < 0) @@ -1361,27 +1344,24 @@ } if (maxevents == -1) { - maxevents = EPOLL_DEFAULT_MAXEVENTS; - } else if (maxevents < 1) { + maxevents = FD_SETSIZE-1; + } + else if (maxevents < 1) { PyErr_Format(PyExc_ValueError, "maxevents must be greater than 0, got %d", maxevents); return NULL; } - if (maxevents > self->maxevents) { - struct epoll_event *orig_evs = self->evs; - PyMem_RESIZE(self->evs, struct epoll_event, maxevents); - if (!self->evs) { - self->evs = orig_evs; - PyErr_NoMemory(); - return NULL; - } - self->maxevents = maxevents; + evs = PyMem_New(struct epoll_event, maxevents); + if (evs == NULL) { + Py_DECREF(self); + PyErr_NoMemory(); + return NULL; } Py_BEGIN_ALLOW_THREADS - nfds = epoll_wait(self->epfd, self->evs, self->maxevents, timeout); + nfds = epoll_wait(self->epfd, evs, maxevents, timeout); Py_END_ALLOW_THREADS if (nfds < 0) { PyErr_SetFromErrno(PyExc_OSError); @@ -1394,7 +1374,7 @@ } for (i = 0; i < nfds; i++) { - etuple = Py_BuildValue("iI", self->evs[i].data.fd, self->evs[i].events); + etuple = Py_BuildValue("iI", evs[i].data.fd, evs[i].events); if (etuple == NULL) { Py_CLEAR(elist); goto error; @@ -1403,6 +1383,7 @@ } error: + PyMem_Free(evs); return elist; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 14:21:32 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 14:21:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2MDc2?= =?utf-8?q?=3A_fix_refleak_in_pickling_of_Element=2E?= Message-ID: <3Yk1mr1TXbzS8w@mail.python.org> http://hg.python.org/cpython/rev/5b36768b9a11 changeset: 81445:5b36768b9a11 branch: 3.3 parent: 81442:b468f6c8eae5 user: Eli Bendersky date: Sat Jan 12 05:20:16 2013 -0800 summary: Issue #16076: fix refleak in pickling of Element. Thanks to Ezio Melotti and Daniel Shahaf for the patch. files: Modules/_elementtree.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -859,8 +859,10 @@ PICKLED_ATTRIB, self->extra->attrib, PICKLED_TEXT, self->text, PICKLED_TAIL, self->tail); - if (instancedict) + if (instancedict) { + Py_DECREF(children); return instancedict; + } else { for (i = 0; i < PyList_GET_SIZE(children); i++) Py_DECREF(PyList_GET_ITEM(children, i)); @@ -884,25 +886,17 @@ PyErr_SetString(PyExc_TypeError, "tag may not be NULL"); return NULL; } - if (!text) { - Py_INCREF(Py_None); - text = Py_None; - } - if (!tail) { - Py_INCREF(Py_None); - tail = Py_None; - } Py_CLEAR(self->tag); self->tag = tag; Py_INCREF(self->tag); Py_CLEAR(self->text); - self->text = text; + self->text = text ? text : Py_None; Py_INCREF(self->text); Py_CLEAR(self->tail); - self->tail = tail; + self->tail = tail ? tail : Py_None; Py_INCREF(self->tail); /* Handle ATTRIB and CHILDREN. */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 14:21:33 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 14:21:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Close_=2316076=3A_fix_refleak_in_pickling_of_Element=2E?= Message-ID: <3Yk1ms4QfjzSBJ@mail.python.org> http://hg.python.org/cpython/rev/848738d3c40f changeset: 81446:848738d3c40f parent: 81444:30eb98c8afef parent: 81445:5b36768b9a11 user: Eli Bendersky date: Sat Jan 12 05:21:06 2013 -0800 summary: Close #16076: fix refleak in pickling of Element. Thanks to Ezio Melotti and Daniel Shahaf for the patch. files: Modules/_elementtree.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -859,8 +859,10 @@ PICKLED_ATTRIB, self->extra->attrib, PICKLED_TEXT, self->text, PICKLED_TAIL, self->tail); - if (instancedict) + if (instancedict) { + Py_DECREF(children); return instancedict; + } else { for (i = 0; i < PyList_GET_SIZE(children); i++) Py_DECREF(PyList_GET_ITEM(children, i)); @@ -884,25 +886,17 @@ PyErr_SetString(PyExc_TypeError, "tag may not be NULL"); return NULL; } - if (!text) { - Py_INCREF(Py_None); - text = Py_None; - } - if (!tail) { - Py_INCREF(Py_None); - tail = Py_None; - } Py_CLEAR(self->tag); self->tag = tag; Py_INCREF(self->tag); Py_CLEAR(self->text); - self->text = text; + self->text = text ? text : Py_None; Py_INCREF(self->text); Py_CLEAR(self->tail); - self->tail = tail; + self->tail = tail ? tail : Py_None; Py_INCREF(self->tail); /* Handle ATTRIB and CHILDREN. */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 14:43:32 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 14:43:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2MDc2?= =?utf-8?q?=3A_check_for_return_value_of_PyTuple=5FNew_for_args_=28followi?= =?utf-8?q?ng?= Message-ID: <3Yk2GD5GLlzSCN@mail.python.org> http://hg.python.org/cpython/rev/4501813ea676 changeset: 81447:4501813ea676 branch: 3.3 parent: 81445:5b36768b9a11 user: Eli Bendersky date: Sat Jan 12 05:42:38 2013 -0800 summary: Issue #16076: check for return value of PyTuple_New for args (following Coverity report) and cleanup code. files: Modules/_elementtree.c | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -950,19 +950,22 @@ PICKLED_TAIL, PICKLED_CHILDREN, 0}; PyObject *args; PyObject *tag, *attrib, *text, *tail, *children; - int error; - - /* More instance dict members than we know to handle? */ + PyObject *retval; + tag = attrib = text = tail = children = NULL; args = PyTuple_New(0); - error = ! PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag, - &attrib, &text, &tail, &children); + if (!args) + return NULL; + + if (PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag, + &attrib, &text, &tail, &children)) + retval = element_setstate_from_attributes(self, tag, attrib, text, + tail, children); + else + retval = NULL; + Py_DECREF(args); - if (error) - return NULL; - else - return element_setstate_from_attributes(self, tag, attrib, text, - tail, children); + return retval; } static PyObject * -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 14:43:34 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 14:43:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316076=3A_check_for_return_value_of_PyTuple=5FNe?= =?utf-8?q?w_for_args_=28following?= Message-ID: <3Yk2GG0jLnzS8H@mail.python.org> http://hg.python.org/cpython/rev/7313096e0bad changeset: 81448:7313096e0bad parent: 81446:848738d3c40f parent: 81447:4501813ea676 user: Eli Bendersky date: Sat Jan 12 05:43:08 2013 -0800 summary: Issue #16076: check for return value of PyTuple_New for args (following Coverity report) and cleanup code. files: Modules/_elementtree.c | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -950,19 +950,22 @@ PICKLED_TAIL, PICKLED_CHILDREN, 0}; PyObject *args; PyObject *tag, *attrib, *text, *tail, *children; - int error; - - /* More instance dict members than we know to handle? */ + PyObject *retval; + tag = attrib = text = tail = children = NULL; args = PyTuple_New(0); - error = ! PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag, - &attrib, &text, &tail, &children); + if (!args) + return NULL; + + if (PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag, + &attrib, &text, &tail, &children)) + retval = element_setstate_from_attributes(self, tag, attrib, text, + tail, children); + else + retval = NULL; + Py_DECREF(args); - if (error) - return NULL; - else - return element_setstate_from_attributes(self, tag, attrib, text, - tail, children); + return retval; } static PyObject * -- Repository URL: http://hg.python.org/cpython From eliben at gmail.com Sat Jan 12 14:46:33 2013 From: eliben at gmail.com (Eli Bendersky) Date: Sat, 12 Jan 2013 05:46:33 -0800 Subject: [Python-checkins] Daily reference leaks (aef7db0d3893): sum=287 In-Reply-To: <50F038FE.208@python.org> References: <50F038FE.208@python.org> Message-ID: On Fri, Jan 11, 2013 at 8:08 AM, Christian Heimes wrote: > Am 11.01.2013 07:09, schrieb Nick Coghlan: > > On Fri, Jan 11, 2013 at 2:57 PM, wrote: > >> results for aef7db0d3893 on branch "default" > >> -------------------------------------------- > >> > >> test_dbm leaked [2, 0, 0] references, sum=2 > >> test_dbm leaked [2, 2, 1] memory blocks, sum=5 > > > > Hmm, I'm starting to wonder if there's something to this one - it > > seems to be popping up a bit lately. > > > >> test_xml_etree_c leaked [56, 56, 56] references, sum=168 > >> test_xml_etree_c leaked [36, 38, 38] memory blocks, sum=112 > > > > I'm gonna take a wild guess and suggest there may be a problem with > > the recent pickling fix in the C extension :) > > It has more issues. Coverity has sent me some complains, see attachment. > The second report is indeed a false positive. Coverity doesn't know that PyList_GET_SIZE returns 0 for PyList_New(0). Maybe it can be taught some project/domain-specific information? The first report is legit, however. PyTuple_New(0) was called and its return value wasn't checked for NULL. I actually think Coverity is very useful for such cases because forgetting to check NULL returns from PyObject constructors is a common mistake and it's not something that would show up in tests. Anyway, this was fixed. Thanks for reporting Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From brett at python.org Sat Jan 12 14:57:39 2013 From: brett at python.org (Brett Cannon) Date: Sat, 12 Jan 2013 08:57:39 -0500 Subject: [Python-checkins] cpython: Issue #15031: Refactor some code in importlib pertaining to validating In-Reply-To: References: <3Yjfsp6PBWzSBY@mail.python.org> Message-ID: On Fri, Jan 11, 2013 at 9:55 PM, Nick Coghlan wrote: > Nice improvement. Just a couple of minor cleanup suggestions. > > On Sat, Jan 12, 2013 at 9:09 AM, brett.cannon > wrote: >> + else: >> + # To prevent having to make all messages have a conditional name. >> + name = 'bytecode' > > For consistency with other default/implied names, I suggest wrapping > this in angle brackets: "") Good suggestion. > >> + if path is not None: >> + exc_details['path'] = path >> + magic = data[:4] >> + raw_timestamp = data[4:8] >> + raw_size = data[8:12] >> + if magic != _MAGIC_BYTES: >> + msg = 'bad magic number in {!r}: {!r}'.format(name, magic) >> + raise ImportError(msg, **exc_details) >> + elif len(raw_timestamp) != 4: >> + message = 'bad timestamp in {!r}'.format(name) >> + _verbose_message(message) >> + raise EOFError(message) >> + elif len(raw_size) != 4: >> + message = 'bad size in {!r}'.format(name) >> + _verbose_message(message) >> + raise EOFError(message) > > For timestamp and size "incomplete" would probably be a better word > than "bad" in the error messages (since we're only checking the length > rather than the value). True. Those were the original messages and in hindsight not accurate. Since we don't consider exception messages a backwards-compatible thing I'll update them. From python-checkins at python.org Sat Jan 12 15:13:56 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 15:13:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Close_=2315442=3A_Expand_t?= =?utf-8?q?he_list_of_default_directories_ignored_by_filecmp=2Edircmp?= Message-ID: <3Yk2xJ5bqrzS5v@mail.python.org> http://hg.python.org/cpython/rev/a1efab48d8f8 changeset: 81449:a1efab48d8f8 user: Eli Bendersky date: Sat Jan 12 06:13:32 2013 -0800 summary: Close #15442: Expand the list of default directories ignored by filecmp.dircmp and expose it as a module attribute files: Doc/library/filecmp.rst | 14 ++++++++++---- Lib/filecmp.py | 10 +++++++--- Lib/test/test_filecmp.py | 16 +++++++++++----- Misc/NEWS | 4 ++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -55,10 +55,10 @@ .. class:: dircmp(a, b, ignore=None, hide=None) - Construct a new directory comparison object, to compare the directories *a* and - *b*. *ignore* is a list of names to ignore, and defaults to ``['RCS', 'CVS', - 'tags']``. *hide* is a list of names to hide, and defaults to ``[os.curdir, - os.pardir]``. + Construct a new directory comparison object, to compare the directories *a* + and *b*. *ignore* is a list of names to ignore, and defaults to + :attr:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and + defaults to ``[os.curdir, os.pardir]``. The :class:`dircmp` class compares files by doing *shallow* comparisons as described for :func:`filecmp.cmp`. @@ -164,6 +164,12 @@ A dictionary mapping names in :attr:`common_dirs` to :class:`dircmp` objects. +.. attribute:: DEFAULT_IGNORES + + .. versionadded:: 3.3 + + List of directories ignored by :class:`dircmp` by default. + Here is a simplified example of using the ``subdirs`` attribute to search recursively through two directories to show common different files:: diff --git a/Lib/filecmp.py b/Lib/filecmp.py --- a/Lib/filecmp.py +++ b/Lib/filecmp.py @@ -13,11 +13,15 @@ import stat from itertools import filterfalse -__all__ = ["cmp", "dircmp", "cmpfiles"] +__all__ = ['cmp', 'dircmp', 'cmpfiles', 'DEFAULT_IGNORES'] _cache = {} BUFSIZE = 8*1024 +DEFAULT_IGNORES = [ + 'RCS', 'CVS', 'tags', '.git', '.hg', '.bzr', '_darcs', '__pycache__'] + + def cmp(f1, f2, shallow=True): """Compare two files. @@ -80,7 +84,7 @@ dircmp(a, b, ignore=None, hide=None) A and B are directories. IGNORE is a list of names to ignore, - defaults to ['RCS', 'CVS', 'tags']. + defaults to DEFAULT_IGNORES. HIDE is a list of names to hide, defaults to [os.curdir, os.pardir]. @@ -116,7 +120,7 @@ else: self.hide = hide if ignore is None: - self.ignore = ['RCS', 'CVS', 'tags'] # Names ignored in comparison + self.ignore = DEFAULT_IGNORES else: self.ignore = ignore diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py --- a/Lib/test/test_filecmp.py +++ b/Lib/test/test_filecmp.py @@ -1,4 +1,3 @@ - import os, filecmp, shutil, tempfile import unittest from test import support @@ -46,9 +45,14 @@ self.dir = os.path.join(tmpdir, 'dir') self.dir_same = os.path.join(tmpdir, 'dir-same') self.dir_diff = os.path.join(tmpdir, 'dir-diff') + + # Another dir is created under dir_same, but it has a name from the + # ignored list so it should not affect testing results. + self.dir_ignored = os.path.join(self.dir_same, '.hg') + self.caseinsensitive = os.path.normcase('A') == os.path.normcase('a') data = 'Contents of file go here.\n' - for dir in [self.dir, self.dir_same, self.dir_diff]: + for dir in (self.dir, self.dir_same, self.dir_diff, self.dir_ignored): shutil.rmtree(dir, True) os.mkdir(dir) if self.caseinsensitive and dir is self.dir_same: @@ -64,9 +68,11 @@ output.close() def tearDown(self): - shutil.rmtree(self.dir) - shutil.rmtree(self.dir_same) - shutil.rmtree(self.dir_diff) + for dir in (self.dir, self.dir_same, self.dir_diff): + shutil.rmtree(dir) + + def test_default_ignores(self): + self.assertIn('.hg', filecmp.DEFAULT_IGNORES) def test_cmpfiles(self): self.assertTrue(filecmp.cmpfiles(self.dir, self.dir, ['file']) == diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1387,6 +1387,10 @@ - Issue #15250: Document that `filecmp.dircmp()` compares files shallowly. Patch contributed by Chris Jerdonek. +- Issue #15442: Expose the default list of directories ignored by + `filecmp.dircmp()` as a module attribute, and expand the list to more modern + values. + Tests ----- -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 15:48:40 2013 From: python-checkins at python.org (nick.coghlan) Date: Sat, 12 Jan 2013 15:48:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Updates_based_on_implementati?= =?utf-8?q?on_progress?= Message-ID: <3Yk3jN1cWKzS8Y@mail.python.org> http://hg.python.org/peps/rev/89781bc231d9 changeset: 4665:89781bc231d9 user: Nick Coghlan date: Sun Jan 13 00:48:28 2013 +1000 summary: Updates based on implementation progress files: pep-0432.txt | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -177,6 +177,8 @@ * Whether or not to use randomised hashes (and if used, potentially specify a specific random seed) +* Whether or not to enable the import system (required by CPython's + build process when freezing the importlib._bootstrap bytecode) * The "Where is Python located?" elements in the ``sys`` module: * ``sys.executable`` * ``sys.base_exec_prefix`` @@ -406,6 +408,7 @@ TBD: Cover the initialization of the following in more detail: +* Completely disabling the import system * The initial warning system state: * ``sys.warnoptions`` * (-W option, PYTHONWARNINGS) @@ -612,9 +615,10 @@ int ignore_environment; /* -E switch */ int use_hash_seed; /* PYTHONHASHSEED */ unsigned long hash_seed; /* PYTHONHASHSEED */ + int _disable_importlib; /* Needed by freeze_importlib */ } Py_CoreConfig; - #define Py_CoreConfig_INIT {0, -1, 0} + #define Py_CoreConfig_INIT {0, -1, 0, 0} The core configuration settings pointer may be ``NULL``, in which case the default values are ``ignore_environment = 0`` and ``use_hash_seed = -1``. @@ -661,6 +665,13 @@ ``hash_seed``. On success the function will return zero. A non-zero return value indicates an error (most likely in the conversion to an integer). +The ``_disable_importlib`` setting is used as part of the CPython build +process to create an interpreter with no import capability at all. It is +considered private to the CPython development team (hence the leading +underscore), as the only known use case is to permit compiler changes +that invalidate the previously frozen bytecode for ``importlib._bootstrap`` +without breaking the build process. + The aim is to keep this initial level of configuration as small as possible in order to keep the bootstrapping environment consistent across different embedding applications. If we can create a valid interpreter state @@ -1046,8 +1057,17 @@ Implementation ============== -None as yet. Once I have a reasonably solid plan of attack, I intend to work -on a reference implementation as a feature branch in my BitBucket sandbox [2_] +The reference implementation is being developed as a feature branch in my +BitBucket sandbox [2_]. + +As the number of application binaries created by the build process is now +four, the reference implementation also creates a new top level "Apps" +directory in the CPython source tree. The source files for the main +``python`` binary and the new ``pysystem`` binary will be located in that +directory. The source files for the ``_freeze_importlib`` binary and the +``_testembed`` binary have been moved out of the Modules directory (which +is intended for CPython builtin and extension modules) and into the Tools +directory. References @@ -1057,7 +1077,7 @@ (http://wiki.python.org/moin/CPythonInterpreterInitialization) .. [2] BitBucket Sandbox - (https://bitbucket.org/ncoghlan/cpython_sandbox) + (https://bitbucket.org/ncoghlan/cpython_sandbox/compare/pep432_modular_bootstrap..default#commits) .. [3] \*nix getpath implementation (http://hg.python.org/cpython/file/default/Modules/getpath.c) -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sat Jan 12 16:45:12 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 16:45:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWVzICMxNTA4?= =?utf-8?q?3_and_=2316992=3A_port_find=2E*_method_tests_to_unittest?= Message-ID: <3Yk4yc4HhNzRxt@mail.python.org> http://hg.python.org/cpython/rev/f9d1d120c19e changeset: 81450:f9d1d120c19e branch: 3.3 parent: 81447:4501813ea676 user: Eli Bendersky date: Sat Jan 12 07:42:46 2013 -0800 summary: Issues #15083 and #16992: port find.* method tests to unittest files: Lib/test/test_xml_etree.py | 228 ++++++++++-------------- 1 files changed, 94 insertions(+), 134 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -329,128 +329,6 @@ 'hello' """ -def find(): - """ - Test find methods (including xpath syntax). - - >>> elem = ET.XML(SAMPLE_XML) - >>> elem.find("tag").tag - 'tag' - >>> ET.ElementTree(elem).find("tag").tag - 'tag' - >>> elem.find("section/tag").tag - 'tag' - >>> elem.find("./tag").tag - 'tag' - >>> ET.ElementTree(elem).find("./tag").tag - 'tag' - >>> ET.ElementTree(elem).find("/tag").tag - 'tag' - >>> elem[2] = ET.XML(SAMPLE_SECTION) - >>> elem.find("section/nexttag").tag - 'nexttag' - >>> ET.ElementTree(elem).find("section/tag").tag - 'tag' - >>> ET.ElementTree(elem).find("tog") - >>> ET.ElementTree(elem).find("tog/foo") - >>> elem.findtext("tag") - 'text' - >>> elem.findtext("section/nexttag") - '' - >>> elem.findtext("section/nexttag", "default") - '' - >>> elem.findtext("tog") - >>> elem.findtext("tog", "default") - 'default' - >>> ET.ElementTree(elem).findtext("tag") - 'text' - >>> ET.ElementTree(elem).findtext("tog/foo") - >>> ET.ElementTree(elem).findtext("tog/foo", "default") - 'default' - >>> ET.ElementTree(elem).findtext("./tag") - 'text' - >>> ET.ElementTree(elem).findtext("/tag") - 'text' - >>> elem.findtext("section/tag") - 'subtext' - >>> ET.ElementTree(elem).findtext("section/tag") - 'subtext' - >>> summarize_list(elem.findall(".")) - ['body'] - >>> summarize_list(elem.findall("tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall("tog")) - [] - >>> summarize_list(elem.findall("tog/foo")) - [] - >>> summarize_list(elem.findall("*")) - ['tag', 'tag', 'section'] - >>> summarize_list(elem.findall(".//tag")) - ['tag', 'tag', 'tag', 'tag'] - >>> summarize_list(elem.findall("section/tag")) - ['tag'] - >>> summarize_list(elem.findall("section//tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall("section/*")) - ['tag', 'nexttag', 'nextsection'] - >>> summarize_list(elem.findall("section//*")) - ['tag', 'nexttag', 'nextsection', 'tag'] - >>> summarize_list(elem.findall("section/.//*")) - ['tag', 'nexttag', 'nextsection', 'tag'] - >>> summarize_list(elem.findall("*/*")) - ['tag', 'nexttag', 'nextsection'] - >>> summarize_list(elem.findall("*//*")) - ['tag', 'nexttag', 'nextsection', 'tag'] - >>> summarize_list(elem.findall("*/tag")) - ['tag'] - >>> summarize_list(elem.findall("*/./tag")) - ['tag'] - >>> summarize_list(elem.findall("./tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall(".//tag")) - ['tag', 'tag', 'tag', 'tag'] - >>> summarize_list(elem.findall("././tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall(".//tag[@class]")) - ['tag', 'tag', 'tag'] - >>> summarize_list(elem.findall(".//tag[@class='a']")) - ['tag'] - >>> summarize_list(elem.findall(".//tag[@class='b']")) - ['tag', 'tag'] - >>> summarize_list(elem.findall(".//tag[@id]")) - ['tag'] - >>> summarize_list(elem.findall(".//section[tag]")) - ['section'] - >>> summarize_list(elem.findall(".//section[element]")) - [] - >>> summarize_list(elem.findall("../tag")) - [] - >>> summarize_list(elem.findall("section/../tag")) - ['tag', 'tag'] - >>> summarize_list(ET.ElementTree(elem).findall("./tag")) - ['tag', 'tag'] - - Following example is invalid in 1.2. - A leading '*' is assumed in 1.3. - - >>> elem.findall("section//") == elem.findall("section//*") - True - - ET's Path module handles this case incorrectly; this gives - a warning in 1.3, and the behaviour will be modified in 1.4. - - >>> summarize_list(ET.ElementTree(elem).findall("/tag")) - ['tag', 'tag'] - - >>> elem = ET.XML(SAMPLE_XML_NS) - >>> summarize_list(elem.findall("tag")) - [] - >>> summarize_list(elem.findall("{http://effbot.org/ns}tag")) - ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag'] - >>> summarize_list(elem.findall(".//{http://effbot.org/ns}tag")) - ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag'] - """ - def file_init(): """ >>> import io @@ -469,16 +347,6 @@ 'empty-element' """ -def bad_find(): - """ - Check bad or unsupported path expressions. - - >>> elem = ET.XML(SAMPLE_XML) - >>> elem.findall("/tag") - Traceback (most recent call last): - SyntaxError: cannot use absolute path on element - """ - def path_cache(): """ Check that the path cache behaves sanely. @@ -1883,6 +1751,98 @@ method='html') self.assertEqual(serialized, expected) + +class ElementFindTest(unittest.TestCase): + def test_find_simple(self): + e = ET.XML(SAMPLE_XML) + self.assertEqual(e.find('tag').tag, 'tag') + self.assertEqual(e.find('section/tag').tag, 'tag') + self.assertEqual(e.find('./tag').tag, 'tag') + + e[2] = ET.XML(SAMPLE_SECTION) + self.assertEqual(e.find('section/nexttag').tag, 'nexttag') + + self.assertEqual(e.findtext('./tag'), 'text') + self.assertEqual(e.findtext('section/tag'), 'subtext') + + # section/nexttag is found but has no text + self.assertEqual(e.findtext('section/nexttag'), '') + self.assertEqual(e.findtext('section/nexttag', 'default'), '') + + # tog doesn't exist and 'default' kicks in + self.assertIsNone(e.findtext('tog')) + self.assertEqual(e.findtext('tog', 'default'), 'default') + + def test_findall(self): + e = ET.XML(SAMPLE_XML) + e[2] = ET.XML(SAMPLE_SECTION) + self.assertEqual(summarize_list(e.findall('.')), ['body']) + self.assertEqual(summarize_list(e.findall('tag')), ['tag', 'tag']) + self.assertEqual(summarize_list(e.findall('tog')), []) + self.assertEqual(summarize_list(e.findall('tog/foo')), []) + self.assertEqual(summarize_list(e.findall('*')), + ['tag', 'tag', 'section']) + self.assertEqual(summarize_list(e.findall('.//tag')), + ['tag'] * 4) + self.assertEqual(summarize_list(e.findall('section/tag')), ['tag']) + self.assertEqual(summarize_list(e.findall('section//tag')), ['tag'] * 2) + self.assertEqual(summarize_list(e.findall('section/*')), + ['tag', 'nexttag', 'nextsection']) + self.assertEqual(summarize_list(e.findall('section//*')), + ['tag', 'nexttag', 'nextsection', 'tag']) + self.assertEqual(summarize_list(e.findall('section/.//*')), + ['tag', 'nexttag', 'nextsection', 'tag']) + self.assertEqual(summarize_list(e.findall('*/*')), + ['tag', 'nexttag', 'nextsection']) + self.assertEqual(summarize_list(e.findall('*//*')), + ['tag', 'nexttag', 'nextsection', 'tag']) + self.assertEqual(summarize_list(e.findall('*/tag')), ['tag']) + self.assertEqual(summarize_list(e.findall('*/./tag')), ['tag']) + self.assertEqual(summarize_list(e.findall('./tag')), ['tag'] * 2) + self.assertEqual(summarize_list(e.findall('././tag')), ['tag'] * 2) + + self.assertEqual(summarize_list(e.findall('.//tag[@class]')), + ['tag'] * 3) + self.assertEqual(summarize_list(e.findall('.//tag[@class="a"]')), + ['tag']) + self.assertEqual(summarize_list(e.findall('.//tag[@class="b"]')), + ['tag'] * 2) + self.assertEqual(summarize_list(e.findall('.//tag[@id]')), + ['tag']) + self.assertEqual(summarize_list(e.findall('.//section[tag]')), + ['section']) + self.assertEqual(summarize_list(e.findall('.//section[element]')), []) + self.assertEqual(summarize_list(e.findall('../tag')), []) + self.assertEqual(summarize_list(e.findall('section/../tag')), + ['tag'] * 2) + self.assertEqual(e.findall('section//'), e.findall('section//*')) + + def test_test_find_with_ns(self): + e = ET.XML(SAMPLE_XML_NS) + self.assertEqual(summarize_list(e.findall('tag')), []) + self.assertEqual( + summarize_list(e.findall("{http://effbot.org/ns}tag")), + ['{http://effbot.org/ns}tag'] * 2) + self.assertEqual( + summarize_list(e.findall(".//{http://effbot.org/ns}tag")), + ['{http://effbot.org/ns}tag'] * 3) + + def test_bad_find(self): + e = ET.XML(SAMPLE_XML) + with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'): + e.findall('/tag') + + def test_find_through_ElementTree(self): + e = ET.XML(SAMPLE_XML) + self.assertEqual(ET.ElementTree(e).find('tag').tag, 'tag') + self.assertEqual(ET.ElementTree(e).findtext('tag'), 'text') + self.assertEqual(summarize_list(ET.ElementTree(e).findall('tag')), + ['tag'] * 2) + # this produces a warning + self.assertEqual(summarize_list(ET.ElementTree(e).findall('//tag')), + ['tag'] * 3) + + class ElementIterTest(unittest.TestCase): def _ilist(self, elem, tag=None): return summarize_list(elem.iter(tag)) @@ -2547,6 +2507,7 @@ ParseErrorTest, XincludeTest, ElementTreeTest, + ElementFindTest, ElementIterTest, TreeBuilderTest, ] @@ -2560,10 +2521,9 @@ ]) try: - support.run_unittest(*test_classes) - # XXX the C module should give the same warnings as the Python module with CleanContext(quiet=(pyET is not ET)): + support.run_unittest(*test_classes) support.run_doctest(sys.modules[__name__], verbosity=True) finally: # don't interfere with subsequent tests -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 16:45:14 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 16:45:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issues_=2315083_and_=2316992=3A_port_find=2E*_method_tes?= =?utf-8?q?ts_to_unittest?= Message-ID: <3Yk4yf1J1RzRnh@mail.python.org> http://hg.python.org/cpython/rev/18b16104166c changeset: 81451:18b16104166c parent: 81449:a1efab48d8f8 parent: 81450:f9d1d120c19e user: Eli Bendersky date: Sat Jan 12 07:43:35 2013 -0800 summary: Issues #15083 and #16992: port find.* method tests to unittest files: Lib/test/test_xml_etree.py | 228 ++++++++++-------------- 1 files changed, 94 insertions(+), 134 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -329,128 +329,6 @@ 'hello' """ -def find(): - """ - Test find methods (including xpath syntax). - - >>> elem = ET.XML(SAMPLE_XML) - >>> elem.find("tag").tag - 'tag' - >>> ET.ElementTree(elem).find("tag").tag - 'tag' - >>> elem.find("section/tag").tag - 'tag' - >>> elem.find("./tag").tag - 'tag' - >>> ET.ElementTree(elem).find("./tag").tag - 'tag' - >>> ET.ElementTree(elem).find("/tag").tag - 'tag' - >>> elem[2] = ET.XML(SAMPLE_SECTION) - >>> elem.find("section/nexttag").tag - 'nexttag' - >>> ET.ElementTree(elem).find("section/tag").tag - 'tag' - >>> ET.ElementTree(elem).find("tog") - >>> ET.ElementTree(elem).find("tog/foo") - >>> elem.findtext("tag") - 'text' - >>> elem.findtext("section/nexttag") - '' - >>> elem.findtext("section/nexttag", "default") - '' - >>> elem.findtext("tog") - >>> elem.findtext("tog", "default") - 'default' - >>> ET.ElementTree(elem).findtext("tag") - 'text' - >>> ET.ElementTree(elem).findtext("tog/foo") - >>> ET.ElementTree(elem).findtext("tog/foo", "default") - 'default' - >>> ET.ElementTree(elem).findtext("./tag") - 'text' - >>> ET.ElementTree(elem).findtext("/tag") - 'text' - >>> elem.findtext("section/tag") - 'subtext' - >>> ET.ElementTree(elem).findtext("section/tag") - 'subtext' - >>> summarize_list(elem.findall(".")) - ['body'] - >>> summarize_list(elem.findall("tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall("tog")) - [] - >>> summarize_list(elem.findall("tog/foo")) - [] - >>> summarize_list(elem.findall("*")) - ['tag', 'tag', 'section'] - >>> summarize_list(elem.findall(".//tag")) - ['tag', 'tag', 'tag', 'tag'] - >>> summarize_list(elem.findall("section/tag")) - ['tag'] - >>> summarize_list(elem.findall("section//tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall("section/*")) - ['tag', 'nexttag', 'nextsection'] - >>> summarize_list(elem.findall("section//*")) - ['tag', 'nexttag', 'nextsection', 'tag'] - >>> summarize_list(elem.findall("section/.//*")) - ['tag', 'nexttag', 'nextsection', 'tag'] - >>> summarize_list(elem.findall("*/*")) - ['tag', 'nexttag', 'nextsection'] - >>> summarize_list(elem.findall("*//*")) - ['tag', 'nexttag', 'nextsection', 'tag'] - >>> summarize_list(elem.findall("*/tag")) - ['tag'] - >>> summarize_list(elem.findall("*/./tag")) - ['tag'] - >>> summarize_list(elem.findall("./tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall(".//tag")) - ['tag', 'tag', 'tag', 'tag'] - >>> summarize_list(elem.findall("././tag")) - ['tag', 'tag'] - >>> summarize_list(elem.findall(".//tag[@class]")) - ['tag', 'tag', 'tag'] - >>> summarize_list(elem.findall(".//tag[@class='a']")) - ['tag'] - >>> summarize_list(elem.findall(".//tag[@class='b']")) - ['tag', 'tag'] - >>> summarize_list(elem.findall(".//tag[@id]")) - ['tag'] - >>> summarize_list(elem.findall(".//section[tag]")) - ['section'] - >>> summarize_list(elem.findall(".//section[element]")) - [] - >>> summarize_list(elem.findall("../tag")) - [] - >>> summarize_list(elem.findall("section/../tag")) - ['tag', 'tag'] - >>> summarize_list(ET.ElementTree(elem).findall("./tag")) - ['tag', 'tag'] - - Following example is invalid in 1.2. - A leading '*' is assumed in 1.3. - - >>> elem.findall("section//") == elem.findall("section//*") - True - - ET's Path module handles this case incorrectly; this gives - a warning in 1.3, and the behaviour will be modified in 1.4. - - >>> summarize_list(ET.ElementTree(elem).findall("/tag")) - ['tag', 'tag'] - - >>> elem = ET.XML(SAMPLE_XML_NS) - >>> summarize_list(elem.findall("tag")) - [] - >>> summarize_list(elem.findall("{http://effbot.org/ns}tag")) - ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag'] - >>> summarize_list(elem.findall(".//{http://effbot.org/ns}tag")) - ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag'] - """ - def file_init(): """ >>> import io @@ -469,16 +347,6 @@ 'empty-element' """ -def bad_find(): - """ - Check bad or unsupported path expressions. - - >>> elem = ET.XML(SAMPLE_XML) - >>> elem.findall("/tag") - Traceback (most recent call last): - SyntaxError: cannot use absolute path on element - """ - def path_cache(): """ Check that the path cache behaves sanely. @@ -1883,6 +1751,98 @@ method='html') self.assertEqual(serialized, expected) + +class ElementFindTest(unittest.TestCase): + def test_find_simple(self): + e = ET.XML(SAMPLE_XML) + self.assertEqual(e.find('tag').tag, 'tag') + self.assertEqual(e.find('section/tag').tag, 'tag') + self.assertEqual(e.find('./tag').tag, 'tag') + + e[2] = ET.XML(SAMPLE_SECTION) + self.assertEqual(e.find('section/nexttag').tag, 'nexttag') + + self.assertEqual(e.findtext('./tag'), 'text') + self.assertEqual(e.findtext('section/tag'), 'subtext') + + # section/nexttag is found but has no text + self.assertEqual(e.findtext('section/nexttag'), '') + self.assertEqual(e.findtext('section/nexttag', 'default'), '') + + # tog doesn't exist and 'default' kicks in + self.assertIsNone(e.findtext('tog')) + self.assertEqual(e.findtext('tog', 'default'), 'default') + + def test_findall(self): + e = ET.XML(SAMPLE_XML) + e[2] = ET.XML(SAMPLE_SECTION) + self.assertEqual(summarize_list(e.findall('.')), ['body']) + self.assertEqual(summarize_list(e.findall('tag')), ['tag', 'tag']) + self.assertEqual(summarize_list(e.findall('tog')), []) + self.assertEqual(summarize_list(e.findall('tog/foo')), []) + self.assertEqual(summarize_list(e.findall('*')), + ['tag', 'tag', 'section']) + self.assertEqual(summarize_list(e.findall('.//tag')), + ['tag'] * 4) + self.assertEqual(summarize_list(e.findall('section/tag')), ['tag']) + self.assertEqual(summarize_list(e.findall('section//tag')), ['tag'] * 2) + self.assertEqual(summarize_list(e.findall('section/*')), + ['tag', 'nexttag', 'nextsection']) + self.assertEqual(summarize_list(e.findall('section//*')), + ['tag', 'nexttag', 'nextsection', 'tag']) + self.assertEqual(summarize_list(e.findall('section/.//*')), + ['tag', 'nexttag', 'nextsection', 'tag']) + self.assertEqual(summarize_list(e.findall('*/*')), + ['tag', 'nexttag', 'nextsection']) + self.assertEqual(summarize_list(e.findall('*//*')), + ['tag', 'nexttag', 'nextsection', 'tag']) + self.assertEqual(summarize_list(e.findall('*/tag')), ['tag']) + self.assertEqual(summarize_list(e.findall('*/./tag')), ['tag']) + self.assertEqual(summarize_list(e.findall('./tag')), ['tag'] * 2) + self.assertEqual(summarize_list(e.findall('././tag')), ['tag'] * 2) + + self.assertEqual(summarize_list(e.findall('.//tag[@class]')), + ['tag'] * 3) + self.assertEqual(summarize_list(e.findall('.//tag[@class="a"]')), + ['tag']) + self.assertEqual(summarize_list(e.findall('.//tag[@class="b"]')), + ['tag'] * 2) + self.assertEqual(summarize_list(e.findall('.//tag[@id]')), + ['tag']) + self.assertEqual(summarize_list(e.findall('.//section[tag]')), + ['section']) + self.assertEqual(summarize_list(e.findall('.//section[element]')), []) + self.assertEqual(summarize_list(e.findall('../tag')), []) + self.assertEqual(summarize_list(e.findall('section/../tag')), + ['tag'] * 2) + self.assertEqual(e.findall('section//'), e.findall('section//*')) + + def test_test_find_with_ns(self): + e = ET.XML(SAMPLE_XML_NS) + self.assertEqual(summarize_list(e.findall('tag')), []) + self.assertEqual( + summarize_list(e.findall("{http://effbot.org/ns}tag")), + ['{http://effbot.org/ns}tag'] * 2) + self.assertEqual( + summarize_list(e.findall(".//{http://effbot.org/ns}tag")), + ['{http://effbot.org/ns}tag'] * 3) + + def test_bad_find(self): + e = ET.XML(SAMPLE_XML) + with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'): + e.findall('/tag') + + def test_find_through_ElementTree(self): + e = ET.XML(SAMPLE_XML) + self.assertEqual(ET.ElementTree(e).find('tag').tag, 'tag') + self.assertEqual(ET.ElementTree(e).findtext('tag'), 'text') + self.assertEqual(summarize_list(ET.ElementTree(e).findall('tag')), + ['tag'] * 2) + # this produces a warning + self.assertEqual(summarize_list(ET.ElementTree(e).findall('//tag')), + ['tag'] * 3) + + class ElementIterTest(unittest.TestCase): def _ilist(self, elem, tag=None): return summarize_list(elem.iter(tag)) @@ -2547,6 +2507,7 @@ ParseErrorTest, XincludeTest, ElementTreeTest, + ElementFindTest, ElementIterTest, TreeBuilderTest, ] @@ -2560,10 +2521,9 @@ ]) try: - support.run_unittest(*test_classes) - # XXX the C module should give the same warnings as the Python module with CleanContext(quiet=(pyET is not ET)): + support.run_unittest(*test_classes) support.run_doctest(sys.modules[__name__], verbosity=True) finally: # don't interfere with subsequent tests -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 16:45:15 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 16:45:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_clean_trailing?= =?utf-8?q?_whitespace?= Message-ID: <3Yk4yg41Z1zS5v@mail.python.org> http://hg.python.org/cpython/rev/bbfc8f62cb67 changeset: 81452:bbfc8f62cb67 branch: 3.3 parent: 81450:f9d1d120c19e user: Eli Bendersky date: Sat Jan 12 07:44:32 2013 -0800 summary: clean trailing whitespace files: Lib/test/test_xml_etree.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1831,7 +1831,7 @@ e = ET.XML(SAMPLE_XML) with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'): e.findall('/tag') - + def test_find_through_ElementTree(self): e = ET.XML(SAMPLE_XML) self.assertEqual(ET.ElementTree(e).find('tag').tag, 'tag') @@ -1841,7 +1841,7 @@ # this produces a warning self.assertEqual(summarize_list(ET.ElementTree(e).findall('//tag')), ['tag'] * 3) - + class ElementIterTest(unittest.TestCase): def _ilist(self, elem, tag=None): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 16:45:16 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 16:45:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_clean_trailing_whitespace?= Message-ID: <3Yk4yh6d29zS7q@mail.python.org> http://hg.python.org/cpython/rev/7bdeeed5960c changeset: 81453:7bdeeed5960c parent: 81451:18b16104166c parent: 81452:bbfc8f62cb67 user: Eli Bendersky date: Sat Jan 12 07:44:47 2013 -0800 summary: clean trailing whitespace files: Lib/test/test_xml_etree.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1831,7 +1831,7 @@ e = ET.XML(SAMPLE_XML) with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'): e.findall('/tag') - + def test_find_through_ElementTree(self): e = ET.XML(SAMPLE_XML) self.assertEqual(ET.ElementTree(e).find('tag').tag, 'tag') @@ -1841,7 +1841,7 @@ # this produces a warning self.assertEqual(summarize_list(ET.ElementTree(e).findall('//tag')), ['tag'] * 3) - + class ElementIterTest(unittest.TestCase): def _ilist(self, elem, tag=None): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 16:56:24 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 12 Jan 2013 16:56:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2NzYy?= =?utf-8?q?=3A_Fix_some_test=5Fsubprocess_failures_on_NetBSD_and_OpenBSD?= =?utf-8?b?OiBraWxsKCk=?= Message-ID: <3Yk5CX1kYWzS65@mail.python.org> http://hg.python.org/cpython/rev/61d6b34af419 changeset: 81454:61d6b34af419 branch: 2.7 parent: 81440:eae31f2b6f60 user: Charles-Fran?ois Natali date: Sat Jan 12 16:52:20 2013 +0100 summary: Issue #16762: Fix some test_subprocess failures on NetBSD and OpenBSD: kill() returns ESRCH for a zombie process, which is not POSIX-compliant. files: Lib/test/test_subprocess.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -892,6 +892,8 @@ getattr(p, method)(*args) return p + @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), + "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 16:56:25 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 12 Jan 2013 16:56:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2NzYy?= =?utf-8?q?=3A_Fix_some_test=5Fsubprocess_failures_on_NetBSD_and_OpenBSD?= =?utf-8?b?OiBraWxsKCk=?= Message-ID: <3Yk5CY4kZszSDd@mail.python.org> http://hg.python.org/cpython/rev/58ce6ac61ada changeset: 81455:58ce6ac61ada branch: 3.2 parent: 81441:3d54723c9be6 user: Charles-Fran?ois Natali date: Sat Jan 12 16:52:20 2013 +0100 summary: Issue #16762: Fix some test_subprocess failures on NetBSD and OpenBSD: kill() returns ESRCH for a zombie process, which is not POSIX-compliant. files: Lib/test/test_subprocess.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1206,6 +1206,8 @@ getattr(p, method)(*args) return p + @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), + "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 16:56:27 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 12 Jan 2013 16:56:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316762=3A_Fix_some_test=5Fsubprocess_failures_on_NetBS?= =?utf-8?q?D_and_OpenBSD=3A_kill=28=29?= Message-ID: <3Yk5Cb0vJQzSF9@mail.python.org> http://hg.python.org/cpython/rev/a3f0414af55b changeset: 81456:a3f0414af55b branch: 3.3 parent: 81452:bbfc8f62cb67 parent: 81455:58ce6ac61ada user: Charles-Fran?ois Natali date: Sat Jan 12 16:54:45 2013 +0100 summary: Issue #16762: Fix some test_subprocess failures on NetBSD and OpenBSD: kill() returns ESRCH for a zombie process, which is not POSIX-compliant. files: Lib/test/test_subprocess.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1360,6 +1360,8 @@ getattr(p, method)(*args) return p + @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), + "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 16:56:28 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 12 Jan 2013 16:56:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316762=3A_Fix_some_test=5Fsubprocess_failures_on?= =?utf-8?q?_NetBSD_and_OpenBSD=3A_kill=28=29?= Message-ID: <3Yk5Cc3d1zzSFK@mail.python.org> http://hg.python.org/cpython/rev/487ed428f0ba changeset: 81457:487ed428f0ba parent: 81453:7bdeeed5960c parent: 81456:a3f0414af55b user: Charles-Fran?ois Natali date: Sat Jan 12 16:55:31 2013 +0100 summary: Issue #16762: Fix some test_subprocess failures on NetBSD and OpenBSD: kill() returns ESRCH for a zombie process, which is not POSIX-compliant. files: Lib/test/test_subprocess.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1360,6 +1360,8 @@ getattr(p, method)(*args) return p + @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), + "Due to known OS bug (issue #16762)") def _kill_dead_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 17:20:26 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 12 Jan 2013 17:20:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2ODI5?= =?utf-8?q?=3A_IDLE_printing_no_longer_fails_if_there_are_spaces_or_other?= Message-ID: <3Yk5lG1nl0zS2D@mail.python.org> http://hg.python.org/cpython/rev/e651d96e6b07 changeset: 81458:e651d96e6b07 branch: 2.7 parent: 81454:61d6b34af419 user: Serhiy Storchaka date: Sat Jan 12 18:12:27 2013 +0200 summary: Issue #16829: IDLE printing no longer fails if there are spaces or other special characters in the file path. files: Lib/idlelib/IOBinding.py | 3 ++- Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -7,6 +7,7 @@ import os import types +import pipes import sys import codecs import tempfile @@ -503,7 +504,7 @@ else: #no printing for this platform printPlatform = False if printPlatform: #we can try to print for this platform - command = command % filename + command = command % pipes.quote(filename) pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,6 +186,9 @@ Library ------- +- Issue #16829: IDLE printing no longer fails if there are spaces or other + special characters in the file path. + - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 17:20:27 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 12 Jan 2013 17:20:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2ODI5?= =?utf-8?q?=3A_IDLE_printing_no_longer_fails_if_there_are_spaces_or_other?= Message-ID: <3Yk5lH4t8wzS8d@mail.python.org> http://hg.python.org/cpython/rev/20065626c0b5 changeset: 81459:20065626c0b5 branch: 3.2 parent: 81455:58ce6ac61ada user: Serhiy Storchaka date: Sat Jan 12 18:13:24 2013 +0200 summary: Issue #16829: IDLE printing no longer fails if there are spaces or other special characters in the file path. files: Lib/idlelib/IOBinding.py | 3 ++- Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -1,5 +1,6 @@ import os import types +import pipes import sys import codecs import tempfile @@ -458,7 +459,7 @@ else: #no printing for this platform printPlatform = False if printPlatform: #we can try to print for this platform - command = command % filename + command = command % pipes.quote(filename) pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -199,6 +199,9 @@ Library ------- +- Issue #16829: IDLE printing no longer fails if there are spaces or other + special characters in the file path. + - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 17:20:29 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 12 Jan 2013 17:20:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316829=3A_IDLE_printing_no_longer_fails_if_there_are_s?= =?utf-8?q?paces_or_other?= Message-ID: <3Yk5lK0p4pzS8d@mail.python.org> http://hg.python.org/cpython/rev/778bead39825 changeset: 81460:778bead39825 branch: 3.3 parent: 81456:a3f0414af55b parent: 81459:20065626c0b5 user: Serhiy Storchaka date: Sat Jan 12 18:16:18 2013 +0200 summary: Issue #16829: IDLE printing no longer fails if there are spaces or other special characters in the file path. files: Lib/idlelib/IOBinding.py | 3 ++- Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -1,5 +1,6 @@ import os import types +import shlex import sys import codecs import tempfile @@ -458,7 +459,7 @@ else: #no printing for this platform printPlatform = False if printPlatform: #we can try to print for this platform - command = command % filename + command = command % shlex.quote(filename) pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -147,6 +147,9 @@ Library ------- +- Issue #16829: IDLE printing no longer fails if there are spaces or other + special characters in the file path. + - Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed. - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 17:20:30 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 12 Jan 2013 17:20:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316829=3A_IDLE_printing_no_longer_fails_if_there?= =?utf-8?q?_are_spaces_or_other?= Message-ID: <3Yk5lL3hyszS9S@mail.python.org> http://hg.python.org/cpython/rev/529b5ced59e0 changeset: 81461:529b5ced59e0 parent: 81457:487ed428f0ba parent: 81460:778bead39825 user: Serhiy Storchaka date: Sat Jan 12 18:17:24 2013 +0200 summary: Issue #16829: IDLE printing no longer fails if there are spaces or other special characters in the file path. files: Lib/idlelib/IOBinding.py | 3 ++- Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -1,5 +1,6 @@ import os import types +import shlex import sys import codecs import tempfile @@ -458,7 +459,7 @@ else: #no printing for this platform printPlatform = False if printPlatform: #we can try to print for this platform - command = command % filename + command = command % shlex.quote(filename) pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -217,6 +217,9 @@ Library ------- +- Issue #16829: IDLE printing no longer fails if there are spaces or other + special characters in the file path. + - Issue #15031: Refactor some .pyc management code to cut down on code duplication. Thanks to Ronan Lamy for the report and taking an initial stab at the problem. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 17:34:55 2013 From: python-checkins at python.org (r.david.murray) Date: Sat, 12 Jan 2013 17:34:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_=2316259=3A_delete_some_no?= =?utf-8?q?-longer-used_code_from_regrtest=2E?= Message-ID: <3Yk63z5nlLzS5j@mail.python.org> http://hg.python.org/cpython/rev/e22c09f636d4 changeset: 81462:e22c09f636d4 user: R David Murray date: Sat Jan 12 11:34:38 2013 -0500 summary: #16259: delete some no-longer-used code from regrtest. dash_R is only called from one location, and from that location an indirect_test is passed. files: Lib/test/regrtest.py | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -1386,14 +1386,6 @@ for obj in abc.__subclasses__() + [abc]: abcs[obj] = obj._abc_registry.copy() - if indirect_test: - def run_the_test(): - indirect_test() - else: - def run_the_test(): - del sys.modules[the_module.__name__] - exec('import ' + the_module.__name__) - nwarmup, ntracked, fname = huntrleaks fname = os.path.join(support.SAVEDCWD, fname) repcount = nwarmup + ntracked @@ -1404,7 +1396,7 @@ print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr) sys.stderr.flush() for i in range(repcount): - run_the_test() + indirect_test() alloc_after, rc_after = dash_R_cleanup(fs, ps, pic, zdc, abcs) sys.stderr.write('.') sys.stderr.flush() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 21:17:12 2013 From: python-checkins at python.org (victor.stinner) Date: Sat, 12 Jan 2013 21:17:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_a_new_PEP=3A_333=3A_Add_c?= =?utf-8?q?loexec_argument_to_functions_creating_file_descriptors?= Message-ID: <3YkC0S160GzS8d@mail.python.org> http://hg.python.org/peps/rev/2033ba1eeabd changeset: 4666:2033ba1eeabd user: Victor Stinner date: Sat Jan 12 21:15:11 2013 +0100 summary: Add a new PEP: 333: Add cloexec argument to functions creating file descriptors files: pep-0433.txt | 519 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 519 insertions(+), 0 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt new file mode 100644 --- /dev/null +++ b/pep-0433.txt @@ -0,0 +1,519 @@ +PEP: 433 +Title: Add cloexec argument to functions creating file descriptors +Version: $Revision$ +Last-Modified: $Date$ +Author: Victor Stinner +Status: Draft +Type: Standards Track +Content-Type: text/x-rst +Created: 10-January-2013 +Python-Version: 3.4 + + +Abstract +======== + +This PEP proposes to add a new optional argument ``cloexec`` on functions +creating file descriptors in the Python standard library. If the argument is +``True``, the close-on-exec flag will be set on the new file descriptor. + + +Rationale +========= + +On UNIX, subprocess closes file descriptors greater than 2 by default since +Python 3.2 [#subprocess_close]_. All file descriptors created by the parent +process are automatically closed. + +There are other cases creating a subprocess or executing a new program where +file descriptors are not closed: functions of the os.spawn*() family and third +party modules calling ``exec()`` or ``fork()`` + ``exec()``. In this case, file +descriptors are shared between the parent and the child processes which is +usually unexpected and causes various issues. + + +Inherited file descriptors issues +--------------------------------- + +Closing the file descriptor in the parent process does not close the related +resource (file, socket, ...) because it is still open in the child process. + +The listening socket of TCPServer is not closed on ``exec()``: the child +process is able to get connection from new clients; if the parent closes the +listening socket and create a new listening socket on the same address, it +would get an "address already is used" error. + +Not closing file descriptors can lead to resource exhaustion: even if the +parent closes all files, creating a new file descriptor may fail with "too many +files" because files are still open in the child process. + + +Security +-------- + +Leaking file descriptors is a major security vulnerability. An untrusted child +process can read sensitive data like passwords and take control of the parent +process though leaked file descriptors. It is for example a known vulnerability +to escape from a chroot. + + +Atomicity +--------- + +Using ``fcntl()`` to set the close-on-exec flag is not safe in a multithreaded +application. If a thread calls ``fork()`` and ``exec()`` between the creation +of the file descriptor and the call to ``fcntl(fd, F_SETFD, new_flags)``: the +file descriptor will be inherited by the child process. Modern operating +systems offer functions to set the flag during the creation of the file +descriptor, which avoids the race condition. + + +Portability +----------- + +Python 3.2 added ``socket.SOCK_CLOEXEC`` flag, Python 3.3 added +``os.O_CLOEXEC`` flag and ``os.pipe2()`` function. It is already possible to +set atomically close-on-exec flag in Python 3.3 when opening a file and +creating a pipe or socket. + +The problem is that these flags and functions are not portable: only recent +versions of operating systems support them. ``O_CLOEXEC`` and ``SOCK_CLOEXEC`` +flags are ignored by old Linux versions and so ``FD_CLOEXEC`` flag must be +checked using ``fcntl(fd, F_GETFD)``. If the kernel ignores ``O_CLOEXEC`` or +``SOCK_CLOEXEC`` flag, a call to ``fcntl(fd, F_SETFD, flags)`` is required to +set close-on-exec flag. + +Note: OpenBSD older 5.2 does not close the file descriptor with close-on-exec +flag set if ``fork()`` is used before ``exec()``, but it works correctly if +``exec()`` is called without ``fork()``. + + +Scope +----- + +Applications still have to close explicitly file descriptors after a +``fork()``. The close-on-exec flag only closes file descriptors after +``exec()``, and so after ``fork()`` + ``exec()``. + +Many functions of the Python standard library creating file descriptors are not +changed by the PEP, and so will not have the close-on-exec flag set. Some +examples: + + * ``os.urandom()``: on UNIX, it creates a file descriptor on UNIX to read + ``/dev/urandom``. Adding an ``cloexec`` argument to ``os.urandom()`` does + not make sense on Windows. + * ``curses.windows.getwin()`` and ``curses.windows.putwin()`` creates a temporary file using ``fdopen(fd, "wb+");`` + * ``mmap.mmap()`` opens ``/dev/null`` using ``open("/dev/zero", O_RDWR);`` if + ``MAP_ANONYMOUS`` is not defined. + * If the ``PYTHONSTARTUP`` environment variable is set, the corresponding file + is opened using ``fopen(startup, "r");`` + * ``python script.py`` opens ``script.py`` using ``fopen(filename, "r");`` + * etc. + +Third party modules creating file descriptors may not set close-on-exec flag. + +Impacted functions: + + * ``os.forkpty()`` + * ``http.server.CGIHTTPRequestHandler.run_cgi()`` + +Impacted modules: + + * ``multiprocessing`` + * ``socketserver`` + * ``subprocess`` + * ``tempfile`` + * ``xmlrpc.server`` + * Maybe: ``signal``, ``threading`` + +XXX Should ``subprocess.Popen`` set the close-on-exec flag on file XXX +XXX descriptors of the constructor the ``pass_fds`` argument? XXX + + +Proposition +=========== + +This PEP proposes to add a new optional argument ``cloexec`` on functions +creating file descriptors in the Python standard library. If the argument is +``True``, the close-on-exec flag will be set on the new file descriptor. + +Add a new function: + + * ``os.set_cloexec(fd: int, cloexec: bool)``: set or unset the close-on-exec + flag of a file descriptor + +Add a new optional ``cloexec`` argument to: + + * ``open()``: ``os.fdopen()`` is indirectly modified + * ``os.dup()``, ``os.dup2()`` + * ``os.pipe()`` + * ``socket.socket()``, ``socket.socketpair()`` ``socket.socket.accept()`` + * Maybe also: ``os.open()``, ``os.openpty()`` + * TODO: + + * ``select.devpoll()`` + * ``select.poll()`` + * ``select.epoll()`` + * ``select.kqueue()`` + * ``socket.socket.recvmsg()``: use ``MSG_CMSG_CLOEXEC``, or ``os.set_cloexec()`` + +The default value of the ``cloexec`` argument is ``False`` to keep the backward +compatibility. + + + + + + +Applications using inherance of file descriptors +================================================ + +Network servers using fork may want to pass the client socket to the child +process. For example, a CGI server pass the socket client through file +descriptors 0 (stdin) and 1 (stdout) using ``dup2()``. + +Example of programs taking file descriptors from the parent process: + + * valgrind: ``--log-fd=``, ``--input-fd=``, etc. + * qemu: ``-add-fd `` command line option + * GnuPG: ``--status-fd ``, ``--logger-fd ``, etc. + * openssl command: ``-pass fd:`` + * xterm: ``-S `` + +On Linux, it is possible to use ``/dev/fd/`` filename to pass a file +descriptor to a program expecting a filename. It can be used to pass a password +for example. + +These applications only pass a few file descriptors, usually only one. +Fixing these applications to unset close-on-exec flag should be easy. + +If the ``subprocess`` module is used, inherited file descriptors must be specified +using the ``pass_fds`` argument (except if the ``close_fds`` argument is set +explicitly to ``False``). So the ``subprocess`` module knows the list of file +descriptors on which close-on-exec flag must be unset. + +File descriptors 0 (stdin), 1 (stdout) and 2 (stderr) are expected to be +inherited and so should not have the close-on-exec flag. So a CGI server should +not be impacted by this PEP. + + +Performances +============ + +Setting close-on-exec flag may require additional system calls for each +creation of new file descriptors. The number of additional system calls +depends on the method used to set the flag: + + * ``O_NOINHERIT``: no additionnal system call + * ``O_CLOEXEC``: one addition system call, but only at the creation of the + first file descriptor, to check if the flag is supported. If no, Python has + to fallback to the next method. + * ``ioctl(fd, FIOCLEX)``: one addition system call per file descriptor + * ``fcntl(fd, F_SETFD, flags)``: two addition system calls per file + descriptor, one to get old flags and one to set new flags + +XXX Benchmark the overhead for these 4 methods. XXX + + +Implementation +============== + +os.set_cloexec(fd, cloexec) +--------------------------- + +Best-effort by definition. Pseudo-code:: + + if os.name == 'nt': + def set_cloexec(fd, cloexec=True): + SetHandleInformation(fd, HANDLE_FLAG_INHERIT, int(cloexec)) + else: + fnctl = None + ioctl = None + try: + import ioctl + except ImportError: + try: + import fcntl + except ImportError: + pass + if ioctl is not None and hasattr('FIOCLEX', ioctl): + def set_cloexec(fd, cloexec=True): + if cloexec: + ioctl.ioctl(fd, ioctl.FIOCLEX) + else: + ioctl.ioctl(fd, ioctl.FIONCLEX) + elif fnctl is not None: + def set_cloexec(fd, cloexec=True): + flags = fcntl.fcntl(fd, fcntl.F_GETFD) + if cloexec: + flags |= FD_CLOEXEC + else: + flags &= ~FD_CLOEXEC + fcntl.fcntl(fd, fcntl.F_SETFD, flags) + else: + def set_cloexec(fd, cloexec=True): + raise NotImplementedError("close-on-exec flag is not supported on your platform") + +ioctl is preferred over fcntl because it requires only one syscall, instead of +two syscalls for fcntl. + +Note: ``fcntl(fd, F_SETFD, flags)`` only supports one flag (``FD_CLOEXEC``), so +it would be possible to avoid ``fcntl(fd, F_GETFD)``. But it may drop other +flags in the future, and so it is safer to keep the two functions calls. + +open() +------ + + * Windows: ``open()`` with ``O_NOINHERIT`` flag [atomic] + * ``open()`` with ``O_CLOEXEC flag`` [atomic] + * ``open()`` + ``os.set_cloexec(fd, True)`` [best-effort] + +os.dup() +-------- + + * ``fcntl(fd, F_DUPFD_CLOEXEC)`` [atomic] + * ``dup()`` + ``os.set_cloexec(fd, True)`` [best-effort] + +os.dup2() +--------- + + * ``dup3()`` with ``O_CLOEXEC`` flag [atomic] + * ``dup2()`` + ``os.set_cloexec(fd, True)`` [best-effort] + +os.pipe() +--------- + + * Windows: ``_pipe()`` with ``O_NOINHERIT`` flag [atomic] + * ``pipe2()`` with ``O_CLOEXEC`` flag [atomic] + * ``pipe()`` + ``os.set_cloexec(fd, True)`` [best-effort] + +socket.socket() +--------------- + + * ``socket()`` with ``SOCK_CLOEXEC`` flag [atomic] + * ``socket()`` + ``os.set_cloexec(fd, True)`` [best-effort] + +socket.socketpair() +------------------- + + * ``socketpair()`` with ``SOCK_CLOEXEC`` flag [atomic] + * ``socketpair()`` + ``os.set_cloexec(fd, True)`` [best-effort] + +socket.socket.accept() +---------------------- + + * ``accept4()`` with ``SOCK_CLOEXEC`` flag [atomic] + * ``accept()`` + ``os.set_cloexec(fd, True)`` [best-effort] + + +Backward compatibility +====================== + +There is no backward incompatible change. The default behaviour is unchanged: +the close-on-exec flag is not set by default. + + +Alternatives +============ + +Always set close-on-exec flag +----------------------------- + +Always set close-on-exec flag on new file descriptors created by Python. This +alternative just changes the default value of the new ``cloexec`` argument. + +``subprocess.Popen`` constructor has an ``pass_fds`` argument to specify which +file descriptors must be inherited. The close-on-exec flag of these file +descriptors must be changed with ``os.set_cloexec()``. + +If the close-on-exec flag must not be set, ``cloexec=False`` can be specified. + +Advantages of setting close-on-exec flag by default: + + * There are far more programs that are bitten by FD inheritance upon + exec (see `Inherited file descriptors issues`_ and `Security`_) than + programs relying on it. + * Checking if a module creates file descriptors is difficult. For example, + ``os.urandom()`` creates a file descriptor on UNIX to read ``/dev/urandom`` + (and closes it at exit), whereas it is implemented using a function call on + Windows. It is not possible to control close-on-exec flag of the file + descriptor used by ``os.urandom()``, because ``os.urandom()`` API does not + allow it. + * No need to add a new ``cloexec`` argument everywhere: functions creating + file descriptors will read ``sys.getdefaultcloexec()`` to decide if the + close-on-exec must be set or not. For example, adding an ``cloexec`` + argument to ``os.urandom()`` does not make sense on Windows. + +Drawbacks of setting close-on-exec flag by default: + + * The os module is written as a thin wrapper to system calls (to functions of + the C standard library). If atomic flags are not supported, a single Python + function call may now call 2 or 3 system calls (see `Performances`_ + section). + * Extra system calls, if any, may slow down Python: see `Performances`_. + * It violates the principle of least surprise. Developers using the os module + may expect that Python respects the POSIX standard and so that close-on-exec + flag is not set by default. + * Only file descriptors created by the Python standard library will comply to + ``sys.setdefaultcloexec()``. The close-on-exec flag is unchanged for file + descriptors created by third party modules calling directly C functions. + Third party modules will have to be modified to read + ``sys.getdefaultcloexec()`` to make them comply to this PEP. + + +Add a function to set close-on-exec flag by default +--------------------------------------------------- + +An alternative is to add also a function to change globally the default +behaviour. It would be possible to set close-on-exec flag for the whole +application including all modules and the Python standard library. This +alternative is based on the PEP but adds extra changes. + +Add new functions: + + * ``sys.getdefaultcloexec() -> bool``: get the default value of the + close-on-exec flag for new file descriptor + * ``sys.setdefaultcloexec(cloexec: bool)``: enable or disable close-on-exec + flag, the state of the flag can be overriden in each function creating a + file descriptor + +The major change is that the default value of the ``cloexec`` argument is +``sys.getdefaultcloexec()``, instead of ``False``. + +When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by default, +we have the same drawbacks than `Always set close-on-exec +flag`_ alternative. + +There are additionnal drawbacks of having two behaviours depending on +``sys.getdefaultcloexec()`` value: + + * It is not more possible to know if the close-on-exec flag will be set or not + just by reading the source code. + + +open(): add "e" flag to mode +---------------------------- + +A new "e" mode would set close-on-exec flag (best-effort). + +This API does not allow to disable explictly close-on-exec flag if it was +enabled globally with ``sys.setdefaultcloexec()``. + +Note: Since its version 2.7, the GNU libc supports ``"e"`` flag for ``fopen()``. +It uses ``O_CLOEXEC`` if available, or use ``fcntl(fd, F_SETFD, FD_CLOEXEC)``. + + +Appendix: Operating system support +================================== + +Windows +------- + +Windows has an ``O_NOINHERIT`` flag: "Do not inherit in child processes". + +For example, it is supported by ``open()`` and ``_pipe()``. + +The value of the flag can be modified using: +``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)``. + +``CreateProcess()`` has an ``bInheritHandles`` argument: if it is FALSE, the +handles are not inherited. It is used by ``subprocess.Popen`` with +``close_fds`` option. + +fcntl +----- + +Functions: + + * ``fcntl(fd, F_GETFD)`` + * ``fcntl(fd, F_SETFD, flags | FD_CLOEXEC)`` + +Availability: AIX, Digital UNIX, FreeBSD, HP-UX, IRIX, Linux, Mac OS X, +OpenBSD, Solaris, SunOS, Unicos. + +ioctl +----- + +Functions: + + * ``ioctl(fd, FIOCLEX, 0)`` sets close-on-exec flag + * ``ioctl(fd, FIONCLEX, 0)`` unsets close-on-exec flag + +Availability: Linux, Mac OS X, QNX, NetBSD, OpenBSD, FreeBSD. + + +Atomic flags +------------ + +New flags: + + * ``O_CLOEXEC``: available on Linux (2.6.23+), FreeBSD (8.3+), OpenBSD 5.0, + will be part of the next NetBSD release (6.1?). This flag is part of + POSIX.1-2008. + * ``socket()``: ``SOCK_CLOEXEC`` flag, available on Linux 2.6.27+, + OpenBSD 5.2, NetBSD 6.0. + * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24+, + OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0. This flag is part of POSIX.1-2008. + * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23+, NetBSD 6.0. + +On Linux older than 2.6.23, ``O_CLOEXEC`` flag is simply ignored. So we have to +check that the flag is supported by calling ``fcntl()``. If it does not work, +we have to set the flag using ``fcntl()``. + +XXX what is the behaviour on Linux older than 2.6.27 with SOCK_CLOEXEC? XXX + +New functions: + + * ``dup3()``: available on Linux 2.6.27+ (and glibc 2.9) + * ``pipe2()``: available on Linux 2.6.27+ (and glibc 2.9) + * ``accept4()``: available on Linux 2.6.28+ (and glibc 2.10) + +If ``accept4()`` is called on Linux older than 2.6.28, ``accept4()`` returns +``-1`` (fail) and errno is set to ``ENOSYS``. + + +Links +===== + +Links: + + * `Secure File Descriptor Handling + `_ (Ulrich Drepper, 2008) + * `win32_support.py of the Tornado project + `_: + emulate fcntl(fd, F_SETFD, FD_CLOEXEC) using + ``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)`` + +Python issues: + + * `open() does not able to set flags, such as O_CLOEXEC + `_ + * `Add "e" mode to open(): close-and-exec (O_CLOEXEC) / O_NOINHERIT + `_ + * `TCP listening sockets created without FD_CLOEXEC flag + `_ + * `Use O_CLOEXEC in the tempfile module + `_ + * `Support accept4() for atomic setting of flags at socket creation + `_ + * `Add an 'afterfork' module + `_ + +Ruby: + + * `Set FD_CLOEXEC for all fds (except 0, 1, 2) + `_ + * `O_CLOEXEC flag missing for Kernel::open + `_: + `commit reverted + `_ later + +Footnotes +========= + +.. [#subprocess_close] On UNIX since Python 3.2, subprocess.Popen() closes all file descriptors by + default: ``close_fds=True``. It closes file descriptors in range 3 inclusive + to ``local_max_fd`` exclusive, where ``local_max_fd`` is ``fcntl(0, + F_MAXFD)`` on NetBSD, or ``sysconf(_SC_OPEN_MAX)`` otherwise. If the error + pipe has a descriptor smaller than 3, ``ValueError`` is raised. + -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sat Jan 12 21:47:14 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 12 Jan 2013 21:47:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogU1NMQ29udGV4dC5s?= =?utf-8?q?oad=5Fdh=5Fparams=28=29_now_properly_closes_the_input_file=2E?= Message-ID: <3YkCg61WZwzS2B@mail.python.org> http://hg.python.org/cpython/rev/523d5b1e3fd5 changeset: 81463:523d5b1e3fd5 branch: 3.3 parent: 81460:778bead39825 user: Antoine Pitrou date: Sat Jan 12 21:43:45 2013 +0100 summary: SSLContext.load_dh_params() now properly closes the input file. files: Misc/NEWS | 2 ++ Modules/_ssl.c | 1 + 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -147,6 +147,8 @@ Library ------- +- SSLContext.load_dh_params() now properly closes the input file. + - Issue #16829: IDLE printing no longer fails if there are spaces or other special characters in the file path. diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2177,6 +2177,7 @@ errno = 0; PySSL_BEGIN_ALLOW_THREADS dh = PEM_read_DHparams(f, NULL, NULL, NULL); + fclose(f); PySSL_END_ALLOW_THREADS if (dh == NULL) { if (errno != 0) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 21:47:15 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 12 Jan 2013 21:47:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_SSLContext=2Eload=5Fdh=5Fparams=28=29_now_properly_close?= =?utf-8?q?s_the_input_file=2E?= Message-ID: <3YkCg74bV0zS47@mail.python.org> http://hg.python.org/cpython/rev/44e614446f78 changeset: 81464:44e614446f78 parent: 81462:e22c09f636d4 parent: 81463:523d5b1e3fd5 user: Antoine Pitrou date: Sat Jan 12 21:44:33 2013 +0100 summary: SSLContext.load_dh_params() now properly closes the input file. files: Misc/NEWS | 2 ++ Modules/_ssl.c | 1 + 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -217,6 +217,8 @@ Library ------- +- SSLContext.load_dh_params() now properly closes the input file. + - Issue #16829: IDLE printing no longer fails if there are spaces or other special characters in the file path. diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2248,6 +2248,7 @@ errno = 0; PySSL_BEGIN_ALLOW_THREADS dh = PEM_read_DHparams(f, NULL, NULL, NULL); + fclose(f); PySSL_END_ALLOW_THREADS if (dh == NULL) { if (errno != 0) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 21:59:28 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 12 Jan 2013 21:59:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTIz?= =?utf-8?q?=3A_Fix_ResourceWarnings_in_test=5Fssl=2E?= Message-ID: <3YkCxD3LGczS3g@mail.python.org> http://hg.python.org/cpython/rev/2c3f5ed7a5c9 changeset: 81465:2c3f5ed7a5c9 branch: 3.3 parent: 81463:523d5b1e3fd5 user: Antoine Pitrou date: Sat Jan 12 21:54:44 2013 +0100 summary: Issue #16923: Fix ResourceWarnings in test_ssl. files: Lib/test/test_ssl.py | 68 ++++++++++++++++--------------- Misc/NEWS | 2 + 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -208,20 +208,21 @@ s = socket.socket(socket.AF_INET) ss = ssl.wrap_socket(s) wr = weakref.ref(ss) - del ss - self.assertEqual(wr(), None) + with support.check_warnings(("", ResourceWarning)): + del ss + self.assertEqual(wr(), None) def test_wrapped_unconnected(self): # Methods on an unconnected SSLSocket propagate the original # socket.error raise by the underlying socket object. s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s) - self.assertRaises(socket.error, ss.recv, 1) - self.assertRaises(socket.error, ss.recv_into, bytearray(b'x')) - self.assertRaises(socket.error, ss.recvfrom, 1) - self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1) - self.assertRaises(socket.error, ss.send, b'x') - self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0)) + with ssl.wrap_socket(s) as ss: + self.assertRaises(socket.error, ss.recv, 1) + self.assertRaises(socket.error, ss.recv_into, bytearray(b'x')) + self.assertRaises(socket.error, ss.recvfrom, 1) + self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1) + self.assertRaises(socket.error, ss.send, b'x') + self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0)) def test_timeout(self): # Issue #8524: when creating an SSL socket, the timeout of the @@ -229,8 +230,8 @@ for timeout in (None, 0.0, 5.0): s = socket.socket(socket.AF_INET) s.settimeout(timeout) - ss = ssl.wrap_socket(s) - self.assertEqual(timeout, ss.gettimeout()) + with ssl.wrap_socket(s) as ss: + self.assertEqual(timeout, ss.gettimeout()) def test_errors(self): sock = socket.socket() @@ -243,9 +244,9 @@ self.assertRaisesRegex(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True, certfile="") - s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE) - self.assertRaisesRegex(ValueError, "can't connect in server-side mode", - s.connect, (HOST, 8080)) + with ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE) as s: + self.assertRaisesRegex(ValueError, "can't connect in server-side mode", + s.connect, (HOST, 8080)) with self.assertRaises(IOError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=WRONGCERT) @@ -358,21 +359,21 @@ def test_unknown_channel_binding(self): # should raise ValueError for unknown type s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s) - with self.assertRaises(ValueError): - ss.get_channel_binding("unknown-type") + with ssl.wrap_socket(s) as ss: + with self.assertRaises(ValueError): + ss.get_channel_binding("unknown-type") @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): # unconnected should return None for known type s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s) - self.assertIsNone(ss.get_channel_binding("tls-unique")) + with ssl.wrap_socket(s) as ss: + self.assertIsNone(ss.get_channel_binding("tls-unique")) # the same for server-side s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) - self.assertIsNone(ss.get_channel_binding("tls-unique")) + with ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) as ss: + self.assertIsNone(ss.get_channel_binding("tls-unique")) def test_dealloc_warn(self): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) @@ -623,10 +624,10 @@ with socket.socket() as s: s.bind(("127.0.0.1", 0)) s.listen(5) - with socket.socket() as c: - c.connect(s.getsockname()) - c.setblocking(False) - c = ctx.wrap_socket(c, False, do_handshake_on_connect=False) + c = socket.socket() + c.connect(s.getsockname()) + c.setblocking(False) + with ctx.wrap_socket(c, False, do_handshake_on_connect=False) as c: with self.assertRaises(ssl.SSLWantReadError) as cm: c.do_handshake() s = str(cm.exception) @@ -867,12 +868,12 @@ def test_ciphers(self): remote = ("svn.python.org", 443) with support.transient_internet(remote[0]): - s = ssl.wrap_socket(socket.socket(socket.AF_INET), - cert_reqs=ssl.CERT_NONE, ciphers="ALL") - s.connect(remote) - s = ssl.wrap_socket(socket.socket(socket.AF_INET), - cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") - s.connect(remote) + with ssl.wrap_socket(socket.socket(socket.AF_INET), + cert_reqs=ssl.CERT_NONE, ciphers="ALL") as s: + s.connect(remote) + with ssl.wrap_socket(socket.socket(socket.AF_INET), + cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") as s: + s.connect(remote) # Error checking can happen at instantiation or when connecting with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): with socket.socket(socket.AF_INET) as sock: @@ -1847,6 +1848,8 @@ client_addr = client.getsockname() client.close() t.join() + remote.close() + server.close() # Sanity checks. self.assertIsInstance(remote, ssl.SSLSocket) self.assertEqual(peer, client_addr) @@ -1861,8 +1864,7 @@ with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_SSLv23, chatty=False) as server: - with socket.socket() as sock: - s = context.wrap_socket(sock) + with context.wrap_socket(socket.socket()) as s: with self.assertRaises((OSError, ssl.SSLError)): s.connect((HOST, server.port)) self.assertIn("no shared cipher", str(server.conn_errors[0])) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -434,6 +434,8 @@ Tests ----- +- Issue #16923: Fix ResourceWarnings in test_ssl. + - Issue #15539: Added regression tests for Tools/scripts/pindent.py. - Issue #16925: test_configparser now works with unittest test discovery. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 21:59:30 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 12 Jan 2013 21:59:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316923=3A_Fix_ResourceWarnings_in_test=5Fssl=2E?= Message-ID: <3YkCxG0DXFzSFS@mail.python.org> http://hg.python.org/cpython/rev/f79d282c8147 changeset: 81466:f79d282c8147 parent: 81464:44e614446f78 parent: 81465:2c3f5ed7a5c9 user: Antoine Pitrou date: Sat Jan 12 21:56:56 2013 +0100 summary: Issue #16923: Fix ResourceWarnings in test_ssl. files: Lib/test/test_ssl.py | 68 ++++++++++++++++--------------- Misc/NEWS | 2 + 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -217,20 +217,21 @@ s = socket.socket(socket.AF_INET) ss = ssl.wrap_socket(s) wr = weakref.ref(ss) - del ss - self.assertEqual(wr(), None) + with support.check_warnings(("", ResourceWarning)): + del ss + self.assertEqual(wr(), None) def test_wrapped_unconnected(self): # Methods on an unconnected SSLSocket propagate the original # OSError raise by the underlying socket object. s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s) - self.assertRaises(OSError, ss.recv, 1) - self.assertRaises(OSError, ss.recv_into, bytearray(b'x')) - self.assertRaises(OSError, ss.recvfrom, 1) - self.assertRaises(OSError, ss.recvfrom_into, bytearray(b'x'), 1) - self.assertRaises(OSError, ss.send, b'x') - self.assertRaises(OSError, ss.sendto, b'x', ('0.0.0.0', 0)) + with ssl.wrap_socket(s) as ss: + self.assertRaises(OSError, ss.recv, 1) + self.assertRaises(OSError, ss.recv_into, bytearray(b'x')) + self.assertRaises(OSError, ss.recvfrom, 1) + self.assertRaises(OSError, ss.recvfrom_into, bytearray(b'x'), 1) + self.assertRaises(OSError, ss.send, b'x') + self.assertRaises(OSError, ss.sendto, b'x', ('0.0.0.0', 0)) def test_timeout(self): # Issue #8524: when creating an SSL socket, the timeout of the @@ -238,8 +239,8 @@ for timeout in (None, 0.0, 5.0): s = socket.socket(socket.AF_INET) s.settimeout(timeout) - ss = ssl.wrap_socket(s) - self.assertEqual(timeout, ss.gettimeout()) + with ssl.wrap_socket(s) as ss: + self.assertEqual(timeout, ss.gettimeout()) def test_errors(self): sock = socket.socket() @@ -252,9 +253,9 @@ self.assertRaisesRegex(ValueError, "certfile must be specified for server-side operations", ssl.wrap_socket, sock, server_side=True, certfile="") - s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE) - self.assertRaisesRegex(ValueError, "can't connect in server-side mode", - s.connect, (HOST, 8080)) + with ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE) as s: + self.assertRaisesRegex(ValueError, "can't connect in server-side mode", + s.connect, (HOST, 8080)) with self.assertRaises(OSError) as cm: with socket.socket() as sock: ssl.wrap_socket(sock, certfile=WRONGCERT) @@ -367,21 +368,21 @@ def test_unknown_channel_binding(self): # should raise ValueError for unknown type s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s) - with self.assertRaises(ValueError): - ss.get_channel_binding("unknown-type") + with ssl.wrap_socket(s) as ss: + with self.assertRaises(ValueError): + ss.get_channel_binding("unknown-type") @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES, "'tls-unique' channel binding not available") def test_tls_unique_channel_binding(self): # unconnected should return None for known type s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s) - self.assertIsNone(ss.get_channel_binding("tls-unique")) + with ssl.wrap_socket(s) as ss: + self.assertIsNone(ss.get_channel_binding("tls-unique")) # the same for server-side s = socket.socket(socket.AF_INET) - ss = ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) - self.assertIsNone(ss.get_channel_binding("tls-unique")) + with ssl.wrap_socket(s, server_side=True, certfile=CERTFILE) as ss: + self.assertIsNone(ss.get_channel_binding("tls-unique")) def test_dealloc_warn(self): ss = ssl.wrap_socket(socket.socket(socket.AF_INET)) @@ -660,10 +661,10 @@ with socket.socket() as s: s.bind(("127.0.0.1", 0)) s.listen(5) - with socket.socket() as c: - c.connect(s.getsockname()) - c.setblocking(False) - c = ctx.wrap_socket(c, False, do_handshake_on_connect=False) + c = socket.socket() + c.connect(s.getsockname()) + c.setblocking(False) + with ctx.wrap_socket(c, False, do_handshake_on_connect=False) as c: with self.assertRaises(ssl.SSLWantReadError) as cm: c.do_handshake() s = str(cm.exception) @@ -904,12 +905,12 @@ def test_ciphers(self): remote = ("svn.python.org", 443) with support.transient_internet(remote[0]): - s = ssl.wrap_socket(socket.socket(socket.AF_INET), - cert_reqs=ssl.CERT_NONE, ciphers="ALL") - s.connect(remote) - s = ssl.wrap_socket(socket.socket(socket.AF_INET), - cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") - s.connect(remote) + with ssl.wrap_socket(socket.socket(socket.AF_INET), + cert_reqs=ssl.CERT_NONE, ciphers="ALL") as s: + s.connect(remote) + with ssl.wrap_socket(socket.socket(socket.AF_INET), + cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") as s: + s.connect(remote) # Error checking can happen at instantiation or when connecting with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"): with socket.socket(socket.AF_INET) as sock: @@ -1886,6 +1887,8 @@ client_addr = client.getsockname() client.close() t.join() + remote.close() + server.close() # Sanity checks. self.assertIsInstance(remote, ssl.SSLSocket) self.assertEqual(peer, client_addr) @@ -1900,8 +1903,7 @@ with ThreadedEchoServer(CERTFILE, ssl_version=ssl.PROTOCOL_SSLv23, chatty=False) as server: - with socket.socket() as sock: - s = context.wrap_socket(sock) + with context.wrap_socket(socket.socket()) as s: with self.assertRaises(OSError): s.connect((HOST, server.port)) self.assertIn("no shared cipher", str(server.conn_errors[0])) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -635,6 +635,8 @@ Tests ----- +- Issue #16923: Fix ResourceWarnings in test_ssl. + - Issue #15539: Added regression tests for Tools/scripts/pindent.py. - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 22:03:23 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 12 Jan 2013 22:03:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSW4gdGVzdF9zc2ws?= =?utf-8?q?_threaded_tests_shouldn=27t_need_the_=22network=22_resource_to_?= =?utf-8?q?be_enabled?= Message-ID: <3YkD1l5ZsJzSFS@mail.python.org> http://hg.python.org/cpython/rev/c276fbd95182 changeset: 81467:c276fbd95182 branch: 3.3 parent: 81465:2c3f5ed7a5c9 user: Antoine Pitrou date: Sat Jan 12 22:00:09 2013 +0100 summary: In test_ssl, threaded tests shouldn't need the "network" resource to be enabled files: Lib/test/test_ssl.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2032,7 +2032,7 @@ if _have_threads: thread_info = support.threading_setup() - if thread_info and support.is_resource_enabled('network'): + if thread_info: tests.append(ThreadedTests) try: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 22:03:25 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 12 Jan 2013 22:03:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_In_test=5Fssl=2C_threaded_tests_shouldn=27t_need_the_net?= =?utf-8?q?work_resource_to_be_enabled?= Message-ID: <3YkD1n245RzSFs@mail.python.org> http://hg.python.org/cpython/rev/5697373c56c1 changeset: 81468:5697373c56c1 parent: 81466:f79d282c8147 parent: 81467:c276fbd95182 user: Antoine Pitrou date: Sat Jan 12 22:00:54 2013 +0100 summary: In test_ssl, threaded tests shouldn't need the network resource to be enabled files: Lib/test/test_ssl.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2166,7 +2166,7 @@ if _have_threads: thread_info = support.threading_setup() - if thread_info and support.is_resource_enabled('network'): + if thread_info: tests.append(ThreadedTests) try: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 12 23:02:53 2013 From: python-checkins at python.org (eli.bendersky) Date: Sat, 12 Jan 2013 23:02:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_fix_versionadded_to_3=2E4?= Message-ID: <3YkFLP16n4zSDr@mail.python.org> http://hg.python.org/cpython/rev/72ddb250f058 changeset: 81469:72ddb250f058 user: Eli Bendersky date: Sat Jan 12 14:02:29 2013 -0800 summary: fix versionadded to 3.4 files: Doc/library/filecmp.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst +++ b/Doc/library/filecmp.rst @@ -166,7 +166,7 @@ .. attribute:: DEFAULT_IGNORES - .. versionadded:: 3.3 + .. versionadded:: 3.4 List of directories ignored by :class:`dircmp` by default. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 00:06:30 2013 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Jan 2013 00:06:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_cleanup=2C_complet?= =?utf-8?q?e=2C_reorganize?= Message-ID: <3YkGlp1znMzSBy@mail.python.org> http://hg.python.org/peps/rev/7fd26f1f2ce1 changeset: 4667:7fd26f1f2ce1 user: Victor Stinner date: Sun Jan 13 00:04:29 2013 +0100 summary: PEP 433: cleanup, complete, reorganize files: pep-0433.txt | 322 +++++++++++++++++++++++--------------- 1 files changed, 192 insertions(+), 130 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -23,7 +23,9 @@ On UNIX, subprocess closes file descriptors greater than 2 by default since Python 3.2 [#subprocess_close]_. All file descriptors created by the parent -process are automatically closed. +process are automatically closed. ``xmlrpc.server.SimpleXMLRPCServer`` sets +the close-on-exec flag of the listening socket, the parent class +``socketserver.BaseServer`` does not set this flag. There are other cases creating a subprocess or executing a new program where file descriptors are not closed: functions of the os.spawn*() family and third @@ -31,6 +33,9 @@ descriptors are shared between the parent and the child processes which is usually unexpected and causes various issues. +This PEP proposes to continue the work started with the change in the +subprocess, to fix the issue in any code, and not just code using subprocess. + Inherited file descriptors issues --------------------------------- @@ -95,22 +100,10 @@ ``fork()``. The close-on-exec flag only closes file descriptors after ``exec()``, and so after ``fork()`` + ``exec()``. -Many functions of the Python standard library creating file descriptors are not -changed by the PEP, and so will not have the close-on-exec flag set. Some -examples: - - * ``os.urandom()``: on UNIX, it creates a file descriptor on UNIX to read - ``/dev/urandom``. Adding an ``cloexec`` argument to ``os.urandom()`` does - not make sense on Windows. - * ``curses.windows.getwin()`` and ``curses.windows.putwin()`` creates a temporary file using ``fdopen(fd, "wb+");`` - * ``mmap.mmap()`` opens ``/dev/null`` using ``open("/dev/zero", O_RDWR);`` if - ``MAP_ANONYMOUS`` is not defined. - * If the ``PYTHONSTARTUP`` environment variable is set, the corresponding file - is opened using ``fopen(startup, "r");`` - * ``python script.py`` opens ``script.py`` using ``fopen(filename, "r");`` - * etc. - -Third party modules creating file descriptors may not set close-on-exec flag. +This PEP only change the close-on-exec flag of file descriptors created by the +Python standard library, or by modules using the standard library. Third party +modules not using the standard library should be modified to conform to this +PEP. The new ``os.set_cloexec()`` function can be used for example. Impacted functions: @@ -129,9 +122,13 @@ XXX Should ``subprocess.Popen`` set the close-on-exec flag on file XXX XXX descriptors of the constructor the ``pass_fds`` argument? XXX +.. note:: + See `Close file descriptors after fork`_ for a possible solution for + ``fork()`` without ``exec()``. -Proposition -=========== + +Proposal +======== This PEP proposes to add a new optional argument ``cloexec`` on functions creating file descriptors in the Python standard library. If the argument is @@ -160,41 +157,196 @@ The default value of the ``cloexec`` argument is ``False`` to keep the backward compatibility. +The close-on-exec flag will not be set on file descriptors 0 (stdin), 1 +(stdout) and 2 (stderr), because these files are expected to be inherited. It +would still be possible to set close-on-exec flag explicitly using +``os.set_cloexec()``. +Drawbacks: + * Many functions of the Python standard library creating file descriptors are + cannot be changed by this proposal, because adding a ``cloexec`` optional + argument would be surprising and too many functions would need it. For + example, ``os.urandom()`` uses a temporary file on UNIX, but it calls a + function of Windows API on Windows. Adding a ``cloexec`` argument to + ``os.urandom()`` would not make sense. See `Always set close-on-exec flag`_ + for an incomplete list of functions creating file descriptors. + * Checking if a module creates file descriptors is difficult. For example, + ``os.urandom()`` creates a file descriptor on UNIX to read ``/dev/urandom`` + (and closes it at exit), whereas it is implemented using a function call on + Windows. It is not possible to control close-on-exec flag of the file + descriptor used by ``os.urandom()``, because ``os.urandom()`` API does not + allow it. +Alternatives +============ + +Always set close-on-exec flag +----------------------------- + +Always set close-on-exec flag on new file descriptors created by Python. This +alternative just changes the default value of the new ``cloexec`` argument. + +If a file must be inherited by child processes, ``cloexec=False`` argument can +be used. + +``subprocess.Popen`` constructor has an ``pass_fds`` argument to specify which +file descriptors must be inherited. The close-on-exec flag of these file +descriptors must be changed with ``os.set_cloexec()``. + +Example of functions creating file descriptors which will be modified to +set close-on-exec flag: + + * ``os.urandom()`` (on UNIX) + * ``curses.window.getwin()``, ``curses.window.putwin()`` + * ``mmap.mmap()`` (if ``MAP_ANONYMOUS`` is not defined) + * ``oss.open()`` + * ``Modules/main.c``: ``RunStartupFile()`` + * ``Python/pythonrun.c``: ``PyRun_SimpleFileExFlags()`` + * ``Modules/getpath.c``: ``search_for_exec_prefix()`` + * ``Modules/zipimport.c``: ``read_directory()`` + * ``Modules/_ssl.c``: ``load_dh_params()`` + * ``PC/getpathp.c``: ``calculate_path()`` + * ``Python/errors.c``: ``PyErr_ProgramText()`` + * ``Python/import.c``: ``imp_load_dynamic()`` + * TODO: ``PC/_msi.c`` + +Many functions are impacted indirectly by this alternative. Examples: + + * ``logging.FileHandler`` + +Advantages of setting close-on-exec flag by default: + + * There are far more programs that are bitten by FD inheritance upon + exec (see `Inherited file descriptors issues`_ and `Security`_) than + programs relying on it + (see `Applications using inherance of file descriptors`_). + +Drawbacks of setting close-on-exec flag by default: + + * The os module is written as a thin wrapper to system calls (to functions of + the C standard library). If atomic flags to set close-on-exec flag are not + supported (see `Appendix: Operating system support`_), a single Python + function call may call 2 or 3 system calls (see `Performances`_ section). + * Extra system calls, if any, may slow down Python: see `Performances`_. + * It violates the principle of least surprise. Developers using the os module + may expect that Python respects the POSIX standard and so that close-on-exec + flag is not set by default. + +Backward compatibility: only a few programs rely on inherance of file +descriptors, and they only pass a few file descriptors, usually just one. +These programs will fail immediatly with ``EBADF`` error, and it will be simple +to fix them: add ``cloexec=False`` argument or use +``os.set_cloexec(fd, False)``. + +The ``subprocess`` module will be changed anyway to unset close-on-exec flag on +file descriptors listed in the ``pass_fds`` argument of Popen constructor. So +it possible that these programs will not need any fix if they use the +``subprocess`` module. + + +Add a function to set close-on-exec flag by default +--------------------------------------------------- + +An alternative is to add also a function to change globally the default +behaviour. It would be possible to set close-on-exec flag for the whole +application including all modules and the Python standard library. This +alternative is based on the `Proposal`_ and adds extra changes. + +Add new functions: + + * ``sys.getdefaultcloexec() -> bool``: get the default value of the + close-on-exec flag for new file descriptor + * ``sys.setdefaultcloexec(cloexec: bool)``: enable or disable close-on-exec + flag, the state of the flag can be overriden in each function creating a + file descriptor + +The major change is that the default value of the ``cloexec`` argument is +``sys.getdefaultcloexec()``, instead of ``False``. + +When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by default, +we have the same drawbacks than `Always set close-on-exec +flag`_ alternative. + +There are additionnal drawbacks of having two behaviours depending on +``sys.getdefaultcloexec()`` value: + + * It is not more possible to know if the close-on-exec flag will be set or not + just by reading the source code. + + +Close file descriptors after fork +--------------------------------- + +This PEP does not fix issues with applications using ``fork()`` without +``exec()``. Python needs a generic process to register callbacks which +would be called after a fork, see `Add an 'afterfork' module`_. Such +registry could be used to close file descriptors just after a ``fork()``. + +Drawbacks: + + * This alternative does not solve the problem for programs using ``exec()`` + without ``fork()``. + * A third party module may call directly the C function ``fork()`` which will + not call "atfork" callbacks. + * All functions creating file descriptors must be changed to register a + callback and then unregister their callback when the file is closed. Or a + list of *all* open file descriptors must be maintained. + * The operating system is a better place than Python to close automatically + file descriptors. For example, it is not easy to avoid a race condition + between closing the file and unregistering the callback closing the file. + + +open(): add "e" flag to mode +---------------------------- + +A new "e" mode would set close-on-exec flag (best-effort). + +This alternative only solves the problem for ``open()``. socket.socket() and +os.pipe() do not have a ``mode`` argument for example. + +Since its version 2.7, the GNU libc supports ``"e"`` flag for ``fopen()``. It +uses ``O_CLOEXEC`` if available, or use ``fcntl(fd, F_SETFD, FD_CLOEXEC)``. +With Visual Studio, fopen() accepts a "N" flag which uses ``O_NOINHERIT``. + Applications using inherance of file descriptors ================================================ +Most developers don't know that file descriptors are inherited by default. Most +programs do not rely on inherance of file descriptors. For example, +``subprocess.Popen`` was changed in Python 3.2 to close all file descriptors +greater than 2 in the child process by default. No user complained about this +behavior change. + Network servers using fork may want to pass the client socket to the child -process. For example, a CGI server pass the socket client through file -descriptors 0 (stdin) and 1 (stdout) using ``dup2()``. +process. For example, on UNIX a CGI server pass the socket client through file +descriptors 0 (stdin) and 1 (stdout) using ``dup2()``. This specific case is +not impacted by this PEP because the close-on-exec flag is never set on file +descriptors smaller than 3. -Example of programs taking file descriptors from the parent process: +To access a restricted resource like creating a socket listening on a TCP port +lower than 1024 or reading a file containing sensitive data like passwords, a +common practice is: start as the root user, create a file descriptor, create +a child process, pass the file descriptor to the child process and exit. +Security is very important in such use case: leaking another file descriptor +would be a critical security vulnerability (see `Security`_). The root process +may not exit but monitors the child process instead, and restarts a new child +process and pass the same file descriptor if the previous child process +crashed. +Example of programs taking file descriptors from the parent process using a +command line option: + + * gpg: ``--status-fd ``, ``--logger-fd ``, etc. + * openssl: ``-pass fd:`` + * qemu: ``-add-fd `` * valgrind: ``--log-fd=``, ``--input-fd=``, etc. - * qemu: ``-add-fd `` command line option - * GnuPG: ``--status-fd ``, ``--logger-fd ``, etc. - * openssl command: ``-pass fd:`` * xterm: ``-S `` -On Linux, it is possible to use ``/dev/fd/`` filename to pass a file -descriptor to a program expecting a filename. It can be used to pass a password -for example. - -These applications only pass a few file descriptors, usually only one. -Fixing these applications to unset close-on-exec flag should be easy. - -If the ``subprocess`` module is used, inherited file descriptors must be specified -using the ``pass_fds`` argument (except if the ``close_fds`` argument is set -explicitly to ``False``). So the ``subprocess`` module knows the list of file -descriptors on which close-on-exec flag must be unset. - -File descriptors 0 (stdin), 1 (stdout) and 2 (stderr) are expected to be -inherited and so should not have the close-on-exec flag. So a CGI server should -not be impacted by this PEP. +On Linux, it is possible to use ``"/dev/fd/"`` filename to pass a file +descriptor to a program expecting a filename. Performances @@ -313,96 +465,6 @@ the close-on-exec flag is not set by default. -Alternatives -============ - -Always set close-on-exec flag ------------------------------ - -Always set close-on-exec flag on new file descriptors created by Python. This -alternative just changes the default value of the new ``cloexec`` argument. - -``subprocess.Popen`` constructor has an ``pass_fds`` argument to specify which -file descriptors must be inherited. The close-on-exec flag of these file -descriptors must be changed with ``os.set_cloexec()``. - -If the close-on-exec flag must not be set, ``cloexec=False`` can be specified. - -Advantages of setting close-on-exec flag by default: - - * There are far more programs that are bitten by FD inheritance upon - exec (see `Inherited file descriptors issues`_ and `Security`_) than - programs relying on it. - * Checking if a module creates file descriptors is difficult. For example, - ``os.urandom()`` creates a file descriptor on UNIX to read ``/dev/urandom`` - (and closes it at exit), whereas it is implemented using a function call on - Windows. It is not possible to control close-on-exec flag of the file - descriptor used by ``os.urandom()``, because ``os.urandom()`` API does not - allow it. - * No need to add a new ``cloexec`` argument everywhere: functions creating - file descriptors will read ``sys.getdefaultcloexec()`` to decide if the - close-on-exec must be set or not. For example, adding an ``cloexec`` - argument to ``os.urandom()`` does not make sense on Windows. - -Drawbacks of setting close-on-exec flag by default: - - * The os module is written as a thin wrapper to system calls (to functions of - the C standard library). If atomic flags are not supported, a single Python - function call may now call 2 or 3 system calls (see `Performances`_ - section). - * Extra system calls, if any, may slow down Python: see `Performances`_. - * It violates the principle of least surprise. Developers using the os module - may expect that Python respects the POSIX standard and so that close-on-exec - flag is not set by default. - * Only file descriptors created by the Python standard library will comply to - ``sys.setdefaultcloexec()``. The close-on-exec flag is unchanged for file - descriptors created by third party modules calling directly C functions. - Third party modules will have to be modified to read - ``sys.getdefaultcloexec()`` to make them comply to this PEP. - - -Add a function to set close-on-exec flag by default ---------------------------------------------------- - -An alternative is to add also a function to change globally the default -behaviour. It would be possible to set close-on-exec flag for the whole -application including all modules and the Python standard library. This -alternative is based on the PEP but adds extra changes. - -Add new functions: - - * ``sys.getdefaultcloexec() -> bool``: get the default value of the - close-on-exec flag for new file descriptor - * ``sys.setdefaultcloexec(cloexec: bool)``: enable or disable close-on-exec - flag, the state of the flag can be overriden in each function creating a - file descriptor - -The major change is that the default value of the ``cloexec`` argument is -``sys.getdefaultcloexec()``, instead of ``False``. - -When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by default, -we have the same drawbacks than `Always set close-on-exec -flag`_ alternative. - -There are additionnal drawbacks of having two behaviours depending on -``sys.getdefaultcloexec()`` value: - - * It is not more possible to know if the close-on-exec flag will be set or not - just by reading the source code. - - -open(): add "e" flag to mode ----------------------------- - -A new "e" mode would set close-on-exec flag (best-effort). - -This API does not allow to disable explictly close-on-exec flag if it was -enabled globally with ``sys.setdefaultcloexec()``. - -Note: Since its version 2.7, the GNU libc supports ``"e"`` flag for ``fopen()``. -It uses ``O_CLOEXEC`` if available, or use ``fcntl(fd, F_SETFD, FD_CLOEXEC)``. - - Appendix: Operating system support ================================== -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 01:32:00 2013 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Jan 2013 01:32:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_reformat_to_70_col?= =?utf-8?q?umns?= Message-ID: <3YkJfS0RL6zRwm@mail.python.org> http://hg.python.org/peps/rev/ac3351088370 changeset: 4668:ac3351088370 user: Victor Stinner date: Sun Jan 13 01:30:02 2013 +0100 summary: PEP 433: reformat to 70 columns files: pep-0433.txt | 423 +++++++++++++++++++++----------------- 1 files changed, 232 insertions(+), 191 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -13,84 +13,92 @@ Abstract ======== -This PEP proposes to add a new optional argument ``cloexec`` on functions -creating file descriptors in the Python standard library. If the argument is -``True``, the close-on-exec flag will be set on the new file descriptor. +This PEP proposes to add a new optional argument ``cloexec`` on +functions creating file descriptors in the Python standard library. If +the argument is ``True``, the close-on-exec flag will be set on the +new file descriptor. Rationale ========= -On UNIX, subprocess closes file descriptors greater than 2 by default since -Python 3.2 [#subprocess_close]_. All file descriptors created by the parent -process are automatically closed. ``xmlrpc.server.SimpleXMLRPCServer`` sets -the close-on-exec flag of the listening socket, the parent class -``socketserver.BaseServer`` does not set this flag. +On UNIX, subprocess closes file descriptors greater than 2 by default +since Python 3.2 [#subprocess_close]_. All file descriptors created by +the parent process are automatically closed. +``xmlrpc.server.SimpleXMLRPCServer`` sets the close-on-exec flag of +the listening socket, the parent class ``socketserver.BaseServer`` +does not set this flag. -There are other cases creating a subprocess or executing a new program where -file descriptors are not closed: functions of the os.spawn*() family and third -party modules calling ``exec()`` or ``fork()`` + ``exec()``. In this case, file -descriptors are shared between the parent and the child processes which is -usually unexpected and causes various issues. +There are other cases creating a subprocess or executing a new program +where file descriptors are not closed: functions of the os.spawn*() +family and third party modules calling ``exec()`` or ``fork()`` + +``exec()``. In this case, file descriptors are shared between the +parent and the child processes which is usually unexpected and causes +various issues. This PEP proposes to continue the work started with the change in the -subprocess, to fix the issue in any code, and not just code using subprocess. +subprocess, to fix the issue in any code, and not just code using +subprocess. Inherited file descriptors issues --------------------------------- -Closing the file descriptor in the parent process does not close the related -resource (file, socket, ...) because it is still open in the child process. +Closing the file descriptor in the parent process does not close the +related resource (file, socket, ...) because it is still open in the +child process. -The listening socket of TCPServer is not closed on ``exec()``: the child -process is able to get connection from new clients; if the parent closes the -listening socket and create a new listening socket on the same address, it -would get an "address already is used" error. +The listening socket of TCPServer is not closed on ``exec()``: the +child process is able to get connection from new clients; if the +parent closes the listening socket and create a new listening socket +on the same address, it would get an "address already is used" error. -Not closing file descriptors can lead to resource exhaustion: even if the -parent closes all files, creating a new file descriptor may fail with "too many -files" because files are still open in the child process. +Not closing file descriptors can lead to resource exhaustion: even if +the parent closes all files, creating a new file descriptor may fail +with "too many files" because files are still open in the child +process. Security -------- -Leaking file descriptors is a major security vulnerability. An untrusted child -process can read sensitive data like passwords and take control of the parent -process though leaked file descriptors. It is for example a known vulnerability -to escape from a chroot. +Leaking file descriptors is a major security vulnerability. An +untrusted child process can read sensitive data like passwords and +take control of the parent process though leaked file descriptors. It +is for example a known vulnerability to escape from a chroot. Atomicity --------- -Using ``fcntl()`` to set the close-on-exec flag is not safe in a multithreaded -application. If a thread calls ``fork()`` and ``exec()`` between the creation -of the file descriptor and the call to ``fcntl(fd, F_SETFD, new_flags)``: the -file descriptor will be inherited by the child process. Modern operating -systems offer functions to set the flag during the creation of the file -descriptor, which avoids the race condition. +Using ``fcntl()`` to set the close-on-exec flag is not safe in a +multithreaded application. If a thread calls ``fork()`` and ``exec()`` +between the creation of the file descriptor and the call to +``fcntl(fd, F_SETFD, new_flags)``: the file descriptor will be +inherited by the child process. Modern operating systems offer +functions to set the flag during the creation of the file descriptor, +which avoids the race condition. Portability ----------- Python 3.2 added ``socket.SOCK_CLOEXEC`` flag, Python 3.3 added -``os.O_CLOEXEC`` flag and ``os.pipe2()`` function. It is already possible to -set atomically close-on-exec flag in Python 3.3 when opening a file and -creating a pipe or socket. +``os.O_CLOEXEC`` flag and ``os.pipe2()`` function. It is already +possible to set atomically close-on-exec flag in Python 3.3 when +opening a file and creating a pipe or socket. -The problem is that these flags and functions are not portable: only recent -versions of operating systems support them. ``O_CLOEXEC`` and ``SOCK_CLOEXEC`` -flags are ignored by old Linux versions and so ``FD_CLOEXEC`` flag must be -checked using ``fcntl(fd, F_GETFD)``. If the kernel ignores ``O_CLOEXEC`` or -``SOCK_CLOEXEC`` flag, a call to ``fcntl(fd, F_SETFD, flags)`` is required to -set close-on-exec flag. +The problem is that these flags and functions are not portable: only +recent versions of operating systems support them. ``O_CLOEXEC`` and +``SOCK_CLOEXEC`` flags are ignored by old Linux versions and so +``FD_CLOEXEC`` flag must be checked using ``fcntl(fd, F_GETFD)``. If +the kernel ignores ``O_CLOEXEC`` or ``SOCK_CLOEXEC`` flag, a call to +``fcntl(fd, F_SETFD, flags)`` is required to set close-on-exec flag. -Note: OpenBSD older 5.2 does not close the file descriptor with close-on-exec -flag set if ``fork()`` is used before ``exec()``, but it works correctly if -``exec()`` is called without ``fork()``. +.. note:: + OpenBSD older 5.2 does not close the file descriptor with + close-on-exec flag set if ``fork()`` is used before ``exec()``, but + it works correctly if ``exec()`` is called without ``fork()``. Scope @@ -100,10 +108,11 @@ ``fork()``. The close-on-exec flag only closes file descriptors after ``exec()``, and so after ``fork()`` + ``exec()``. -This PEP only change the close-on-exec flag of file descriptors created by the -Python standard library, or by modules using the standard library. Third party -modules not using the standard library should be modified to conform to this -PEP. The new ``os.set_cloexec()`` function can be used for example. +This PEP only change the close-on-exec flag of file descriptors +created by the Python standard library, or by modules using the +standard library. Third party modules not using the standard library +should be modified to conform to this PEP. The new +``os.set_cloexec()`` function can be used for example. Impacted functions: @@ -144,7 +153,8 @@ * ``open()``: ``os.fdopen()`` is indirectly modified * ``os.dup()``, ``os.dup2()`` * ``os.pipe()`` - * ``socket.socket()``, ``socket.socketpair()`` ``socket.socket.accept()`` + * ``socket.socket()``, ``socket.socketpair()``, + ``socket.socket.accept()`` * Maybe also: ``os.open()``, ``os.openpty()`` * TODO: @@ -152,31 +162,33 @@ * ``select.poll()`` * ``select.epoll()`` * ``select.kqueue()`` - * ``socket.socket.recvmsg()``: use ``MSG_CMSG_CLOEXEC``, or ``os.set_cloexec()`` + * ``socket.socket.recvmsg()``: use ``MSG_CMSG_CLOEXEC``, + or ``os.set_cloexec()`` -The default value of the ``cloexec`` argument is ``False`` to keep the backward -compatibility. +The default value of the ``cloexec`` argument is ``False`` to keep the +backward compatibility. -The close-on-exec flag will not be set on file descriptors 0 (stdin), 1 -(stdout) and 2 (stderr), because these files are expected to be inherited. It -would still be possible to set close-on-exec flag explicitly using -``os.set_cloexec()``. +The close-on-exec flag will not be set on file descriptors 0 (stdin), +1 (stdout) and 2 (stderr), because these files are expected to be +inherited. It would still be possible to set close-on-exec flag +explicitly using ``os.set_cloexec()``. Drawbacks: - * Many functions of the Python standard library creating file descriptors are - cannot be changed by this proposal, because adding a ``cloexec`` optional - argument would be surprising and too many functions would need it. For - example, ``os.urandom()`` uses a temporary file on UNIX, but it calls a - function of Windows API on Windows. Adding a ``cloexec`` argument to - ``os.urandom()`` would not make sense. See `Always set close-on-exec flag`_ - for an incomplete list of functions creating file descriptors. - * Checking if a module creates file descriptors is difficult. For example, - ``os.urandom()`` creates a file descriptor on UNIX to read ``/dev/urandom`` - (and closes it at exit), whereas it is implemented using a function call on - Windows. It is not possible to control close-on-exec flag of the file - descriptor used by ``os.urandom()``, because ``os.urandom()`` API does not - allow it. + * Many functions of the Python standard library creating file + descriptors are cannot be changed by this proposal, because adding + a ``cloexec`` optional argument would be surprising and too many + functions would need it. For example, ``os.urandom()`` uses a + temporary file on UNIX, but it calls a function of Windows API on + Windows. Adding a ``cloexec`` argument to ``os.urandom()`` would + not make sense. See `Always set close-on-exec flag`_ for an + incomplete list of functions creating file descriptors. + * Checking if a module creates file descriptors is difficult. For + example, ``os.urandom()`` creates a file descriptor on UNIX to read + ``/dev/urandom`` (and closes it at exit), whereas it is implemented + using a function call on Windows. It is not possible to control + close-on-exec flag of the file descriptor used by ``os.urandom()``, + because ``os.urandom()`` API does not allow it. Alternatives @@ -185,18 +197,20 @@ Always set close-on-exec flag ----------------------------- -Always set close-on-exec flag on new file descriptors created by Python. This -alternative just changes the default value of the new ``cloexec`` argument. +Always set close-on-exec flag on new file descriptors created by +Python. This alternative just changes the default value of the new +``cloexec`` argument. -If a file must be inherited by child processes, ``cloexec=False`` argument can -be used. +If a file must be inherited by child processes, ``cloexec=False`` +argument can be used. -``subprocess.Popen`` constructor has an ``pass_fds`` argument to specify which -file descriptors must be inherited. The close-on-exec flag of these file -descriptors must be changed with ``os.set_cloexec()``. +``subprocess.Popen`` constructor has an ``pass_fds`` argument to +specify which file descriptors must be inherited. The close-on-exec +flag of these file descriptors must be changed with +``os.set_cloexec()``. -Example of functions creating file descriptors which will be modified to -set close-on-exec flag: +Example of functions creating file descriptors which will be modified +to set close-on-exec flag: * ``os.urandom()`` (on UNIX) * ``curses.window.getwin()``, ``curses.window.putwin()`` @@ -219,83 +233,89 @@ Advantages of setting close-on-exec flag by default: * There are far more programs that are bitten by FD inheritance upon - exec (see `Inherited file descriptors issues`_ and `Security`_) than - programs relying on it - (see `Applications using inherance of file descriptors`_). + exec (see `Inherited file descriptors issues`_ and `Security`_) + than programs relying on it (see `Applications using inherance of + file descriptors`_). Drawbacks of setting close-on-exec flag by default: - * The os module is written as a thin wrapper to system calls (to functions of - the C standard library). If atomic flags to set close-on-exec flag are not - supported (see `Appendix: Operating system support`_), a single Python - function call may call 2 or 3 system calls (see `Performances`_ section). - * Extra system calls, if any, may slow down Python: see `Performances`_. - * It violates the principle of least surprise. Developers using the os module - may expect that Python respects the POSIX standard and so that close-on-exec - flag is not set by default. + * The os module is written as a thin wrapper to system calls (to + functions of the C standard library). If atomic flags to set + close-on-exec flag are not supported (see `Appendix: Operating + system support`_), a single Python function call may call 2 or 3 + system calls (see `Performances`_ section). + * Extra system calls, if any, may slow down Python: see + `Performances`_. + * It violates the principle of least surprise. Developers using the + os module may expect that Python respects the POSIX standard and so + that close-on-exec flag is not set by default. Backward compatibility: only a few programs rely on inherance of file -descriptors, and they only pass a few file descriptors, usually just one. -These programs will fail immediatly with ``EBADF`` error, and it will be simple -to fix them: add ``cloexec=False`` argument or use +descriptors, and they only pass a few file descriptors, usually just +one. These programs will fail immediatly with ``EBADF`` error, and it +will be simple to fix them: add ``cloexec=False`` argument or use ``os.set_cloexec(fd, False)``. -The ``subprocess`` module will be changed anyway to unset close-on-exec flag on -file descriptors listed in the ``pass_fds`` argument of Popen constructor. So -it possible that these programs will not need any fix if they use the -``subprocess`` module. +The ``subprocess`` module will be changed anyway to unset +close-on-exec flag on file descriptors listed in the ``pass_fds`` +argument of Popen constructor. So it possible that these programs will +not need any fix if they use the ``subprocess`` module. Add a function to set close-on-exec flag by default --------------------------------------------------- -An alternative is to add also a function to change globally the default -behaviour. It would be possible to set close-on-exec flag for the whole -application including all modules and the Python standard library. This -alternative is based on the `Proposal`_ and adds extra changes. +An alternative is to add also a function to change globally the +default behaviour. It would be possible to set close-on-exec flag for +the whole application including all modules and the Python standard +library. This alternative is based on the `Proposal`_ and adds extra +changes. Add new functions: * ``sys.getdefaultcloexec() -> bool``: get the default value of the close-on-exec flag for new file descriptor - * ``sys.setdefaultcloexec(cloexec: bool)``: enable or disable close-on-exec - flag, the state of the flag can be overriden in each function creating a - file descriptor + * ``sys.setdefaultcloexec(cloexec: bool)``: enable or disable + close-on-exec flag, the state of the flag can be overriden in each + function creating a file descriptor -The major change is that the default value of the ``cloexec`` argument is -``sys.getdefaultcloexec()``, instead of ``False``. +The major change is that the default value of the ``cloexec`` argument +is ``sys.getdefaultcloexec()``, instead of ``False``. -When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by default, -we have the same drawbacks than `Always set close-on-exec +When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by +default, we have the same drawbacks than `Always set close-on-exec flag`_ alternative. There are additionnal drawbacks of having two behaviours depending on ``sys.getdefaultcloexec()`` value: - * It is not more possible to know if the close-on-exec flag will be set or not - just by reading the source code. + * It is not more possible to know if the close-on-exec flag will be + set or not just by reading the source code. Close file descriptors after fork --------------------------------- -This PEP does not fix issues with applications using ``fork()`` without -``exec()``. Python needs a generic process to register callbacks which -would be called after a fork, see `Add an 'afterfork' module`_. Such -registry could be used to close file descriptors just after a ``fork()``. +This PEP does not fix issues with applications using ``fork()`` +without ``exec()``. Python needs a generic process to register +callbacks which would be called after a fork, see `Add an 'afterfork' +module`_. Such registry could be used to close file descriptors just +after a ``fork()``. Drawbacks: - * This alternative does not solve the problem for programs using ``exec()`` - without ``fork()``. - * A third party module may call directly the C function ``fork()`` which will - not call "atfork" callbacks. - * All functions creating file descriptors must be changed to register a - callback and then unregister their callback when the file is closed. Or a - list of *all* open file descriptors must be maintained. - * The operating system is a better place than Python to close automatically - file descriptors. For example, it is not easy to avoid a race condition - between closing the file and unregistering the callback closing the file. + * This alternative does not solve the problem for programs using + ``exec()`` without ``fork()``. + * A third party module may call directly the C function ``fork()`` + which will not call "atfork" callbacks. + * All functions creating file descriptors must be changed to register + a callback and then unregister their callback when the file is + closed. Or a list of *all* open file descriptors must be + maintained. + * The operating system is a better place than Python to close + automatically file descriptors. For example, it is not easy to + avoid a race condition between closing the file and unregistering + the callback closing the file. open(): add "e" flag to mode @@ -303,41 +323,44 @@ A new "e" mode would set close-on-exec flag (best-effort). -This alternative only solves the problem for ``open()``. socket.socket() and -os.pipe() do not have a ``mode`` argument for example. +This alternative only solves the problem for ``open()``. +socket.socket() and os.pipe() do not have a ``mode`` argument for +example. -Since its version 2.7, the GNU libc supports ``"e"`` flag for ``fopen()``. It -uses ``O_CLOEXEC`` if available, or use ``fcntl(fd, F_SETFD, FD_CLOEXEC)``. -With Visual Studio, fopen() accepts a "N" flag which uses ``O_NOINHERIT``. +Since its version 2.7, the GNU libc supports ``"e"`` flag for +``fopen()``. It uses ``O_CLOEXEC`` if available, or use ``fcntl(fd, +F_SETFD, FD_CLOEXEC)``. With Visual Studio, fopen() accepts a "N" +flag which uses ``O_NOINHERIT``. Applications using inherance of file descriptors ================================================ -Most developers don't know that file descriptors are inherited by default. Most -programs do not rely on inherance of file descriptors. For example, -``subprocess.Popen`` was changed in Python 3.2 to close all file descriptors -greater than 2 in the child process by default. No user complained about this -behavior change. +Most developers don't know that file descriptors are inherited by +default. Most programs do not rely on inherance of file descriptors. +For example, ``subprocess.Popen`` was changed in Python 3.2 to close +all file descriptors greater than 2 in the child process by default. +No user complained about this behavior change. -Network servers using fork may want to pass the client socket to the child -process. For example, on UNIX a CGI server pass the socket client through file -descriptors 0 (stdin) and 1 (stdout) using ``dup2()``. This specific case is -not impacted by this PEP because the close-on-exec flag is never set on file -descriptors smaller than 3. +Network servers using fork may want to pass the client socket to the +child process. For example, on UNIX a CGI server pass the socket +client through file descriptors 0 (stdin) and 1 (stdout) using +``dup2()``. This specific case is not impacted by this PEP because the +close-on-exec flag is never set on file descriptors smaller than 3. -To access a restricted resource like creating a socket listening on a TCP port -lower than 1024 or reading a file containing sensitive data like passwords, a -common practice is: start as the root user, create a file descriptor, create -a child process, pass the file descriptor to the child process and exit. -Security is very important in such use case: leaking another file descriptor -would be a critical security vulnerability (see `Security`_). The root process -may not exit but monitors the child process instead, and restarts a new child -process and pass the same file descriptor if the previous child process +To access a restricted resource like creating a socket listening on a +TCP port lower than 1024 or reading a file containing sensitive data +like passwords, a common practice is: start as the root user, create a +file descriptor, create a child process, pass the file descriptor to +the child process and exit. Security is very important in such use +case: leaking another file descriptor would be a critical security +vulnerability (see `Security`_). The root process may not exit but +monitors the child process instead, and restarts a new child process +and pass the same file descriptor if the previous child process crashed. -Example of programs taking file descriptors from the parent process using a -command line option: +Example of programs taking file descriptors from the parent process +using a command line option: * gpg: ``--status-fd ``, ``--logger-fd ``, etc. * openssl: ``-pass fd:`` @@ -345,22 +368,23 @@ * valgrind: ``--log-fd=``, ``--input-fd=``, etc. * xterm: ``-S `` -On Linux, it is possible to use ``"/dev/fd/"`` filename to pass a file -descriptor to a program expecting a filename. +On Linux, it is possible to use ``"/dev/fd/"`` filename to pass a +file descriptor to a program expecting a filename. Performances ============ -Setting close-on-exec flag may require additional system calls for each -creation of new file descriptors. The number of additional system calls -depends on the method used to set the flag: +Setting close-on-exec flag may require additional system calls for +each creation of new file descriptors. The number of additional system +calls depends on the method used to set the flag: * ``O_NOINHERIT``: no additionnal system call - * ``O_CLOEXEC``: one addition system call, but only at the creation of the - first file descriptor, to check if the flag is supported. If no, Python has - to fallback to the next method. - * ``ioctl(fd, FIOCLEX)``: one addition system call per file descriptor + * ``O_CLOEXEC``: one addition system call, but only at the creation + of the first file descriptor, to check if the flag is supported. If + no, Python has to fallback to the next method. + * ``ioctl(fd, FIOCLEX)``: one addition system call per file + descriptor * ``fcntl(fd, F_SETFD, flags)``: two addition system calls per file descriptor, one to get old flags and one to set new flags @@ -377,7 +401,8 @@ if os.name == 'nt': def set_cloexec(fd, cloexec=True): - SetHandleInformation(fd, HANDLE_FLAG_INHERIT, int(cloexec)) + SetHandleInformation(fd, HANDLE_FLAG_INHERIT, + int(cloexec)) else: fnctl = None ioctl = None @@ -404,14 +429,22 @@ fcntl.fcntl(fd, fcntl.F_SETFD, flags) else: def set_cloexec(fd, cloexec=True): - raise NotImplementedError("close-on-exec flag is not supported on your platform") + raise NotImplementedError( + "close-on-exec flag is not supported " + "on your platform") -ioctl is preferred over fcntl because it requires only one syscall, instead of -two syscalls for fcntl. +ioctl is preferred over fcntl because it requires only one syscall, +instead of two syscalls for fcntl. -Note: ``fcntl(fd, F_SETFD, flags)`` only supports one flag (``FD_CLOEXEC``), so -it would be possible to avoid ``fcntl(fd, F_GETFD)``. But it may drop other -flags in the future, and so it is safer to keep the two functions calls. +.. note:: + ``fcntl(fd, F_SETFD, flags)`` only supports one flag + (``FD_CLOEXEC``), so it would be possible to avoid ``fcntl(fd, + F_GETFD)``. But it may drop other flags in the future, and so it is + safer to keep the two functions calls. + +.. note:: + ``fopen()`` function of the GNU libc ignores the error if + ``fcntl(fd, F_SETFD, flags)`` failed. open() ------ @@ -461,8 +494,8 @@ Backward compatibility ====================== -There is no backward incompatible change. The default behaviour is unchanged: -the close-on-exec flag is not set by default. +There is no backward incompatible change. The default behaviour is +unchanged: the close-on-exec flag is not set by default. Appendix: Operating system support @@ -471,16 +504,17 @@ Windows ------- -Windows has an ``O_NOINHERIT`` flag: "Do not inherit in child processes". +Windows has an ``O_NOINHERIT`` flag: "Do not inherit in child +processes". For example, it is supported by ``open()`` and ``_pipe()``. The value of the flag can be modified using: ``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)``. -``CreateProcess()`` has an ``bInheritHandles`` argument: if it is FALSE, the -handles are not inherited. It is used by ``subprocess.Popen`` with -``close_fds`` option. +``CreateProcess()`` has an ``bInheritHandles`` argument: if it is +FALSE, the handles are not inherited. It is used by +``subprocess.Popen`` with ``close_fds`` option. fcntl ----- @@ -490,8 +524,8 @@ * ``fcntl(fd, F_GETFD)`` * ``fcntl(fd, F_SETFD, flags | FD_CLOEXEC)`` -Availability: AIX, Digital UNIX, FreeBSD, HP-UX, IRIX, Linux, Mac OS X, -OpenBSD, Solaris, SunOS, Unicos. +Availability: AIX, Digital UNIX, FreeBSD, HP-UX, IRIX, Linux, Mac OS +X, OpenBSD, Solaris, SunOS, Unicos. ioctl ----- @@ -509,20 +543,23 @@ New flags: - * ``O_CLOEXEC``: available on Linux (2.6.23+), FreeBSD (8.3+), OpenBSD 5.0, - will be part of the next NetBSD release (6.1?). This flag is part of - POSIX.1-2008. + * ``O_CLOEXEC``: available on Linux (2.6.23+), FreeBSD (8.3+), + OpenBSD 5.0, QNX, BeOS, next NetBSD release (6.1?). This flag is + part of POSIX.1-2008. * ``socket()``: ``SOCK_CLOEXEC`` flag, available on Linux 2.6.27+, OpenBSD 5.2, NetBSD 6.0. * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24+, - OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0. This flag is part of POSIX.1-2008. - * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23+, NetBSD 6.0. + OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0. This flag is part of + POSIX.1-2008. + * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23+, + NetBSD 6.0. -On Linux older than 2.6.23, ``O_CLOEXEC`` flag is simply ignored. So we have to -check that the flag is supported by calling ``fcntl()``. If it does not work, -we have to set the flag using ``fcntl()``. +On Linux older than 2.6.23, ``O_CLOEXEC`` flag is simply ignored. So +we have to check that the flag is supported by calling ``fcntl()``. If +it does not work, we have to set the flag using ``fcntl()``. -XXX what is the behaviour on Linux older than 2.6.27 with SOCK_CLOEXEC? XXX +XXX what is the behaviour on Linux older than 2.6.27 +XXX with SOCK_CLOEXEC? XXX New functions: @@ -530,8 +567,8 @@ * ``pipe2()``: available on Linux 2.6.27+ (and glibc 2.9) * ``accept4()``: available on Linux 2.6.28+ (and glibc 2.10) -If ``accept4()`` is called on Linux older than 2.6.28, ``accept4()`` returns -``-1`` (fail) and errno is set to ``ENOSYS``. +If ``accept4()`` is called on Linux older than 2.6.28, ``accept4()`` +returns ``-1`` (fail) and errno is set to ``ENOSYS``. Links @@ -540,7 +577,8 @@ Links: * `Secure File Descriptor Handling - `_ (Ulrich Drepper, 2008) + `_ (Ulrich Drepper, + 2008) * `win32_support.py of the Tornado project `_: emulate fcntl(fd, F_SETFD, FD_CLOEXEC) using @@ -568,14 +606,17 @@ * `O_CLOEXEC flag missing for Kernel::open `_: `commit reverted - `_ later + `_ + later Footnotes ========= -.. [#subprocess_close] On UNIX since Python 3.2, subprocess.Popen() closes all file descriptors by - default: ``close_fds=True``. It closes file descriptors in range 3 inclusive - to ``local_max_fd`` exclusive, where ``local_max_fd`` is ``fcntl(0, - F_MAXFD)`` on NetBSD, or ``sysconf(_SC_OPEN_MAX)`` otherwise. If the error - pipe has a descriptor smaller than 3, ``ValueError`` is raised. +.. [#subprocess_close] On UNIX since Python 3.2, subprocess.Popen() + closes all file descriptors by default: ``close_fds=True``. It + closes file descriptors in range 3 inclusive to ``local_max_fd`` + exclusive, where ``local_max_fd`` is ``fcntl(0, F_MAXFD)`` on + NetBSD, or ``sysconf(_SC_OPEN_MAX)`` otherwise. If the error pipe + has a descriptor smaller than 3, ``ValueError`` is raised. + -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 01:36:38 2013 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Jan 2013 01:36:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_finish_to_format_t?= =?utf-8?q?o_70_columns?= Message-ID: <3YkJlp2HFkzS8Z@mail.python.org> http://hg.python.org/peps/rev/a6879f3056ad changeset: 4669:a6879f3056ad user: Victor Stinner date: Sun Jan 13 01:34:36 2013 +0100 summary: PEP 433: finish to format to 70 columns files: pep-0433.txt | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -132,21 +132,22 @@ XXX descriptors of the constructor the ``pass_fds`` argument? XXX .. note:: - See `Close file descriptors after fork`_ for a possible solution for - ``fork()`` without ``exec()``. + See `Close file descriptors after fork`_ for a possible solution + for ``fork()`` without ``exec()``. Proposal ======== -This PEP proposes to add a new optional argument ``cloexec`` on functions -creating file descriptors in the Python standard library. If the argument is -``True``, the close-on-exec flag will be set on the new file descriptor. +This PEP proposes to add a new optional argument ``cloexec`` on +functions creating file descriptors in the Python standard library. If +the argument is ``True``, the close-on-exec flag will be set on the +new file descriptor. Add a new function: - * ``os.set_cloexec(fd: int, cloexec: bool)``: set or unset the close-on-exec - flag of a file descriptor + * ``os.set_cloexec(fd: int, cloexec: bool)``: set or unset the + close-on-exec flag of a file descriptor Add a new optional ``cloexec`` argument to: -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 03:23:09 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 13 Jan 2013 03:23:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogbWFrZSBkZXF1ZV9j?= =?utf-8?q?lear_void=2C_since_it=27s_infallible?= Message-ID: <3YkM6j4wTLzSG6@mail.python.org> http://hg.python.org/cpython/rev/623a7de80432 changeset: 81470:623a7de80432 branch: 3.3 parent: 81467:c276fbd95182 user: Benjamin Peterson date: Sat Jan 12 21:22:18 2013 -0500 summary: make deque_clear void, since it's infallible files: Modules/_collectionsmodule.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -588,7 +588,7 @@ PyDoc_STRVAR(remove_doc, "D.remove(value) -- remove first occurrence of value."); -static int +static void deque_clear(dequeobject *deque) { PyObject *item; @@ -601,7 +601,6 @@ assert(deque->leftblock == deque->rightblock && deque->leftindex - 1 == deque->rightindex && deque->len == 0); - return 0; } static PyObject * @@ -704,10 +703,7 @@ static PyObject * deque_clearmethod(dequeobject *deque) { - int rv; - - rv = deque_clear(deque); - assert (rv != -1); + deque_clear(deque); Py_RETURN_NONE; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 03:23:11 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 13 Jan 2013 03:23:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3YkM6l0KQ3zSGL@mail.python.org> http://hg.python.org/cpython/rev/016953aabc47 changeset: 81471:016953aabc47 parent: 81469:72ddb250f058 parent: 81470:623a7de80432 user: Benjamin Peterson date: Sat Jan 12 21:22:33 2013 -0500 summary: merge 3.3 files: Modules/_collectionsmodule.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -632,7 +632,7 @@ PyDoc_STRVAR(remove_doc, "D.remove(value) -- remove first occurrence of value."); -static int +static void deque_clear(dequeobject *deque) { PyObject *item; @@ -645,7 +645,6 @@ assert(deque->leftblock == deque->rightblock && deque->leftindex - 1 == deque->rightindex && deque->len == 0); - return 0; } static PyObject * @@ -748,10 +747,7 @@ static PyObject * deque_clearmethod(dequeobject *deque) { - int rv; - - rv = deque_clear(deque); - assert (rv != -1); + deque_clear(deque); Py_RETURN_NONE; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 03:23:12 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 13 Jan 2013 03:23:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogbWFrZSBkZXF1ZV9j?= =?utf-8?q?lear_void=2C_since_it=27s_infallible?= Message-ID: <3YkM6m2sr4zSFw@mail.python.org> http://hg.python.org/cpython/rev/ad585b439d97 changeset: 81472:ad585b439d97 branch: 2.7 parent: 81458:e651d96e6b07 user: Benjamin Peterson date: Sat Jan 12 21:22:18 2013 -0500 summary: make deque_clear void, since it's infallible files: Modules/_collectionsmodule.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -632,7 +632,7 @@ PyDoc_STRVAR(remove_doc, "D.remove(value) -- remove first occurrence of value."); -static int +static void deque_clear(dequeobject *deque) { PyObject *item; @@ -645,7 +645,6 @@ assert(deque->leftblock == deque->rightblock && deque->leftindex - 1 == deque->rightindex && deque->len == 0); - return 0; } static PyObject * @@ -748,10 +747,7 @@ static PyObject * deque_clearmethod(dequeobject *deque) { - int rv; - - rv = deque_clear(deque); - assert (rv != -1); + deque_clear(deque); Py_RETURN_NONE; } -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Sun Jan 13 05:55:53 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 13 Jan 2013 05:55:53 +0100 Subject: [Python-checkins] Daily reference leaks (016953aabc47): sum=6 Message-ID: results for 016953aabc47 on branch "default" -------------------------------------------- test_dbm leaked [0, 2, 0] references, sum=2 test_dbm leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflog81Sac8', '-x'] From python-checkins at python.org Sun Jan 13 07:35:15 2013 From: python-checkins at python.org (nick.coghlan) Date: Sun, 13 Jan 2013 07:35:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_432=3A_Flesh_out_a_design?= =?utf-8?q?_for_main_execution?= Message-ID: <3YkSjb01nPzS5y@mail.python.org> http://hg.python.org/peps/rev/ecbd58cf5115 changeset: 4670:ecbd58cf5115 user: Nick Coghlan date: Sun Jan 13 16:35:06 2013 +1000 summary: PEP 432: Flesh out a design for main execution files: pep-0432.txt | 231 +++++++++++++++++++++++++++++--------- 1 files changed, 175 insertions(+), 56 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -43,9 +43,11 @@ * Initializing - interpreter partially available * Initialized - interpreter available, __main__ related metadata incomplete -* Main Execution - __main__ related metadata populated, bytecode - executing in the __main__ module namespace (embedding applications - may choose not to use this phase) +* Main Preparation - __main__ related metadata populated +* Main Execution - bytecode executing in the __main__ module namespace + +(Embedding applications may choose not to use the Main Preparation and +Execution phases) As a concrete use case to help guide any design changes, and to solve a known problem where the appropriate defaults for system utilities differ from those @@ -78,21 +80,21 @@ (such as configuring the Unicode settings for OS interfaces in Python 3 as well as bootstrapping a pure Python implementation of the import system). -Much of this complexity is accessible only through the ``Py_Main`` and -``Py_Initialize`` APIs, offering embedding applications little opportunity -for customisation. This creeping complexity also makes life difficult for -maintainers, as much of the configuration needs to take place prior to the -``Py_Initialize`` call, meaning much of the Python C API cannot be used -safely. +Much of this complexity is formally accessible only through the ``Py_Main`` +and ``Py_Initialize`` APIs, offering embedding applications little +opportunity for customisation. This creeping complexity also makes life +difficult for maintainers, as much of the configuration needs to take +place prior to the ``Py_Initialize`` call, meaning much of the Python C +API cannot be used safely. A number of proposals are on the table for even *more* sophisticated startup behaviour, such as an isolated mode equivalent to that described in this PEP as a "system Python" [6_], better control over ``sys.path`` initialization (easily adding additional directories on the command line in a cross-platform fashion [7_], as well as controlling the configuration of -``sys.path[0]`` [8_]), easier configuration of utilities like coverage tracing -when launching Python subprocesses [9_], and easier control of the encoding -used for the standard IO streams when embedding CPython in a larger +``sys.path[0]`` [8_]), easier configuration of utilities like coverage +tracing when launching Python subprocesses [9_], and easier control of the +encoding used for the standard IO streams when embedding CPython in a larger application [10_]. Rather than attempting to bolt such behaviour onto an already complicated @@ -118,8 +120,8 @@ By moving to an explicitly multi-phase startup sequence, developers should only need to understand which features are not available in the core -bootstrapping state, as the vast majority of the configuration process -will now take place in that state. +bootstrapping phase, as the vast majority of the configuration process +will now take place during that phase. By basing the new design on a combination of C structures and Python data types, it should also be easier to modify the system in the @@ -504,14 +506,13 @@ Interpreter Initialization Phases --------------------------------- -Four distinct phases are proposed: +Five distinct phases are proposed: * Pre-Initialization: * no interpreter is available. * ``Py_IsInitializing()`` returns ``0`` * ``Py_IsInitialized()`` returns ``0`` - * ``Py_IsRunningMain()`` returns ``0`` * The embedding application determines the settings required to create the main interpreter and moves to the next phase by calling ``Py_BeginInitialization``. @@ -521,7 +522,6 @@ * the main interpreter is available, but only partially configured. * ``Py_IsInitializing()`` returns ``1`` * ``Py_IsInitialized()`` returns ``0`` - * ``Py_RunningMain()`` returns ``0`` * The embedding application determines and applies the settings required to complete the initialization process by calling ``Py_ReadConfiguration`` and ``Py_EndInitialization``. @@ -529,26 +529,28 @@ * Initialized: * the main interpreter is available and fully operational, but - ``__main__`` related metadata is incomplete and the site module may - not have been imported. + ``__main__`` related metadata is incomplete * ``Py_IsInitializing()`` returns ``0`` * ``Py_IsInitialized()`` returns ``1`` - * ``Py_IsRunningMain()`` returns ``0`` * Optionally, the embedding application may identify and begin executing code in the ``__main__`` module namespace by calling - ``Py_RunPathAsMain``, ``Py_RunModuleAsMain`` or ``Py_RunStreamAsMain``. + ``PyRun_PrepareMain`` and ``PyRun_ExecMain``. + +* Main Preparation: + + * subphase of Initialized (not separately identified at runtime) + * fully populates ``__main__`` related metadata + * may execute code in ``__main__`` namespace (e.g. ``PYTHONSTARTUP``) * Main Execution: - * bytecode is being executed in the ``__main__`` namespace - * ``Py_IsInitializing()`` returns ``0`` - * ``Py_IsInitialized()`` returns ``1`` - * ``Py_IsRunningMain()`` returns ``1`` + * subphase of Initialized (not separately identified at runtime) + * user supplied bytecode is being executed in the ``__main__`` namespace -As indicated by the phase reporting functions, main module execution is -an optional subphase of Initialized rather than a completely distinct phase. +As noted above, main module preparation and execution are optional subphases +of Initialized rather than completely distinct phases. -All 4 phases will be used by the standard CPython interpreter and the +All listed phases will be used by the standard CPython interpreter and the proposed System Python interpreter. Other embedding applications may choose to skip the step of executing code in the ``__main__`` namespace. @@ -817,15 +819,9 @@ /* Filesystem access */ PyUnicodeObject *fs_encoding; - /* Interactive interpreter */ - int stdin_is_interactive; /* Force interactive behaviour */ - int inspect_main; /* -i switch, PYTHONINSPECT */ - PyUnicodeObject *startup_file; /* PYTHONSTARTUP */ - /* Debugging output */ int debug_parser; /* -d switch, PYTHONDEBUG */ int verbosity; /* -v switch */ - int suppress_banner; /* -q switch */ /* Code generation */ int bytes_warnings; /* -b switch */ @@ -833,6 +829,32 @@ /* Signal handling */ int install_sig_handlers; + + /* Implicit execution */ + PyUnicodeObject *startup_file; /* PYTHONSTARTUP */ + + /* Main module + * + * If prepare_main is set, at most one of the main_* settings should + * be set before calling PyRun_PrepareMain (Py_ReadConfiguration will + * set one of them based on the command line arguments if prepare_main + * is non-zero when that API is called). + int prepare_main; + PyUnicodeObject *main_source; /* -c switch */ + PyUnicodeObject *main_path; /* filesystem path */ + PyUnicodeObject *main_module; /* -m switch */ + PyCodeObject *main_code; /* Run directly from a code object */ + PyObject *main_stream; /* Run from stream */ + int run_implicit_code; /* Run implicit code during prep */ + + /* Interactive main + * + * Note: Settings related to interactive mode are very much in flux. + */ + PyObject *prompt_stream; /* Output interactive prompt */ + int show_banner; /* -q switch (inverted) */ + int inspect_main; /* -i switch, PYTHONINSPECT */ + } Py_Config; @@ -844,17 +866,19 @@ #define _Py_ImportConfig_INIT -1, -1, NULL #define _Py_StreamConfig_INIT -1, NULL, NULL, NULL, NULL, NULL, NULL #define _Py_FilesystemConfig_INIT NULL - #define _Py_InteractiveConfig_INIT -1, -1, NULL #define _Py_DebuggingConfig_INIT -1, -1, -1 #define _Py_CodeGenConfig_INIT -1, -1 #define _Py_SignalConfig_INIT -1 + #define _Py_ImplicitConfig_INIT NULL + #define _Py_MainConfig_INIT -1, NULL, NULL, NULL, NULL, NULL, -1 + #define _Py_InteractiveConfig_INIT NULL, -1, -1 #define Py_Config_INIT {_Py_ArgConfig_INIT, _Py_LocationConfig_INIT, _Py_SiteConfig_INIT, _Py_ImportConfig_INIT, _Py_StreamConfig_INIT, _Py_FilesystemConfig_INIT, - _Py_InteractiveConfig_INIT, _Py_DebuggingConfig_INIT, _Py_CodeGenConfig_INIT, - _Py_SignalConfig_INIT} + _Py_SignalConfig_INIT, _Py_ImplicitConfig_INIT, + _Py_MainConfig_INIT, _Py_InteractiveConfig_INIT} @@ -893,6 +917,11 @@ * it will be the same as ``sys.path[0]`` rather than the location of the ``__main__`` module when executing a valid ``sys.path`` entry (typically a zipfile or directory) + * otherwise, it will be accurate: + + * the script name if running an ordinary script + * ``-c`` if executing a supplied string + * ``-`` or the empty string if running from stdin * the metadata in the ``__main__`` module will still indicate it is a builtin module @@ -904,21 +933,103 @@ ``import site`` is later explicitly executed in the process. +Preparing the main module +------------------------- + +This subphase completes the population of the ``__main__`` module +related metadata, without actually starting execution of the ``__main__`` +module code. + +It is handled by calling the following API:: + + int PyRun_PrepareMain(); + +The actual processing is driven by the main related settings stored in +the interpreter state as part of the configuration struct. + +If ``prepare_main`` is zero, this call does nothing. + +If all of ``main_source``, ``main_path``, ``main_module``, +``main_stream`` and ``main_code`` are NULL, this call does nothing. + +If more than one of ``main_source``, ``main_path``, ``main_module``, +``main_stream`` or ``main_code`` are set, ``RuntimeError`` will be reported. + +If ``main_code`` is already set, then this call does nothing. + +If ``main_stream`` is set, and ``run_implicit_code`` is also set, then +the file identified in ``startup_file`` will be read, compiled and +executed in the ``__main__`` namespace. + +If ``main_source``, ``main_path`` or ``main_module`` are set, then this +call will take whatever steps are needed to populate ``main_code``: + +* For ``main_source``, the supplied string will be compiled and saved to + ``main_code``. + +* For ``main_path``: + * if the supplied path is recognised as a valid ``sys.path`` entry, it + is inserted as ``sys.path[0]``, ``main_module`` is set + to ``__main__`` and processing continues as for ``main_module`` below. + * otherwise, path is read as a CPython bytecode file + * if that fails, it is read as a Python source file and compiled + * in the latter two cases, the code object is saved to ``main_code`` + and ``__main__.__file__`` is set appropriately + +* For ``main_module``: + * any parent package is imported + * the loader for the module is determined + * if the loader indicates the module is a package, add ``.__main__`` to + the end of ``main_module`` and try again (if the final name segment + is already ``.__main__`` then fail immediately) + * once the module source code is located, save the compiled module code + as ``main_code`` and populate the following attributes in ``__main__`` + appropriately: ``__name__``, ``__loader__``, ``__file__``, + ``__cached__``, ``__package__``. + + +(Note: the behaviour described in this section isn't new, it's a write-up +of the current behaviour of the CPython interpreter adjusted for the new +configuration system) + + Executing the main module ------------------------- - +This subphase covers the execution of the actual ``__main__`` module code. -Initial thought is that hiding the various options behind a single API -would make that API too complicated, so 3 separate APIs is more likely:: +It is handled by calling the following API:: - Py_RunPathAsMain - Py_RunModuleAsMain - Py_RunStreamAsMain + int PyRun_ExecMain(); -Query API to indicate that ``sys.argv[0]`` is fully populated:: +The actual processing is driven by the main related settings stored in +the interpreter state as part of the configuration struct. - Py_IsRunningMain() +If both ``main_stream`` and ``main_code`` are NULL, this call does nothing. + +If both ``main_stream`` and ``main_code`` are set, ``RuntimeError`` will +be reported. + +If ``main_stream`` and ``prompt_stream`` are both set, main execution will +be delegated to a new API:: + + int PyRun_InteractiveMain(PyObject *input, PyObject* output); + +If ``main_stream`` is set and ``prompt_stream`` is NULL, main execution will +be delegated to a new API:: + + int PyRun_StreamInMain(PyObject *input); + +If ``main_code`` is set, main execution will be delegated to a new +API:: + + int PyRun_CodeInMain(PyCodeObject *code); + +After execution of main completes, if ``inspect_main`` is set, or +the ``PYTHONINSPECT`` environment variable has been set, then +``PyRun_ExecMain`` will invoke +``PyRun_InteractiveMain(sys.__stdin__, sys.__stdout__)``. + Internal Storage of Configuration Data -------------------------------------- @@ -931,7 +1042,7 @@ For debugging purposes, the configuration settings will be exposed as a ``sys._configuration`` simple namespace (similar to ``sys.flags`` and ``sys.implementation``. Field names will match those in the configuration -structs, exception for ``hash_seed``, which will be deliberately excluded. +structs, except for ``hash_seed``, which will be deliberately excluded. An underscored attribute is chosen deliberately, as these configuration settings are part of the CPython implementation, rather than part of the @@ -941,16 +1052,19 @@ attributes on ``sys.implementation``, as described in PEP 421. These are *snapshots* of the initial configuration settings. They are not -consulted by the interpreter during runtime. +modified by the interpreter during runtime (except as noted above). Stable ABI ---------- -All of the APIs proposed in this PEP are excluded from the stable ABI, as +Most of the APIs proposed in this PEP are excluded from the stable ABI, as embedding a Python interpreter involves a much higher degree of coupling than merely writing an extension. +The only newly exposed API that will be part of the stable ABI is the +``Py_IsInitializing()`` query. + Build time configuration ------------------------ @@ -1038,27 +1152,32 @@ * Error details for Py_ReadConfiguration and Py_EndInitialization (these should become clear as the implementation progresses) -* Is ``Py_IsRunningMain()`` worth keeping? -* Should the answers to ``Py_IsInitialized()`` and ``Py_IsRunningMain()`` be - exposed via the ``sys`` module? -* Is the ``Py_Config`` struct too unwieldy to be practical? Would a Python - dictionary be a better choice? +* Should there be ``Py_PreparingMain()`` and ``Py_RunningMain()`` query APIs? +* Should the answer to ``Py_IsInitialized()`` be exposed via the ``sys`` + module? +* Is initialisation of the ``Py_Config`` struct too unwieldy to be + maintainable? Would a Python dictionary be a better choice, despite + being harder to work with from C code? * Would it be better to manage the flag variables in ``Py_Config`` as Python integers or as "negative means false, positive means true, zero means not set" so the struct can be initialized with a simple ``memset(&config, 0, sizeof(*config))``, eliminating the need to update both Py_Config and Py_Config_INIT when adding new fields? -* The name of the system Python executable is a bikeshed waiting to be +* The name of the new system Python executable is a bikeshed waiting to be painted. The 3 options considered so far are ``spython``, ``pysystem`` and ``python-minimal``. The PEP text reflects my current preferred choice - i.e. ``pysystem``. + (``pysystem``). Implementation ============== The reference implementation is being developed as a feature branch in my -BitBucket sandbox [2_]. +BitBucket sandbox [2_]. Pull requests to fix the inevitably broken +Windows builds are welcome, but the basic design is still in too much flux +for other pull requests to be feasible just yet. Once the overall design +settles down and it's a matter of migrating individual settings over to +the new design, that level of collaboration should become more practical. As the number of application binaries created by the build process is now four, the reference implementation also creates a new top level "Apps" -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 08:24:18 2013 From: python-checkins at python.org (nick.coghlan) Date: Sun, 13 Jan 2013 08:24:18 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_No_need_for_the_abbreviation?= Message-ID: <3YkTpB5p8CzS5R@mail.python.org> http://hg.python.org/peps/rev/4f996a14d315 changeset: 4671:4f996a14d315 user: Nick Coghlan date: Sun Jan 13 17:24:10 2013 +1000 summary: No need for the abbreviation files: pep-0432.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -828,7 +828,7 @@ int optimize; /* -O switch */ /* Signal handling */ - int install_sig_handlers; + int install_signal_handlers; /* Implicit execution */ PyUnicodeObject *startup_file; /* PYTHONSTARTUP */ -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 11:26:31 2013 From: python-checkins at python.org (georg.brandl) Date: Sun, 13 Jan 2013 11:26:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Closes_=2316949=3A_update_wor?= =?utf-8?q?ding_about_string_exceptions=2E?= Message-ID: <3YkYrR594RzS0n@mail.python.org> http://hg.python.org/peps/rev/bf68a42a43bf changeset: 4672:bf68a42a43bf user: Georg Brandl date: Sun Jan 13 11:27:31 2013 +0100 summary: Closes #16949: update wording about string exceptions. files: pep-0008.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pep-0008.txt b/pep-0008.txt --- a/pep-0008.txt +++ b/pep-0008.txt @@ -763,8 +763,8 @@ - Use class-based exceptions. - String exceptions in new code are forbidden, because this language - feature is being removed in Python 2.6. + String exceptions in new code are forbidden, and this language + feature has been removed in Python 2.6. Modules or packages should define their own domain-specific base exception class, which should be subclassed from the built-in -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 11:27:10 2013 From: python-checkins at python.org (georg.brandl) Date: Sun, 13 Jan 2013 11:27:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Closes_=2316950=3A_update_wor?= =?utf-8?q?ding_about_raise_syntax=2E?= Message-ID: <3YkYsB3HjgzRxn@mail.python.org> http://hg.python.org/peps/rev/89db18c77152 changeset: 4673:89db18c77152 user: Georg Brandl date: Sun Jan 13 11:28:10 2013 +0100 summary: Closes #16950: update wording about raise syntax. files: pep-0008.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0008.txt b/pep-0008.txt --- a/pep-0008.txt +++ b/pep-0008.txt @@ -783,7 +783,7 @@ The paren-using form is preferred because when the exception arguments are long or include string formatting, you don't need to use line continuation characters thanks to the containing - parentheses. The older form will be removed in Python 3. + parentheses. The older form is not legal syntax in Python 3. - When catching exceptions, mention specific exceptions whenever possible instead of using a bare ``except:`` clause. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 14:15:54 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sun, 13 Jan 2013 14:15:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogdGVzdF9hc3luY29y?= =?utf-8?q?e=3A_wait_explicitly_for_a_thread_termination_=28this_dangling_?= =?utf-8?q?thread?= Message-ID: <3Ykdbt4GpFzS7k@mail.python.org> http://hg.python.org/cpython/rev/6e8788353ddf changeset: 81473:6e8788353ddf branch: 2.7 user: Charles-Fran?ois Natali date: Sun Jan 13 13:55:13 2013 +0100 summary: test_asyncore: wait explicitly for a thread termination (this dangling thread could be the cause of a random failure). files: Lib/test/test_asyncore.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -712,6 +712,7 @@ server = TCPServer() t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() + self.addCleanup(t.join) for x in xrange(20): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:15:56 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sun, 13 Jan 2013 14:15:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogdGVzdF9hc3luY29y?= =?utf-8?q?e=3A_wait_explicitly_for_a_thread_termination_=28this_dangling_?= =?utf-8?q?thread?= Message-ID: <3Ykdbw06RyzSD1@mail.python.org> http://hg.python.org/cpython/rev/d55a06f7ccbf changeset: 81474:d55a06f7ccbf branch: 3.2 parent: 81459:20065626c0b5 user: Charles-Fran?ois Natali date: Sun Jan 13 13:56:52 2013 +0100 summary: test_asyncore: wait explicitly for a thread termination (this dangling thread could be the cause of a random failure). files: Lib/test/test_asyncore.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -738,6 +738,7 @@ server = TCPServer() t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() + self.addCleanup(t.join) for x in range(20): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:15:57 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sun, 13 Jan 2013 14:15:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_test=5Fasyncore=3A_wait_explicitly_for_a_thread_termination_?= =?utf-8?q?=28this_dangling_thread?= Message-ID: <3Ykdbx2gR2zSDF@mail.python.org> http://hg.python.org/cpython/rev/0545ecc24b3a changeset: 81475:0545ecc24b3a branch: 3.3 parent: 81470:623a7de80432 parent: 81474:d55a06f7ccbf user: Charles-Fran?ois Natali date: Sun Jan 13 14:08:01 2013 +0100 summary: test_asyncore: wait explicitly for a thread termination (this dangling thread could be the cause of a random failure). files: Lib/test/test_asyncore.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -789,7 +789,7 @@ t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() - + self.addCleanup(t.join) s = socket.socket(self.family, socket.SOCK_STREAM) s.settimeout(.2) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:15:58 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sun, 13 Jan 2013 14:15:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogRml4IHRlc3RfcG9z?= =?utf-8?q?ix_failure_on_NetBSD_buildbots=3A_sched=5Fsetparam=28=29_and?= Message-ID: <3Ykdby5FrnzS9S@mail.python.org> http://hg.python.org/cpython/rev/1719136ca357 changeset: 81476:1719136ca357 branch: 3.3 user: Charles-Fran?ois Natali date: Sun Jan 13 14:10:37 2013 +0100 summary: Fix test_posix failure on NetBSD buildbots: sched_setparam() and sched_setscheduler() can fail with EINVAL if the process scheduling policy is neither SCHED_FIFO nor SCHED_RR. files: Lib/test/test_posix.py | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -930,17 +930,17 @@ self.assertRaises(OSError, posix.sched_getparam, -1) param = posix.sched_getparam(0) self.assertIsInstance(param.sched_priority, int) - try: - posix.sched_setscheduler(0, mine, param) - except OSError as e: - if e.errno != errno.EPERM: - raise - # POSIX states that calling sched_setparam() on a process with a - # scheduling policy other than SCHED_FIFO or SCHED_RR is - # implementation-defined: FreeBSD returns EINVAL. - if not sys.platform.startswith('freebsd'): - posix.sched_setparam(0, param) + # POSIX states that calling sched_setparam() or sched_setscheduler() on + # a process with a scheduling policy other than SCHED_FIFO or SCHED_RR + # is implementation-defined: NetBSD and FreeBSD can return EINVAL. + if not sys.platform.startswith(('freebsd', 'netbsd')): + try: + posix.sched_setscheduler(0, mine, param) + posix.sched_setparam(0, param) + except OSError as e: + if e.errno != errno.EPERM: + raise self.assertRaises(OSError, posix.sched_setparam, -1, param) self.assertRaises(OSError, posix.sched_setscheduler, -1, mine, param) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:16:00 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sun, 13 Jan 2013 14:16:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_test=5Fasyncore=3A_wait_explicitly_for_a_thread_terminat?= =?utf-8?q?ion_=28this_dangling_thread?= Message-ID: <3Ykdc015zWzSGw@mail.python.org> http://hg.python.org/cpython/rev/aa26568e4739 changeset: 81477:aa26568e4739 parent: 81471:016953aabc47 parent: 81476:1719136ca357 user: Charles-Fran?ois Natali date: Sun Jan 13 14:12:35 2013 +0100 summary: test_asyncore: wait explicitly for a thread termination (this dangling thread could be the cause of a random failure). files: Lib/test/test_asyncore.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -789,7 +789,7 @@ t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() - + self.addCleanup(t.join) s = socket.socket(self.family, socket.SOCK_STREAM) s.settimeout(.2) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:16:01 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sun, 13 Jan 2013 14:16:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_test=5Fposix_failure_o?= =?utf-8?q?n_NetBSD_buildbots=3A_sched=5Fsetparam=28=29_and?= Message-ID: <3Ykdc13gSFzSGs@mail.python.org> http://hg.python.org/cpython/rev/3c67bd5abe38 changeset: 81478:3c67bd5abe38 user: Charles-Fran?ois Natali date: Sun Jan 13 14:13:25 2013 +0100 summary: Fix test_posix failure on NetBSD buildbots: sched_setparam() and sched_setscheduler() can fail with EINVAL if the process scheduling policy is neither SCHED_FIFO nor SCHED_RR. files: Lib/test/test_posix.py | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -930,17 +930,17 @@ self.assertRaises(OSError, posix.sched_getparam, -1) param = posix.sched_getparam(0) self.assertIsInstance(param.sched_priority, int) - try: - posix.sched_setscheduler(0, mine, param) - except OSError as e: - if e.errno != errno.EPERM: - raise - # POSIX states that calling sched_setparam() on a process with a - # scheduling policy other than SCHED_FIFO or SCHED_RR is - # implementation-defined: FreeBSD returns EINVAL. - if not sys.platform.startswith('freebsd'): - posix.sched_setparam(0, param) + # POSIX states that calling sched_setparam() or sched_setscheduler() on + # a process with a scheduling policy other than SCHED_FIFO or SCHED_RR + # is implementation-defined: NetBSD and FreeBSD can return EINVAL. + if not sys.platform.startswith(('freebsd', 'netbsd')): + try: + posix.sched_setscheduler(0, mine, param) + posix.sched_setparam(0, param) + except OSError as e: + if e.errno != errno.EPERM: + raise self.assertRaises(OSError, posix.sched_setparam, -1, param) self.assertRaises(OSError, posix.sched_setscheduler, -1, mine, param) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:18:19 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:18:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Clean_trailing?= =?utf-8?q?_whitespace_in_=5Felementtree=2Ec?= Message-ID: <3Ykdfg2FFgzS9R@mail.python.org> http://hg.python.org/cpython/rev/7e072816b197 changeset: 81479:7e072816b197 branch: 3.3 parent: 81470:623a7de80432 user: Eli Bendersky date: Sun Jan 13 05:14:47 2013 -0800 summary: Clean trailing whitespace in _elementtree.c files: Modules/_elementtree.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -310,7 +310,7 @@ /* Helper function for extracting the attrib dictionary from a keywords dict. * This is required by some constructors/functions in this module that can - * either accept attrib as a keyword argument or all attributes splashed + * either accept attrib as a keyword argument or all attributes splashed * directly into *kwds. * If there is no 'attrib' keyword, return an empty dict. */ @@ -1977,7 +1977,7 @@ elementiter_next(ElementIterObject *it) { /* Sub-element iterator. - * + * * A short note on gettext: this function serves both the iter() and * itertext() methods to avoid code duplication. However, there are a few * small differences in the way these iterations work. Namely: @@ -3039,7 +3039,7 @@ } } -static void +static void expat_start_doctype_handler(XMLParserObject *self, const XML_Char *doctype_name, const XML_Char *sysid, @@ -3244,7 +3244,7 @@ self_xp->handle_doctype = PyObject_GetAttrString(target, "doctype"); PyErr_Clear(); - + /* configure parser */ EXPAT(SetUserData)(self_xp->parser, self_xp); EXPAT(SetElementHandler)( -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:18:20 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:18:20 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Clean_trailing_whitespace_in_=5Felementtree=2Ec?= Message-ID: <3Ykdfh58CszSGs@mail.python.org> http://hg.python.org/cpython/rev/0b3ebb344a8a changeset: 81480:0b3ebb344a8a parent: 81471:016953aabc47 parent: 81479:7e072816b197 user: Eli Bendersky date: Sun Jan 13 05:15:52 2013 -0800 summary: Clean trailing whitespace in _elementtree.c files: Modules/_elementtree.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -310,7 +310,7 @@ /* Helper function for extracting the attrib dictionary from a keywords dict. * This is required by some constructors/functions in this module that can - * either accept attrib as a keyword argument or all attributes splashed + * either accept attrib as a keyword argument or all attributes splashed * directly into *kwds. * If there is no 'attrib' keyword, return an empty dict. */ @@ -1977,7 +1977,7 @@ elementiter_next(ElementIterObject *it) { /* Sub-element iterator. - * + * * A short note on gettext: this function serves both the iter() and * itertext() methods to avoid code duplication. However, there are a few * small differences in the way these iterations work. Namely: @@ -3039,7 +3039,7 @@ } } -static void +static void expat_start_doctype_handler(XMLParserObject *self, const XML_Char *doctype_name, const XML_Char *sysid, @@ -3244,7 +3244,7 @@ self_xp->handle_doctype = PyObject_GetAttrString(target, "doctype"); PyErr_Clear(); - + /* configure parser */ EXPAT(SetUserData)(self_xp->parser, self_xp); EXPAT(SetElementHandler)( -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:18:22 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:18:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_merge_heads?= Message-ID: <3Ykdfk0dWNzS9S@mail.python.org> http://hg.python.org/cpython/rev/05cacbd2f545 changeset: 81481:05cacbd2f545 parent: 81480:0b3ebb344a8a parent: 81478:3c67bd5abe38 user: Eli Bendersky date: Sun Jan 13 05:16:36 2013 -0800 summary: merge heads files: Lib/test/test_asyncore.py | 2 +- Lib/test/test_posix.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -789,7 +789,7 @@ t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() - + self.addCleanup(t.join) s = socket.socket(self.family, socket.SOCK_STREAM) s.settimeout(.2) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -930,17 +930,17 @@ self.assertRaises(OSError, posix.sched_getparam, -1) param = posix.sched_getparam(0) self.assertIsInstance(param.sched_priority, int) - try: - posix.sched_setscheduler(0, mine, param) - except OSError as e: - if e.errno != errno.EPERM: - raise - # POSIX states that calling sched_setparam() on a process with a - # scheduling policy other than SCHED_FIFO or SCHED_RR is - # implementation-defined: FreeBSD returns EINVAL. - if not sys.platform.startswith('freebsd'): - posix.sched_setparam(0, param) + # POSIX states that calling sched_setparam() or sched_setscheduler() on + # a process with a scheduling policy other than SCHED_FIFO or SCHED_RR + # is implementation-defined: NetBSD and FreeBSD can return EINVAL. + if not sys.platform.startswith(('freebsd', 'netbsd')): + try: + posix.sched_setscheduler(0, mine, param) + posix.sched_setparam(0, param) + except OSError as e: + if e.errno != errno.EPERM: + raise self.assertRaises(OSError, posix.sched_setparam, -1, param) self.assertRaises(OSError, posix.sched_setscheduler, -1, mine, param) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:18:23 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:18:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_merge_heads?= Message-ID: <3Ykdfl3JK1zSHG@mail.python.org> http://hg.python.org/cpython/rev/9202a716673b changeset: 81482:9202a716673b branch: 3.3 parent: 81479:7e072816b197 parent: 81476:1719136ca357 user: Eli Bendersky date: Sun Jan 13 05:17:19 2013 -0800 summary: merge heads files: Lib/test/test_asyncore.py | 2 +- Lib/test/test_posix.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -789,7 +789,7 @@ t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) t.start() - + self.addCleanup(t.join) s = socket.socket(self.family, socket.SOCK_STREAM) s.settimeout(.2) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -930,17 +930,17 @@ self.assertRaises(OSError, posix.sched_getparam, -1) param = posix.sched_getparam(0) self.assertIsInstance(param.sched_priority, int) - try: - posix.sched_setscheduler(0, mine, param) - except OSError as e: - if e.errno != errno.EPERM: - raise - # POSIX states that calling sched_setparam() on a process with a - # scheduling policy other than SCHED_FIFO or SCHED_RR is - # implementation-defined: FreeBSD returns EINVAL. - if not sys.platform.startswith('freebsd'): - posix.sched_setparam(0, param) + # POSIX states that calling sched_setparam() or sched_setscheduler() on + # a process with a scheduling policy other than SCHED_FIFO or SCHED_RR + # is implementation-defined: NetBSD and FreeBSD can return EINVAL. + if not sys.platform.startswith(('freebsd', 'netbsd')): + try: + posix.sched_setscheduler(0, mine, param) + posix.sched_setparam(0, param) + except OSError as e: + if e.errno != errno.EPERM: + raise self.assertRaises(OSError, posix.sched_setparam, -1, param) self.assertRaises(OSError, posix.sched_setscheduler, -1, mine, param) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:18:25 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:18:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_null_merge?= Message-ID: <3Ykdfn1BtSzSDR@mail.python.org> http://hg.python.org/cpython/rev/3e0739b30370 changeset: 81483:3e0739b30370 parent: 81481:05cacbd2f545 parent: 81482:9202a716673b user: Eli Bendersky date: Sun Jan 13 05:17:52 2013 -0800 summary: null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:26:59 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:26:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2OTIy?= =?utf-8?q?=3A_fixed_findtext=28=29_to_return_empty_Unicode_string_instead?= =?utf-8?q?_of_empty?= Message-ID: <3Ykdrg4G94zP6D@mail.python.org> http://hg.python.org/cpython/rev/849eb27baf1c changeset: 81484:849eb27baf1c branch: 3.2 parent: 81474:d55a06f7ccbf user: Eli Bendersky date: Sun Jan 13 05:22:05 2013 -0800 summary: Issue #16922: fixed findtext() to return empty Unicode string instead of empty bytes object when there's no text. Patch by Serhiy Storchaka. files: Lib/test/test_xml_etree.py | 2 ++ Modules/_elementtree.c | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -352,6 +352,8 @@ 'subtext' >>> ET.ElementTree(elem).findtext("section/tag") 'subtext' + >>> ET.XML('').findtext('empty') + '' >>> summarize_list(elem.findall(".")) ['body'] >>> summarize_list(elem.findall("tag")) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -840,7 +840,7 @@ PyObject* text = element_get_text(item); if (text == Py_None) - return PyBytes_FromString(""); + return PyUnicode_FromString(""); Py_XINCREF(text); return text; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:27:01 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:27:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge_3=2E2_and_revert_changes_since_the_changes_in_3=2E3_are_?= =?utf-8?q?a_bit_different?= Message-ID: <3Ykdrj01QWzSGW@mail.python.org> http://hg.python.org/cpython/rev/d50e259f5482 changeset: 81485:d50e259f5482 branch: 3.3 parent: 81482:9202a716673b parent: 81484:849eb27baf1c user: Eli Bendersky date: Sun Jan 13 05:25:17 2013 -0800 summary: Merge 3.2 and revert changes since the changes in 3.3 are a bit different files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:27:02 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:27:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTIy?= =?utf-8?q?=3A_fixed_findtext=28=29_to_return_empty_Unicode_string_instead?= =?utf-8?q?_of_empty?= Message-ID: <3Ykdrk2cqnzSHp@mail.python.org> http://hg.python.org/cpython/rev/6323e5f1ed81 changeset: 81486:6323e5f1ed81 branch: 3.3 user: Eli Bendersky date: Sun Jan 13 05:26:07 2013 -0800 summary: Issue #16922: fixed findtext() to return empty Unicode string instead of empty bytes object when there's no text. Patch by Serhiy Storchaka. files: Lib/test/test_xml_etree.py | 3 +++ Modules/_elementtree.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1773,6 +1773,9 @@ self.assertIsNone(e.findtext('tog')) self.assertEqual(e.findtext('tog', 'default'), 'default') + # Issue #16922 + self.assertEqual(ET.XML('').findtext('empty'), '') + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1129,7 +1129,7 @@ PyObject* text = element_get_text(item); if (text == Py_None) - return PyBytes_FromString(""); + return PyUnicode_New(0, 0); Py_XINCREF(text); return text; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:27:03 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 14:27:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316922=3A_fixed_findtext=28=29_to_return_empty_U?= =?utf-8?q?nicode_string_instead_of_empty?= Message-ID: <3Ykdrl5NjJzSHl@mail.python.org> http://hg.python.org/cpython/rev/c38423931724 changeset: 81487:c38423931724 parent: 81483:3e0739b30370 parent: 81486:6323e5f1ed81 user: Eli Bendersky date: Sun Jan 13 05:26:31 2013 -0800 summary: Issue #16922: fixed findtext() to return empty Unicode string instead of empty bytes object when there's no text. Patch by Serhiy Storchaka. files: Lib/test/test_xml_etree.py | 3 +++ Modules/_elementtree.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1773,6 +1773,9 @@ self.assertIsNone(e.findtext('tog')) self.assertEqual(e.findtext('tog', 'default'), 'default') + # Issue #16922 + self.assertEqual(ET.XML('').findtext('empty'), '') + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1129,7 +1129,7 @@ PyObject* text = element_get_text(item); if (text == Py_None) - return PyBytes_FromString(""); + return PyUnicode_New(0, 0); Py_XINCREF(text); return text; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 14:57:46 2013 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Jan 2013 14:57:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A?= Message-ID: <3YkfXB3dP9zSHM@mail.python.org> http://hg.python.org/peps/rev/5e580a0eebcd changeset: 4674:5e580a0eebcd user: Victor Stinner date: Sun Jan 13 14:53:59 2013 +0100 summary: PEP 433: * argument=>parameter * "always set" => "set by default" * unset => clear * add more example of inherance issues * add more examples of security issues files: pep-0433.txt | 100 +++++++++++++++++++++++++------------- 1 files changed, 66 insertions(+), 34 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -1,5 +1,5 @@ PEP: 433 -Title: Add cloexec argument to functions creating file descriptors +Title: Add cloexec parameter to functions creating file descriptors Version: $Revision$ Last-Modified: $Date$ Author: Victor Stinner @@ -13,18 +13,21 @@ Abstract ======== -This PEP proposes to add a new optional argument ``cloexec`` on +This PEP proposes to add a new optional parameter ``cloexec`` on functions creating file descriptors in the Python standard library. If -the argument is ``True``, the close-on-exec flag will be set on the +the parameter is ``True``, the close-on-exec flag will be set on the new file descriptor. Rationale ========= +XXX recap briefly what the close-on-exec flag does + On UNIX, subprocess closes file descriptors greater than 2 by default since Python 3.2 [#subprocess_close]_. All file descriptors created by -the parent process are automatically closed. +the parent process are automatically closed in the child process. + ``xmlrpc.server.SimpleXMLRPCServer`` sets the close-on-exec flag of the listening socket, the parent class ``socketserver.BaseServer`` does not set this flag. @@ -58,6 +61,17 @@ with "too many files" because files are still open in the child process. +See also the following issues: + + * `Issue #2320: Race condition in subprocess using stdin + `_ (2008) + * `Issue #3006: subprocess.Popen causes socket to remain open after + close `_ (2008) + * `Issue #7213: subprocess leaks open file descriptors between Popen + instances causing hangs `_ (2009) + * `Issue #12786: subprocess wait() hangs when stdin is closed + `_ (2011) + Security -------- @@ -67,6 +81,22 @@ take control of the parent process though leaked file descriptors. It is for example a known vulnerability to escape from a chroot. +See also the CERT recommandation: +`FIO42-C. Ensure files are properly closed when they are no longer needed +`_. + + +Example of vulnerabilities: + + + * `OpenSSH Security Advisory: portable-keysign-rand-helper.adv + `_ + (April 2011) + * `CWE-403: Exposure of File Descriptor to Unintended Control Sphere + `_ (2008) + * `Hijacking Apache https by mod_php + `_ (Dec 2003) + Atomicity --------- @@ -100,6 +130,8 @@ close-on-exec flag set if ``fork()`` is used before ``exec()``, but it works correctly if ``exec()`` is called without ``fork()``. +XXX recheck this OpenBSD bug using a C program. XXX + Scope ----- @@ -128,8 +160,8 @@ * ``xmlrpc.server`` * Maybe: ``signal``, ``threading`` -XXX Should ``subprocess.Popen`` set the close-on-exec flag on file XXX -XXX descriptors of the constructor the ``pass_fds`` argument? XXX +XXX Should ``subprocess.Popen`` clear the close-on-exec flag on file +XXX descriptors of the constructor the ``pass_fds`` parameter? .. note:: See `Close file descriptors after fork`_ for a possible solution @@ -139,17 +171,17 @@ Proposal ======== -This PEP proposes to add a new optional argument ``cloexec`` on +This PEP proposes to add a new optional parameter ``cloexec`` on functions creating file descriptors in the Python standard library. If -the argument is ``True``, the close-on-exec flag will be set on the +the parameter is ``True``, the close-on-exec flag will be set on the new file descriptor. Add a new function: - * ``os.set_cloexec(fd: int, cloexec: bool)``: set or unset the + * ``os.set_cloexec(fd: int, cloexec: bool)``: set or clear the close-on-exec flag of a file descriptor -Add a new optional ``cloexec`` argument to: +Add a new optional ``cloexec`` parameter to: * ``open()``: ``os.fdopen()`` is indirectly modified * ``os.dup()``, ``os.dup2()`` @@ -166,7 +198,7 @@ * ``socket.socket.recvmsg()``: use ``MSG_CMSG_CLOEXEC``, or ``os.set_cloexec()`` -The default value of the ``cloexec`` argument is ``False`` to keep the +The default value of the ``cloexec`` parameter is ``False`` to keep the backward compatibility. The close-on-exec flag will not be set on file descriptors 0 (stdin), @@ -177,12 +209,12 @@ Drawbacks: * Many functions of the Python standard library creating file - descriptors are cannot be changed by this proposal, because adding - a ``cloexec`` optional argument would be surprising and too many + descriptors cannot be changed by this proposal, because adding + a ``cloexec`` optional parameter would be surprising and too many functions would need it. For example, ``os.urandom()`` uses a temporary file on UNIX, but it calls a function of Windows API on - Windows. Adding a ``cloexec`` argument to ``os.urandom()`` would - not make sense. See `Always set close-on-exec flag`_ for an + Windows. Adding a ``cloexec`` parameter to ``os.urandom()`` would + not make sense. See `Set the close-on-exec flag by default`_ for an incomplete list of functions creating file descriptors. * Checking if a module creates file descriptors is difficult. For example, ``os.urandom()`` creates a file descriptor on UNIX to read @@ -195,17 +227,17 @@ Alternatives ============ -Always set close-on-exec flag ------------------------------ +Set the close-on-exec flag by default +------------------------------------- -Always set close-on-exec flag on new file descriptors created by -Python. This alternative just changes the default value of the new -``cloexec`` argument. +Set the close-on-exec flag by default on new file descriptors created +by Python. This alternative just changes the default value of the new +``cloexec`` parameter. If a file must be inherited by child processes, ``cloexec=False`` -argument can be used. +parameter can be used. -``subprocess.Popen`` constructor has an ``pass_fds`` argument to +``subprocess.Popen`` constructor has an ``pass_fds`` parameter to specify which file descriptors must be inherited. The close-on-exec flag of these file descriptors must be changed with ``os.set_cloexec()``. @@ -254,12 +286,12 @@ Backward compatibility: only a few programs rely on inherance of file descriptors, and they only pass a few file descriptors, usually just one. These programs will fail immediatly with ``EBADF`` error, and it -will be simple to fix them: add ``cloexec=False`` argument or use +will be simple to fix them: add ``cloexec=False`` parameter or use ``os.set_cloexec(fd, False)``. -The ``subprocess`` module will be changed anyway to unset +The ``subprocess`` module will be changed anyway to clear close-on-exec flag on file descriptors listed in the ``pass_fds`` -argument of Popen constructor. So it possible that these programs will +parameter of Popen constructor. So it possible that these programs will not need any fix if they use the ``subprocess`` module. @@ -280,12 +312,12 @@ close-on-exec flag, the state of the flag can be overriden in each function creating a file descriptor -The major change is that the default value of the ``cloexec`` argument +The major change is that the default value of the ``cloexec`` parameter is ``sys.getdefaultcloexec()``, instead of ``False``. When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by -default, we have the same drawbacks than `Always set close-on-exec -flag`_ alternative. +default, we have the same drawbacks than `Set the close-on-exec flag +by default`_ alternative. There are additionnal drawbacks of having two behaviours depending on ``sys.getdefaultcloexec()`` value: @@ -299,7 +331,7 @@ This PEP does not fix issues with applications using ``fork()`` without ``exec()``. Python needs a generic process to register -callbacks which would be called after a fork, see `Add an 'afterfork' +callbacks which would be called after a fork, see `Add an 'atfork' module`_. Such registry could be used to close file descriptors just after a ``fork()``. @@ -325,7 +357,7 @@ A new "e" mode would set close-on-exec flag (best-effort). This alternative only solves the problem for ``open()``. -socket.socket() and os.pipe() do not have a ``mode`` argument for +socket.socket() and os.pipe() do not have a ``mode`` parameter for example. Since its version 2.7, the GNU libc supports ``"e"`` flag for @@ -341,7 +373,7 @@ default. Most programs do not rely on inherance of file descriptors. For example, ``subprocess.Popen`` was changed in Python 3.2 to close all file descriptors greater than 2 in the child process by default. -No user complained about this behavior change. +No user complained about this behavior change yet. Network servers using fork may want to pass the client socket to the child process. For example, on UNIX a CGI server pass the socket @@ -513,7 +545,7 @@ The value of the flag can be modified using: ``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)``. -``CreateProcess()`` has an ``bInheritHandles`` argument: if it is +``CreateProcess()`` has an ``bInheritHandles`` parameter: if it is FALSE, the handles are not inherited. It is used by ``subprocess.Popen`` with ``close_fds`` option. @@ -534,7 +566,7 @@ Functions: * ``ioctl(fd, FIOCLEX, 0)`` sets close-on-exec flag - * ``ioctl(fd, FIONCLEX, 0)`` unsets close-on-exec flag + * ``ioctl(fd, FIONCLEX, 0)`` clears close-on-exec flag Availability: Linux, Mac OS X, QNX, NetBSD, OpenBSD, FreeBSD. @@ -597,7 +629,7 @@ `_ * `Support accept4() for atomic setting of flags at socket creation `_ - * `Add an 'afterfork' module + * `Add an 'atfork' module `_ Ruby: -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sun Jan 13 15:05:10 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 15:05:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Close_=2314377=3A_Add_a_ne?= =?utf-8?q?w_parameter_to_ElementTree=2Ewrite_and_some_module-level?= Message-ID: <3Ykfhk63djzSH8@mail.python.org> http://hg.python.org/cpython/rev/58168d69b496 changeset: 81488:58168d69b496 user: Eli Bendersky date: Sun Jan 13 06:04:43 2013 -0800 summary: Close #14377: Add a new parameter to ElementTree.write and some module-level serialization functions - short_empty_elements. It controls how elements without contents are emitted. Patch by Serhiy Storchaka. Feature initially proposed by Ariel Poliak. files: Doc/library/xml.etree.elementtree.rst | 23 +++++++++- Lib/test/test_xml_etree.py | 12 +++++ Lib/xml/etree/ElementTree.py | 31 +++++++++----- Misc/NEWS | 4 + 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -428,29 +428,39 @@ arguments. Returns an element instance. -.. function:: tostring(element, encoding="us-ascii", method="xml") +.. function:: tostring(element, encoding="us-ascii", method="xml", *, \ + short_empty_elements=True) Generates a string representation of an XML element, including all subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is the output encoding (default is US-ASCII). Use ``encoding="unicode"`` to generate a Unicode string (otherwise, a bytestring is generated). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). + *short_empty_elements* has the same meaning as in :meth:`ElementTree.write`. Returns an (optionally) encoded string containing the XML data. + .. versionadded:: 3.4 + The *short_empty_elements* parameter. -.. function:: tostringlist(element, encoding="us-ascii", method="xml") + +.. function:: tostringlist(element, encoding="us-ascii", method="xml", *, \ + short_empty_elements=True) Generates a string representation of an XML element, including all subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is the output encoding (default is US-ASCII). Use ``encoding="unicode"`` to generate a Unicode string (otherwise, a bytestring is generated). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). + *short_empty_elements* has the same meaning as in :meth:`ElementTree.write`. Returns a list of (optionally) encoded strings containing the XML data. It does not guarantee any specific sequence, except that ``"".join(tostringlist(element)) == tostring(element)``. .. versionadded:: 3.2 + .. versionadded:: 3.4 + The *short_empty_elements* parameter. + .. function:: XML(text, parser=None) @@ -742,7 +752,7 @@ .. method:: write(file, encoding="us-ascii", xml_declaration=None, \ - method="xml") + method="xml", *, short_empty_elements=True) Writes the element tree to a file, as XML. *file* is a file name, or a :term:`file object` opened for writing. *encoding* [1]_ is the output @@ -752,6 +762,10 @@ for only if not US-ASCII or UTF-8 or Unicode (default is ``None``). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). + The keyword-only *short_empty_elements* parameter controls the formatting + of elements that contain no content. If *True* (the default), they are + emitted as a single self-closed tag, otherwise they are emitted as a pair + of start/end tags. The output is either a string (:class:`str`) or binary (:class:`bytes`). This is controlled by the *encoding* argument. If *encoding* is @@ -760,6 +774,9 @@ :term:`file object`; make sure you do not try to write a string to a binary stream and vice versa. + .. versionadded:: 3.4 + The *short_empty_elements* parameter. + This is the XML file that is going to be manipulated:: diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -2380,6 +2380,18 @@ ET.tostring(root, 'utf-16'), b''.join(ET.tostringlist(root, 'utf-16'))) + def test_short_empty_elements(self): + root = ET.fromstring('abc') + self.assertEqual( + ET.tostring(root, 'unicode'), + 'abc') + self.assertEqual( + ET.tostring(root, 'unicode', short_empty_elements=True), + 'abc') + self.assertEqual( + ET.tostring(root, 'unicode', short_empty_elements=False), + 'abc') + class ParseErrorTest(unittest.TestCase): def test_subclass(self): diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -797,7 +797,8 @@ encoding=None, xml_declaration=None, default_namespace=None, - method=None): + method=None, *, + short_empty_elements=True): if not method: method = "xml" elif method not in _serialize: @@ -825,7 +826,8 @@ else: qnames, namespaces = _namespaces(self._root, default_namespace) serialize = _serialize[method] - serialize(write, self._root, qnames, namespaces) + serialize(write, self._root, qnames, namespaces, + short_empty_elements=short_empty_elements) def write_c14n(self, file): # lxml.etree compatibility. use output method instead @@ -947,7 +949,8 @@ add_qname(text.text) return qnames, namespaces -def _serialize_xml(write, elem, qnames, namespaces): +def _serialize_xml(write, elem, qnames, namespaces, + short_empty_elements, **kwargs): tag = elem.tag text = elem.text if tag is Comment: @@ -960,7 +963,8 @@ if text: write(_escape_cdata(text)) for e in elem: - _serialize_xml(write, e, qnames, None) + _serialize_xml(write, e, qnames, None, + short_empty_elements=short_empty_elements) else: write("<" + tag) items = list(elem.items()) @@ -982,12 +986,13 @@ else: v = _escape_attrib(v) write(" %s=\"%s\"" % (qnames[k], v)) - if text or len(elem): + if text or len(elem) or not short_empty_elements: write(">") if text: write(_escape_cdata(text)) for e in elem: - _serialize_xml(write, e, qnames, None) + _serialize_xml(write, e, qnames, None, + short_empty_elements=short_empty_elements) write("") else: write(" />") @@ -1002,7 +1007,7 @@ except NameError: pass -def _serialize_html(write, elem, qnames, namespaces): +def _serialize_html(write, elem, qnames, namespaces, **kwargs): tag = elem.tag text = elem.text if tag is Comment: @@ -1166,9 +1171,11 @@ # @return An (optionally) encoded string containing the XML data. # @defreturn string -def tostring(element, encoding=None, method=None): +def tostring(element, encoding=None, method=None, *, + short_empty_elements=True): stream = io.StringIO() if encoding == 'unicode' else io.BytesIO() - ElementTree(element).write(stream, encoding, method=method) + ElementTree(element).write(stream, encoding, method=method, + short_empty_elements=short_empty_elements) return stream.getvalue() ## @@ -1202,10 +1209,12 @@ def tell(self): return len(self.lst) -def tostringlist(element, encoding=None, method=None): +def tostringlist(element, encoding=None, method=None, *, + short_empty_elements=True): lst = [] stream = _ListDataStream(lst) - ElementTree(element).write(stream, encoding, method=method) + ElementTree(element).write(stream, encoding, method=method, + short_empty_elements=short_empty_elements) return lst ## diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -559,6 +559,10 @@ - Issue #16123: IDLE - deprecate running without a subprocess. Patch by Roger Serwy. +- Issue #14377: ElementTree.write and some of the module-level functions have + a new parameter - *short_empty_elements*. It controls how elements with no + contents are emitted. + - Issue #16089: Allow ElementTree.TreeBuilder to work again with a non-Element element_factory (fixes a regression in SimpleTAL). -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 15:05:59 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 15:05:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Add_Ariel_to_Misc/ACKS?= Message-ID: <3Ykfjg2NqkzSG0@mail.python.org> http://hg.python.org/cpython/rev/3f202d4954d6 changeset: 81489:3f202d4954d6 user: Eli Bendersky date: Sun Jan 13 06:05:34 2013 -0800 summary: Add Ariel to Misc/ACKS files: Misc/ACKS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -944,6 +944,7 @@ Jean-Fran?ois Pi?ronne Oleg Plakhotnyuk Remi Pointel +Ariel Poliak Guilherme Polo Michael Pomraning Iustin Pop -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 15:28:17 2013 From: python-checkins at python.org (eli.bendersky) Date: Sun, 13 Jan 2013 15:28:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Cleanup_the_docs_ElementTr?= =?utf-8?q?ee_a_bit_and_describe_the_default=5Fnamespace?= Message-ID: <3YkgCP49RlzS4W@mail.python.org> http://hg.python.org/cpython/rev/f0e80c7404a5 changeset: 81490:f0e80c7404a5 user: Eli Bendersky date: Sun Jan 13 06:27:51 2013 -0800 summary: Cleanup the docs ElementTree a bit and describe the default_namespace parameter. In the code, replace the old outdated Doxygen-ish comment above ElementTree.write by a proper docstring. files: Doc/library/xml.etree.elementtree.rst | 12 +++-- Lib/xml/etree/ElementTree.py | 28 +++++++------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -428,7 +428,7 @@ arguments. Returns an element instance. -.. function:: tostring(element, encoding="us-ascii", method="xml", *, \ +.. function:: tostring(element, encoding="us-ascii", method="xml", *,\ short_empty_elements=True) Generates a string representation of an XML element, including all @@ -443,7 +443,7 @@ The *short_empty_elements* parameter. -.. function:: tostringlist(element, encoding="us-ascii", method="xml", *, \ +.. function:: tostringlist(element, encoding="us-ascii", method="xml", *,\ short_empty_elements=True) Generates a string representation of an XML element, including all @@ -751,8 +751,9 @@ section root element. - .. method:: write(file, encoding="us-ascii", xml_declaration=None, \ - method="xml", *, short_empty_elements=True) + .. method:: write(file, encoding="us-ascii", xml_declaration=None,\ + default_namespace=None, method="xml", *,\ + short_empty_elements=True) Writes the element tree to a file, as XML. *file* is a file name, or a :term:`file object` opened for writing. *encoding* [1]_ is the output @@ -761,7 +762,8 @@ file. Use ``False`` for never, ``True`` for always, ``None`` for only if not US-ASCII or UTF-8 or Unicode (default is ``None``). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is - ``"xml"``). + ``"xml"``). *default_namespace* sets the default XML namespace (for + "xmlns"). The keyword-only *short_empty_elements* parameter controls the formatting of elements that contain no content. If *True* (the default), they are emitted as a single self-closed tag, otherwise they are emitted as a pair diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -779,26 +779,26 @@ ) return self._root.iterfind(path, namespaces) - ## - # Writes the element tree to a file, as XML. - # - # @def write(file, **options) - # @param file A file name, or a file object opened for writing. - # @param **options Options, given as keyword arguments. - # @keyparam encoding Optional output encoding (default is US-ASCII). - # Use "unicode" to return a Unicode string. - # @keyparam method Optional output method ("xml", "html", "text" or - # "c14n"; default is "xml"). - # @keyparam xml_declaration Controls if an XML declaration should - # be added to the file. Use False for never, True for always, - # None for only if not US-ASCII or UTF-8 or Unicode. None is default. - def write(self, file_or_filename, encoding=None, xml_declaration=None, default_namespace=None, method=None, *, short_empty_elements=True): + """Write the element tree to a file, as XML. 'file_or_filename' is a + file name or a file object opened for writing. 'encoding' is the + output encoding (default is US-ASCII). 'xml_declaration' controls + if an XML declaration should be added to the output. Use False + for never, True for always, None for only if not US-ASCII or + UTF-8 or Unicode (default is None). 'method' is either "xml" + (default), "html", "text" or "c14n". + 'default_namespace' sets the default XML namespace (for "xmlns"). + The keyword-only 'short_empty_elements' parameter controls the + formatting of elements that contain no content. If True (default), + they are emitted as a single self-closed tag, otherwise they are + emitted as a pair of start/end tags. + + """ if not method: method = "xml" elif method not in _serialize: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 21:31:48 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 13 Jan 2013 21:31:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Describe_the_d?= =?utf-8?q?efault=5Fnamespace_parameter_of_ElemetTree=2Ewrite=2E?= Message-ID: <3YkqGr5qrPzMbW@mail.python.org> http://hg.python.org/cpython/rev/c5451d4a0cdd changeset: 81491:c5451d4a0cdd branch: 2.7 parent: 81473:6e8788353ddf user: Serhiy Storchaka date: Sun Jan 13 21:57:14 2013 +0200 summary: Describe the default_namespace parameter of ElemetTree.write. files: Doc/library/xml.etree.elementtree.rst | 6 ++++-- Lib/xml/etree/ElementTree.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -767,13 +767,15 @@ root element. - .. method:: write(file, encoding="us-ascii", xml_declaration=None, method="xml") + .. method:: write(file, encoding="us-ascii", xml_declaration=None, \ + default_namespace=None, method="xml") Writes the element tree to a file, as XML. *file* is a file name, or a file object opened for writing. *encoding* [1]_ is the output encoding (default is US-ASCII). *xml_declaration* controls if an XML declaration should be added to the file. Use False for never, True for always, None - for only if not US-ASCII or UTF-8 (default is None). *method* is either + for only if not US-ASCII or UTF-8 (default is None). *default_namespace* + sets the default XML namespace (for "xmlns"). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). Returns an encoded string. diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -779,11 +779,12 @@ # @param file A file name, or a file object opened for writing. # @param **options Options, given as keyword arguments. # @keyparam encoding Optional output encoding (default is US-ASCII). - # @keyparam method Optional output method ("xml", "html", "text" or - # "c14n"; default is "xml"). # @keyparam xml_declaration Controls if an XML declaration should # be added to the file. Use False for never, True for always, # None for only if not US-ASCII or UTF-8. None is default. + # @keyparam default_namespace Sets the default XML namespace (for "xmlns"). + # @keyparam method Optional output method ("xml", "html", "text" or + # "c14n"; default is "xml"). def write(self, file_or_filename, # keyword arguments -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 21:31:50 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 13 Jan 2013 21:31:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Describe_the_d?= =?utf-8?q?efault=5Fnamespace_parameter_of_ElemetTree=2Ewrite=2E?= Message-ID: <3YkqGt1TkmzMbW@mail.python.org> http://hg.python.org/cpython/rev/df8609f1854d changeset: 81492:df8609f1854d branch: 3.2 parent: 81484:849eb27baf1c user: Serhiy Storchaka date: Sun Jan 13 21:58:04 2013 +0200 summary: Describe the default_namespace parameter of ElemetTree.write. files: Doc/library/xml.etree.elementtree.rst | 16 ++++++++------ Lib/xml/etree/ElementTree.py | 5 ++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -468,16 +468,18 @@ root element. - .. method:: write(file, encoding="us-ascii", xml_declaration=None, method="xml") + .. method:: write(file, encoding="us-ascii", xml_declaration=None, \ + default_namespace=None, method="xml") Writes the element tree to a file, as XML. *file* is a file name, or a - :term:`file object` opened for writing. *encoding* [1]_ is the output encoding - (default is US-ASCII). Use ``encoding="unicode"`` to write a Unicode string. - *xml_declaration* controls if an XML declaration + :term:`file object` opened for writing. *encoding* [1]_ is the output + encoding (default is US-ASCII). Use ``encoding="unicode"`` to write a + Unicode string. *xml_declaration* controls if an XML declaration should be added to the file. Use False for never, True for always, None - for only if not US-ASCII or UTF-8 or Unicode (default is None). *method* is - either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). - Returns an (optionally) encoded string. + for only if not US-ASCII or UTF-8 or Unicode (default is None). + *default_namespace* sets the default XML namespace (for "xmlns"). + *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is + ``"xml"``). Returns an (optionally) encoded string. This is the XML file that is going to be manipulated:: diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -802,11 +802,12 @@ # @param **options Options, given as keyword arguments. # @keyparam encoding Optional output encoding (default is US-ASCII). # Use "unicode" to return a Unicode string. - # @keyparam method Optional output method ("xml", "html", "text" or - # "c14n"; default is "xml"). # @keyparam xml_declaration Controls if an XML declaration should # be added to the file. Use False for never, True for always, # None for only if not US-ASCII or UTF-8 or Unicode. None is default. + # @keyparam default_namespace Sets the default XML namespace (for "xmlns"). + # @keyparam method Optional output method ("xml", "html", "text" or + # "c14n"; default is "xml"). def write(self, file_or_filename, # keyword arguments -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 21:31:51 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 13 Jan 2013 21:31:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Describe_the_default=5Fnamespace_parameter_of_ElemetTree=2Ewri?= =?utf-8?b?dGUu?= Message-ID: <3YkqGv4WQ3zRws@mail.python.org> http://hg.python.org/cpython/rev/159276962d16 changeset: 81493:159276962d16 branch: 3.3 parent: 81486:6323e5f1ed81 parent: 81492:df8609f1854d user: Serhiy Storchaka date: Sun Jan 13 22:04:43 2013 +0200 summary: Describe the default_namespace parameter of ElemetTree.write. files: Doc/library/xml.etree.elementtree.rst | 3 ++- Lib/xml/etree/ElementTree.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -742,7 +742,7 @@ .. method:: write(file, encoding="us-ascii", xml_declaration=None, \ - method="xml") + default_namespace=None, method="xml") Writes the element tree to a file, as XML. *file* is a file name, or a :term:`file object` opened for writing. *encoding* [1]_ is the output @@ -750,6 +750,7 @@ *xml_declaration* controls if an XML declaration should be added to the file. Use ``False`` for never, ``True`` for always, ``None`` for only if not US-ASCII or UTF-8 or Unicode (default is ``None``). + *default_namespace* sets the default XML namespace (for "xmlns"). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -789,11 +789,12 @@ # @param **options Options, given as keyword arguments. # @keyparam encoding Optional output encoding (default is US-ASCII). # Use "unicode" to return a Unicode string. - # @keyparam method Optional output method ("xml", "html", "text" or - # "c14n"; default is "xml"). # @keyparam xml_declaration Controls if an XML declaration should # be added to the file. Use False for never, True for always, # None for only if not US-ASCII or UTF-8 or Unicode. None is default. + # @keyparam default_namespace Sets the default XML namespace (for "xmlns"). + # @keyparam method Optional output method ("xml", "html", "text" or + # "c14n"; default is "xml"). def write(self, file_or_filename, encoding=None, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 21:31:53 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 13 Jan 2013 21:31:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Cleanup_the_docs_ElementTree_a_bit=2E?= Message-ID: <3YkqGx1WCxzSHZ@mail.python.org> http://hg.python.org/cpython/rev/50606131a987 changeset: 81494:50606131a987 parent: 81490:f0e80c7404a5 parent: 81493:159276962d16 user: Serhiy Storchaka date: Sun Jan 13 22:24:27 2013 +0200 summary: Cleanup the docs ElementTree a bit. files: Doc/library/xml.etree.elementtree.rst | 12 +++++----- Lib/xml/etree/ElementTree.py | 16 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -428,7 +428,7 @@ arguments. Returns an element instance. -.. function:: tostring(element, encoding="us-ascii", method="xml", *,\ +.. function:: tostring(element, encoding="us-ascii", method="xml", *, \ short_empty_elements=True) Generates a string representation of an XML element, including all @@ -443,7 +443,7 @@ The *short_empty_elements* parameter. -.. function:: tostringlist(element, encoding="us-ascii", method="xml", *,\ +.. function:: tostringlist(element, encoding="us-ascii", method="xml", *, \ short_empty_elements=True) Generates a string representation of an XML element, including all @@ -751,8 +751,8 @@ section root element. - .. method:: write(file, encoding="us-ascii", xml_declaration=None,\ - default_namespace=None, method="xml", *,\ + .. method:: write(file, encoding="us-ascii", xml_declaration=None, \ + default_namespace=None, method="xml", *, \ short_empty_elements=True) Writes the element tree to a file, as XML. *file* is a file name, or a @@ -761,9 +761,9 @@ *xml_declaration* controls if an XML declaration should be added to the file. Use ``False`` for never, ``True`` for always, ``None`` for only if not US-ASCII or UTF-8 or Unicode (default is ``None``). + *default_namespace* sets the default XML namespace (for "xmlns"). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is - ``"xml"``). *default_namespace* sets the default XML namespace (for - "xmlns"). + ``"xml"``). The keyword-only *short_empty_elements* parameter controls the formatting of elements that contain no content. If *True* (the default), they are emitted as a single self-closed tag, otherwise they are emitted as a pair diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -785,16 +785,16 @@ default_namespace=None, method=None, *, short_empty_elements=True): - """Write the element tree to a file, as XML. 'file_or_filename' is a - file name or a file object opened for writing. 'encoding' is the - output encoding (default is US-ASCII). 'xml_declaration' controls - if an XML declaration should be added to the output. Use False - for never, True for always, None for only if not US-ASCII or - UTF-8 or Unicode (default is None). 'method' is either "xml" - (default), "html", "text" or "c14n". + """Write the element tree to a file, as XML. 'file_or_filename' is a + file name or a file object opened for writing. + 'encoding' is the output encoding (default is US-ASCII). + 'xml_declaration' controls if an XML declaration should be added + to the output. Use False for never, True for always, None for only + if not US-ASCII or UTF-8 or Unicode (default is None). 'default_namespace' sets the default XML namespace (for "xmlns"). + 'method' is either "xml" (default), "html", "text" or "c14n". The keyword-only 'short_empty_elements' parameter controls the - formatting of elements that contain no content. If True (default), + formatting of elements that contain no content. If True (default), they are emitted as a single self-closed tag, otherwise they are emitted as a pair of start/end tags. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 23:54:28 2013 From: python-checkins at python.org (richard.oudkerk) Date: Sun, 13 Jan 2013 23:54:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTU1?= =?utf-8?q?=3A_Fix_the_poll=28=29_method_for_multiprocessing=27s_socket?= Message-ID: <3YktRS2wgtzSH7@mail.python.org> http://hg.python.org/cpython/rev/e1c81ab5ad97 changeset: 81495:e1c81ab5ad97 branch: 3.3 parent: 81493:159276962d16 user: Richard Oudkerk date: Sun Jan 13 22:46:48 2013 +0000 summary: Issue #16955: Fix the poll() method for multiprocessing's socket connections on Windows. files: Lib/multiprocessing/connection.py | 2 +- Lib/test/test_multiprocessing.py | 11 +++++++++++ Misc/NEWS | 3 +++ 3 files changed, 15 insertions(+), 1 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -405,7 +405,7 @@ return self._recv(size) def _poll(self, timeout): - r = wait([self._handle], timeout) + r = wait([self], timeout) return bool(r) diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2383,6 +2383,17 @@ p.join() l.close() + def test_issue16955(self): + for fam in self.connection.families: + l = self.connection.Listener(family=fam) + c = self.connection.Client(l.address) + a = l.accept() + a.send_bytes(b"hello") + self.assertTrue(c.poll(1)) + a.close() + c.close() + l.close() + class _TestPoll(unittest.TestCase): ALLOWED_TYPES = ('processes', 'threads') diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -147,6 +147,9 @@ Library ------- +- Issue #16955: Fix the poll() method for multiprocessing's socket + connections on Windows. + - SSLContext.load_dh_params() now properly closes the input file. - Issue #16829: IDLE printing no longer fails if there are spaces or other -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 13 23:54:29 2013 From: python-checkins at python.org (richard.oudkerk) Date: Sun, 13 Jan 2013 23:54:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316955=3A_Fix_the_poll=28=29_method_for_multipro?= =?utf-8?q?cessing=27s_socket?= Message-ID: <3YktRT65grzSHH@mail.python.org> http://hg.python.org/cpython/rev/d904a741afde changeset: 81496:d904a741afde parent: 81494:50606131a987 parent: 81495:e1c81ab5ad97 user: Richard Oudkerk date: Sun Jan 13 22:52:13 2013 +0000 summary: Issue #16955: Fix the poll() method for multiprocessing's socket connections on Windows. files: Lib/multiprocessing/connection.py | 2 +- Lib/test/test_multiprocessing.py | 11 +++++++++++ Misc/NEWS | 3 +++ 3 files changed, 15 insertions(+), 1 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -405,7 +405,7 @@ return self._recv(size) def _poll(self, timeout): - r = wait([self._handle], timeout) + r = wait([self], timeout) return bool(r) diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2358,6 +2358,17 @@ p.join() l.close() + def test_issue16955(self): + for fam in self.connection.families: + l = self.connection.Listener(family=fam) + c = self.connection.Client(l.address) + a = l.accept() + a.send_bytes(b"hello") + self.assertTrue(c.poll(1)) + a.close() + c.close() + l.close() + class _TestPoll(unittest.TestCase): ALLOWED_TYPES = ('processes', 'threads') diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -217,6 +217,9 @@ Library ------- +- Issue #16955: Fix the poll() method for multiprocessing's socket + connections on Windows. + - SSLContext.load_dh_params() now properly closes the input file. - Issue #16829: IDLE printing no longer fails if there are spaces or other -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 14 02:24:19 2013 From: python-checkins at python.org (giampaolo.rodola) Date: Mon, 14 Jan 2013 02:24:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_fix_for_previous_commit_re?= =?utf-8?q?lated_to_issue_10527_which_didn=27t_have_the_intended?= Message-ID: <3YkxmM0JwNzSJb@mail.python.org> http://hg.python.org/cpython/rev/831f49cc00fc changeset: 81497:831f49cc00fc user: Giampaolo Rodola' date: Mon Jan 14 02:24:05 2013 +0100 summary: fix for previous commit related to issue 10527 which didn't have the intended effect as per http://bugs.python.org/issue10527#msg179895 files: Lib/multiprocessing/connection.py | 48 +++++++++--------- Lib/test/test_multiprocessing.py | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -509,27 +509,6 @@ return c1, c2 else: - if hasattr(select, 'poll'): - def _poll(fds, timeout): - if timeout is not None: - timeout = int(timeout) * 1000 # timeout is in milliseconds - fd_map = {} - pollster = select.poll() - for fd in fds: - pollster.register(fd, select.POLLIN) - if hasattr(fd, 'fileno'): - fd_map[fd.fileno()] = fd - else: - fd_map[fd] = fd - ls = [] - for fd, event in pollster.poll(timeout): - if event & select.POLLNVAL: - raise ValueError('invalid file descriptor %i' % fd) - ls.append(fd_map[fd]) - return ls - else: - def _poll(fds, timeout): - return select.select(fds, [], [], timeout)[0] def Pipe(duplex=True): ''' @@ -883,6 +862,29 @@ else: + if hasattr(select, 'poll'): + def _poll(fds, timeout): + if timeout is not None: + timeout = int(timeout) * 1000 # timeout is in milliseconds + fd_map = {} + pollster = select.poll() + for fd in fds: + pollster.register(fd, select.POLLIN) + if hasattr(fd, 'fileno'): + fd_map[fd.fileno()] = fd + else: + fd_map[fd] = fd + ls = [] + for fd, event in pollster.poll(timeout): + if event & select.POLLNVAL: + raise ValueError('invalid file descriptor %i' % fd) + ls.append(fd_map[fd]) + return ls + else: + def _poll(fds, timeout): + return select.select(fds, [], [], timeout)[0] + + def wait(object_list, timeout=None): ''' Wait till an object in object_list is ready/readable. @@ -891,12 +893,12 @@ ''' if timeout is not None: if timeout <= 0: - return select.select(object_list, [], [], 0)[0] + return _poll(object_list, 0) else: deadline = time.time() + timeout while True: try: - return select.select(object_list, [], [], timeout)[0] + return _poll(object_list, timeout) except OSError as e: if e.errno != errno.EINTR: raise diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -3263,7 +3263,7 @@ from multiprocessing.connection import wait expected = 3 - sorted_ = lambda l: sorted(l, key=lambda x: isinstance(x, int)) + sorted_ = lambda l: sorted(l, key=lambda x: id(x)) sem = multiprocessing.Semaphore(0) a, b = multiprocessing.Pipe() p = multiprocessing.Process(target=self.signal_and_sleep, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 14 02:24:35 2013 From: python-checkins at python.org (giampaolo.rodola) Date: Mon, 14 Jan 2013 02:24:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_fix_for_previo?= =?utf-8?q?us_commit_related_to_issue_10527_which_didn=27t_have_the_intend?= =?utf-8?q?ed?= Message-ID: <3Ykxmg1NdXzSKN@mail.python.org> http://hg.python.org/cpython/rev/88fadc0d7b20 changeset: 81498:88fadc0d7b20 branch: 3.3 parent: 81495:e1c81ab5ad97 user: Giampaolo Rodola' date: Mon Jan 14 02:24:25 2013 +0100 summary: fix for previous commit related to issue 10527 which didn't have the intended effect as per http://bugs.python.org/issue10527#msg179895 files: Lib/multiprocessing/connection.py | 48 +++++++++--------- Lib/test/test_multiprocessing.py | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -509,27 +509,6 @@ return c1, c2 else: - if hasattr(select, 'poll'): - def _poll(fds, timeout): - if timeout is not None: - timeout = int(timeout) * 1000 # timeout is in milliseconds - fd_map = {} - pollster = select.poll() - for fd in fds: - pollster.register(fd, select.POLLIN) - if hasattr(fd, 'fileno'): - fd_map[fd.fileno()] = fd - else: - fd_map[fd] = fd - ls = [] - for fd, event in pollster.poll(timeout): - if event & select.POLLNVAL: - raise ValueError('invalid file descriptor %i' % fd) - ls.append(fd_map[fd]) - return ls - else: - def _poll(fds, timeout): - return select.select(fds, [], [], timeout)[0] def Pipe(duplex=True): ''' @@ -883,6 +862,29 @@ else: + if hasattr(select, 'poll'): + def _poll(fds, timeout): + if timeout is not None: + timeout = int(timeout) * 1000 # timeout is in milliseconds + fd_map = {} + pollster = select.poll() + for fd in fds: + pollster.register(fd, select.POLLIN) + if hasattr(fd, 'fileno'): + fd_map[fd.fileno()] = fd + else: + fd_map[fd] = fd + ls = [] + for fd, event in pollster.poll(timeout): + if event & select.POLLNVAL: + raise ValueError('invalid file descriptor %i' % fd) + ls.append(fd_map[fd]) + return ls + else: + def _poll(fds, timeout): + return select.select(fds, [], [], timeout)[0] + + def wait(object_list, timeout=None): ''' Wait till an object in object_list is ready/readable. @@ -891,12 +893,12 @@ ''' if timeout is not None: if timeout <= 0: - return select.select(object_list, [], [], 0)[0] + return _poll(object_list, 0) else: deadline = time.time() + timeout while True: try: - return select.select(object_list, [], [], timeout)[0] + return _poll(object_list, timeout) except OSError as e: if e.errno != errno.EINTR: raise diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -3244,7 +3244,7 @@ from multiprocessing.connection import wait expected = 3 - sorted_ = lambda l: sorted(l, key=lambda x: isinstance(x, int)) + sorted_ = lambda l: sorted(l, key=lambda x: id(x)) sem = multiprocessing.Semaphore(0) a, b = multiprocessing.Pipe() p = multiprocessing.Process(target=self.signal_and_sleep, -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Mon Jan 14 05:59:31 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 14 Jan 2013 05:59:31 +0100 Subject: [Python-checkins] Daily reference leaks (831f49cc00fc): sum=0 Message-ID: results for 831f49cc00fc on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogrkl4w6', '-x'] From python-checkins at python.org Mon Jan 14 18:27:49 2013 From: python-checkins at python.org (andrew.svetlov) Date: Mon, 14 Jan 2013 18:27:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=235066=3A_Update_ID?= =?utf-8?q?LE_docs?= Message-ID: <3YlM854hJfzR26@mail.python.org> http://hg.python.org/cpython/rev/d1ef91025d70 changeset: 81499:d1ef91025d70 parent: 81497:831f49cc00fc user: Andrew Svetlov date: Mon Jan 14 19:27:36 2013 +0200 summary: Issue #5066: Update IDLE docs Patch by Todd Rovito files: Doc/library/idle.rst | 343 ++++++++++++++++---- Lib/idlelib/NEWS.txt | 2 + Lib/idlelib/help.txt | 498 +++++++++++++++++------------- Misc/NEWS | 2 + 4 files changed, 558 insertions(+), 287 deletions(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -16,70 +16,82 @@ * coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit -* cross-platform: works on Windows and Unix +* cross-platform: works on Windows, Unix, and Mac OS X -* multi-window text editor with multiple undo, Python colorizing and many other - features, e.g. smart indent and call tips +* multi-window text editor with multiple undo, Python colorizing, + smart indent, call tips, and many other features * Python shell window (a.k.a. interactive interpreter) -* debugger (not complete, but you can set breakpoints, view and step) +* debugger (not complete, but you can set breakpoints, view and step) Menus ----- +IDLE has two window types, the Shell window and the Editor window. It is +possible to have multiple editor windows simultaneously. IDLE's +menus dynamically change based on which window is currently selected. Each menu +documented below indicates which window type it is associated with. Click on +the dotted line at the top of a menu to "tear it off": a separate window +containing the menu is created (for Unix and Windows only). -File menu -^^^^^^^^^ +File menu (Shell and Editor) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ New window - create a new editing window + Create a new editing window Open... - open an existing file + Open an existing file Open module... - open an existing module (searches sys.path) + Open an existing module (searches sys.path) + +Recent Files + Open a list of recent files Class browser - show classes and methods in current file + Show classes and methods in current file Path browser - show sys.path directories, modules, classes and methods + Show sys.path directories, modules, classes and methods .. index:: single: Class browser single: Path browser Save - save current window to the associated file (unsaved windows have a \* before and - after the window title) + Save current window to the associated file (unsaved windows have a + \* before and after the window title) Save As... - save current window to new file, which becomes the associated file + Save current window to new file, which becomes the associated file Save Copy As... - save current window to different file without changing the associated file + Save current window to different file without changing the associated file + +Print Window + Print the current window Close - close current window (asks to save if unsaved) + Close current window (asks to save if unsaved) Exit - close all windows and quit IDLE (asks to save if unsaved) + Close all windows and quit IDLE (asks to save if unsaved) -Edit menu -^^^^^^^^^ +Edit menu (Shell and Editor) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undo - Undo last change to current window (max 1000 changes) + Undo last change to current window (a maximum of 1000 changes may be undone) Redo Redo last undone change to current window Cut - Copy selection into system-wide clipboard; then delete selection + Copy selection into system-wide clipboard; then delete the selection Copy Copy selection into system-wide clipboard @@ -108,11 +120,30 @@ Go to line Ask for a line number and show that line +Expand word + Expand the word you have typed to match another word in the same buffer; + repeat to get a different expansion + +Show call tip + After an unclosed parenthesis for a function, open a small window with + function parameter hints + +Show surrounding parens + Highlight the surrounding parenthesis + +Show Completions + Open a scroll window allowing selection keywords and attributes. See + Completions below. + + +Format menu (Editor window only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Indent region - Shift selected lines right 4 spaces + Shift selected lines right by the indent width (default 4 spaces) Dedent region - Shift selected lines left 4 spaces + Shift selected lines left by the indent width (default 4 spaces) Comment out region Insert ## in front of selected lines @@ -121,67 +152,121 @@ Remove leading # or ## from selected lines Tabify region - Turns *leading* stretches of spaces into tabs + Turns *leading* stretches of spaces into tabs. (Note: We recommend using + 4 space blocks to indent Python code.) Untabify region - Turn *all* tabs into the right number of spaces + Turn *all* tabs into the correct number of spaces -Expand word - Expand the word you have typed to match another word in the same buffer; repeat - to get a different expansion +Toggle tabs + Open a dialog to switch between indenting with spaces and tabs. + +New Indent Width + Open a dialog to change indent width. The accepted default by the Python + community is 4 spaces. Format Paragraph - Reformat the current blank-line-separated paragraph + Reformat the current blank-line-separated paragraph. All lines in the + paragraph will be formatted to less than 80 columns. -Import module - Import or reload the current module - -Run script - Execute the current file in the __main__ namespace +Strip trailing whitespace + Removes any space characters after the end of the last non-space character .. index:: single: Import module single: Run script -Windows menu -^^^^^^^^^^^^ +Run menu (Editor window only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Zoom Height - toggles the window between normal size (24x80) and maximum height. +Python Shell + Open or wake up the Python Shell window -The rest of this menu lists the names of all open windows; select one to bring -it to the foreground (deiconifying it if necessary). +Check module + Check the syntax of the module currently open in the Editor window. If the + module has not been saved IDLE will prompt the user to save the code. +Run module + Restart the shell to clean the environment, then execute the currently + open module. If the module has not been saved IDLE will prompt the user + to save the code. -Debug menu -^^^^^^^^^^ +Shell menu (Shell window only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* in the Python Shell window only +View Last Restart + Scroll the shell window to the last Shell restart + +Restart Shell + Restart the shell to clean the environment + +Debug menu (Shell window only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Go to file/line Look around the insert point for a filename and line number, open the file, and show the line. Useful to view the source lines referenced in an - exception traceback. + exception traceback. Available in the context menu of the Shell window. -Debugger - Run commands in the shell under the debugger. +Debugger (toggle) + This feature is not complete and considered experimental. Run commands in + the shell under the debugger Stack viewer - Show the stack traceback of the last exception. + Show the stack traceback of the last exception Auto-open Stack Viewer - Open stack viewer on traceback. + Toggle automatically opening the stack viewer on unhandled exception .. index:: single: stack viewer single: debugger +Options menu (Shell and Editor) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Edit context menu -^^^^^^^^^^^^^^^^^ +Configure IDLE + Open a configuration dialog. Fonts, indentation, keybindings, and color + themes may be altered. Startup Preferences may be set, and additional + help sources can be specified. -* Right-click in Edit window (Control-click on OS X) +Code Context (toggle)(Editor Window only) + Open a pane at the top of the edit window which shows the block context + of the section of code which is scrolling off the top of the window. + +Windows menu (Shell and Editor) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Zoom Height + Toggles the window between normal size (40x80 initial setting) and maximum + height. The initial size is in the Configure IDLE dialog under the general + tab. + +The rest of this menu lists the names of all open windows; select one to bring +it to the foreground (deiconifying it if necessary). + +Help menu (Shell and Editor) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +About IDLE + Version, copyright, license, credits + +IDLE Help + Display a help file for IDLE detailing the menu options, basic editing and + navigation, and other tips. + +Python Docs + Access local Python documentation, if installed. Or will start a web browser + and open docs.python.org showing the latest Python documentation. + +Additional help sources may be added here with the Configure IDLE dialog under +the General tab. + +Editor Window context menu +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* Right-click in Editor window (Control-click on OS X) Cut Copy selection into system-wide clipboard; then delete selection @@ -207,8 +292,8 @@ single: breakpoints -Shell context menu -^^^^^^^^^^^^^^^^^^ +Shell Window context menu +^^^^^^^^^^^^^^^^^^^^^^^^^ * Right-click in Python Shell window (Control-click on OS X) @@ -225,19 +310,44 @@ Same as in Debug menu. -Basic editing and navigation ----------------------------- +Editing and navigation +---------------------- * :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right +* :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right + * Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around +* :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words + * :kbd:`Home`/:kbd:`End` go to begin/end of line * :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file -* Some :program:`Emacs` bindings may also work, including :kbd:`C-B`, - :kbd:`C-P`, :kbd:`C-A`, :kbd:`C-E`, :kbd:`C-D`, :kbd:`C-L` +* Some useful Emacs bindings are inherited from Tcl/Tk: + + * :kbd:`C-a` beginning of line + + * :kbd:`C-e` end of line + + * :kbd:`C-k` kill line (but doesn't put it in clipboard) + + * :kbd:`C-l` center window around the insertion point + + * :kbd:`C-b` go backwards one character without deleting (usually you can + also use the cursor key for this) + + * :kbd:`C-f` go forward one character without deleting (usually you can + also use the cursor key for this) + + * :kbd:`C-p` go up one line (usually you can also use the cursor key for + this) + + * :kbd:`C-d` delete next character + +Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste) +may work. Keybindings are selected in the Configure IDLE dialog. Automatic indentation @@ -246,27 +356,76 @@ After a block-opening statement, the next line is indented by 4 spaces (in the Python Shell window by one tab). After certain keywords (break, return etc.) the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up -to 4 spaces if they are there. :kbd:`Tab` inserts 1-4 spaces (in the Python -Shell window one tab). See also the indent/dedent region commands in the edit -menu. +to 4 spaces if they are there. :kbd:`Tab` inserts spaces (in the Python +Shell window one tab), number depends on Indent width. Currently tabs +are restricted to four spaces due to Tcl/Tk limitations. +See also the indent/dedent region commands in the edit menu. + +Completions +^^^^^^^^^^^ + +Completions are supplied for functions, classes, and attributes of classes, +both built-in and user-defined. Completions are also provided for +filenames. + +The AutoCompleteWindow (ACW) will open after a predefined delay (default is +two seconds) after a '.' or (in a string) an os.sep is typed. If after one +of those characters (plus zero or more other characters) a tab is typed +the ACW will open immediately if a possible continuation is found. + +If there is only one possible completion for the characters entered, a +:kbd:`Tab` will supply that completion without opening the ACW. + +'Show Completions' will force open a completions window, by default the +:kbd:`C-space` will open a completions window. In an empty +string, this will contain the files in the current directory. On a +blank line, it will contain the built-in and user-defined functions and +classes in the current name spaces, plus any modules imported. If some +characters have been entered, the ACW will attempt to be more specific. + +If a string of characters is typed, the ACW selection will jump to the +entry most closely matching those characters. Entering a :kbd:`tab` will +cause the longest non-ambiguous match to be entered in the Editor window or +Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as +will return or a double click. Cursor keys, Page Up/Down, mouse selection, +and the scroll wheel all operate on the ACW. + +"Hidden" attributes can be accessed by typing the beginning of hidden +name after a '.', e.g. '_'. This allows access to modules with +``__all__`` set, or to class-private attributes. + +Completions and the 'Expand Word' facility can save a lot of typing! + +Completions are currently limited to those in the namespaces. Names in +an Editor window which are not via ``__main__`` and :data:`sys.modules` will +not be found. Run the module once with your imports to correct this situation. +Note that IDLE itself places quite a few modules in sys.modules, so +much can be found by default, e.g. the re module. + +If you don't like the ACW popping up unbidden, simply make the delay +longer or disable the extension. Or another option is the delay could +be set to zero. Another alternative to preventing ACW popups is to +disable the call tips extension. Python Shell window ^^^^^^^^^^^^^^^^^^^ -* :kbd:`C-C` interrupts executing command +* :kbd:`C-c` interrupts executing command -* :kbd:`C-D` sends end-of-file; closes window if typed at a ``>>>`` prompt +* :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt + (this is :kbd:`C-z` on Windows). -* :kbd:`Alt-p` retrieves previous command matching what you have typed +* :kbd:`Alt-/` (Expand word) is also useful to reduce typing -* :kbd:`Alt-n` retrieves next + Command history -* :kbd:`Return` while on any previous command retrieves that command + * :kbd:`Alt-p` retrieves previous command matching what you have typed. On + OS X use :kbd:`C-p`. -* :kbd:`Alt-/` (Expand word) is also useful here + * :kbd:`Alt-n` retrieves next. On OS X use :kbd:`C-n`. -.. index:: single: indentation + * :kbd:`Return` while on any previous command retrieves that command Syntax colors @@ -308,17 +467,17 @@ Upon startup with the ``-s`` option, IDLE will execute the file referenced by the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`. -Idle first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file -referenced is run. If ``IDLESTARTUP`` is not present, Idle checks for +IDLE first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file +referenced is run. If ``IDLESTARTUP`` is not present, IDLE checks for ``PYTHONSTARTUP``. Files referenced by these environment variables are -convenient places to store functions that are used frequently from the Idle +convenient places to store functions that are used frequently from the IDLE shell, or for executing import statements to import common modules. In addition, ``Tk`` also loads a startup file if it is present. Note that the Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is looked for in the user's home directory. Statements in this file will be executed in the Tk namespace, so this file is not useful for importing functions -to be used from Idle's Python shell. +to be used from IDLE's Python shell. Command line usage @@ -349,3 +508,45 @@ the arguments are still available in ``sys.argv``. +Additional help sources +----------------------- + +IDLE includes a help menu entry called "Python Docs" that will open the +extensive sources of help, including tutorials, available at docs.python.org. +Selected URLs can be added or removed from the help menu at any time using the +Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for +more information. + + +Other preferences +----------------- + +The font preferences, highlighting, keys, and general preferences can be +changed via the Configure IDLE menu option. Be sure to note that +keys can be user defined, IDLE ships with four built in key sets. In +addition a user can create a custom key set in the Configure IDLE dialog +under the keys tab. + +Extensions +---------- + +IDLE contains an extension facility. See the beginning of +config-extensions.def in the idlelib directory for further information. The +default extensions are currently: + +* FormatParagraph + +* AutoExpand + +* ZoomHeight + +* ScriptBinding + +* CallTips + +* ParenMatch + +* AutoComplete + +* CodeContext + diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -1,6 +1,8 @@ What's New in IDLE 3.4.0? ========================= +- Issue #5066: Update IDLE docs. Patch by Todd Rovito. + - Issue #16226: Fix IDLE Path Browser crash. (Patch by Roger Serwy) diff --git a/Lib/idlelib/help.txt b/Lib/idlelib/help.txt --- a/Lib/idlelib/help.txt +++ b/Lib/idlelib/help.txt @@ -1,142 +1,185 @@ [See the end of this file for ** TIPS ** on using IDLE !!] -Click on the dotted line at the top of a menu to "tear it off": a -separate window containing the menu is created. +IDLE is the Python IDE built with the tkinter GUI toolkit. -File Menu: +IDLE has the following features: +-coded in 100% pure Python, using the tkinter GUI toolkit +-cross-platform: works on Windows, Unix, and OS X +-multi-window text editor with multiple undo, Python colorizing, smart indent, +call tips, and many other features +-Python shell window (a.k.a interactive interpreter) +-debugger (not complete, but you can set breakpoints, view and step) - New Window -- Create a new editing window - Open... -- Open an existing file - Recent Files... -- Open a list of recent files - Open Module... -- Open an existing module (searches sys.path) - Class Browser -- Show classes and methods in current file - Path Browser -- Show sys.path directories, modules, classes +Menus: + +IDLE has two window types the Shell window and the Editor window. It is +possible to have multiple editor windows simultaneously. IDLE's +menus dynamically change based on which window is currently selected. Each menu +documented below indicates which window type it is associated with. Click on +the dotted line at the top of a menu to "tear it off": a separate window +containing the menu is created (for Unix and Windows only). + +File Menu (Shell and Editor): + + New Window -- Create a new editing window + Open... -- Open an existing file + Open Module... -- Open an existing module (searches sys.path) + Recent Files... -- Open a list of recent files + Class Browser -- Show classes and methods in current file + Path Browser -- Show sys.path directories, modules, classes, and methods - --- - Save -- Save current window to the associated file (unsaved - windows have a * before and after the window title) + --- + Save -- Save current window to the associated file (unsaved + windows have a * before and after the window title) - Save As... -- Save current window to new file, which becomes - the associated file - Save Copy As... -- Save current window to different file - without changing the associated file - --- - Print Window -- Print the current window - --- - Close -- Close current window (asks to save if unsaved) - Exit -- Close all windows, quit (asks to save if unsaved) + Save As... -- Save current window to new file, which becomes + the associated file + Save Copy As... -- Save current window to different file + without changing the associated file + --- + Print Window -- Print the current window + --- + Close -- Close current window (asks to save if unsaved) + Exit -- Close all windows, quit (asks to save if unsaved) -Edit Menu: +Edit Menu (Shell and Editor): - Undo -- Undo last change to current window - (A maximum of 1000 changes may be undone) - Redo -- Redo last undone change to current window - --- - Cut -- Copy a selection into system-wide clipboard, + Undo -- Undo last change to current window + (a maximum of 1000 changes may be undone) + Redo -- Redo last undone change to current window + --- + Cut -- Copy a selection into system-wide clipboard, then delete the selection - Copy -- Copy selection into system-wide clipboard - Paste -- Insert system-wide clipboard into window - Select All -- Select the entire contents of the edit buffer - --- - Find... -- Open a search dialog box with many options - Find Again -- Repeat last search - Find Selection -- Search for the string in the selection - Find in Files... -- Open a search dialog box for searching files - Replace... -- Open a search-and-replace dialog box - Go to Line -- Ask for a line number and show that line - Show Calltip -- Open a small window with function param hints - Show Completions -- Open a scroll window allowing selection keywords - and attributes. (see '*TIPS*', below) - Show Parens -- Highlight the surrounding parenthesis - Expand Word -- Expand the word you have typed to match another - word in the same buffer; repeat to get a + Copy -- Copy selection into system-wide clipboard + Paste -- Insert system-wide clipboard into window + Select All -- Select the entire contents of the edit buffer + --- + Find... -- Open a search dialog box with many options + Find Again -- Repeat last search + Find Selection -- Search for the string in the selection + Find in Files... -- Open a search dialog box for searching files + Replace... -- Open a search-and-replace dialog box + Go to Line -- Ask for a line number and show that line + Expand Word -- Expand the word you have typed to match another + word in the same buffer; repeat to get a different expansion + Show Calltip -- After an unclosed parenthesis for a function, open + a small window with function parameter hints + Show Parens -- Highlight the surrounding parenthesis + Show Completions -- Open a scroll window allowing selection keywords + and attributes. (see '*TIPS*', below) -Format Menu (only in Edit window): +Format Menu (Editor window only): - Indent Region -- Shift selected lines right 4 spaces - Dedent Region -- Shift selected lines left 4 spaces - Comment Out Region -- Insert ## in front of selected lines - Uncomment Region -- Remove leading # or ## from selected lines - Tabify Region -- Turns *leading* stretches of spaces into tabs - (Note: We recommend using 4 space blocks to indent Python code.) - Untabify Region -- Turn *all* tabs into the right number of spaces - New Indent Width... -- Open dialog to change indent width - Format Paragraph -- Reformat the current blank-line-separated - paragraph + Indent Region -- Shift selected lines right by the indent width + (default 4 spaces) + Dedent Region -- Shift selected lines left by the indent width + (default 4 spaces) + Comment Out Region -- Insert ## in front of selected lines + Uncomment Region -- Remove leading # or ## from selected lines + Tabify Region -- Turns *leading* stretches of spaces into tabs. + (Note: We recommend using 4 space blocks to indent Python code.) + Untabify Region -- Turn *all* tabs into the corrent number of spaces + Toggle tabs -- Open a dialog to switch between indenting with + spaces and tabs. + New Indent Width... -- Open a dialog to change indent width. The + accepted default by the Python community is 4 + spaces. + Format Paragraph -- Reformat the current blank-line-separated + paragraph. All lines in the paragraph will be + formatted to less than 80 columns. + --- + Strip trailing whitespace -- Removed any space characters after the end + of the last non-space character -Run Menu (only in Edit window): +Run Menu (Editor window only): - Python Shell -- Open or wake up the Python shell window - --- - Check Module -- Run a syntax check on the module - Run Module -- Execute the current file in the __main__ namespace + Python Shell -- Open or wake up the Python shell window + --- + Check Module -- Check the syntax of the module currently open in the + Editor window. If the module has not been saved IDLE + will prompt the user to save the code. + Run Module -- Restart the shell to clean the environment, then + execute the currently open module. If the module has + not been saved IDLE will prompt the user to save the + code. -Shell Menu (only in Shell window): +Shell Menu (Shell window only): - View Last Restart -- Scroll the shell window to the last restart - Restart Shell -- Restart the interpreter with a fresh environment + View Last Restart -- Scroll the shell window to the last Shell restart + Restart Shell -- Restart the shell to clean the environment -Debug Menu (only in Shell window): +Debug Menu (Shell window only): - Go to File/Line -- look around the insert point for a filename - and line number, open the file, and show the line - Debugger (toggle) -- Run commands in the shell under the debugger - Stack Viewer -- Show the stack traceback of the last exception - Auto-open Stack Viewer (toggle) -- Open stack viewer on traceback + Go to File/Line -- Look around the insert point for a filename + and line number, open the file, and show the line. + Useful to view the source lines referenced in an + exception traceback. Available in the context + menu of the Shell window. + Debugger (toggle) -- This feature is not complete and considered + experimental. Run commands in the shell under the + debugger. + Stack Viewer -- Show the stack traceback of the last exception + Auto-open Stack Viewer (toggle) -- Toggle automatically opening the + stack viewer on unhandled + exception -Options Menu: +Options Menu (Shell and Editor): - Configure IDLE -- Open a configuration dialog. Fonts, indentation, + Configure IDLE -- Open a configuration dialog. Fonts, indentation, keybindings, and color themes may be altered. - Startup Preferences may be set, and Additional Help - Sources can be specified. - - On OS X this menu is not present, use - menu 'IDLE -> Preferences...' instead. - --- - Code Context -- Open a pane at the top of the edit window which - shows the block context of the section of code - which is scrolling off the top or the window. - (Not present in Shell window.) + Startup Preferences may be set, and additional Help + sources can be specified. -Windows Menu: + --- + Code Context (toggle) -- Open a pane at the top of the edit window + which shows the block context of the section + of code which is scrolling off the top or the + window. This is not present in the Shell + window only the Editor window. - Zoom Height -- toggles the window between configured size - and maximum height. - --- - The rest of this menu lists the names of all open windows; - select one to bring it to the foreground (deiconifying it if - necessary). +Windows Menu (Shell and Editor): + + Zoom Height -- Toggles the window between normal size (40x80 initial + setting) and maximum height. The initial size is in the Configure + IDLE dialog under the general tab. + --- + The rest of this menu lists the names of all open windows; + select one to bring it to the foreground (deiconifying it if + necessary). Help Menu: - About IDLE -- Version, copyright, license, credits - IDLE Readme -- Background discussion and change details - --- - IDLE Help -- Display this file - Python Docs -- Access local Python documentation, if - installed. Otherwise, access www.python.org. - --- - (Additional Help Sources may be added here) + About IDLE -- Version, copyright, license, credits + --- + IDLE Help -- Display this file which is a help file for IDLE + detailing the menu options, basic editing and navigation, + and other tips. + Python Docs -- Access local Python documentation, if + installed. Or will start a web browser and open + docs.python.org showing the latest Python documentation. + --- + Additional help sources may be added here with the Configure IDLE + dialog under the General tab. -Edit context menu (Right-click / Control-click on OS X in Edit window): +Editor context menu (Right-click / Control-click on OS X in Edit window): - Cut -- Copy a selection into system-wide clipboard, + Cut -- Copy a selection into system-wide clipboard, then delete the selection - Copy -- Copy selection into system-wide clipboard - Paste -- Insert system-wide clipboard into window - Set Breakpoint -- Sets a breakpoint (when debugger open) - Clear Breakpoint -- Clears the breakpoint on that line + Copy -- Copy selection into system-wide clipboard + Paste -- Insert system-wide clipboard into window + Set Breakpoint -- Sets a breakpoint. Breakpoints are only enabled + when the debugger is open. + Clear Breakpoint -- Clears the breakpoint on that line Shell context menu (Right-click / Control-click on OS X in Shell window): - Cut -- Copy a selection into system-wide clipboard, + Cut -- Copy a selection into system-wide clipboard, then delete the selection - Copy -- Copy selection into system-wide clipboard - Paste -- Insert system-wide clipboard into window - --- - Go to file/line -- Same as in Debug menu + Copy -- Copy selection into system-wide clipboard + Paste -- Insert system-wide clipboard into window + --- + Go to file/line -- Same as in Debug menu ** TIPS ** @@ -144,160 +187,183 @@ Additional Help Sources: - Windows users can Google on zopeshelf.chm to access Zope help files in - the Windows help format. The Additional Help Sources feature of the - configuration GUI supports .chm, along with any other filetypes - supported by your browser. Supply a Menu Item title, and enter the - location in the Help File Path slot of the New Help Source dialog. Use - http:// and/or www. to identify external URLs, or download the file and - browse for its path on your machine using the Browse button. + Windows users can Google on zopeshelf.chm to access Zope help files in + the Windows help format. The Additional Help Sources feature of the + configuration GUI supports .chm, along with any other filetypes + supported by your browser. Supply a Menu Item title, and enter the + location in the Help File Path slot of the New Help Source dialog. Use + http:// and/or www. to identify external URLs, or download the file and + browse for its path on your machine using the Browse button. - All users can access the extensive sources of help, including - tutorials, available at www.python.org/doc. Selected URLs can be added - or removed from the Help menu at any time using Configure IDLE. + All users can access the extensive sources of help, including + tutorials, available at docs.python.org. Selected URLs can be added + or removed from the Help menu at any time using Configure IDLE. Basic editing and navigation: - Backspace deletes char to the left; DEL deletes char to the right. - Control-backspace deletes word left, Control-DEL deletes word right. - Arrow keys and Page Up/Down move around. - Control-left/right Arrow moves by words in a strange but useful way. - Home/End go to begin/end of line. - Control-Home/End go to begin/end of file. - Some useful Emacs bindings are inherited from Tcl/Tk: - Control-a beginning of line - Control-e end of line - Control-k kill line (but doesn't put it in clipboard) - Control-l center window around the insertion point - Standard Windows bindings may work on that platform. - Keybindings are selected in the Settings Dialog, look there. + Backspace deletes char to the left; DEL deletes char to the right. + Control-backspace deletes word left, Control-DEL deletes word right. + Arrow keys and Page Up/Down move around. + Control-left/right Arrow moves by words in a strange but useful way. + Home/End go to begin/end of line. + Control-Home/End go to begin/end of file. + Some useful Emacs bindings are inherited from Tcl/Tk: + Control-a beginning of line + Control-e end of line + Control-k kill line (but doesn't put it in clipboard) + Control-l center window around the insertion point + Standard keybindings (like Control-c to copy and Control-v to + paste) may work. Keybindings are selected in the Configure IDLE + dialog. Automatic indentation: - After a block-opening statement, the next line is indented by 4 spaces - (in the Python Shell window by one tab). After certain keywords - (break, return etc.) the next line is dedented. In leading - indentation, Backspace deletes up to 4 spaces if they are there. Tab - inserts spaces (in the Python Shell window one tab), number depends on - Indent Width. (N.B. Currently tabs are restricted to four spaces due - to Tcl/Tk issues.) + After a block-opening statement, the next line is indented by 4 spaces + (in the Python Shell window by one tab). After certain keywords + (break, return etc.) the next line is dedented. In leading + indentation, Backspace deletes up to 4 spaces if they are there. Tab + inserts spaces (in the Python Shell window one tab), number depends on + Indent Width. Currently tabs are restricted to four spaces due + to Tcl/Tk limitations. See also the indent/dedent region commands in the edit menu. Completions: - Completions are supplied for functions, classes, and attributes of - classes, both built-in and user-defined. Completions are also provided - for filenames. + Completions are supplied for functions, classes, and attributes of + classes, both built-in and user-defined. Completions are also provided + for filenames. - The AutoCompleteWindow (ACW) will open after a predefined delay - (default is two seconds) after a '.' or (in a string) an os.sep is - typed. If after one of those characters (plus zero or more other - characters) you type a Tab the ACW will open immediately if a possible - continuation is found. + The AutoCompleteWindow (ACW) will open after a predefined delay + (default is two seconds) after a '.' or (in a string) an os.sep is + typed. If after one of those characters (plus zero or more other + characters) a tab is typed the ACW will open immediately if a possible + continuation is found. - If there is only one possible completion for the characters entered, a - Tab will supply that completion without opening the ACW. + If there is only one possible completion for the characters entered, a + tab will supply that completion without opening the ACW. - 'Show Completions' will force open a completions window. In an empty - string, this will contain the files in the current directory. On a - blank line, it will contain the built-in and user-defined functions and - classes in the current name spaces, plus any modules imported. If some - characters have been entered, the ACW will attempt to be more specific. + 'Show Completions' will force open a completions window, by default the + Control-space keys will open a completions window. In an empty + string, this will contain the files in the current directory. On a + blank line, it will contain the built-in and user-defined functions and + classes in the current name spaces, plus any modules imported. If some + characters have been entered, the ACW will attempt to be more specific. - If string of characters is typed, the ACW selection will jump to the - entry most closely matching those characters. Entering a Tab will cause - the longest non-ambiguous match to be entered in the Edit window or - Shell. Two Tabs in a row will supply the current ACW selection, as - will Return or a double click. Cursor keys, Page Up/Down, mouse - selection, and the scrollwheel all operate on the ACW. + If string of characters is typed, the ACW selection will jump to the + entry most closely matching those characters. Entering a tab will cause + the longest non-ambiguous match to be entered in the Edit window or + Shell. Two tabs in a row will supply the current ACW selection, as + will return or a double click. Cursor keys, Page Up/Down, mouse + selection, and the scroll wheel all operate on the ACW. - 'Hidden' attributes can be accessed by typing the beginning of hidden - name after a '.'. e.g. '_'. This allows access to modules with - '__all__' set, or to class-private attributes. + "Hidden" attributes can be accessed by typing the beginning of hidden + name after a '.', e.g. '_'. This allows access to modules with + '__all__' set, or to class-private attributes. - Completions and the 'Expand Word' facility can save a lot of typing! + Completions and the 'Expand Word' facility can save a lot of typing! - Completions are currently limited to those in the namespaces. Names in - an Edit window which are not via __main__ or sys.modules will not be - found. Run the module once with your imports to correct this - situation. Note that IDLE itself places quite a few modules in - sys.modules, so much can be found by default, e.g. the re module. + Completions are currently limited to those in the namespaces. Names in + an Editor window which are not via __main__ or sys.modules will not be + found. Run the module once with your imports to correct this + situation. Note that IDLE itself places quite a few modules in + sys.modules, so much can be found by default, e.g. the re module. - If you don't like the ACW popping up unbidden, simply make the delay - longer or disable the extension. OTOH, you could make the delay zero. - - You could also switch off the CallTips extension. (We will be adding - a delay to the call tip window.) + If you don't like the ACW popping up unbidden, simply make the delay + longer or disable the extension. Or another option is the delay could + be set to zero. Another alternative to preventing ACW popups is to + disable the call tips extension. Python Shell window: - Control-c interrupts executing command. - Control-d sends end-of-file; closes window if typed at >>> prompt - (this is Control-z on Windows). + Control-c interrupts executing command. + Control-d sends end-of-file; closes window if typed at >>> prompt + (this is Control-z on Windows). + Alt-/ expand word is also useful to reduce typing. Command history: - Alt-p retrieves previous command matching what you have typed. - Alt-n retrieves next. - (These are Control-p, Control-n on OS X) - Return while cursor is on a previous command retrieves that command. - Expand word is also useful to reduce typing. + Alt-p retrieves previous command matching what you have typed. On OS X + use Control-p. + Alt-n retrieves next. On OS X use Control-n. + Return while cursor is on a previous command retrieves that command. Syntax colors: - The coloring is applied in a background "thread", so you may - occasionally see uncolorized text. To change the color - scheme, use the Configure IDLE / Highlighting dialog. + The coloring is applied in a background "thread", so you may + occasionally see uncolorized text. To change the color + scheme, use the Configure IDLE / Highlighting dialog. Python default syntax colors: - Keywords orange - Builtins royal purple - Strings green - Comments red - Definitions blue + Keywords orange + Builtins royal purple + Strings green + Comments red + Definitions blue Shell default colors: - Console output brown - stdout blue - stderr red - stdin black + Console output brown + stdout blue + stderr red + stdin black Other preferences: - The font preferences, keybinding, and startup preferences can - be changed using the Settings dialog. + The font preferences, highlighting, keys, and general preferences can + be changed via the Configure IDLE menu option. Be sure to note that + keys can be user defined, IDLE ships with four built in key sets. In + addition a user can create a custom key set in the Configure IDLE + dialog under the keys tab. Command line usage: - Enter idle -h at the command prompt to get a usage message. + Enter idle -h at the command prompt to get a usage message. -Running without a subprocess: (DEPRECATED) + idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ... - If IDLE is started with the -n command line switch it will run in a - single process and will not create the subprocess which runs the RPC - Python execution server. This can be useful if Python cannot create - the subprocess or the RPC socket interface on your platform. However, - in this mode user code is not isolated from IDLE itself. Also, the - environment is not restarted when Run/Run Module (F5) is selected. If - your code has been modified, you must reload() the affected modules and - re-import any specific items (e.g. from foo import baz) if the changes - are to take effect. For these reasons, it is preferable to run IDLE - with the default subprocess if at all possible. + -c command run this command + -d enable debugger + -e edit mode; arguments are files to be edited + -s run $IDLESTARTUP or $PYTHONSTARTUP first + -t title set title of shell window + + If there are arguments: + 1. If -e is used, arguments are files opened for editing and sys.argv + reflects the arguments passed to IDLE itself. + 2. Otherwise, if -c is used, all arguments are placed in + sys.argv[1:...], with sys.argv[0] set to -c. + 3. Otherwise, if neither -e nor -c is used, the first argument is a + script which is executed with the remaining arguments in + sys.argv[1:...] and sys.argv[0] set to the script name. If the + script name is -, no script is executed but an interactive Python + session is started; the arguments are still available in sys.argv. + +Running without a subprocess: (DEPRECATED in Python 3.5 see Issue 16123) + + If IDLE is started with the -n command line switch it will run in a + single process and will not create the subprocess which runs the RPC + Python execution server. This can be useful if Python cannot create + the subprocess or the RPC socket interface on your platform. However, + in this mode user code is not isolated from IDLE itself. Also, the + environment is not restarted when Run/Run Module (F5) is selected. If + your code has been modified, you must reload() the affected modules and + re-import any specific items (e.g. from foo import baz) if the changes + are to take effect. For these reasons, it is preferable to run IDLE + with the default subprocess if at all possible. Extensions: - IDLE contains an extension facility. See the beginning of - config-extensions.def in the idlelib directory for further information. - The default extensions are currently: + IDLE contains an extension facility. See the beginning of + config-extensions.def in the idlelib directory for further information. + The default extensions are currently: - FormatParagraph - AutoExpand - ZoomHeight - ScriptBinding - CallTips - ParenMatch - AutoComplete - CodeContext + FormatParagraph + AutoExpand + ZoomHeight + ScriptBinding + CallTips + ParenMatch + AutoComplete + CodeContext diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -217,6 +217,8 @@ Library ------- +- Issue #5066: Update IDLE docs. Patch by Todd Rovito. + - Issue #16955: Fix the poll() method for multiprocessing's socket connections on Windows. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 14 23:12:03 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 14 Jan 2013 23:12:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3YlTS351dfzS9K@mail.python.org> http://hg.python.org/cpython/rev/084c46ff80ae changeset: 81500:084c46ff80ae parent: 81499:d1ef91025d70 parent: 81498:88fadc0d7b20 user: Serhiy Storchaka date: Tue Jan 15 00:11:19 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 14 23:45:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 14 Jan 2013 23:45:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzk3MjA6?= =?utf-8?q?_zipfile_now_writes_correct_local_headers_for_files_larger_than?= =?utf-8?q?_4?= Message-ID: <3YlVBG2rJlzS0r@mail.python.org> http://hg.python.org/cpython/rev/ce869b05762c changeset: 81501:ce869b05762c branch: 2.7 parent: 81491:c5451d4a0cdd user: Serhiy Storchaka date: Tue Jan 15 00:29:51 2013 +0200 summary: Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. files: Lib/zipfile.py | 47 +++++++++++++++++++++++++------------ Misc/NEWS | 3 ++ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -316,7 +316,7 @@ # compress_size Size of the compressed file # file_size Size of the uncompressed file - def FileHeader(self): + def FileHeader(self, zip64=None): """Return the per-file header as a string.""" dt = self.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] @@ -331,12 +331,17 @@ extra = self.extra - if file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT: - # File is larger than what fits into a 4 byte integer, - # fall back to the ZIP64 extension + if zip64 is None: + zip64 = file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT + if zip64: fmt = ' ZIP64_LIMIT or compress_size > ZIP64_LIMIT: + if not zip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + # File is larger than what fits into a 4 byte integer, + # fall back to the ZIP64 extension file_size = 0xffffffff compress_size = 0xffffffff self.extract_version = max(45, self.extract_version) @@ -1113,20 +1118,23 @@ zinfo.CRC = 0 self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo - self.fp.write(zinfo.FileHeader()) + self.fp.write(zinfo.FileHeader(False)) return with open(filename, "rb") as fp: # Must overwrite CRC and sizes with correct data later zinfo.CRC = CRC = 0 zinfo.compress_size = compress_size = 0 - zinfo.file_size = file_size = 0 - self.fp.write(zinfo.FileHeader()) + # Compressed size can be larger than uncompressed size + zip64 = self._allowZip64 and \ + zinfo.file_size * 1.05 > ZIP64_LIMIT + self.fp.write(zinfo.FileHeader(zip64)) if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None + file_size = 0 while 1: buf = fp.read(1024 * 8) if not buf: @@ -1146,11 +1154,16 @@ zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size - # Seek backwards and write CRC and file sizes + if not zip64 and self._allowZip64: + if file_size > ZIP64_LIMIT: + raise RuntimeError('File size has increased during compressing') + if compress_size > ZIP64_LIMIT: + raise RuntimeError('Compressed size larger than uncompressed size') + # Seek backwards and write file header (which will now include + # correct CRC and file sizes) position = self.fp.tell() # Preserve current position in file - self.fp.seek(zinfo.header_offset + 14, 0) - self.fp.write(struct.pack(" ZIP64_LIMIT or \ + zinfo.compress_size > ZIP64_LIMIT + if zip64 and not self._allowZip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + self.fp.write(zinfo.FileHeader(zip64)) self.fp.write(bytes) - self.fp.flush() if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data - self.fp.write(struct.pack(" http://hg.python.org/cpython/rev/b93848ca7760 changeset: 81502:b93848ca7760 branch: 3.2 parent: 81492:df8609f1854d user: Serhiy Storchaka date: Tue Jan 15 00:31:39 2013 +0200 summary: Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. files: Lib/zipfile.py | 47 +++++++++++++++++++++++++------------ Misc/NEWS | 3 ++ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -326,7 +326,7 @@ # compress_size Size of the compressed file # file_size Size of the uncompressed file - def FileHeader(self): + def FileHeader(self, zip64=None): """Return the per-file header as a string.""" dt = self.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] @@ -341,12 +341,17 @@ extra = self.extra - if file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT: - # File is larger than what fits into a 4 byte integer, - # fall back to the ZIP64 extension + if zip64 is None: + zip64 = file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT + if zip64: fmt = ' ZIP64_LIMIT or compress_size > ZIP64_LIMIT: + if not zip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + # File is larger than what fits into a 4 byte integer, + # fall back to the ZIP64 extension file_size = 0xffffffff compress_size = 0xffffffff self.extract_version = max(45, self.extract_version) @@ -1135,20 +1140,23 @@ zinfo.CRC = 0 self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo - self.fp.write(zinfo.FileHeader()) + self.fp.write(zinfo.FileHeader(False)) return with open(filename, "rb") as fp: # Must overwrite CRC and sizes with correct data later zinfo.CRC = CRC = 0 zinfo.compress_size = compress_size = 0 - zinfo.file_size = file_size = 0 - self.fp.write(zinfo.FileHeader()) + # Compressed size can be larger than uncompressed size + zip64 = self._allowZip64 and \ + zinfo.file_size * 1.05 > ZIP64_LIMIT + self.fp.write(zinfo.FileHeader(zip64)) if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None + file_size = 0 while 1: buf = fp.read(1024 * 8) if not buf: @@ -1168,11 +1176,16 @@ zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size - # Seek backwards and write CRC and file sizes + if not zip64 and self._allowZip64: + if file_size > ZIP64_LIMIT: + raise RuntimeError('File size has increased during compressing') + if compress_size > ZIP64_LIMIT: + raise RuntimeError('Compressed size larger than uncompressed size') + # Seek backwards and write file header (which will now include + # correct CRC and file sizes) position = self.fp.tell() # Preserve current position in file - self.fp.seek(zinfo.header_offset + 14, 0) - self.fp.write(struct.pack(" ZIP64_LIMIT or \ + zinfo.compress_size > ZIP64_LIMIT + if zip64 and not self._allowZip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + self.fp.write(zinfo.FileHeader(zip64)) self.fp.write(data) - self.fp.flush() if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data - self.fp.write(struct.pack(" http://hg.python.org/cpython/rev/656a45738e5e changeset: 81503:656a45738e5e branch: 3.3 parent: 81498:88fadc0d7b20 parent: 81502:b93848ca7760 user: Serhiy Storchaka date: Tue Jan 15 00:38:17 2013 +0200 summary: Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. files: Lib/zipfile.py | 47 +++++++++++++++++++++++++------------ Misc/NEWS | 3 ++ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -346,7 +346,7 @@ # compress_size Size of the compressed file # file_size Size of the uncompressed file - def FileHeader(self): + def FileHeader(self, zip64=None): """Return the per-file header as a string.""" dt = self.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] @@ -362,12 +362,17 @@ extra = self.extra min_version = 0 - if file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT: - # File is larger than what fits into a 4 byte integer, - # fall back to the ZIP64 extension + if zip64 is None: + zip64 = file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT + if zip64: fmt = ' ZIP64_LIMIT or compress_size > ZIP64_LIMIT: + if not zip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + # File is larger than what fits into a 4 byte integer, + # fall back to the ZIP64 extension file_size = 0xffffffff compress_size = 0xffffffff min_version = ZIP64_VERSION @@ -1301,7 +1306,7 @@ zinfo.CRC = 0 self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo - self.fp.write(zinfo.FileHeader()) + self.fp.write(zinfo.FileHeader(False)) return cmpr = _get_compressor(zinfo.compress_type) @@ -1309,8 +1314,11 @@ # Must overwrite CRC and sizes with correct data later zinfo.CRC = CRC = 0 zinfo.compress_size = compress_size = 0 - zinfo.file_size = file_size = 0 - self.fp.write(zinfo.FileHeader()) + # Compressed size can be larger than uncompressed size + zip64 = self._allowZip64 and \ + zinfo.file_size * 1.05 > ZIP64_LIMIT + self.fp.write(zinfo.FileHeader(zip64)) + file_size = 0 while 1: buf = fp.read(1024 * 8) if not buf: @@ -1330,11 +1338,16 @@ zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size - # Seek backwards and write CRC and file sizes + if not zip64 and self._allowZip64: + if file_size > ZIP64_LIMIT: + raise RuntimeError('File size has increased during compressing') + if compress_size > ZIP64_LIMIT: + raise RuntimeError('Compressed size larger than uncompressed size') + # Seek backwards and write file header (which will now include + # correct CRC and file sizes) position = self.fp.tell() # Preserve current position in file - self.fp.seek(zinfo.header_offset + 14, 0) - self.fp.write(struct.pack(" ZIP64_LIMIT or \ + zinfo.compress_size > ZIP64_LIMIT + if zip64 and not self._allowZip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + self.fp.write(zinfo.FileHeader(zip64)) self.fp.write(data) - self.fp.flush() if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data - self.fp.write(struct.pack(" http://hg.python.org/cpython/rev/628a6af64a46 changeset: 81504:628a6af64a46 parent: 81500:084c46ff80ae parent: 81503:656a45738e5e user: Serhiy Storchaka date: Tue Jan 15 00:41:43 2013 +0200 summary: Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. files: Lib/zipfile.py | 46 ++++++++++++++++++++++++++----------- Misc/NEWS | 3 ++ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -346,7 +346,7 @@ # compress_size Size of the compressed file # file_size Size of the uncompressed file - def FileHeader(self): + def FileHeader(self, zip64=None): """Return the per-file header as a string.""" dt = self.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] @@ -362,12 +362,17 @@ extra = self.extra min_version = 0 - if file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT: - # File is larger than what fits into a 4 byte integer, - # fall back to the ZIP64 extension + if zip64 is None: + zip64 = file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT + if zip64: fmt = ' ZIP64_LIMIT or compress_size > ZIP64_LIMIT: + if not zip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + # File is larger than what fits into a 4 byte integer, + # fall back to the ZIP64 extension file_size = 0xffffffff compress_size = 0xffffffff min_version = ZIP64_VERSION @@ -1301,7 +1306,7 @@ zinfo.CRC = 0 self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo - self.fp.write(zinfo.FileHeader()) + self.fp.write(zinfo.FileHeader(False)) return cmpr = _get_compressor(zinfo.compress_type) @@ -1309,8 +1314,11 @@ # Must overwrite CRC and sizes with correct data later zinfo.CRC = CRC = 0 zinfo.compress_size = compress_size = 0 - zinfo.file_size = file_size = 0 - self.fp.write(zinfo.FileHeader()) + # Compressed size can be larger than uncompressed size + zip64 = self._allowZip64 and \ + zinfo.file_size * 1.05 > ZIP64_LIMIT + self.fp.write(zinfo.FileHeader(zip64)) + file_size = 0 while 1: buf = fp.read(1024 * 8) if not buf: @@ -1330,11 +1338,16 @@ zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size - # Seek backwards and write CRC and file sizes + if not zip64 and self._allowZip64: + if file_size > ZIP64_LIMIT: + raise RuntimeError('File size has increased during compressing') + if compress_size > ZIP64_LIMIT: + raise RuntimeError('Compressed size larger than uncompressed size') + # Seek backwards and write file header (which will now include + # correct CRC and file sizes) position = self.fp.tell() # Preserve current position in file - self.fp.seek(zinfo.header_offset + 14, 0) - self.fp.write(struct.pack(" ZIP64_LIMIT or \ + zinfo.compress_size > ZIP64_LIMIT + if zip64 and not self._allowZip64: + raise LargeZipFile("Filesize would require ZIP64 extensions") + self.fp.write(zinfo.FileHeader(zip64)) self.fp.write(data) - self.fp.flush() if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data - self.fp.write(struct.pack(" http://hg.python.org/cpython/rev/13e2e44db99d changeset: 81505:13e2e44db99d user: Serhiy Storchaka date: Tue Jan 15 01:12:17 2013 +0200 summary: Issue #15989: Fix several occurrences of integer overflow when result of PyLong_AsLong() narrowed to int without checks. files: Include/longobject.h | 3 ++ Lib/ctypes/test/test_structures.py | 9 ++++++ Lib/test/string_tests.py | 11 ++++++++ Lib/test/test_fcntl.py | 21 +++++++++++++++ Lib/test/test_fileio.py | 4 +++ Lib/test/test_io.py | 9 ++++++ Lib/test/test_poll.py | 10 +++++++ Lib/test/test_posix.py | 5 +++ Lib/test/test_socket.py | 22 ++++++++++++++-- Modules/_ctypes/stgdict.c | 2 +- Modules/_io/fileio.c | 4 +- Modules/_io/textio.c | 2 +- Modules/parsermodule.c | 24 ++++++++++++++--- Modules/posixmodule.c | 2 +- Modules/selectmodule.c | 12 ++++++--- Modules/socketmodule.c | 6 ++-- Objects/fileobject.c | 4 +- Objects/longobject.c | 18 +++++++++++++ Objects/unicodeobject.c | 4 +- 19 files changed, 148 insertions(+), 24 deletions(-) diff --git a/Include/longobject.h b/Include/longobject.h --- a/Include/longobject.h +++ b/Include/longobject.h @@ -26,6 +26,9 @@ PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); +#endif PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); /* It may be useful in the future. I've added it in the PyInt -> PyLong diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -1,6 +1,7 @@ import unittest from ctypes import * from struct import calcsize +import _testcapi class SubclassesTest(unittest.TestCase): def test_subclass(self): @@ -199,6 +200,14 @@ "_pack_": -1} self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + # Issue 15989 + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.INT_MAX + 1} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.UINT_MAX + 2} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + def test_initializers(self): class Person(Structure): _fields_ = [("name", c_char*6), diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -5,6 +5,7 @@ import unittest, string, sys, struct from test import support from collections import UserList +import _testcapi class Sequence: def __init__(self, seq='wxyz'): self.seq = seq @@ -1206,6 +1207,16 @@ self.checkraises(ValueError, '%%%df' % (2**64), '__mod__', (3.2)) self.checkraises(ValueError, '%%.%df' % (2**64), '__mod__', (3.2)) + self.checkraises(OverflowError, '%*s', '__mod__', + (_testcapi.PY_SSIZE_T_MAX + 1, '')) + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.INT_MAX + 1, 1. / 7)) + # Issue 15989 + self.checkraises(OverflowError, '%*s', '__mod__', + (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), '')) + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.UINT_MAX + 1, 1. / 7)) + class X(object): pass self.checkraises(TypeError, 'abc', '__mod__', X()) diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -3,6 +3,7 @@ import os import struct import sys +import _testcapi import unittest from test.support import verbose, TESTFN, unlink, run_unittest, import_module @@ -69,6 +70,26 @@ rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) self.f.close() + def test_fcntl_bad_file(self): + class F: + def __init__(self, fn): + self.fn = fn + def fileno(self): + return self.fn + self.assertRaises(ValueError, fcntl.fcntl, -1, fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(ValueError, fcntl.fcntl, F(-1), fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, 'spam', fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, F('spam'), fcntl.F_SETFL, os.O_NONBLOCK) + # Issue 15989 + self.assertRaises(OverflowError, fcntl.fcntl, _testcapi.INT_MAX + 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, F(_testcapi.INT_MAX + 1), + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, _testcapi.INT_MIN - 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, F(_testcapi.INT_MIN - 1), + fcntl.F_SETFL, os.O_NONBLOCK) + def test_fcntl_64_bit(self): # Issue #1309352: fcntl shouldn't fail when the third arg fits in a # C 'long' but not in a C 'int'. diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -8,6 +8,7 @@ from array import array from weakref import proxy from functools import wraps +import _testcapi from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd from collections import UserList @@ -347,6 +348,9 @@ if sys.platform == 'win32': import msvcrt self.assertRaises(OSError, msvcrt.get_osfhandle, make_bad_fd()) + # Issue 15989 + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1) + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) def testBadModeArgument(self): # verify that we get a sensible error message for bad mode argument diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -32,6 +32,7 @@ import unittest import warnings import weakref +import _testcapi from collections import deque, UserList from itertools import cycle, count from test import support @@ -1970,6 +1971,14 @@ os.environ.clear() os.environ.update(old_environ) + # Issue 15989 + def test_device_encoding(self): + b = self.BytesIO() + b.fileno = lambda: _testcapi.INT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + b.fileno = lambda: _testcapi.UINT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + def test_encoding(self): # Check the encoding attribute is always set, and valid b = self.BytesIO() diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py --- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -1,6 +1,7 @@ # Test case for the os.poll() function import os, select, random, unittest, subprocess +import _testcapi from test.support import TESTFN, run_unittest try: @@ -151,6 +152,15 @@ if x != 5: self.fail('Overflow must have occurred') + pollster = select.poll() + # Issue 15989 + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.SHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.USHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1) + def test_main(): run_unittest(PollTests) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -17,6 +17,7 @@ import tempfile import unittest import warnings +import _testcapi _DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(), support.TESTFN + '-dummy-symlink') @@ -537,6 +538,10 @@ except OSError: pass + # Issue 15989 + self.assertRaises(OverflowError, os.pipe2, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, os.pipe2, _testcapi.UINT_MAX + 1) + def test_utime(self): if hasattr(posix, 'utime'): now = time.time() diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1262,11 +1262,17 @@ for protocol in range(pickle.HIGHEST_PROTOCOL + 1): self.assertRaises(TypeError, pickle.dumps, sock, protocol) - def test_listen_backlog0(self): + def test_listen_backlog(self): + for backlog in 0, -1: + srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + srv.bind((HOST, 0)) + srv.listen(backlog) + srv.close() + + # Issue 15989 srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) - # backlog = 0 - srv.listen(0) + self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) srv.close() @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @@ -1582,6 +1588,11 @@ def _testShutdown(self): self.serv_conn.send(MSG) + # Issue 15989 + self.assertRaises(OverflowError, self.serv_conn.shutdown, + _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, self.serv_conn.shutdown, + 2 + (_testcapi.UINT_MAX + 1)) self.serv_conn.shutdown(2) def testDetach(self): @@ -3563,6 +3574,11 @@ pass end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") + # Issue 15989 + self.assertRaises(OverflowError, self.serv.setblocking, + _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, self.serv.setblocking, + _testcapi.UINT_MAX + 1) def _testSetBlocking(self): pass diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -335,7 +335,7 @@ isPacked = PyObject_GetAttrString(type, "_pack_"); if (isPacked) { - pack = PyLong_AsLong(isPacked); + pack = _PyLong_AsInt(isPacked); if (pack < 0 || PyErr_Occurred()) { Py_XDECREF(isPacked); PyErr_SetString(PyExc_ValueError, diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -244,7 +244,7 @@ return -1; } - fd = PyLong_AsLong(nameobj); + fd = _PyLong_AsInt(nameobj); if (fd < 0) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ValueError, @@ -382,7 +382,7 @@ goto error; } - self->fd = PyLong_AsLong(fdobj); + self->fd = _PyLong_AsInt(fdobj); Py_DECREF(fdobj); if (self->fd == -1) { goto error; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -881,7 +881,7 @@ } } else { - int fd = (int) PyLong_AsLong(fileno); + int fd = _PyLong_AsInt(fileno); Py_DECREF(fileno); if (fd == -1 && PyErr_Occurred()) { goto error; diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -725,7 +725,7 @@ /* elem must always be a sequence, however simple */ PyObject* elem = PySequence_GetItem(tuple, i); int ok = elem != NULL; - long type = 0; + int type = 0; char *strn = 0; if (ok) @@ -736,8 +736,14 @@ ok = 0; else { ok = PyLong_Check(temp); - if (ok) - type = PyLong_AS_LONG(temp); + if (ok) { + type = _PyLong_AsInt(temp); + if (type == -1 && PyErr_Occurred()) { + Py_DECREF(temp); + Py_DECREF(elem); + return 0; + } + } Py_DECREF(temp); } } @@ -773,8 +779,16 @@ if (len == 3) { PyObject *o = PySequence_GetItem(elem, 2); if (o != NULL) { - if (PyLong_Check(o)) - *line_num = PyLong_AS_LONG(o); + if (PyLong_Check(o)) { + int num = _PyLong_AsInt(o); + if (num == -1 && PyErr_Occurred()) { + Py_DECREF(o); + Py_DECREF(temp); + Py_DECREF(elem); + return 0; + } + *line_num = num; + } else { PyErr_Format(parser_error, "third item in terminal node must be an" diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -7647,7 +7647,7 @@ int fds[2]; int res; - flags = PyLong_AsLong(arg); + flags = _PyLong_AsInt(arg); if (flags == -1 && PyErr_Occurred()) return NULL; diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -352,10 +352,13 @@ i = pos = 0; while (PyDict_Next(self->dict, &pos, &key, &value)) { - self->ufds[i].fd = PyLong_AsLong(key); + assert(i < self->ufd_len); + /* Never overflow */ + self->ufds[i].fd = (int)PyLong_AsLong(key); self->ufds[i].events = (short)PyLong_AsLong(value); i++; } + assert(i == self->ufd_len); self->ufd_uptodate = 1; return 1; } @@ -371,10 +374,11 @@ poll_register(pollObject *self, PyObject *args) { PyObject *o, *key, *value; - int fd, events = POLLIN | POLLPRI | POLLOUT; + int fd; + short events = POLLIN | POLLPRI | POLLOUT; int err; - if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { + if (!PyArg_ParseTuple(args, "O|h:register", &o, &events)) { return NULL; } @@ -513,7 +517,7 @@ tout = PyNumber_Long(tout); if (!tout) return NULL; - timeout = PyLong_AsLong(tout); + timeout = _PyLong_AsInt(tout); Py_DECREF(tout); if (timeout == -1 && PyErr_Occurred()) return NULL; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2013,7 +2013,7 @@ static PyObject * sock_setblocking(PySocketSockObject *s, PyObject *arg) { - int block; + long block; block = PyLong_AsLong(arg); if (block == -1 && PyErr_Occurred()) @@ -2495,7 +2495,7 @@ int backlog; int res; - backlog = PyLong_AsLong(arg); + backlog = _PyLong_AsInt(arg); if (backlog == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -3647,7 +3647,7 @@ int how; int res; - how = PyLong_AsLong(arg); + how = _PyLong_AsInt(arg); if (how == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS diff --git a/Objects/fileobject.c b/Objects/fileobject.c --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -200,7 +200,7 @@ _Py_IDENTIFIER(fileno); if (PyLong_Check(o)) { - fd = PyLong_AsLong(o); + fd = _PyLong_AsInt(o); } else if ((meth = _PyObject_GetAttrId(o, &PyId_fileno)) != NULL) { @@ -210,7 +210,7 @@ return -1; if (PyLong_Check(fno)) { - fd = PyLong_AsLong(fno); + fd = _PyLong_AsInt(fno); Py_DECREF(fno); } else { diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -434,6 +434,24 @@ return result; } +/* Get a C int from a long int object or any object that has an __int__ + method. Return -1 and set an error if overflow occurs. */ + +int +_PyLong_AsInt(PyObject *obj) +{ + int overflow; + long result = PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow || result > INT_MAX || result < INT_MIN) { + /* XXX: could be cute and give a different + message for overflow == -1 */ + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C int"); + return -1; + } + return (int)result; +} + /* Get a Py_ssize_t from a long int object. Returns -1 and sets an error condition if overflow occurs. */ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13521,7 +13521,7 @@ "* wants int"); return -1; } - arg->width = PyLong_AsLong(v); + arg->width = PyLong_AsSsize_t(v); if (arg->width == -1 && PyErr_Occurred()) return -1; if (arg->width < 0) { @@ -13568,7 +13568,7 @@ "* wants int"); return -1; } - arg->prec = PyLong_AsLong(v); + arg->prec = _PyLong_AsInt(v); if (arg->prec == -1 && PyErr_Occurred()) return -1; if (arg->prec < 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 01:50:13 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 01:50:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzEwNTI3?= =?utf-8?q?=3A_Use_poll=28=29_instead_of_select=28=29_for_multiprocessing_?= =?utf-8?q?pipes?= Message-ID: <3YlXyY1fNnzRyf@mail.python.org> http://hg.python.org/cpython/rev/da5e520a7ba5 changeset: 81506:da5e520a7ba5 branch: 2.7 parent: 81501:ce869b05762c user: Richard Oudkerk date: Mon Jan 14 23:09:14 2013 +0000 summary: Issue #10527: Use poll() instead of select() for multiprocessing pipes files: Misc/NEWS | 2 + Modules/_multiprocessing/socket_connection.c | 33 ++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,6 +186,8 @@ Library ------- +- Issue #10527: Use poll() instead of select() for multiprocessing pipes. + - Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. diff --git a/Modules/_multiprocessing/socket_connection.c b/Modules/_multiprocessing/socket_connection.c --- a/Modules/_multiprocessing/socket_connection.c +++ b/Modules/_multiprocessing/socket_connection.c @@ -8,6 +8,10 @@ #include "multiprocessing.h" +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) +# include "poll.h" +#endif + #ifdef MS_WINDOWS # define WRITE(h, buffer, length) send((SOCKET)h, buffer, length, 0) # define READ(h, buffer, length) recv((SOCKET)h, buffer, length, 0) @@ -158,6 +162,34 @@ static int conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) { +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) + int res; + struct pollfd p; + + p.fd = (int)conn->handle; + p.events = POLLIN | POLLPRI; + p.revents = 0; + + if (timeout < 0) { + res = poll(&p, 1, -1); + } else { + res = poll(&p, 1, (int)(timeout * 1000 + 0.5)); + } + + if (res < 0) { + return MP_SOCKET_ERROR; + } else if (p.revents & (POLLNVAL|POLLERR)) { + Py_BLOCK_THREADS + PyErr_SetString(PyExc_IOError, "poll() gave POLLNVAL or POLLERR"); + Py_UNBLOCK_THREADS + return MP_EXCEPTION_HAS_BEEN_SET; + } else if (p.revents != 0) { + return TRUE; + } else { + assert(res == 0); + return FALSE; + } +#else int res; fd_set rfds; @@ -193,6 +225,7 @@ assert(res == 0); return FALSE; } +#endif } /* -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 02:08:30 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 02:08:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEwNTI3?= =?utf-8?q?=3A_Use_poll=28=29_instead_of_select=28=29_for_multiprocessing_?= =?utf-8?q?pipes?= Message-ID: <3YlYMf34nxzS0r@mail.python.org> http://hg.python.org/cpython/rev/abf111b9a464 changeset: 81507:abf111b9a464 branch: 3.2 parent: 81502:b93848ca7760 user: Richard Oudkerk date: Tue Jan 15 01:01:01 2013 +0000 summary: Issue #10527: Use poll() instead of select() for multiprocessing pipes files: Misc/NEWS | 2 + Modules/_multiprocessing/socket_connection.c | 33 ++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -199,6 +199,8 @@ Library ------- +- Issue #10527: Use poll() instead of select() for multiprocessing pipes. + - Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. diff --git a/Modules/_multiprocessing/socket_connection.c b/Modules/_multiprocessing/socket_connection.c --- a/Modules/_multiprocessing/socket_connection.c +++ b/Modules/_multiprocessing/socket_connection.c @@ -8,6 +8,10 @@ #include "multiprocessing.h" +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) +# include "poll.h" +#endif + #ifdef MS_WINDOWS # define WRITE(h, buffer, length) send((SOCKET)h, buffer, length, 0) # define READ(h, buffer, length) recv((SOCKET)h, buffer, length, 0) @@ -158,6 +162,34 @@ static int conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) { +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) + int res; + struct pollfd p; + + p.fd = (int)conn->handle; + p.events = POLLIN | POLLPRI; + p.revents = 0; + + if (timeout < 0) { + res = poll(&p, 1, -1); + } else { + res = poll(&p, 1, (int)(timeout * 1000 + 0.5)); + } + + if (res < 0) { + return MP_SOCKET_ERROR; + } else if (p.revents & (POLLNVAL|POLLERR)) { + Py_BLOCK_THREADS + PyErr_SetString(PyExc_IOError, "poll() gave POLLNVAL or POLLERR"); + Py_UNBLOCK_THREADS + return MP_EXCEPTION_HAS_BEEN_SET; + } else if (p.revents != 0) { + return TRUE; + } else { + assert(res == 0); + return FALSE; + } +#else int res; fd_set rfds; @@ -193,6 +225,7 @@ assert(res == 0); return FALSE; } +#endif } /* -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 02:08:31 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 02:08:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Dummy_merge?= Message-ID: <3YlYMg5nNTzS4w@mail.python.org> http://hg.python.org/cpython/rev/27600ad15931 changeset: 81508:27600ad15931 branch: 3.3 parent: 81503:656a45738e5e parent: 81507:abf111b9a464 user: Richard Oudkerk date: Tue Jan 15 01:04:03 2013 +0000 summary: Dummy merge files: Misc/NEWS | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -147,6 +147,8 @@ Library ------- +- Issue #10527: Use poll() instead of select() for multiprocessing pipes. + - Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 02:08:33 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 02:08:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge?= Message-ID: <3YlYMj2YjbzS5X@mail.python.org> http://hg.python.org/cpython/rev/de719ed20c74 changeset: 81509:de719ed20c74 parent: 81505:13e2e44db99d parent: 81508:27600ad15931 user: Richard Oudkerk date: Tue Jan 15 01:06:53 2013 +0000 summary: Merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 02:10:49 2013 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 15 Jan 2013 02:10:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Updates_for_cancelling_handle?= =?utf-8?q?rs_and_remove=5Freader/writer/connector=2E?= Message-ID: <3YlYQK5cPZzS0r@mail.python.org> http://hg.python.org/peps/rev/a2d0814e9b9c changeset: 4675:a2d0814e9b9c user: Guido van Rossum date: Mon Jan 14 17:10:45 2013 -0800 summary: Updates for cancelling handlers and remove_reader/writer/connector. files: pep-3156.txt | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -371,9 +371,10 @@ used to cancel the callback. Note that, unlike ``call_later()``, the callback may be called many times. Calling ``add_reader()`` again for the same file descriptor implicitly cancels the previous - callback for that file descriptor. (TBD: Returning a - ``Handler`` that can be cancelled seems awkward. Let's forget - about that.) (TBD: Change this to raise an exception if a handler + callback for that file descriptor. Note: cancelling the handler + may be delayed until the handler would be called. If you plan to + close ``fd``, you should use ``remove_reader(fd)`` instead. + (TBD: Change this to raise an exception if a handler is already set.) - ``add_writer(fd, callback, *args)``. Like ``add_reader()``, @@ -384,8 +385,8 @@ currently set for the file descriptor. (The reason for providing this alternate interface is that it is often more convenient to remember the file descriptor than to remember the ``Handler`` - object.) (TBD: Return ``True`` if a handler was removed, ``False`` - if not.) + object.) Returns ``True`` if a handler was removed, ``False`` + if not. - ``remove_writer(fd)``. This is to ``add_writer()`` as ``remove_reader()`` is to ``add_reader()``. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Tue Jan 15 03:44:51 2013 From: python-checkins at python.org (daniel.holth) Date: Tue, 15 Jan 2013 03:44:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_add_Obsoleted-By?= Message-ID: <3YlbVq1phQzRxn@mail.python.org> http://hg.python.org/peps/rev/2eede0bf8fcb changeset: 4676:2eede0bf8fcb user: Daniel Holth date: Mon Jan 14 21:44:40 2013 -0500 summary: add Obsoleted-By files: pep-0426.txt | 37 ++++++++++++++++++------------------- 1 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pep-0426.txt b/pep-0426.txt --- a/pep-0426.txt +++ b/pep-0426.txt @@ -24,11 +24,10 @@ Version 1.2 is specified in PEP 345. Version 1.3 of the metadata format adds fields designed to make -third-party packaging of Python Software easier and defines a -formal extension mechanism. The fields are "Setup-Requires-Dist" -"Provides-Extra", and "Extension". This version also adds the `extra` -variable to the `environment markers` specification and allows the -description to be placed into a payload section. +third-party packaging of Python Software easier and defines a formal +extension mechanism. This version also adds the `extra` variable to the +`environment markers` specification and allows the description to be +placed into a payload section. Metadata Files ============== @@ -354,24 +353,23 @@ Provides-Dist: virtual_package -Obsoletes-Dist (multiple use) -::::::::::::::::::::::::::::: +Obsoleted-By (optional) +::::::::::::::::::::::: -Each entry contains a string describing a distutils project's distribution -which this distribution renders obsolete, meaning that the two projects -should not be installed at the same time. +Indicates that this project is no longer being developed. The named +project provides a substitute or replacement. -Version declarations can be supplied. Version numbers must be in the -format specified in `Version Specifiers`_. +A version declaration may be supplied and must follow the rules described +in `Version Specifiers`_. -The most common use of this field will be in case a project name changes, -e.g. Gorgon 2.3 gets renamed to Torqued Python 1.0. When you install -Torqued Python, the Gorgon distribution should be removed. +The most common use of this field will be in case a project name changes. Examples:: - Obsoletes-Dist: Gorgon - Obsoletes-Dist: OtherProject (<3.0) + Name: BadName + Obsoleted-By: AcceptableName + + Obsoleted-By: AcceptableName (>=4.0.0) Requires-Python (optional) @@ -554,7 +552,6 @@ Here are some example of fields using such markers:: Requires-Dist: pywin32 (>1.0); sys.platform == 'win32' - Obsoletes-Dist: pywin31; sys.platform == 'win32' Requires-Dist: foo (1,!=1.3); platform.machine == 'i386' Requires-Dist: bar; python_version == '2.4' or python_version == '2.5' Requires-External: libxslt; 'linux' in sys.platform @@ -590,7 +587,6 @@ - Requires-Dist - Setup-Requires-Dist - Provides-Dist -- Obsoletes-Dist - Classifier (The `extra` variable is only meaningful for Requires-Dist.) @@ -608,6 +604,8 @@ * Most fields are now optional. +* Removed `Obsoletes-Dist` + * Changed fields: - Description @@ -619,6 +617,7 @@ - Extension - Provides-Extra - Setup-Requires-Dist + - Obsoleted-By References ========== -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Tue Jan 15 05:58:14 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 15 Jan 2013 05:58:14 +0100 Subject: [Python-checkins] Daily reference leaks (de719ed20c74): sum=-2 Message-ID: results for de719ed20c74 on branch "default" -------------------------------------------- test_concurrent_futures leaked [0, 0, -2] memory blocks, sum=-2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogRsRnNa', '-x'] From python-checkins at python.org Tue Jan 15 10:09:34 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 10:09:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_test=5Fsocket_broken_i?= =?utf-8?q?n_previous_commit_=28changeset_13e2e44db99d=29=2E?= Message-ID: <3Ylm2k75QczP9T@mail.python.org> http://hg.python.org/cpython/rev/525407d89277 changeset: 81510:525407d89277 user: Serhiy Storchaka date: Tue Jan 15 11:08:30 2013 +0200 summary: Fix test_socket broken in previous commit (changeset 13e2e44db99d). Added new checks for socket.setblocking(). files: Lib/test/test_socket.py | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -3566,7 +3566,10 @@ def testSetBlocking(self): # Testing whether set blocking works - self.serv.setblocking(0) + self.serv.setblocking(True) + self.assertIsNone(self.serv.gettimeout()) + self.serv.setblocking(False) + self.assertEqual(self.serv.gettimeout(), 0.0) start = time.time() try: self.serv.accept() @@ -3575,10 +3578,9 @@ end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") # Issue 15989 - self.assertRaises(OverflowError, self.serv.setblocking, - _testcapi.INT_MAX + 1) - self.assertRaises(OverflowError, self.serv.setblocking, - _testcapi.UINT_MAX + 1) + if _testcapi.UINT_MAX < _testcapi.ULONG_MAX: + self.serv.setblocking(_testcapi.UINT_MAX + 1) + self.assertIsNone(self.serv.gettimeout()) def _testSetBlocking(self): pass -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 12:33:35 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 12:33:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Check_for_NULL?= =?utf-8?q?_before_the_pointer_aligning_in_fastsearch=5Fmemchr=5F1char=2E?= Message-ID: <3YlqDv24RkzN4d@mail.python.org> http://hg.python.org/cpython/rev/ad9b5c69b8b6 changeset: 81511:ad9b5c69b8b6 branch: 3.3 parent: 81508:27600ad15931 user: Serhiy Storchaka date: Tue Jan 15 13:27:28 2013 +0200 summary: Check for NULL before the pointer aligning in fastsearch_memchr_1char. There is no guarantee that NULL is aligned. files: Objects/stringlib/fastsearch.h | 25 ++++++++------------- 1 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h --- a/Objects/stringlib/fastsearch.h +++ b/Objects/stringlib/fastsearch.h @@ -38,25 +38,18 @@ STRINGLIB_CHAR ch, unsigned char needle, Py_ssize_t maxcount, int mode) { - void *candidate; - const STRINGLIB_CHAR *found; - -#define DO_MEMCHR(memchr, s, needle, nchars) do { \ - candidate = memchr((const void *) (s), (needle), (nchars) * sizeof(STRINGLIB_CHAR)); \ - found = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR)); \ - } while (0) - if (mode == FAST_SEARCH) { const STRINGLIB_CHAR *ptr = s; const STRINGLIB_CHAR *e = s + n; while (ptr < e) { - DO_MEMCHR(memchr, ptr, needle, e - ptr); - if (found == NULL) + void *candidate = memchr((const void *) ptr, needle, (e - ptr) * sizeof(STRINGLIB_CHAR)); + if (candidate == NULL) return -1; - if (sizeof(STRINGLIB_CHAR) == 1 || *found == ch) - return (found - s); + ptr = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR)); + if (sizeof(STRINGLIB_CHAR) == 1 || *ptr == ch) + return (ptr - s); /* False positive */ - ptr = found + 1; + ptr++; } return -1; } @@ -66,9 +59,11 @@ faster than our hand-written loop in FASTSEARCH below */ else if (mode == FAST_RSEARCH) { while (n > 0) { - DO_MEMCHR(memrchr, s, needle, n); - if (found == NULL) + const STRINGLIB_CHAR *found; + void *candidate = memrchr((const void *) s, needle, n * sizeof(STRINGLIB_CHAR)); + if (candidate == NULL) return -1; + found = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR)); n = found - s; if (sizeof(STRINGLIB_CHAR) == 1 || *found == ch) return n; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 12:33:36 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 12:33:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Check_for_NULL_before_the_pointer_aligning_in_fastsearch?= =?utf-8?q?=5Fmemchr=5F1char=2E?= Message-ID: <3YlqDw53cXzP9m@mail.python.org> http://hg.python.org/cpython/rev/1f66fc397c8d changeset: 81512:1f66fc397c8d parent: 81510:525407d89277 parent: 81511:ad9b5c69b8b6 user: Serhiy Storchaka date: Tue Jan 15 13:32:41 2013 +0200 summary: Check for NULL before the pointer aligning in fastsearch_memchr_1char. There is no guarantee that NULL is aligned. files: Objects/stringlib/fastsearch.h | 25 ++++++++------------- 1 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h --- a/Objects/stringlib/fastsearch.h +++ b/Objects/stringlib/fastsearch.h @@ -38,25 +38,18 @@ STRINGLIB_CHAR ch, unsigned char needle, Py_ssize_t maxcount, int mode) { - void *candidate; - const STRINGLIB_CHAR *found; - -#define DO_MEMCHR(memchr, s, needle, nchars) do { \ - candidate = memchr((const void *) (s), (needle), (nchars) * sizeof(STRINGLIB_CHAR)); \ - found = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR)); \ - } while (0) - if (mode == FAST_SEARCH) { const STRINGLIB_CHAR *ptr = s; const STRINGLIB_CHAR *e = s + n; while (ptr < e) { - DO_MEMCHR(memchr, ptr, needle, e - ptr); - if (found == NULL) + void *candidate = memchr((const void *) ptr, needle, (e - ptr) * sizeof(STRINGLIB_CHAR)); + if (candidate == NULL) return -1; - if (sizeof(STRINGLIB_CHAR) == 1 || *found == ch) - return (found - s); + ptr = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR)); + if (sizeof(STRINGLIB_CHAR) == 1 || *ptr == ch) + return (ptr - s); /* False positive */ - ptr = found + 1; + ptr++; } return -1; } @@ -66,9 +59,11 @@ faster than our hand-written loop in FASTSEARCH below */ else if (mode == FAST_RSEARCH) { while (n > 0) { - DO_MEMCHR(memrchr, s, needle, n); - if (found == NULL) + const STRINGLIB_CHAR *found; + void *candidate = memrchr((const void *) s, needle, n * sizeof(STRINGLIB_CHAR)); + if (candidate == NULL) return -1; + found = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR)); n = found - s; if (sizeof(STRINGLIB_CHAR) == 1 || *found == ch) return n; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 13:29:23 2013 From: python-checkins at python.org (nick.coghlan) Date: Tue, 15 Jan 2013 13:29:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_432=3A_Move_the_descripti?= =?utf-8?q?on_of_the_status_quo_to_the_end?= Message-ID: <3YlrTH2sZXzPCZ@mail.python.org> http://hg.python.org/peps/rev/316e42e482d6 changeset: 4677:316e42e482d6 user: Nick Coghlan date: Tue Jan 15 21:50:35 2013 +1000 summary: PEP 432: Move the description of the status quo to the end files: pep-0432.txt | 490 +++++++++++++++++++------------------- 1 files changed, 245 insertions(+), 245 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -242,250 +242,6 @@ deliberately avoids adding any new settings of its own. -The Status Quo -============== - -The current mechanisms for configuring the interpreter have accumulated in -a fairly ad hoc fashion over the past 20+ years, leading to a rather -inconsistent interface with varying levels of documentation. - -(Note: some of the info below could probably be cleaned up and added to the -C API documentation - it's all CPython specific, so it doesn't belong in -the language reference) - - -Ignoring Environment Variables ------------------------------- - -The ``-E`` command line option allows all environment variables to be -ignored when initializing the Python interpreter. An embedding application -can enable this behaviour by setting ``Py_IgnoreEnvironmentFlag`` before -calling ``Py_Initialize()``. - -In the CPython source code, the ``Py_GETENV`` macro implicitly checks this -flag, and always produces ``NULL`` if it is set. - - - - - -Randomised Hashing ------------------- - -The randomised hashing is controlled via the ``-R`` command line option (in -releases prior to 3.3), as well as the ``PYTHONHASHSEED`` environment -variable. - -In Python 3.3, only the environment variable remains relevant. It can be -used to disable randomised hashing (by using a seed value of 0) or else -to force a specific hash value (e.g. for repeatability of testing, or -to share hash values between processes) - -However, embedding applications must use the ``Py_HashRandomizationFlag`` -to explicitly request hash randomisation (CPython sets it in ``Py_Main()`` -rather than in ``Py_Initialize()``). - -The new configuration API should make it straightforward for an -embedding application to reuse the ``PYTHONHASHSEED`` processing with -a text based configuration setting provided by other means (e.g. a -config file or separate environment variable). - - -Locating Python and the standard library ----------------------------------------- - -The location of the Python binary and the standard library is influenced -by several elements. The algorithm used to perform the calculation is -not documented anywhere other than in the source code [3_,4_]. Even that -description is incomplete, as it failed to be updated for the virtual -environment support added in Python 3.3 (detailed in PEP 405). - -These calculations are affected by the following function calls (made -prior to calling ``Py_Initialize()``) and environment variables: - -* ``Py_SetProgramName()`` -* ``Py_SetPythonHome()`` -* ``PYTHONHOME`` - -The filesystem is also inspected for ``pyvenv.cfg`` files (see PEP 405) or, -failing that, a ``lib/os.py`` (Windows) or ``lib/python$VERSION/os.py`` -file. - -The build time settings for ``PREFIX`` and ``EXEC_PREFIX`` are also relevant, -as are some registry settings on Windows. The hardcoded fallbacks are -based on the layout of the CPython source tree and build output when -working in a source checkout. - - -Configuring ``sys.path`` ------------------------- - -An embedding application may call ``Py_SetPath()`` prior to -``Py_Initialize()`` to completely override the calculation of -``sys.path``. It is not straightforward to only allow *some* of the -calculations, as modifying ``sys.path`` after initialization is -already complete means those modifications will not be in effect -when standard library modules are imported during the startup sequence. - -If ``Py_SetPath()`` is not used prior to the first call to ``Py_GetPath()`` -(implicit in ``Py_Initialize()``), then it builds on the location data -calculations above to calculate suitable path entries, along with -the ``PYTHONPATH`` environment variable. - - - -The ``site`` module, which is implicitly imported at startup (unless -disabled via the ``-S`` option) adds additional paths to this initial -set of paths, as described in its documentation [5_]. - -The ``-s`` command line option can be used to exclude the user site -directory from the list of directories added. Embedding applications -can control this by setting the ``Py_NoUserSiteDirectory`` global variable. - -The following commands can be used to check the default path configurations -for a given Python executable on a given system: - -* ``./python -c "import sys, pprint; pprint.pprint(sys.path)"`` - - standard configuration -* ``./python -s -c "import sys, pprint; pprint.pprint(sys.path)"`` - - user site directory disabled -* ``./python -S -c "import sys, pprint; pprint.pprint(sys.path)"`` - - all site path modifications disabled - -(Note: you can see similar information using ``-m site`` instead of ``-c``, -but this is slightly misleading as it calls ``os.abspath`` on all of the -path entries, making relative path entries look absolute. Using the ``site`` -module also causes problems in the last case, as on Python versions prior to -3.3, explicitly importing site will carry out the path modifications ``-S`` -avoids, while on 3.3+ combining ``-m site`` with ``-S`` currently fails) - -The calculation of ``sys.path[0]`` is comparatively straightforward: - -* For an ordinary script (Python source or compiled bytecode), - ``sys.path[0]`` will be the directory containing the script. -* For a valid ``sys.path`` entry (typically a zipfile or directory), - ``sys.path[0]`` will be that path -* For an interactive session, running from stdin or when using the ``-c`` or - ``-m`` switches, ``sys.path[0]`` will be the empty string, which the import - system interprets as allowing imports from the current directory - - -Configuring ``sys.argv`` ------------------------- - -Unlike most other settings discussed in this PEP, ``sys.argv`` is not -set implicitly by ``Py_Initialize()``. Instead, it must be set via an -explicitly call to ``Py_SetArgv()``. - -CPython calls this in ``Py_Main()`` after calling ``Py_Initialize()``. The -calculation of ``sys.argv[1:]`` is straightforward: they're the command line -arguments passed after the script name or the argument to the ``-c`` or -``-m`` options. - -The calculation of ``sys.argv[0]`` is a little more complicated: - -* For an ordinary script (source or bytecode), it will be the script name -* For a ``sys.path`` entry (typically a zipfile or directory) it will - initially be the zipfile or directory name, but will later be changed by - the ``runpy`` module to the full path to the imported ``__main__`` module. -* For a module specified with the ``-m`` switch, it will initially be the - string ``"-m"``, but will later be changed by the ``runpy`` module to the - full path to the executed module. -* For a package specified with the ``-m`` switch, it will initially be the - string ``"-m"``, but will later be changed by the ``runpy`` module to the - full path to the executed ``__main__`` submodule of the package. -* For a command executed with ``-c``, it will be the string ``"-c"`` -* For explicitly requested input from stdin, it will be the string ``"-"`` -* Otherwise, it will be the empty string - -Embedding applications must call Py_SetArgv themselves. The CPython logic -for doing so is part of ``Py_Main()`` and is not exposed separately. -However, the ``runpy`` module does provide roughly equivalent logic in -``runpy.run_module`` and ``runpy.run_path``. - - - -Other configuration settings ----------------------------- - -TBD: Cover the initialization of the following in more detail: - -* Completely disabling the import system -* The initial warning system state: - * ``sys.warnoptions`` - * (-W option, PYTHONWARNINGS) -* Arbitrary extended options (e.g. to automatically enable ``faulthandler``): - * ``sys._xoptions`` - * (-X option) -* The filesystem encoding used by: - * ``sys.getfsencoding`` - * ``os.fsencode`` - * ``os.fsdecode`` -* The IO encoding and buffering used by: - * ``sys.stdin`` - * ``sys.stdout`` - * ``sys.stderr`` - * (-u option, PYTHONIOENCODING, PYTHONUNBUFFEREDIO) -* Whether or not to implicitly cache bytecode files: - * ``sys.dont_write_bytecode`` - * (-B option, PYTHONDONTWRITEBYTECODE) -* Whether or not to enforce correct case in filenames on case-insensitive - platforms - * ``os.environ["PYTHONCASEOK"]`` -* The other settings exposed to Python code in ``sys.flags``: - - * ``debug`` (Enable debugging output in the pgen parser) - * ``inspect`` (Enter interactive interpreter after __main__ terminates) - * ``interactive`` (Treat stdin as a tty) - * ``optimize`` (__debug__ status, write .pyc or .pyo, strip doc strings) - * ``no_user_site`` (don't add the user site directory to sys.path) - * ``no_site`` (don't implicitly import site during startup) - * ``ignore_environment`` (whether environment vars are used during config) - * ``verbose`` (enable all sorts of random output) - * ``bytes_warning`` (warnings/errors for implicit str/bytes interaction) - * ``quiet`` (disable banner output even if verbose is also enabled or - stdin is a tty and the interpreter is launched in interactive mode) - -* Whether or not CPython's signal handlers should be installed - -Much of the configuration of CPython is currently handled through C level -global variables:: - - Py_BytesWarningFlag (-b) - Py_DebugFlag (-d option) - Py_InspectFlag (-i option, PYTHONINSPECT) - Py_InteractiveFlag (property of stdin, cannot be overridden) - Py_OptimizeFlag (-O option, PYTHONOPTIMIZE) - Py_DontWriteBytecodeFlag (-B option, PYTHONDONTWRITEBYTECODE) - Py_NoUserSiteDirectory (-s option, PYTHONNOUSERSITE) - Py_NoSiteFlag (-S option) - Py_UnbufferedStdioFlag (-u, PYTHONUNBUFFEREDIO) - Py_VerboseFlag (-v option, PYTHONVERBOSE) - -For the above variables, the conversion of command line options and -environment variables to C global variables is handled by ``Py_Main``, -so each embedding application must set those appropriately in order to -change them from their defaults. - -Some configuration can only be provided as OS level environment variables:: - - PYTHONSTARTUP - PYTHONCASEOK - PYTHONIOENCODING - -The ``Py_InitializeEx()`` API also accepts a boolean flag to indicate -whether or not CPython's signal handlers should be installed. - -Finally, some interactive behaviour (such as printing the introductory -banner) is triggered only when standard input is reported as a terminal -connection by the operating system. - -TBD: Document how the "-x" option is handled (skips processing of the -first comment line in the main script) - -Also see detailed sequence of operations notes at [1_] - - Design Details ============== @@ -623,7 +379,7 @@ #define Py_CoreConfig_INIT {0, -1, 0, 0} The core configuration settings pointer may be ``NULL``, in which case the -default values are ``ignore_environment = 0`` and ``use_hash_seed = -1``. +default values are ``ignore_environment = -1`` and ``use_hash_seed = -1``. The ``Py_CoreConfig_INIT`` macro is designed to allow easy initialization of a struct instance with sensible defaults:: @@ -1189,6 +945,250 @@ directory. +The Status Quo +============== + +The current mechanisms for configuring the interpreter have accumulated in +a fairly ad hoc fashion over the past 20+ years, leading to a rather +inconsistent interface with varying levels of documentation. + +(Note: some of the info below could probably be cleaned up and added to the +C API documentation for at least 3.3. - it's all CPython specific, so it +doesn't belong in the language reference) + + +Ignoring Environment Variables +------------------------------ + +The ``-E`` command line option allows all environment variables to be +ignored when initializing the Python interpreter. An embedding application +can enable this behaviour by setting ``Py_IgnoreEnvironmentFlag`` before +calling ``Py_Initialize()``. + +In the CPython source code, the ``Py_GETENV`` macro implicitly checks this +flag, and always produces ``NULL`` if it is set. + + + + + +Randomised Hashing +------------------ + +The randomised hashing is controlled via the ``-R`` command line option (in +releases prior to 3.3), as well as the ``PYTHONHASHSEED`` environment +variable. + +In Python 3.3, only the environment variable remains relevant. It can be +used to disable randomised hashing (by using a seed value of 0) or else +to force a specific hash value (e.g. for repeatability of testing, or +to share hash values between processes) + +However, embedding applications must use the ``Py_HashRandomizationFlag`` +to explicitly request hash randomisation (CPython sets it in ``Py_Main()`` +rather than in ``Py_Initialize()``). + +The new configuration API should make it straightforward for an +embedding application to reuse the ``PYTHONHASHSEED`` processing with +a text based configuration setting provided by other means (e.g. a +config file or separate environment variable). + + +Locating Python and the standard library +---------------------------------------- + +The location of the Python binary and the standard library is influenced +by several elements. The algorithm used to perform the calculation is +not documented anywhere other than in the source code [3_,4_]. Even that +description is incomplete, as it failed to be updated for the virtual +environment support added in Python 3.3 (detailed in PEP 405). + +These calculations are affected by the following function calls (made +prior to calling ``Py_Initialize()``) and environment variables: + +* ``Py_SetProgramName()`` +* ``Py_SetPythonHome()`` +* ``PYTHONHOME`` + +The filesystem is also inspected for ``pyvenv.cfg`` files (see PEP 405) or, +failing that, a ``lib/os.py`` (Windows) or ``lib/python$VERSION/os.py`` +file. + +The build time settings for ``PREFIX`` and ``EXEC_PREFIX`` are also relevant, +as are some registry settings on Windows. The hardcoded fallbacks are +based on the layout of the CPython source tree and build output when +working in a source checkout. + + +Configuring ``sys.path`` +------------------------ + +An embedding application may call ``Py_SetPath()`` prior to +``Py_Initialize()`` to completely override the calculation of +``sys.path``. It is not straightforward to only allow *some* of the +calculations, as modifying ``sys.path`` after initialization is +already complete means those modifications will not be in effect +when standard library modules are imported during the startup sequence. + +If ``Py_SetPath()`` is not used prior to the first call to ``Py_GetPath()`` +(implicit in ``Py_Initialize()``), then it builds on the location data +calculations above to calculate suitable path entries, along with +the ``PYTHONPATH`` environment variable. + + + +The ``site`` module, which is implicitly imported at startup (unless +disabled via the ``-S`` option) adds additional paths to this initial +set of paths, as described in its documentation [5_]. + +The ``-s`` command line option can be used to exclude the user site +directory from the list of directories added. Embedding applications +can control this by setting the ``Py_NoUserSiteDirectory`` global variable. + +The following commands can be used to check the default path configurations +for a given Python executable on a given system: + +* ``./python -c "import sys, pprint; pprint.pprint(sys.path)"`` + - standard configuration +* ``./python -s -c "import sys, pprint; pprint.pprint(sys.path)"`` + - user site directory disabled +* ``./python -S -c "import sys, pprint; pprint.pprint(sys.path)"`` + - all site path modifications disabled + +(Note: you can see similar information using ``-m site`` instead of ``-c``, +but this is slightly misleading as it calls ``os.abspath`` on all of the +path entries, making relative path entries look absolute. Using the ``site`` +module also causes problems in the last case, as on Python versions prior to +3.3, explicitly importing site will carry out the path modifications ``-S`` +avoids, while on 3.3+ combining ``-m site`` with ``-S`` currently fails) + +The calculation of ``sys.path[0]`` is comparatively straightforward: + +* For an ordinary script (Python source or compiled bytecode), + ``sys.path[0]`` will be the directory containing the script. +* For a valid ``sys.path`` entry (typically a zipfile or directory), + ``sys.path[0]`` will be that path +* For an interactive session, running from stdin or when using the ``-c`` or + ``-m`` switches, ``sys.path[0]`` will be the empty string, which the import + system interprets as allowing imports from the current directory + + +Configuring ``sys.argv`` +------------------------ + +Unlike most other settings discussed in this PEP, ``sys.argv`` is not +set implicitly by ``Py_Initialize()``. Instead, it must be set via an +explicitly call to ``Py_SetArgv()``. + +CPython calls this in ``Py_Main()`` after calling ``Py_Initialize()``. The +calculation of ``sys.argv[1:]`` is straightforward: they're the command line +arguments passed after the script name or the argument to the ``-c`` or +``-m`` options. + +The calculation of ``sys.argv[0]`` is a little more complicated: + +* For an ordinary script (source or bytecode), it will be the script name +* For a ``sys.path`` entry (typically a zipfile or directory) it will + initially be the zipfile or directory name, but will later be changed by + the ``runpy`` module to the full path to the imported ``__main__`` module. +* For a module specified with the ``-m`` switch, it will initially be the + string ``"-m"``, but will later be changed by the ``runpy`` module to the + full path to the executed module. +* For a package specified with the ``-m`` switch, it will initially be the + string ``"-m"``, but will later be changed by the ``runpy`` module to the + full path to the executed ``__main__`` submodule of the package. +* For a command executed with ``-c``, it will be the string ``"-c"`` +* For explicitly requested input from stdin, it will be the string ``"-"`` +* Otherwise, it will be the empty string + +Embedding applications must call Py_SetArgv themselves. The CPython logic +for doing so is part of ``Py_Main()`` and is not exposed separately. +However, the ``runpy`` module does provide roughly equivalent logic in +``runpy.run_module`` and ``runpy.run_path``. + + + +Other configuration settings +---------------------------- + +TBD: Cover the initialization of the following in more detail: + +* Completely disabling the import system +* The initial warning system state: + * ``sys.warnoptions`` + * (-W option, PYTHONWARNINGS) +* Arbitrary extended options (e.g. to automatically enable ``faulthandler``): + * ``sys._xoptions`` + * (-X option) +* The filesystem encoding used by: + * ``sys.getfsencoding`` + * ``os.fsencode`` + * ``os.fsdecode`` +* The IO encoding and buffering used by: + * ``sys.stdin`` + * ``sys.stdout`` + * ``sys.stderr`` + * (-u option, PYTHONIOENCODING, PYTHONUNBUFFEREDIO) +* Whether or not to implicitly cache bytecode files: + * ``sys.dont_write_bytecode`` + * (-B option, PYTHONDONTWRITEBYTECODE) +* Whether or not to enforce correct case in filenames on case-insensitive + platforms + * ``os.environ["PYTHONCASEOK"]`` +* The other settings exposed to Python code in ``sys.flags``: + + * ``debug`` (Enable debugging output in the pgen parser) + * ``inspect`` (Enter interactive interpreter after __main__ terminates) + * ``interactive`` (Treat stdin as a tty) + * ``optimize`` (__debug__ status, write .pyc or .pyo, strip doc strings) + * ``no_user_site`` (don't add the user site directory to sys.path) + * ``no_site`` (don't implicitly import site during startup) + * ``ignore_environment`` (whether environment vars are used during config) + * ``verbose`` (enable all sorts of random output) + * ``bytes_warning`` (warnings/errors for implicit str/bytes interaction) + * ``quiet`` (disable banner output even if verbose is also enabled or + stdin is a tty and the interpreter is launched in interactive mode) + +* Whether or not CPython's signal handlers should be installed + +Much of the configuration of CPython is currently handled through C level +global variables:: + + Py_BytesWarningFlag (-b) + Py_DebugFlag (-d option) + Py_InspectFlag (-i option, PYTHONINSPECT) + Py_InteractiveFlag (property of stdin, cannot be overridden) + Py_OptimizeFlag (-O option, PYTHONOPTIMIZE) + Py_DontWriteBytecodeFlag (-B option, PYTHONDONTWRITEBYTECODE) + Py_NoUserSiteDirectory (-s option, PYTHONNOUSERSITE) + Py_NoSiteFlag (-S option) + Py_UnbufferedStdioFlag (-u, PYTHONUNBUFFEREDIO) + Py_VerboseFlag (-v option, PYTHONVERBOSE) + +For the above variables, the conversion of command line options and +environment variables to C global variables is handled by ``Py_Main``, +so each embedding application must set those appropriately in order to +change them from their defaults. + +Some configuration can only be provided as OS level environment variables:: + + PYTHONSTARTUP + PYTHONCASEOK + PYTHONIOENCODING + +The ``Py_InitializeEx()`` API also accepts a boolean flag to indicate +whether or not CPython's signal handlers should be installed. + +Finally, some interactive behaviour (such as printing the introductory +banner) is triggered only when standard input is reported as a terminal +connection by the operating system. + +TBD: Document how the "-x" option is handled (skips processing of the +first comment line in the main script) + +Also see detailed sequence of operations notes at [1_] + + References ========== -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Tue Jan 15 13:29:24 2013 From: python-checkins at python.org (nick.coghlan) Date: Tue, 15 Jan 2013 13:29:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_432=3A_Reduce_typing_in_p?= =?utf-8?q?roposed_API?= Message-ID: <3YlrTJ6bGvzPCZ@mail.python.org> http://hg.python.org/peps/rev/ba6561f6a514 changeset: 4678:ba6561f6a514 user: Nick Coghlan date: Tue Jan 15 22:28:45 2013 +1000 summary: PEP 432: Reduce typing in proposed API - consistently abbreviate Config - follow the Py*Object naming convention for Py*Config structs by dropping the underscore after the Py/_Py prefix files: pep-0432.txt | 97 +++++++++++++++++++++------------------ 1 files changed, 51 insertions(+), 46 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -61,7 +61,8 @@ To keep the implementation complexity under control, this PEP does *not* propose wholesale changes to the way the interpreter state is accessed at runtime, nor does it propose changes to the way subinterpreters are -created after the main interpreter has already been initialized. Changing +created after the main interpreter has already been initialized (beyond +any changes needed to make sure they continue working as expected). Changing the order in which the existing initialization steps occur in order to make the startup sequence easier to maintain is already a substantial change, and attempting to make those other changes at the same time will make the @@ -239,7 +240,9 @@ Note that this just covers settings that are currently configurable in some manner when using the main CPython executable. While this PEP aims to make adding additional configuration settings easier in the future, it -deliberately avoids adding any new settings of its own. +deliberately avoids adding any new settings of its own (except where such +additional settings arise naturally in the course of migrating existing +settings to the new structure). Design Details @@ -280,7 +283,7 @@ * ``Py_IsInitialized()`` returns ``0`` * The embedding application determines and applies the settings required to complete the initialization process by calling - ``Py_ReadConfiguration`` and ``Py_EndInitialization``. + ``Py_ReadConfig`` and ``Py_EndInitialization``. * Initialized: @@ -318,8 +321,8 @@ over the initialization process:: /* Phase 1: Pre-Initialization */ - Py_CoreConfig core_config = Py_CoreConfig_INIT; - Py_Config config = Py_Config_INIT; + PyCoreConfig core_config = PyCoreConfig_INIT; + PyConfig config = PyConfig_INIT; /* Easily control the core configuration */ core_config.ignore_environment = 1; /* Ignore environment variables */ core_config.use_hash_seed = 0; /* Full hash randomisation */ @@ -327,13 +330,13 @@ /* Phase 2: Initialization */ /* Optionally preconfigure some settings here - they will then be * used to derive other settings */ - Py_ReadConfiguration(&config); + Py_ReadConfig(&config); /* Can completely override derived settings here */ Py_EndInitialization(&config); /* Phase 3: Initialized */ /* If an embedding application has no real concept of a main module - * it can leave the interpreter in this state indefinitely. - * Otherwise, it can launch __main__ via the Py_Run*AsMain functions. + * it can just stop the initialization process here. + * Alternatively, it can launch __main__ via the PyRun_*Main functions. */ @@ -352,11 +355,13 @@ for the seed (a seed value of zero disables randomised hashing). In addition, due to the possible use of ``PYTHONHASHSEED`` in configuring the hash randomisation, the question of whether or not to consider environment -variables must also be addressed early. +variables must also be addressed early. Finally, to support the CPython +build process, an option is offered to completely disable the import +system. The proposed API for this step in the startup sequence is:: - void Py_BeginInitialization(const Py_CoreConfig *config); + void Py_BeginInitialization(const PyCoreConfig *config); Like Py_Initialize, this part of the new API treats initialization failures as fatal errors. While that's still not particularly embedding friendly, @@ -364,27 +369,27 @@ to return error codes instead of aborting would be an even larger task than the one already being proposed. -The new ``Py_CoreConfig`` struct holds the settings required for preliminary +The new ``PyCoreConfig`` struct holds the settings required for preliminary configuration:: - /* Note: if changing anything in Py_CoreConfig, also update - * Py_CoreConfig_INIT */ + /* Note: if changing anything in PyCoreConfig, also update + * PyCoreConfig_INIT */ typedef struct { int ignore_environment; /* -E switch */ int use_hash_seed; /* PYTHONHASHSEED */ unsigned long hash_seed; /* PYTHONHASHSEED */ int _disable_importlib; /* Needed by freeze_importlib */ - } Py_CoreConfig; + } PyCoreConfig; - #define Py_CoreConfig_INIT {0, -1, 0, 0} + #define PyCoreConfig_INIT {0, -1, 0, 0} The core configuration settings pointer may be ``NULL``, in which case the default values are ``ignore_environment = -1`` and ``use_hash_seed = -1``. -The ``Py_CoreConfig_INIT`` macro is designed to allow easy initialization +The ``PyCoreConfig_INIT`` macro is designed to allow easy initialization of a struct instance with sensible defaults:: - Py_CoreConfig core_config = Py_CoreConfig_INIT; + PyCoreConfig core_config = PyCoreConfig_INIT; ``ignore_environment`` controls the processing of all Python related environment variables. If the flag is zero, then environment variables are @@ -498,7 +503,7 @@ settings needed to complete the process. No changes are made to the interpreter state at this point. The core API for this step is:: - int Py_ReadConfiguration(PyConfig *config); + int Py_ReadConfig(PyConfig *config); The config argument should be a pointer to a config struct (which may be a temporary one stored on the C stack). For any already configured value @@ -534,11 +539,11 @@ Supported configuration settings -------------------------------- -The new ``Py_Config`` struct holds the settings required to complete the +The new ``PyConfig`` struct holds the settings required to complete the interpreter configuration. All fields are either pointers to Python data types (not set == ``NULL``) or numeric flags (not set == ``-1``):: - /* Note: if changing anything in Py_Config, also update Py_Config_INIT */ + /* Note: if changing anything in PyConfig, also update PyConfig_INIT */ typedef struct { /* Argument processing */ PyListObject *raw_argv; @@ -611,30 +616,30 @@ int show_banner; /* -q switch (inverted) */ int inspect_main; /* -i switch, PYTHONINSPECT */ - } Py_Config; + } PyConfig; /* Struct initialization is pretty ugly in C89. Avoiding this mess would * be the most attractive aspect of using a PyDictObject* instead... */ - #define _Py_ArgConfig_INIT NULL, NULL, NULL, NULL - #define _Py_LocationConfig_INIT NULL, NULL, NULL, NULL, NULL, NULL - #define _Py_SiteConfig_INIT -1, -1 - #define _Py_ImportConfig_INIT -1, -1, NULL - #define _Py_StreamConfig_INIT -1, NULL, NULL, NULL, NULL, NULL, NULL - #define _Py_FilesystemConfig_INIT NULL - #define _Py_DebuggingConfig_INIT -1, -1, -1 - #define _Py_CodeGenConfig_INIT -1, -1 - #define _Py_SignalConfig_INIT -1 - #define _Py_ImplicitConfig_INIT NULL - #define _Py_MainConfig_INIT -1, NULL, NULL, NULL, NULL, NULL, -1 - #define _Py_InteractiveConfig_INIT NULL, -1, -1 + #define _PyArgConfig_INIT NULL, NULL, NULL, NULL + #define _PyLocationConfig_INIT NULL, NULL, NULL, NULL, NULL, NULL + #define _PySiteConfig_INIT -1, -1 + #define _PyImportConfig_INIT -1, -1, NULL + #define _PyStreamConfig_INIT -1, NULL, NULL, NULL, NULL, NULL, NULL + #define _PyFilesystemConfig_INIT NULL + #define _PyDebuggingConfig_INIT -1, -1, -1 + #define _PyCodeGenConfig_INIT -1, -1 + #define _PySignalConfig_INIT -1 + #define _PyImplicitConfig_INIT NULL + #define _PyMainConfig_INIT -1, NULL, NULL, NULL, NULL, NULL, -1 + #define _PyInteractiveConfig_INIT NULL, -1, -1 - #define Py_Config_INIT {_Py_ArgConfig_INIT, _Py_LocationConfig_INIT, - _Py_SiteConfig_INIT, _Py_ImportConfig_INIT, - _Py_StreamConfig_INIT, _Py_FilesystemConfig_INIT, - _Py_DebuggingConfig_INIT, _Py_CodeGenConfig_INIT, - _Py_SignalConfig_INIT, _Py_ImplicitConfig_INIT, - _Py_MainConfig_INIT, _Py_InteractiveConfig_INIT} + #define PyConfig_INIT {_PyArgConfig_INIT, _PyLocationConfig_INIT, + _PySiteConfig_INIT, _PyImportConfig_INIT, + _PyStreamConfig_INIT, _PyFilesystemConfig_INIT, + _PyDebuggingConfig_INIT, _PyCodeGenConfig_INIT, + _PySignalConfig_INIT, _PyImplicitConfig_INIT, + _PyMainConfig_INIT, _PyInteractiveConfig_INIT} @@ -646,14 +651,14 @@ configuration settings into effect and finish bootstrapping the interpreter up to full operation:: - int Py_EndInitialization(const Py_Config *config); + int Py_EndInitialization(const PyConfig *config); Like Py_ReadConfiguration, this call will raise an exception and report an error return rather than exhibiting fatal errors if a problem is found with the config data. All configuration settings are required - the configuration struct -should always be passed through ``Py_ReadConfiguration()`` to ensure it +should always be passed through ``Py_ReadConfig()`` to ensure it is fully populated. After a successful call, ``Py_IsInitializing()`` will be false, while @@ -792,7 +797,7 @@ The interpreter state will be updated to include details of the configuration settings supplied during initialization by extending the interpreter state -object with an embedded copy of the ``Py_CoreConfig`` and ``Py_Config`` +object with an embedded copy of the ``PyCoreConfig`` and ``PyConfig`` structs. For debugging purposes, the configuration settings will be exposed as @@ -834,7 +839,7 @@ ----------------------- Backwards compatibility will be preserved primarily by ensuring that -``Py_ReadConfiguration()`` interrogates all the previously defined +``Py_ReadConfig()`` interrogates all the previously defined configuration settings stored in global variables and environment variables, and that ``Py_EndInitialization()`` writes affected settings back to the relevant locations. @@ -911,14 +916,14 @@ * Should there be ``Py_PreparingMain()`` and ``Py_RunningMain()`` query APIs? * Should the answer to ``Py_IsInitialized()`` be exposed via the ``sys`` module? -* Is initialisation of the ``Py_Config`` struct too unwieldy to be +* Is initialisation of the ``PyConfig`` struct too unwieldy to be maintainable? Would a Python dictionary be a better choice, despite being harder to work with from C code? -* Would it be better to manage the flag variables in ``Py_Config`` as +* Would it be better to manage the flag variables in ``PyConfig`` as Python integers or as "negative means false, positive means true, zero means not set" so the struct can be initialized with a simple ``memset(&config, 0, sizeof(*config))``, eliminating the need to update - both Py_Config and Py_Config_INIT when adding new fields? + both PyConfig and PyConfig_INIT when adding new fields? * The name of the new system Python executable is a bikeshed waiting to be painted. The 3 options considered so far are ``spython``, ``pysystem`` and ``python-minimal``. The PEP text reflects my current preferred choice -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Tue Jan 15 14:14:43 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 14:14:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzEwNTI3?= =?utf-8?q?=3A_Remove_dead_code?= Message-ID: <3YlsTb0WwZzP57@mail.python.org> http://hg.python.org/cpython/rev/f07435fa6736 changeset: 81513:f07435fa6736 branch: 2.7 parent: 81506:da5e520a7ba5 user: Richard Oudkerk date: Tue Jan 15 13:13:35 2013 +0000 summary: Issue #10527: Remove dead code files: Lib/multiprocessing/connection.py | 23 ------------------- 1 files changed, 0 insertions(+), 23 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -41,7 +41,6 @@ import time import tempfile import itertools -import select import _multiprocessing from multiprocessing import current_process, AuthenticationError @@ -201,28 +200,6 @@ return c1, c2 else: - if hasattr(select, 'poll'): - def _poll(fds, timeout): - if timeout is not None: - timeout = int(timeout) * 1000 # timeout is in milliseconds - fd_map = {} - pollster = select.poll() - for fd in fds: - pollster.register(fd, select.POLLIN) - if hasattr(fd, 'fileno'): - fd_map[fd.fileno()] = fd - else: - fd_map[fd] = fd - ls = [] - for fd, event in pollster.poll(timeout): - if event & select.POLLNVAL: - raise ValueError('invalid file descriptor %i' % fd) - ls.append(fd_map[fd]) - return ls - else: - def _poll(fds, timeout): - return select.select(fds, [], [], timeout)[0] - from _multiprocessing import win32 def Pipe(duplex=True): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:24:38 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 14:24:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEwNTI3?= =?utf-8?q?=3A_Remove_dead_code?= Message-ID: <3Ylsj24d1CzPCZ@mail.python.org> http://hg.python.org/cpython/rev/49d45151b9ed changeset: 81514:49d45151b9ed branch: 3.2 parent: 81507:abf111b9a464 user: Richard Oudkerk date: Tue Jan 15 13:19:24 2013 +0000 summary: Issue #10527: Remove dead code files: Lib/multiprocessing/connection.py | 23 ------------------- 1 files changed, 0 insertions(+), 23 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -41,7 +41,6 @@ import time import tempfile import itertools -import select import _multiprocessing from multiprocessing import current_process, AuthenticationError @@ -214,28 +213,6 @@ return c1, c2 else: - if hasattr(select, 'poll'): - def _poll(fds, timeout): - if timeout is not None: - timeout = int(timeout) * 1000 # timeout is in milliseconds - fd_map = {} - pollster = select.poll() - for fd in fds: - pollster.register(fd, select.POLLIN) - if hasattr(fd, 'fileno'): - fd_map[fd.fileno()] = fd - else: - fd_map[fd] = fd - ls = [] - for fd, event in pollster.poll(timeout): - if event & select.POLLNVAL: - raise ValueError('invalid file descriptor %i' % fd) - ls.append(fd_map[fd]) - return ls - else: - def _poll(fds, timeout): - return select.select(fds, [], [], timeout)[0] - from _multiprocessing import win32 def Pipe(duplex=True): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:24:40 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 14:24:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge?= Message-ID: <3Ylsj401MYzPCZ@mail.python.org> http://hg.python.org/cpython/rev/44d35f578f0c changeset: 81515:44d35f578f0c branch: 3.3 parent: 81511:ad9b5c69b8b6 parent: 81514:49d45151b9ed user: Richard Oudkerk date: Tue Jan 15 13:22:34 2013 +0000 summary: Merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:24:41 2013 From: python-checkins at python.org (richard.oudkerk) Date: Tue, 15 Jan 2013 14:24:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge?= Message-ID: <3Ylsj533mPzPNV@mail.python.org> http://hg.python.org/cpython/rev/2ba6fa21303d changeset: 81516:2ba6fa21303d parent: 81512:1f66fc397c8d parent: 81515:44d35f578f0c user: Richard Oudkerk date: Tue Jan 15 13:23:32 2013 +0000 summary: Merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:39:59 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:39:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE0ODUw?= =?utf-8?q?=3A_Now_a_chamap_decoder_treates_U+FFFE_as_=22undefined_mapping?= =?utf-8?q?=22?= Message-ID: <3Ylt2l5dDdzNlw@mail.python.org> http://hg.python.org/cpython/rev/33a8ef498b1e changeset: 81517:33a8ef498b1e branch: 2.7 parent: 81506:da5e520a7ba5 user: Serhiy Storchaka date: Tue Jan 15 14:42:59 2013 +0200 summary: Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" in any mapping, not only in an unicode string. files: Lib/test/test_codecs.py | 56 ++++++++++++++++++++++++++-- Misc/NEWS | 3 + Objects/unicodeobject.c | 46 ++++++++++++---------- 3 files changed, 79 insertions(+), 26 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1551,6 +1551,14 @@ (u"abc", 3) ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", u"ab" + ) + + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, "\x00\x01\x02", "strict", u"ab\ufffe" + ) + self.assertEqual( codecs.charmap_decode("\x00\x01\x02", "replace", u"ab"), (u"ab\ufffd", 3) @@ -1566,10 +1574,6 @@ (u"ab", 3) ) - self.assertRaises(UnicodeDecodeError, - codecs.charmap_decode, b"\x00\x01\x02", "strict", u"ab" - ) - self.assertEqual( codecs.charmap_decode("\x00\x01\x02", "ignore", u"ab\ufffe"), (u"ab", 3) @@ -1611,6 +1615,17 @@ {0: u'a', 1: u'b'} ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, "\x00\x01\x02", "strict", + {0: u'a', 1: u'b', 2: None} + ) + + # Issue #14850 + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, "\x00\x01\x02", "strict", + {0: u'a', 1: u'b', 2: u'\ufffe'} + ) + self.assertEqual( codecs.charmap_decode("\x00\x01\x02", "replace", {0: u'a', 1: u'b'}), @@ -1623,6 +1638,13 @@ (u"ab\ufffd", 3) ) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode("\x00\x01\x02", "replace", + {0: u'a', 1: u'b', 2: u'\ufffe'}), + (u"ab\ufffd", 3) + ) + self.assertEqual( codecs.charmap_decode("\x00\x01\x02", "ignore", {0: u'a', 1: u'b'}), @@ -1635,7 +1657,14 @@ (u"ab", 3) ) - allbytes = bytes(range(256)) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode("\x00\x01\x02", "ignore", + {0: u'a', 1: u'b', 2: u'\ufffe'}), + (u"ab", 3) + ) + + allbytes = "".join(chr(i) for i in xrange(256)) self.assertEqual( codecs.charmap_decode(allbytes, "ignore", {}), (u"", len(allbytes)) @@ -1669,6 +1698,11 @@ {0: a, 1: b}, ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, "\x00\x01\x02", "strict", + {0: a, 1: b, 2: 0xFFFE}, + ) + self.assertEqual( codecs.charmap_decode("\x00\x01\x02", "replace", {0: a, 1: b}), @@ -1676,11 +1710,23 @@ ) self.assertEqual( + codecs.charmap_decode("\x00\x01\x02", "replace", + {0: a, 1: b, 2: 0xFFFE}), + (u"ab\ufffd", 3) + ) + + self.assertEqual( codecs.charmap_decode("\x00\x01\x02", "ignore", {0: a, 1: b}), (u"ab", 3) ) + self.assertEqual( + codecs.charmap_decode("\x00\x01\x02", "ignore", + {0: a, 1: b, 2: 0xFFFE}), + (u"ab", 3) + ) + class WithStmtTest(unittest.TestCase): def test_encodedfile(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,9 @@ Core and Builtins ----------------- +- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" + in any mapping, not only in an unicode string. + - Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4121,15 +4121,18 @@ if (PyErr_ExceptionMatches(PyExc_LookupError)) { /* No mapping found means: mapping is undefined. */ PyErr_Clear(); - x = Py_None; - Py_INCREF(x); + goto Undefined; } else goto onError; } /* Apply mapping */ + if (x == Py_None) + goto Undefined; if (PyInt_Check(x)) { long value = PyInt_AS_LONG(x); + if (value == 0xFFFE) + goto Undefined; if (value < 0 || value > 0x10FFFF) { PyErr_SetString(PyExc_TypeError, "character mapping must be in range(0x110000)"); @@ -4162,29 +4165,16 @@ #endif *p++ = (Py_UNICODE)value; } - else if (x == Py_None) { - /* undefined mapping */ - outpos = p-PyUnicode_AS_UNICODE(v); - startinpos = s-starts; - endinpos = startinpos+1; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "charmap", "character maps to ", - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) { - Py_DECREF(x); - goto onError; - } - Py_DECREF(x); - continue; - } else if (PyUnicode_Check(x)) { Py_ssize_t targetsize = PyUnicode_GET_SIZE(x); - if (targetsize == 1) + if (targetsize == 1) { /* 1-1 mapping */ - *p++ = *PyUnicode_AS_UNICODE(x); - + Py_UNICODE value = *PyUnicode_AS_UNICODE(x); + if (value == 0xFFFE) + goto Undefined; + *p++ = value; + } else if (targetsize > 1) { /* 1-n mapping */ if (targetsize > extrachars) { @@ -4218,6 +4208,20 @@ } Py_DECREF(x); ++s; + continue; +Undefined: + /* undefined mapping */ + Py_XDECREF(x); + outpos = p-PyUnicode_AS_UNICODE(v); + startinpos = s-starts; + endinpos = startinpos+1; + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "charmap", "character maps to ", + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) { + goto onError; + } } } if (p - PyUnicode_AS_UNICODE(v) < PyUnicode_GET_SIZE(v)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:01 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE0ODUw?= =?utf-8?q?=3A_Now_a_chamap_decoder_treates_U+FFFE_as_=22undefined_mapping?= =?utf-8?q?=22?= Message-ID: <3Ylt2n35H6zPNG@mail.python.org> http://hg.python.org/cpython/rev/13cd78a2a17b changeset: 81518:13cd78a2a17b branch: 3.2 parent: 81507:abf111b9a464 user: Serhiy Storchaka date: Tue Jan 15 14:43:21 2013 +0200 summary: Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" in any mapping, not only in an unicode string. files: Lib/test/test_codecs.py | 46 +++++++++++++++++++++++++++++ Misc/NEWS | 3 + Objects/unicodeobject.c | 46 +++++++++++++++------------- 3 files changed, 74 insertions(+), 21 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1586,6 +1586,10 @@ codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab" ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab\ufffe" + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab"), ("ab\ufffd", 3) @@ -1642,6 +1646,17 @@ {0: 'a', 1: 'b'} ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: 'a', 1: 'b', 2: None} + ) + + # Issue #14850 + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: 'a', 1: 'b', 2: '\ufffe'} + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: 'a', 1: 'b'}), @@ -1654,6 +1669,13 @@ ("ab\ufffd", 3) ) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "replace", + {0: 'a', 1: 'b', 2: '\ufffe'}), + ("ab\ufffd", 3) + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: 'a', 1: 'b'}), @@ -1666,6 +1688,13 @@ ("ab", 3) ) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "ignore", + {0: 'a', 1: 'b', 2: '\ufffe'}), + ("ab", 3) + ) + allbytes = bytes(range(256)) self.assertEqual( codecs.charmap_decode(allbytes, "ignore", {}), @@ -1700,6 +1729,11 @@ {0: a, 1: b}, ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: a, 1: b, 2: 0xFFFE}, + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: a, 1: b}), @@ -1707,11 +1741,23 @@ ) self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "replace", + {0: a, 1: b, 2: 0xFFFE}), + ("ab\ufffd", 3) + ) + + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: a, 1: b}), ("ab", 3) ) + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "ignore", + {0: a, 1: b, 2: 0xFFFE}), + ("ab", 3) + ) + class WithStmtTest(unittest.TestCase): def test_encodedfile(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" + in any mapping, not only in a string. + - Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5245,15 +5245,18 @@ if (PyErr_ExceptionMatches(PyExc_LookupError)) { /* No mapping found means: mapping is undefined. */ PyErr_Clear(); - x = Py_None; - Py_INCREF(x); + goto Undefined; } else goto onError; } /* Apply mapping */ + if (x == Py_None) + goto Undefined; if (PyLong_Check(x)) { long value = PyLong_AS_LONG(x); + if (value == 0xFFFE) + goto Undefined; if (value < 0 || value > 0x10FFFF) { PyErr_SetString(PyExc_TypeError, "character mapping must be in range(0x110000)"); @@ -5286,29 +5289,16 @@ #endif *p++ = (Py_UNICODE)value; } - else if (x == Py_None) { - /* undefined mapping */ - outpos = p-PyUnicode_AS_UNICODE(v); - startinpos = s-starts; - endinpos = startinpos+1; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "charmap", "character maps to ", - &starts, &e, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) { - Py_DECREF(x); - goto onError; - } - Py_DECREF(x); - continue; - } else if (PyUnicode_Check(x)) { Py_ssize_t targetsize = PyUnicode_GET_SIZE(x); - if (targetsize == 1) + if (targetsize == 1) { /* 1-1 mapping */ - *p++ = *PyUnicode_AS_UNICODE(x); - + Py_UNICODE value = *PyUnicode_AS_UNICODE(x); + if (value == 0xFFFE) + goto Undefined; + *p++ = value; + } else if (targetsize > 1) { /* 1-n mapping */ if (targetsize > extrachars) { @@ -5342,6 +5332,20 @@ } Py_DECREF(x); ++s; + continue; +Undefined: + /* undefined mapping */ + Py_XDECREF(x); + outpos = p-PyUnicode_AS_UNICODE(v); + startinpos = s-starts; + endinpos = startinpos+1; + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "charmap", "character maps to ", + &starts, &e, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) { + goto onError; + } } } if (p - PyUnicode_AS_UNICODE(v) < PyUnicode_GET_SIZE(v)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:03 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2314850=3A_Now_a_chamap_decoder_treates_U+FFFE_as_=22un?= =?utf-8?q?defined_mapping=22?= Message-ID: <3Ylt2q0RyhzPRW@mail.python.org> http://hg.python.org/cpython/rev/6ac4f1609847 changeset: 81519:6ac4f1609847 branch: 3.3 parent: 81511:ad9b5c69b8b6 parent: 81518:13cd78a2a17b user: Serhiy Storchaka date: Tue Jan 15 15:01:20 2013 +0200 summary: Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" in any mapping, not only in an unicode string. files: Lib/test/test_codecs.py | 46 +++++++++++++++++++++++++++++ Misc/NEWS | 3 + Objects/unicodeobject.c | 41 +++++++++++++----------- 3 files changed, 71 insertions(+), 19 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1737,6 +1737,10 @@ codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab" ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab\ufffe" + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab"), ("ab\ufffd", 3) @@ -1793,6 +1797,17 @@ {0: 'a', 1: 'b'} ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: 'a', 1: 'b', 2: None} + ) + + # Issue #14850 + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: 'a', 1: 'b', 2: '\ufffe'} + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: 'a', 1: 'b'}), @@ -1805,6 +1820,13 @@ ("ab\ufffd", 3) ) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "replace", + {0: 'a', 1: 'b', 2: '\ufffe'}), + ("ab\ufffd", 3) + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: 'a', 1: 'b'}), @@ -1817,6 +1839,13 @@ ("ab", 3) ) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "ignore", + {0: 'a', 1: 'b', 2: '\ufffe'}), + ("ab", 3) + ) + allbytes = bytes(range(256)) self.assertEqual( codecs.charmap_decode(allbytes, "ignore", {}), @@ -1857,6 +1886,11 @@ {0: a, 1: b}, ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: a, 1: b, 2: 0xFFFE}, + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: a, 1: b}), @@ -1864,11 +1898,23 @@ ) self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "replace", + {0: a, 1: b, 2: 0xFFFE}), + ("ab\ufffd", 3) + ) + + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: a, 1: b}), ("ab", 3) ) + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "ignore", + {0: a, 1: b, 2: 0xFFFE}), + ("ab", 3) + ) + class WithStmtTest(unittest.TestCase): def test_encodedfile(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" + in any mapping, not only in a string. + - Issue #16730: importlib.machinery.FileFinder now no longers raises an exception when trying to populate its cache and it finds out the directory is unreadable or has turned into a file. Reported and diagnosed by diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -7511,15 +7511,18 @@ if (PyErr_ExceptionMatches(PyExc_LookupError)) { /* No mapping found means: mapping is undefined. */ PyErr_Clear(); - x = Py_None; - Py_INCREF(x); + goto Undefined; } else goto onError; } /* Apply mapping */ + if (x == Py_None) + goto Undefined; if (PyLong_Check(x)) { long value = PyLong_AS_LONG(x); + if (value == 0xFFFE) + goto Undefined; if (value < 0 || value > MAX_UNICODE) { PyErr_Format(PyExc_TypeError, "character mapping must be in range(0x%lx)", @@ -7530,21 +7533,6 @@ if (unicode_putchar(&v, &outpos, value) < 0) goto onError; } - else if (x == Py_None) { - /* undefined mapping */ - startinpos = s-starts; - endinpos = startinpos+1; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "charmap", "character maps to ", - &starts, &e, &startinpos, &endinpos, &exc, &s, - &v, &outpos)) { - Py_DECREF(x); - goto onError; - } - Py_DECREF(x); - continue; - } else if (PyUnicode_Check(x)) { Py_ssize_t targetsize; @@ -7554,8 +7542,10 @@ if (targetsize == 1) { /* 1-1 mapping */ - if (unicode_putchar(&v, &outpos, - PyUnicode_READ_CHAR(x, 0)) < 0) + Py_UCS4 value = PyUnicode_READ_CHAR(x, 0); + if (value == 0xFFFE) + goto Undefined; + if (unicode_putchar(&v, &outpos, value) < 0) goto onError; } else if (targetsize > 1) { @@ -7590,6 +7580,19 @@ } Py_DECREF(x); ++s; + continue; +Undefined: + /* undefined mapping */ + Py_XDECREF(x); + startinpos = s-starts; + endinpos = startinpos+1; + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "charmap", "character maps to ", + &starts, &e, &startinpos, &endinpos, &exc, &s, + &v, &outpos)) { + goto onError; + } } } if (unicode_resize(&v, outpos) < 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:04 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2314850=3A_Now_a_chamap_decoder_treates_U+FFFE_as?= =?utf-8?q?_=22undefined_mapping=22?= Message-ID: <3Ylt2r4gZ6zPWC@mail.python.org> http://hg.python.org/cpython/rev/03e22cc9407a changeset: 81520:03e22cc9407a parent: 81512:1f66fc397c8d parent: 81519:6ac4f1609847 user: Serhiy Storchaka date: Tue Jan 15 15:30:04 2013 +0200 summary: Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" in any mapping, not only in an unicode string. files: Lib/test/test_codecs.py | 46 +++++++++++++++++++++++++ Misc/NEWS | 3 + Objects/unicodeobject.c | 52 ++++++++++++++++++---------- 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1737,6 +1737,10 @@ codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab" ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab\ufffe" + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab"), ("ab\ufffd", 3) @@ -1793,6 +1797,17 @@ {0: 'a', 1: 'b'} ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: 'a', 1: 'b', 2: None} + ) + + # Issue #14850 + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: 'a', 1: 'b', 2: '\ufffe'} + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: 'a', 1: 'b'}), @@ -1805,6 +1820,13 @@ ("ab\ufffd", 3) ) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "replace", + {0: 'a', 1: 'b', 2: '\ufffe'}), + ("ab\ufffd", 3) + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: 'a', 1: 'b'}), @@ -1817,6 +1839,13 @@ ("ab", 3) ) + # Issue #14850 + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "ignore", + {0: 'a', 1: 'b', 2: '\ufffe'}), + ("ab", 3) + ) + allbytes = bytes(range(256)) self.assertEqual( codecs.charmap_decode(allbytes, "ignore", {}), @@ -1857,6 +1886,11 @@ {0: a, 1: b}, ) + self.assertRaises(UnicodeDecodeError, + codecs.charmap_decode, b"\x00\x01\x02", "strict", + {0: a, 1: b, 2: 0xFFFE}, + ) + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", {0: a, 1: b}), @@ -1864,11 +1898,23 @@ ) self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "replace", + {0: a, 1: b, 2: 0xFFFE}), + ("ab\ufffd", 3) + ) + + self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "ignore", {0: a, 1: b}), ("ab", 3) ) + self.assertEqual( + codecs.charmap_decode(b"\x00\x01\x02", "ignore", + {0: a, 1: b, 2: 0xFFFE}), + ("ab", 3) + ) + class WithStmtTest(unittest.TestCase): def test_encodedfile(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" + in any mapping, not only in a string. + - Issue #16730: importlib.machinery.FileFinder now no longers raises an exception when trying to populate its cache and it finds out the directory is unreadable or has turned into a file. Reported and diagnosed by diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -7393,15 +7393,18 @@ if (PyErr_ExceptionMatches(PyExc_LookupError)) { /* No mapping found means: mapping is undefined. */ PyErr_Clear(); - x = Py_None; - Py_INCREF(x); + goto Undefined; } else goto onError; } /* Apply mapping */ + if (x == Py_None) + goto Undefined; if (PyLong_Check(x)) { long value = PyLong_AS_LONG(x); + if (value == 0xFFFE) + goto Undefined; if (value < 0 || value > MAX_UNICODE) { PyErr_Format(PyExc_TypeError, "character mapping must be in range(0x%lx)", @@ -7415,25 +7418,23 @@ PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); writer.pos++; } - else if (x == Py_None) { - /* undefined mapping */ - startinpos = s-starts; - endinpos = startinpos+1; - if (unicode_decode_call_errorhandler_writer( - errors, &errorHandler, - "charmap", "character maps to ", - &starts, &e, &startinpos, &endinpos, &exc, &s, - &writer)) { - Py_DECREF(x); + else if (PyUnicode_Check(x)) { + if (PyUnicode_READY(x) == -1) goto onError; + if (PyUnicode_GET_LENGTH(x) == 1) { + Py_UCS4 value = PyUnicode_READ_CHAR(x, 0); + if (value == 0xFFFE) + goto Undefined; + if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) + goto onError; + PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); + writer.pos++; } - Py_DECREF(x); - continue; - } - else if (PyUnicode_Check(x)) { - writer.overallocate = 1; - if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) - goto onError; + else { + writer.overallocate = 1; + if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) + goto onError; + } } else { /* wrong return value */ @@ -7444,6 +7445,19 @@ } Py_DECREF(x); ++s; + continue; +Undefined: + /* undefined mapping */ + Py_XDECREF(x); + startinpos = s-starts; + endinpos = startinpos+1; + if (unicode_decode_call_errorhandler_writer( + errors, &errorHandler, + "charmap", "character maps to ", + &starts, &e, &startinpos, &endinpos, &exc, &s, + &writer)) { + goto onError; + } } } Py_XDECREF(errorHandler); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:06 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3Ylt2t0bMPzQSc@mail.python.org> http://hg.python.org/cpython/rev/2e1f1b096f3d changeset: 81521:2e1f1b096f3d branch: 2.7 parent: 81517:33a8ef498b1e parent: 81513:f07435fa6736 user: Serhiy Storchaka date: Tue Jan 15 15:32:49 2013 +0200 summary: Merge heads files: Lib/multiprocessing/connection.py | 23 ------------------- 1 files changed, 0 insertions(+), 23 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -41,7 +41,6 @@ import time import tempfile import itertools -import select import _multiprocessing from multiprocessing import current_process, AuthenticationError @@ -201,28 +200,6 @@ return c1, c2 else: - if hasattr(select, 'poll'): - def _poll(fds, timeout): - if timeout is not None: - timeout = int(timeout) * 1000 # timeout is in milliseconds - fd_map = {} - pollster = select.poll() - for fd in fds: - pollster.register(fd, select.POLLIN) - if hasattr(fd, 'fileno'): - fd_map[fd.fileno()] = fd - else: - fd_map[fd] = fd - ls = [] - for fd, event in pollster.poll(timeout): - if event & select.POLLNVAL: - raise ValueError('invalid file descriptor %i' % fd) - ls.append(fd_map[fd]) - return ls - else: - def _poll(fds, timeout): - return select.select(fds, [], [], timeout)[0] - from _multiprocessing import win32 def Pipe(duplex=True): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:07 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMik6?= =?utf-8?q?_Merge_heads?= Message-ID: <3Ylt2v3HfqzPXW@mail.python.org> http://hg.python.org/cpython/rev/2ededf960837 changeset: 81522:2ededf960837 branch: 3.2 parent: 81518:13cd78a2a17b parent: 81514:49d45151b9ed user: Serhiy Storchaka date: Tue Jan 15 15:32:59 2013 +0200 summary: Merge heads files: Lib/multiprocessing/connection.py | 23 ------------------- 1 files changed, 0 insertions(+), 23 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -41,7 +41,6 @@ import time import tempfile import itertools -import select import _multiprocessing from multiprocessing import current_process, AuthenticationError @@ -214,28 +213,6 @@ return c1, c2 else: - if hasattr(select, 'poll'): - def _poll(fds, timeout): - if timeout is not None: - timeout = int(timeout) * 1000 # timeout is in milliseconds - fd_map = {} - pollster = select.poll() - for fd in fds: - pollster.register(fd, select.POLLIN) - if hasattr(fd, 'fileno'): - fd_map[fd.fileno()] = fd - else: - fd_map[fd] = fd - ls = [] - for fd, event in pollster.poll(timeout): - if event & select.POLLNVAL: - raise ValueError('invalid file descriptor %i' % fd) - ls.append(fd_map[fd]) - return ls - else: - def _poll(fds, timeout): - return select.select(fds, [], [], timeout)[0] - from _multiprocessing import win32 def Pipe(duplex=True): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:08 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:08 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3Ylt2w5shdzPSS@mail.python.org> http://hg.python.org/cpython/rev/eb45c92e415a changeset: 81523:eb45c92e415a branch: 3.3 parent: 81519:6ac4f1609847 parent: 81515:44d35f578f0c user: Serhiy Storchaka date: Tue Jan 15 15:33:09 2013 +0200 summary: Merge heads files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge_heads?= Message-ID: <3Ylt2y1JQ9zPqf@mail.python.org> http://hg.python.org/cpython/rev/29c60517fa97 changeset: 81524:29c60517fa97 parent: 81520:03e22cc9407a parent: 81516:2ba6fa21303d user: Serhiy Storchaka date: Tue Jan 15 15:33:18 2013 +0200 summary: Merge heads files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:11 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null_merge?= Message-ID: <3Ylt2z4yK6zPNV@mail.python.org> http://hg.python.org/cpython/rev/1fea46c6a012 changeset: 81525:1fea46c6a012 branch: 3.3 parent: 81523:eb45c92e415a parent: 81522:2ededf960837 user: Serhiy Storchaka date: Tue Jan 15 15:33:52 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 14:40:13 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 14:40:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3Ylt310TgrzPLs@mail.python.org> http://hg.python.org/cpython/rev/fb17969ace93 changeset: 81526:fb17969ace93 parent: 81524:29c60517fa97 parent: 81525:1fea46c6a012 user: Serhiy Storchaka date: Tue Jan 15 15:34:08 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 17:04:36 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 17:04:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE1ODYx?= =?utf-8?q?=3A_tkinter_now_correctly_works_with_lists_and_tuples_containin?= =?utf-8?q?g?= Message-ID: <3YlxFc62RxzP6n@mail.python.org> http://hg.python.org/cpython/rev/411bb75be5d1 changeset: 81527:411bb75be5d1 branch: 3.2 parent: 81522:2ededf960837 user: Serhiy Storchaka date: Tue Jan 15 17:56:08 2013 +0200 summary: Issue #15861: tkinter now correctly works with lists and tuples containing strings with whitespaces, backslashes or unbalanced braces. files: Lib/tkinter/__init__.py | 31 ++- Lib/tkinter/test/test_ttk/test_functions.py | 40 ++- Lib/tkinter/test/test_ttk/test_widgets.py | 8 + Lib/tkinter/ttk.py | 122 +++------ Misc/NEWS | 3 + 5 files changed, 123 insertions(+), 81 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -39,6 +39,7 @@ import _tkinter # If this fails your Python may not be configured for Tk TclError = _tkinter.TclError from tkinter.constants import * +import re wantobjects = 1 @@ -50,6 +51,34 @@ EXCEPTION = _tkinter.EXCEPTION +_magic_re = re.compile(r'([\\{}])') +_space_re = re.compile(r'([\s])', re.ASCII) + +def _join(value): + """Internal function.""" + return ' '.join(map(_stringify, value)) + +def _stringify(value): + """Internal function.""" + if isinstance(value, (list, tuple)): + if len(value) == 1: + value = _stringify(value[0]) + if value[0] == '{': + value = '{%s}' % value + else: + value = '{%s}' % _join(value) + else: + value = str(value) + if not value: + value = '{}' + elif _magic_re.search(value): + # add '\' before special characters and spaces + value = _magic_re.sub(r'\\\1', value) + value = _space_re.sub(r'\\\1', value) + elif value[0] == '"' or _space_re.search(value): + value = '{%s}' % value + return value + def _flatten(seq): """Internal function.""" res = () @@ -1075,7 +1104,7 @@ if isinstance(item, int): nv.append(str(item)) elif isinstance(item, str): - nv.append(('{%s}' if ' ' in item else '%s') % item) + nv.append(_stringify(item)) else: break else: diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py --- a/Lib/tkinter/test/test_ttk/test_functions.py +++ b/Lib/tkinter/test/test_ttk/test_functions.py @@ -49,13 +49,17 @@ ttk._format_optdict({'test': {'left': 'as is'}}), {'-test': {'left': 'as is'}}) - # check script formatting and untouched value(s) + # check script formatting check_against( ttk._format_optdict( - {'test': [1, -1, '', '2m', 0], 'nochange1': 3, - 'nochange2': 'abc def'}, script=True), - {'-test': '{1 -1 {} 2m 0}', '-nochange1': 3, - '-nochange2': 'abc def' }) + {'test': [1, -1, '', '2m', 0], 'test2': 3, + 'test3': '', 'test4': 'abc def', + 'test5': '"abc"', 'test6': '{}', + 'test7': '} -spam {'}, script=True), + {'-test': '{1 -1 {} 2m 0}', '-test2': '3', + '-test3': '{}', '-test4': '{abc def}', + '-test5': '{"abc"}', '-test6': r'\{\}', + '-test7': r'\}\ -spam\ \{'}) opts = {'???': True, '?': False} orig_opts = opts.copy() @@ -69,6 +73,32 @@ ttk._format_optdict( {'option': ('one two', 'three')}), {'-option': '{one two} three'}) + check_against( + ttk._format_optdict( + {'option': ('one\ttwo', 'three')}), + {'-option': '{one\ttwo} three'}) + + # passing empty strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('', 'one')}), + {'-option': '{} one'}) + + # passing values with braces inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('one} {two', 'three')}), + {'-option': r'one\}\ \{two three'}) + + # passing quoted strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('"one"', 'two')}), + {'-option': '{"one"} two'}) + check_against( + ttk._format_optdict( + {'option': ('{one}', 'two')}), + {'-option': r'\{one\} two'}) # ignore an option amount_opts = len(ttk._format_optdict(opts, ignore=('?'))) / 2 diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py --- a/Lib/tkinter/test/test_ttk/test_widgets.py +++ b/Lib/tkinter/test/test_ttk/test_widgets.py @@ -189,6 +189,14 @@ self.combo.configure(values=[1, '', 2]) self.assertEqual(self.combo['values'], ('1', '', '2')) + # testing values with spaces + self.combo['values'] = ['a b', 'a\tb', 'a\nb'] + self.assertEqual(self.combo['values'], ('a b', 'a\tb', 'a\nb')) + + # testing values with special characters + self.combo['values'] = [r'a\tb', '"a"', '} {'] + self.assertEqual(self.combo['values'], (r'a\tb', '"a"', '} {')) + # out of range self.assertRaises(tkinter.TclError, self.combo.current, len(self.combo['values'])) diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -26,8 +26,7 @@ "tclobjs_to_py", "setup_master"] import tkinter - -_flatten = tkinter._flatten +from tkinter import _flatten, _join, _stringify # Verify if Tk is new enough to not need the Tile package _REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False @@ -47,39 +46,54 @@ master.tk.eval('package require tile') # TclError may be raised here master._tile_loaded = True +def _format_optvalue(value, script=False): + """Internal function.""" + if script: + # if caller passes a Tcl script to tk.call, all the values need to + # be grouped into words (arguments to a command in Tcl dialect) + value = _stringify(value) + elif isinstance(value, (list, tuple)): + value = _join(value) + return value + def _format_optdict(optdict, script=False, ignore=None): """Formats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')""" - format = "%s" if not script else "{%s}" opts = [] for opt, value in optdict.items(): - if ignore and opt in ignore: - continue + if not ignore or opt not in ignore: + opts.append("-%s" % opt) + if value is not None: + opts.append(_format_optvalue(value, script)) - if isinstance(value, (list, tuple)): - v = [] - for val in value: - if isinstance(val, str): - v.append(str(val) if val else '{}') - else: - v.append(str(val)) + return _flatten(opts) - # format v according to the script option, but also check for - # space in any value in v in order to group them correctly - value = format % ' '.join( - ('{%s}' if ' ' in val else '%s') % val for val in v) - - if script and value == '': - value = '{}' # empty string in Python is equivalent to {} in Tcl - - opts.append(("-%s" % opt, value)) - - # Remember: _flatten skips over None - return _flatten(opts) +def _mapdict_values(items): + # each value in mapdict is expected to be a sequence, where each item + # is another sequence containing a state (or several) and a value + # E.g. (script=False): + # [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])] + # returns: + # ['active selected', 'grey', 'focus', [1, 2, 3, 4]] + opt_val = [] + for *state, val in items: + # hacks for bakward compatibility + state[0] # raise IndexError if empty + if len(state) == 1: + # if it is empty (something that evaluates to False), then + # format it to Tcl code to denote the "normal" state + state = state[0] or '' + else: + # group multiple states + state = ' '.join(state) # raise TypeError if not str + opt_val.append(state) + if val is not None: + opt_val.append(val) + return opt_val def _format_mapdict(mapdict, script=False): """Formats mapdict to pass it to tk.call. @@ -90,32 +104,11 @@ returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')""" - # if caller passes a Tcl script to tk.call, all the values need to - # be grouped into words (arguments to a command in Tcl dialect) - format = "%s" if not script else "{%s}" opts = [] for opt, value in mapdict.items(): - - opt_val = [] - # each value in mapdict is expected to be a sequence, where each item - # is another sequence containing a state (or several) and a value - for statespec in value: - state, val = statespec[:-1], statespec[-1] - - if len(state) > 1: # group multiple states - state = "{%s}" % ' '.join(state) - else: # single state - # if it is empty (something that evaluates to False), then - # format it to Tcl code to denote the "normal" state - state = state[0] or '{}' - - if isinstance(val, (list, tuple)): # val needs to be grouped - val = "{%s}" % ' '.join(map(str, val)) - - opt_val.append("%s %s" % (state, val)) - - opts.append(("-%s" % opt, format % ' '.join(opt_val))) + opts.extend(("-%s" % opt, + _format_optvalue(_mapdict_values(value), script))) return _flatten(opts) @@ -129,7 +122,7 @@ iname = args[0] # next args, if any, are statespec/value pairs which is almost # a mapdict, but we just need the value - imagespec = _format_mapdict({None: args[1:]})[1] + imagespec = _join(_mapdict_values(args[1:])) spec = "%s %s" % (iname, imagespec) else: @@ -138,7 +131,7 @@ # themed styles on Windows XP and Vista. # Availability: Tk 8.6, Windows XP and Vista. class_name, part_id = args[:2] - statemap = _format_mapdict({None: args[2:]})[1] + statemap = _join(_mapdict_values(args[2:])) spec = "%s %s %s" % (class_name, part_id, statemap) opts = _format_optdict(kw, script) @@ -148,11 +141,11 @@ # otherwise it will clone {} (empty element) spec = args[0] # theme name if len(args) > 1: # elementfrom specified - opts = (args[1], ) + opts = (_format_optvalue(args[1], script),) if script: spec = '{%s}' % spec - opts = ' '.join(map(str, opts)) + opts = ' '.join(opts) return spec, opts @@ -189,7 +182,7 @@ for layout_elem in layout: elem, opts = layout_elem opts = opts or {} - fopts = ' '.join(map(str, _format_optdict(opts, True, "children"))) + fopts = ' '.join(_format_optdict(opts, True, ("children",))) head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '') if "children" in opts: @@ -215,11 +208,11 @@ for name, opts in settings.items(): # will format specific keys according to Tcl code if opts.get('configure'): # format 'configure' - s = ' '.join(map(str, _format_optdict(opts['configure'], True))) + s = ' '.join(_format_optdict(opts['configure'], True)) script.append("ttk::style configure %s %s;" % (name, s)) if opts.get('map'): # format 'map' - s = ' '.join(map(str, _format_mapdict(opts['map'], True))) + s = ' '.join(_format_mapdict(opts['map'], True)) script.append("ttk::style map %s %s;" % (name, s)) if 'layout' in opts: # format 'layout' which may be empty @@ -706,30 +699,9 @@ exportselection, justify, height, postcommand, state, textvariable, values, width """ - # The "values" option may need special formatting, so leave to - # _format_optdict the responsibility to format it - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - Entry.__init__(self, master, "ttk::combobox", **kw) - def __setitem__(self, item, value): - if item == "values": - value = _format_optdict({item: value})[1] - - Entry.__setitem__(self, item, value) - - - def configure(self, cnf=None, **kw): - """Custom Combobox configure, created to properly format the values - option.""" - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - - return Entry.configure(self, cnf, **kw) - - def current(self, newindex=None): """If newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,9 @@ Library ------- +- Issue #15861: tkinter now correctly works with lists and tuples containing + strings with whitespaces, backslashes or unbalanced braces. + - Issue #10527: Use poll() instead of select() for multiprocessing pipes. - Issue #9720: zipfile now writes correct local headers for files larger than -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 17:04:38 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 17:04:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2315861=3A_tkinter_now_correctly_works_with_lists_and_t?= =?utf-8?q?uples_containing?= Message-ID: <3YlxFf3g7KzR5B@mail.python.org> http://hg.python.org/cpython/rev/927352d7e994 changeset: 81528:927352d7e994 branch: 3.3 parent: 81525:1fea46c6a012 parent: 81527:411bb75be5d1 user: Serhiy Storchaka date: Tue Jan 15 17:58:14 2013 +0200 summary: Issue #15861: tkinter now correctly works with lists and tuples containing strings with whitespaces, backslashes or unbalanced braces. files: Lib/tkinter/__init__.py | 31 ++- Lib/tkinter/test/test_ttk/test_functions.py | 40 ++- Lib/tkinter/test/test_ttk/test_widgets.py | 8 + Lib/tkinter/ttk.py | 122 +++------ Misc/NEWS | 3 + 5 files changed, 123 insertions(+), 81 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -40,6 +40,7 @@ import _tkinter # If this fails your Python may not be configured for Tk TclError = _tkinter.TclError from tkinter.constants import * +import re wantobjects = 1 @@ -52,6 +53,34 @@ EXCEPTION = _tkinter.EXCEPTION +_magic_re = re.compile(r'([\\{}])') +_space_re = re.compile(r'([\s])', re.ASCII) + +def _join(value): + """Internal function.""" + return ' '.join(map(_stringify, value)) + +def _stringify(value): + """Internal function.""" + if isinstance(value, (list, tuple)): + if len(value) == 1: + value = _stringify(value[0]) + if value[0] == '{': + value = '{%s}' % value + else: + value = '{%s}' % _join(value) + else: + value = str(value) + if not value: + value = '{}' + elif _magic_re.search(value): + # add '\' before special characters and spaces + value = _magic_re.sub(r'\\\1', value) + value = _space_re.sub(r'\\\1', value) + elif value[0] == '"' or _space_re.search(value): + value = '{%s}' % value + return value + def _flatten(seq): """Internal function.""" res = () @@ -1089,7 +1118,7 @@ if isinstance(item, int): nv.append(str(item)) elif isinstance(item, str): - nv.append(('{%s}' if ' ' in item else '%s') % item) + nv.append(_stringify(item)) else: break else: diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py --- a/Lib/tkinter/test/test_ttk/test_functions.py +++ b/Lib/tkinter/test/test_ttk/test_functions.py @@ -49,13 +49,17 @@ ttk._format_optdict({'test': {'left': 'as is'}}), {'-test': {'left': 'as is'}}) - # check script formatting and untouched value(s) + # check script formatting check_against( ttk._format_optdict( - {'test': [1, -1, '', '2m', 0], 'nochange1': 3, - 'nochange2': 'abc def'}, script=True), - {'-test': '{1 -1 {} 2m 0}', '-nochange1': 3, - '-nochange2': 'abc def' }) + {'test': [1, -1, '', '2m', 0], 'test2': 3, + 'test3': '', 'test4': 'abc def', + 'test5': '"abc"', 'test6': '{}', + 'test7': '} -spam {'}, script=True), + {'-test': '{1 -1 {} 2m 0}', '-test2': '3', + '-test3': '{}', '-test4': '{abc def}', + '-test5': '{"abc"}', '-test6': r'\{\}', + '-test7': r'\}\ -spam\ \{'}) opts = {'???': True, '?': False} orig_opts = opts.copy() @@ -69,6 +73,32 @@ ttk._format_optdict( {'option': ('one two', 'three')}), {'-option': '{one two} three'}) + check_against( + ttk._format_optdict( + {'option': ('one\ttwo', 'three')}), + {'-option': '{one\ttwo} three'}) + + # passing empty strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('', 'one')}), + {'-option': '{} one'}) + + # passing values with braces inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('one} {two', 'three')}), + {'-option': r'one\}\ \{two three'}) + + # passing quoted strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('"one"', 'two')}), + {'-option': '{"one"} two'}) + check_against( + ttk._format_optdict( + {'option': ('{one}', 'two')}), + {'-option': r'\{one\} two'}) # ignore an option amount_opts = len(ttk._format_optdict(opts, ignore=('?'))) / 2 diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py --- a/Lib/tkinter/test/test_ttk/test_widgets.py +++ b/Lib/tkinter/test/test_ttk/test_widgets.py @@ -189,6 +189,14 @@ self.combo.configure(values=[1, '', 2]) self.assertEqual(self.combo['values'], ('1', '', '2')) + # testing values with spaces + self.combo['values'] = ['a b', 'a\tb', 'a\nb'] + self.assertEqual(self.combo['values'], ('a b', 'a\tb', 'a\nb')) + + # testing values with special characters + self.combo['values'] = [r'a\tb', '"a"', '} {'] + self.assertEqual(self.combo['values'], (r'a\tb', '"a"', '} {')) + # out of range self.assertRaises(tkinter.TclError, self.combo.current, len(self.combo['values'])) diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -26,8 +26,7 @@ "tclobjs_to_py", "setup_master"] import tkinter - -_flatten = tkinter._flatten +from tkinter import _flatten, _join, _stringify # Verify if Tk is new enough to not need the Tile package _REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False @@ -47,39 +46,54 @@ master.tk.eval('package require tile') # TclError may be raised here master._tile_loaded = True +def _format_optvalue(value, script=False): + """Internal function.""" + if script: + # if caller passes a Tcl script to tk.call, all the values need to + # be grouped into words (arguments to a command in Tcl dialect) + value = _stringify(value) + elif isinstance(value, (list, tuple)): + value = _join(value) + return value + def _format_optdict(optdict, script=False, ignore=None): """Formats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')""" - format = "%s" if not script else "{%s}" opts = [] for opt, value in optdict.items(): - if ignore and opt in ignore: - continue + if not ignore or opt not in ignore: + opts.append("-%s" % opt) + if value is not None: + opts.append(_format_optvalue(value, script)) - if isinstance(value, (list, tuple)): - v = [] - for val in value: - if isinstance(val, str): - v.append(str(val) if val else '{}') - else: - v.append(str(val)) + return _flatten(opts) - # format v according to the script option, but also check for - # space in any value in v in order to group them correctly - value = format % ' '.join( - ('{%s}' if ' ' in val else '%s') % val for val in v) - - if script and value == '': - value = '{}' # empty string in Python is equivalent to {} in Tcl - - opts.append(("-%s" % opt, value)) - - # Remember: _flatten skips over None - return _flatten(opts) +def _mapdict_values(items): + # each value in mapdict is expected to be a sequence, where each item + # is another sequence containing a state (or several) and a value + # E.g. (script=False): + # [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])] + # returns: + # ['active selected', 'grey', 'focus', [1, 2, 3, 4]] + opt_val = [] + for *state, val in items: + # hacks for bakward compatibility + state[0] # raise IndexError if empty + if len(state) == 1: + # if it is empty (something that evaluates to False), then + # format it to Tcl code to denote the "normal" state + state = state[0] or '' + else: + # group multiple states + state = ' '.join(state) # raise TypeError if not str + opt_val.append(state) + if val is not None: + opt_val.append(val) + return opt_val def _format_mapdict(mapdict, script=False): """Formats mapdict to pass it to tk.call. @@ -90,32 +104,11 @@ returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')""" - # if caller passes a Tcl script to tk.call, all the values need to - # be grouped into words (arguments to a command in Tcl dialect) - format = "%s" if not script else "{%s}" opts = [] for opt, value in mapdict.items(): - - opt_val = [] - # each value in mapdict is expected to be a sequence, where each item - # is another sequence containing a state (or several) and a value - for statespec in value: - state, val = statespec[:-1], statespec[-1] - - if len(state) > 1: # group multiple states - state = "{%s}" % ' '.join(state) - else: # single state - # if it is empty (something that evaluates to False), then - # format it to Tcl code to denote the "normal" state - state = state[0] or '{}' - - if isinstance(val, (list, tuple)): # val needs to be grouped - val = "{%s}" % ' '.join(map(str, val)) - - opt_val.append("%s %s" % (state, val)) - - opts.append(("-%s" % opt, format % ' '.join(opt_val))) + opts.extend(("-%s" % opt, + _format_optvalue(_mapdict_values(value), script))) return _flatten(opts) @@ -129,7 +122,7 @@ iname = args[0] # next args, if any, are statespec/value pairs which is almost # a mapdict, but we just need the value - imagespec = _format_mapdict({None: args[1:]})[1] + imagespec = _join(_mapdict_values(args[1:])) spec = "%s %s" % (iname, imagespec) else: @@ -138,7 +131,7 @@ # themed styles on Windows XP and Vista. # Availability: Tk 8.6, Windows XP and Vista. class_name, part_id = args[:2] - statemap = _format_mapdict({None: args[2:]})[1] + statemap = _join(_mapdict_values(args[2:])) spec = "%s %s %s" % (class_name, part_id, statemap) opts = _format_optdict(kw, script) @@ -148,11 +141,11 @@ # otherwise it will clone {} (empty element) spec = args[0] # theme name if len(args) > 1: # elementfrom specified - opts = (args[1], ) + opts = (_format_optvalue(args[1], script),) if script: spec = '{%s}' % spec - opts = ' '.join(map(str, opts)) + opts = ' '.join(opts) return spec, opts @@ -189,7 +182,7 @@ for layout_elem in layout: elem, opts = layout_elem opts = opts or {} - fopts = ' '.join(map(str, _format_optdict(opts, True, "children"))) + fopts = ' '.join(_format_optdict(opts, True, ("children",))) head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '') if "children" in opts: @@ -215,11 +208,11 @@ for name, opts in settings.items(): # will format specific keys according to Tcl code if opts.get('configure'): # format 'configure' - s = ' '.join(map(str, _format_optdict(opts['configure'], True))) + s = ' '.join(_format_optdict(opts['configure'], True)) script.append("ttk::style configure %s %s;" % (name, s)) if opts.get('map'): # format 'map' - s = ' '.join(map(str, _format_mapdict(opts['map'], True))) + s = ' '.join(_format_mapdict(opts['map'], True)) script.append("ttk::style map %s %s;" % (name, s)) if 'layout' in opts: # format 'layout' which may be empty @@ -706,30 +699,9 @@ exportselection, justify, height, postcommand, state, textvariable, values, width """ - # The "values" option may need special formatting, so leave to - # _format_optdict the responsibility to format it - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - Entry.__init__(self, master, "ttk::combobox", **kw) - def __setitem__(self, item, value): - if item == "values": - value = _format_optdict({item: value})[1] - - Entry.__setitem__(self, item, value) - - - def configure(self, cnf=None, **kw): - """Custom Combobox configure, created to properly format the values - option.""" - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - - return Entry.configure(self, cnf, **kw) - - def current(self, newindex=None): """If newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #15861: tkinter now correctly works with lists and tuples containing + strings with whitespaces, backslashes or unbalanced braces. + - Issue #10527: Use poll() instead of select() for multiprocessing pipes. - Issue #9720: zipfile now writes correct local headers for files larger than -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 17:04:40 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 17:04:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2315861=3A_tkinter_now_correctly_works_with_lists?= =?utf-8?q?_and_tuples_containing?= Message-ID: <3YlxFh2H0zzR76@mail.python.org> http://hg.python.org/cpython/rev/340e97ebe911 changeset: 81529:340e97ebe911 parent: 81526:fb17969ace93 parent: 81528:927352d7e994 user: Serhiy Storchaka date: Tue Jan 15 17:59:53 2013 +0200 summary: Issue #15861: tkinter now correctly works with lists and tuples containing strings with whitespaces, backslashes or unbalanced braces. files: Lib/tkinter/__init__.py | 31 ++- Lib/tkinter/test/test_ttk/test_functions.py | 40 ++- Lib/tkinter/test/test_ttk/test_widgets.py | 8 + Lib/tkinter/ttk.py | 122 +++------ Misc/NEWS | 3 + 5 files changed, 123 insertions(+), 81 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -40,6 +40,7 @@ import _tkinter # If this fails your Python may not be configured for Tk TclError = _tkinter.TclError from tkinter.constants import * +import re wantobjects = 1 @@ -52,6 +53,34 @@ EXCEPTION = _tkinter.EXCEPTION +_magic_re = re.compile(r'([\\{}])') +_space_re = re.compile(r'([\s])', re.ASCII) + +def _join(value): + """Internal function.""" + return ' '.join(map(_stringify, value)) + +def _stringify(value): + """Internal function.""" + if isinstance(value, (list, tuple)): + if len(value) == 1: + value = _stringify(value[0]) + if value[0] == '{': + value = '{%s}' % value + else: + value = '{%s}' % _join(value) + else: + value = str(value) + if not value: + value = '{}' + elif _magic_re.search(value): + # add '\' before special characters and spaces + value = _magic_re.sub(r'\\\1', value) + value = _space_re.sub(r'\\\1', value) + elif value[0] == '"' or _space_re.search(value): + value = '{%s}' % value + return value + def _flatten(seq): """Internal function.""" res = () @@ -1089,7 +1118,7 @@ if isinstance(item, int): nv.append(str(item)) elif isinstance(item, str): - nv.append(('{%s}' if ' ' in item else '%s') % item) + nv.append(_stringify(item)) else: break else: diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py --- a/Lib/tkinter/test/test_ttk/test_functions.py +++ b/Lib/tkinter/test/test_ttk/test_functions.py @@ -49,13 +49,17 @@ ttk._format_optdict({'test': {'left': 'as is'}}), {'-test': {'left': 'as is'}}) - # check script formatting and untouched value(s) + # check script formatting check_against( ttk._format_optdict( - {'test': [1, -1, '', '2m', 0], 'nochange1': 3, - 'nochange2': 'abc def'}, script=True), - {'-test': '{1 -1 {} 2m 0}', '-nochange1': 3, - '-nochange2': 'abc def' }) + {'test': [1, -1, '', '2m', 0], 'test2': 3, + 'test3': '', 'test4': 'abc def', + 'test5': '"abc"', 'test6': '{}', + 'test7': '} -spam {'}, script=True), + {'-test': '{1 -1 {} 2m 0}', '-test2': '3', + '-test3': '{}', '-test4': '{abc def}', + '-test5': '{"abc"}', '-test6': r'\{\}', + '-test7': r'\}\ -spam\ \{'}) opts = {'???': True, '?': False} orig_opts = opts.copy() @@ -69,6 +73,32 @@ ttk._format_optdict( {'option': ('one two', 'three')}), {'-option': '{one two} three'}) + check_against( + ttk._format_optdict( + {'option': ('one\ttwo', 'three')}), + {'-option': '{one\ttwo} three'}) + + # passing empty strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('', 'one')}), + {'-option': '{} one'}) + + # passing values with braces inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('one} {two', 'three')}), + {'-option': r'one\}\ \{two three'}) + + # passing quoted strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('"one"', 'two')}), + {'-option': '{"one"} two'}) + check_against( + ttk._format_optdict( + {'option': ('{one}', 'two')}), + {'-option': r'\{one\} two'}) # ignore an option amount_opts = len(ttk._format_optdict(opts, ignore=('?'))) / 2 diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py --- a/Lib/tkinter/test/test_ttk/test_widgets.py +++ b/Lib/tkinter/test/test_ttk/test_widgets.py @@ -189,6 +189,14 @@ self.combo.configure(values=[1, '', 2]) self.assertEqual(self.combo['values'], ('1', '', '2')) + # testing values with spaces + self.combo['values'] = ['a b', 'a\tb', 'a\nb'] + self.assertEqual(self.combo['values'], ('a b', 'a\tb', 'a\nb')) + + # testing values with special characters + self.combo['values'] = [r'a\tb', '"a"', '} {'] + self.assertEqual(self.combo['values'], (r'a\tb', '"a"', '} {')) + # out of range self.assertRaises(tkinter.TclError, self.combo.current, len(self.combo['values'])) diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -26,8 +26,7 @@ "tclobjs_to_py", "setup_master"] import tkinter - -_flatten = tkinter._flatten +from tkinter import _flatten, _join, _stringify # Verify if Tk is new enough to not need the Tile package _REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False @@ -47,39 +46,54 @@ master.tk.eval('package require tile') # TclError may be raised here master._tile_loaded = True +def _format_optvalue(value, script=False): + """Internal function.""" + if script: + # if caller passes a Tcl script to tk.call, all the values need to + # be grouped into words (arguments to a command in Tcl dialect) + value = _stringify(value) + elif isinstance(value, (list, tuple)): + value = _join(value) + return value + def _format_optdict(optdict, script=False, ignore=None): """Formats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')""" - format = "%s" if not script else "{%s}" opts = [] for opt, value in optdict.items(): - if ignore and opt in ignore: - continue + if not ignore or opt not in ignore: + opts.append("-%s" % opt) + if value is not None: + opts.append(_format_optvalue(value, script)) - if isinstance(value, (list, tuple)): - v = [] - for val in value: - if isinstance(val, str): - v.append(str(val) if val else '{}') - else: - v.append(str(val)) + return _flatten(opts) - # format v according to the script option, but also check for - # space in any value in v in order to group them correctly - value = format % ' '.join( - ('{%s}' if ' ' in val else '%s') % val for val in v) - - if script and value == '': - value = '{}' # empty string in Python is equivalent to {} in Tcl - - opts.append(("-%s" % opt, value)) - - # Remember: _flatten skips over None - return _flatten(opts) +def _mapdict_values(items): + # each value in mapdict is expected to be a sequence, where each item + # is another sequence containing a state (or several) and a value + # E.g. (script=False): + # [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])] + # returns: + # ['active selected', 'grey', 'focus', [1, 2, 3, 4]] + opt_val = [] + for *state, val in items: + # hacks for bakward compatibility + state[0] # raise IndexError if empty + if len(state) == 1: + # if it is empty (something that evaluates to False), then + # format it to Tcl code to denote the "normal" state + state = state[0] or '' + else: + # group multiple states + state = ' '.join(state) # raise TypeError if not str + opt_val.append(state) + if val is not None: + opt_val.append(val) + return opt_val def _format_mapdict(mapdict, script=False): """Formats mapdict to pass it to tk.call. @@ -90,32 +104,11 @@ returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')""" - # if caller passes a Tcl script to tk.call, all the values need to - # be grouped into words (arguments to a command in Tcl dialect) - format = "%s" if not script else "{%s}" opts = [] for opt, value in mapdict.items(): - - opt_val = [] - # each value in mapdict is expected to be a sequence, where each item - # is another sequence containing a state (or several) and a value - for statespec in value: - state, val = statespec[:-1], statespec[-1] - - if len(state) > 1: # group multiple states - state = "{%s}" % ' '.join(state) - else: # single state - # if it is empty (something that evaluates to False), then - # format it to Tcl code to denote the "normal" state - state = state[0] or '{}' - - if isinstance(val, (list, tuple)): # val needs to be grouped - val = "{%s}" % ' '.join(map(str, val)) - - opt_val.append("%s %s" % (state, val)) - - opts.append(("-%s" % opt, format % ' '.join(opt_val))) + opts.extend(("-%s" % opt, + _format_optvalue(_mapdict_values(value), script))) return _flatten(opts) @@ -129,7 +122,7 @@ iname = args[0] # next args, if any, are statespec/value pairs which is almost # a mapdict, but we just need the value - imagespec = _format_mapdict({None: args[1:]})[1] + imagespec = _join(_mapdict_values(args[1:])) spec = "%s %s" % (iname, imagespec) else: @@ -138,7 +131,7 @@ # themed styles on Windows XP and Vista. # Availability: Tk 8.6, Windows XP and Vista. class_name, part_id = args[:2] - statemap = _format_mapdict({None: args[2:]})[1] + statemap = _join(_mapdict_values(args[2:])) spec = "%s %s %s" % (class_name, part_id, statemap) opts = _format_optdict(kw, script) @@ -148,11 +141,11 @@ # otherwise it will clone {} (empty element) spec = args[0] # theme name if len(args) > 1: # elementfrom specified - opts = (args[1], ) + opts = (_format_optvalue(args[1], script),) if script: spec = '{%s}' % spec - opts = ' '.join(map(str, opts)) + opts = ' '.join(opts) return spec, opts @@ -189,7 +182,7 @@ for layout_elem in layout: elem, opts = layout_elem opts = opts or {} - fopts = ' '.join(map(str, _format_optdict(opts, True, "children"))) + fopts = ' '.join(_format_optdict(opts, True, ("children",))) head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '') if "children" in opts: @@ -215,11 +208,11 @@ for name, opts in settings.items(): # will format specific keys according to Tcl code if opts.get('configure'): # format 'configure' - s = ' '.join(map(str, _format_optdict(opts['configure'], True))) + s = ' '.join(_format_optdict(opts['configure'], True)) script.append("ttk::style configure %s %s;" % (name, s)) if opts.get('map'): # format 'map' - s = ' '.join(map(str, _format_mapdict(opts['map'], True))) + s = ' '.join(_format_mapdict(opts['map'], True)) script.append("ttk::style map %s %s;" % (name, s)) if 'layout' in opts: # format 'layout' which may be empty @@ -706,30 +699,9 @@ exportselection, justify, height, postcommand, state, textvariable, values, width """ - # The "values" option may need special formatting, so leave to - # _format_optdict the responsibility to format it - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - Entry.__init__(self, master, "ttk::combobox", **kw) - def __setitem__(self, item, value): - if item == "values": - value = _format_optdict({item: value})[1] - - Entry.__setitem__(self, item, value) - - - def configure(self, cnf=None, **kw): - """Custom Combobox configure, created to properly format the values - option.""" - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - - return Entry.configure(self, cnf, **kw) - - def current(self, newindex=None): """If newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -220,6 +220,9 @@ Library ------- +- Issue #15861: tkinter now correctly works with lists and tuples containing + strings with whitespaces, backslashes or unbalanced braces. + - Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 17:04:42 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 15 Jan 2013 17:04:42 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE1ODYx?= =?utf-8?q?=3A_tkinter_now_correctly_works_with_lists_and_tuples_containin?= =?utf-8?q?g?= Message-ID: <3YlxFk0rtWzQp7@mail.python.org> http://hg.python.org/cpython/rev/917ae14831ec changeset: 81530:917ae14831ec branch: 2.7 parent: 81521:2e1f1b096f3d user: Serhiy Storchaka date: Tue Jan 15 18:01:21 2013 +0200 summary: Issue #15861: tkinter now correctly works with lists and tuples containing strings with whitespaces, backslashes or unbalanced braces. files: Lib/lib-tk/Tkinter.py | 34 ++- Lib/lib-tk/test/test_ttk/test_functions.py | 40 ++- Lib/lib-tk/test/test_ttk/test_widgets.py | 8 + Lib/lib-tk/ttk.py | 124 +++------ Misc/NEWS | 3 + 5 files changed, 128 insertions(+), 81 deletions(-) diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -41,6 +41,7 @@ TclError = _tkinter.TclError from types import * from Tkconstants import * +import re wantobjects = 1 @@ -58,6 +59,37 @@ except AttributeError: _tkinter.deletefilehandler = None +_magic_re = re.compile(r'([\\{}])') +_space_re = re.compile(r'([\s])') + +def _join(value): + """Internal function.""" + return ' '.join(map(_stringify, value)) + +def _stringify(value): + """Internal function.""" + if isinstance(value, (list, tuple)): + if len(value) == 1: + value = _stringify(value[0]) + if value[0] == '{': + value = '{%s}' % value + else: + value = '{%s}' % _join(value) + else: + if isinstance(value, basestring): + value = unicode(value) + else: + value = str(value) + if not value: + value = '{}' + elif _magic_re.search(value): + # add '\' before special characters and spaces + value = _magic_re.sub(r'\\\1', value) + value = _space_re.sub(r'\\\1', value) + elif value[0] == '"' or _space_re.search(value): + value = '{%s}' % value + return value + def _flatten(tuple): """Internal function.""" res = () @@ -1086,7 +1118,7 @@ nv.append('%d' % item) else: # format it to proper Tcl code if it contains space - nv.append(('{%s}' if ' ' in item else '%s') % item) + nv.append(_stringify(item)) else: v = ' '.join(nv) res = res + ('-'+k, v) diff --git a/Lib/lib-tk/test/test_ttk/test_functions.py b/Lib/lib-tk/test/test_ttk/test_functions.py --- a/Lib/lib-tk/test/test_ttk/test_functions.py +++ b/Lib/lib-tk/test/test_ttk/test_functions.py @@ -50,13 +50,17 @@ ttk._format_optdict({'test': {'left': 'as is'}}), {'-test': {'left': 'as is'}}) - # check script formatting and untouched value(s) + # check script formatting check_against( ttk._format_optdict( - {'test': [1, -1, '', '2m', 0], 'nochange1': 3, - 'nochange2': 'abc def'}, script=True), - {'-test': '{1 -1 {} 2m 0}', '-nochange1': 3, - '-nochange2': 'abc def' }) + {'test': [1, -1, '', '2m', 0], 'test2': 3, + 'test3': '', 'test4': 'abc def', + 'test5': '"abc"', 'test6': '{}', + 'test7': '} -spam {'}, script=True), + {'-test': '{1 -1 {} 2m 0}', '-test2': '3', + '-test3': '{}', '-test4': '{abc def}', + '-test5': '{"abc"}', '-test6': r'\{\}', + '-test7': r'\}\ -spam\ \{'}) opts = {u'???': True, u'?': False} orig_opts = opts.copy() @@ -70,6 +74,32 @@ ttk._format_optdict( {'option': ('one two', 'three')}), {'-option': '{one two} three'}) + check_against( + ttk._format_optdict( + {'option': ('one\ttwo', 'three')}), + {'-option': '{one\ttwo} three'}) + + # passing empty strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('', 'one')}), + {'-option': '{} one'}) + + # passing values with braces inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('one} {two', 'three')}), + {'-option': r'one\}\ \{two three'}) + + # passing quoted strings inside a tuple/list + check_against( + ttk._format_optdict( + {'option': ('"one"', 'two')}), + {'-option': '{"one"} two'}) + check_against( + ttk._format_optdict( + {'option': ('{one}', 'two')}), + {'-option': r'\{one\} two'}) # ignore an option amount_opts = len(ttk._format_optdict(opts, ignore=(u'?'))) // 2 diff --git a/Lib/lib-tk/test/test_ttk/test_widgets.py b/Lib/lib-tk/test/test_ttk/test_widgets.py --- a/Lib/lib-tk/test/test_ttk/test_widgets.py +++ b/Lib/lib-tk/test/test_ttk/test_widgets.py @@ -188,6 +188,14 @@ self.combo.configure(values=[1, '', 2]) self.assertEqual(self.combo['values'], ('1', '', '2')) + # testing values with spaces + self.combo['values'] = ['a b', 'a\tb', 'a\nb'] + self.assertEqual(self.combo['values'], ('a b', 'a\tb', 'a\nb')) + + # testing values with special characters + self.combo['values'] = [r'a\tb', '"a"', '} {'] + self.assertEqual(self.combo['values'], (r'a\tb', '"a"', '} {')) + # out of range self.assertRaises(Tkinter.TclError, self.combo.current, len(self.combo['values'])) diff --git a/Lib/lib-tk/ttk.py b/Lib/lib-tk/ttk.py --- a/Lib/lib-tk/ttk.py +++ b/Lib/lib-tk/ttk.py @@ -26,8 +26,7 @@ "tclobjs_to_py", "setup_master"] import Tkinter - -_flatten = Tkinter._flatten +from Tkinter import _flatten, _join, _stringify # Verify if Tk is new enough to not need the Tile package _REQUIRE_TILE = True if Tkinter.TkVersion < 8.5 else False @@ -47,39 +46,56 @@ master.tk.eval('package require tile') # TclError may be raised here master._tile_loaded = True +def _format_optvalue(value, script=False): + """Internal function.""" + if script: + # if caller passes a Tcl script to tk.call, all the values need to + # be grouped into words (arguments to a command in Tcl dialect) + value = _stringify(value) + elif isinstance(value, (list, tuple)): + value = _join(value) + return value + def _format_optdict(optdict, script=False, ignore=None): """Formats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')""" - format = "%s" if not script else "{%s}" opts = [] for opt, value in optdict.iteritems(): - if ignore and opt in ignore: - continue + if not ignore or opt not in ignore: + opts.append("-%s" % opt) + if value is not None: + opts.append(_format_optvalue(value, script)) - if isinstance(value, (list, tuple)): - v = [] - for val in value: - if isinstance(val, basestring): - v.append(unicode(val) if val else '{}') - else: - v.append(str(val)) + return _flatten(opts) - # format v according to the script option, but also check for - # space in any value in v in order to group them correctly - value = format % ' '.join( - ('{%s}' if ' ' in val else '%s') % val for val in v) - - if script and value == '': - value = '{}' # empty string in Python is equivalent to {} in Tcl - - opts.append(("-%s" % opt, value)) - - # Remember: _flatten skips over None - return _flatten(opts) +def _mapdict_values(items): + # each value in mapdict is expected to be a sequence, where each item + # is another sequence containing a state (or several) and a value + # E.g. (script=False): + # [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])] + # returns: + # ['active selected', 'grey', 'focus', [1, 2, 3, 4]] + opt_val = [] + for item in items: + state = item[:-1] + val = item[-1] + # hacks for bakward compatibility + state[0] # raise IndexError if empty + if len(state) == 1: + # if it is empty (something that evaluates to False), then + # format it to Tcl code to denote the "normal" state + state = state[0] or '' + else: + # group multiple states + state = ' '.join(state) # raise TypeError if not str + opt_val.append(state) + if val is not None: + opt_val.append(val) + return opt_val def _format_mapdict(mapdict, script=False): """Formats mapdict to pass it to tk.call. @@ -90,32 +106,11 @@ returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')""" - # if caller passes a Tcl script to tk.call, all the values need to - # be grouped into words (arguments to a command in Tcl dialect) - format = "%s" if not script else "{%s}" opts = [] for opt, value in mapdict.iteritems(): - - opt_val = [] - # each value in mapdict is expected to be a sequence, where each item - # is another sequence containing a state (or several) and a value - for statespec in value: - state, val = statespec[:-1], statespec[-1] - - if len(state) > 1: # group multiple states - state = "{%s}" % ' '.join(state) - else: # single state - # if it is empty (something that evaluates to False), then - # format it to Tcl code to denote the "normal" state - state = state[0] or '{}' - - if isinstance(val, (list, tuple)): # val needs to be grouped - val = "{%s}" % ' '.join(map(str, val)) - - opt_val.append("%s %s" % (state, val)) - - opts.append(("-%s" % opt, format % ' '.join(opt_val))) + opts.extend(("-%s" % opt, + _format_optvalue(_mapdict_values(value), script))) return _flatten(opts) @@ -129,7 +124,7 @@ iname = args[0] # next args, if any, are statespec/value pairs which is almost # a mapdict, but we just need the value - imagespec = _format_mapdict({None: args[1:]})[1] + imagespec = _join(_mapdict_values(args[1:])) spec = "%s %s" % (iname, imagespec) else: @@ -138,7 +133,7 @@ # themed styles on Windows XP and Vista. # Availability: Tk 8.6, Windows XP and Vista. class_name, part_id = args[:2] - statemap = _format_mapdict({None: args[2:]})[1] + statemap = _join(_mapdict_values(args[2:])) spec = "%s %s %s" % (class_name, part_id, statemap) opts = _format_optdict(kw, script) @@ -148,11 +143,11 @@ # otherwise it will clone {} (empty element) spec = args[0] # theme name if len(args) > 1: # elementfrom specified - opts = (args[1], ) + opts = (_format_optvalue(args[1], script),) if script: spec = '{%s}' % spec - opts = ' '.join(map(str, opts)) + opts = ' '.join(opts) return spec, opts @@ -189,7 +184,7 @@ for layout_elem in layout: elem, opts = layout_elem opts = opts or {} - fopts = ' '.join(map(str, _format_optdict(opts, True, "children"))) + fopts = ' '.join(_format_optdict(opts, True, ("children",))) head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '') if "children" in opts: @@ -215,11 +210,11 @@ for name, opts in settings.iteritems(): # will format specific keys according to Tcl code if opts.get('configure'): # format 'configure' - s = ' '.join(map(unicode, _format_optdict(opts['configure'], True))) + s = ' '.join(_format_optdict(opts['configure'], True)) script.append("ttk::style configure %s %s;" % (name, s)) if opts.get('map'): # format 'map' - s = ' '.join(map(unicode, _format_mapdict(opts['map'], True))) + s = ' '.join(_format_mapdict(opts['map'], True)) script.append("ttk::style map %s %s;" % (name, s)) if 'layout' in opts: # format 'layout' which may be empty @@ -706,30 +701,9 @@ exportselection, justify, height, postcommand, state, textvariable, values, width """ - # The "values" option may need special formatting, so leave to - # _format_optdict the responsibility to format it - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - Entry.__init__(self, master, "ttk::combobox", **kw) - def __setitem__(self, item, value): - if item == "values": - value = _format_optdict({item: value})[1] - - Entry.__setitem__(self, item, value) - - - def configure(self, cnf=None, **kw): - """Custom Combobox configure, created to properly format the values - option.""" - if "values" in kw: - kw["values"] = _format_optdict({'v': kw["values"]})[1] - - return Entry.configure(self, cnf, **kw) - - def current(self, newindex=None): """If newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,9 @@ Library ------- +- Issue #15861: tkinter now correctly works with lists and tuples containing + strings with whitespaces, backslashes or unbalanced braces. + - Issue #10527: Use poll() instead of select() for multiprocessing pipes. - Issue #9720: zipfile now writes correct local headers for files larger than -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 18:57:35 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 15 Jan 2013 18:57:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzk1MDE6?= =?utf-8?q?_Improved_shutdown_handling_to_deal_with_module_attributes?= Message-ID: <3Ylzlz1sT2zNy8@mail.python.org> http://hg.python.org/cpython/rev/966887830011 changeset: 81531:966887830011 branch: 2.7 user: Vinay Sajip date: Tue Jan 15 17:55:13 2013 +0000 summary: Issue #9501: Improved shutdown handling to deal with module attributes correctly. files: Lib/logging/__init__.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -624,7 +624,8 @@ # This function can be called during module teardown, when globals are # set to None. If _acquireLock is None, assume this is the case and do # nothing. - if _acquireLock is not None: + if (_acquireLock is not None and _handlerList is not None and + _releaseLock is not None): _acquireLock() try: if wr in _handlerList: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 18:57:36 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 15 Jan 2013 18:57:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzk1MDE6?= =?utf-8?q?_Improved_shutdown_handling_to_deal_with_module_attributes?= Message-ID: <3Ylzm059HqzRC1@mail.python.org> http://hg.python.org/cpython/rev/8eac88f49cc0 changeset: 81532:8eac88f49cc0 branch: 3.2 parent: 81527:411bb75be5d1 user: Vinay Sajip date: Tue Jan 15 17:55:57 2013 +0000 summary: Issue #9501: Improved shutdown handling to deal with module attributes correctly. files: Lib/logging/__init__.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -711,7 +711,8 @@ # This function can be called during module teardown, when globals are # set to None. If _acquireLock is None, assume this is the case and do # nothing. - if _acquireLock is not None: + if (_acquireLock is not None and _handlerList is not None and + _releaseLock is not None): _acquireLock() try: if wr in _handlerList: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 18:57:39 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 15 Jan 2013 18:57:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=239501=3A_Merged_fix_from_3=2E2=2E?= Message-ID: <3Ylzm313PqzPQD@mail.python.org> http://hg.python.org/cpython/rev/3161a94ff73c changeset: 81533:3161a94ff73c branch: 3.3 parent: 81528:927352d7e994 parent: 81532:8eac88f49cc0 user: Vinay Sajip date: Tue Jan 15 17:56:43 2013 +0000 summary: Issue #9501: Merged fix from 3.2. files: Lib/logging/__init__.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -708,7 +708,8 @@ # This function can be called during module teardown, when globals are # set to None. If _acquireLock is None, assume this is the case and do # nothing. - if _acquireLock is not None: + if (_acquireLock is not None and _handlerList is not None and + _releaseLock is not None): _acquireLock() try: if wr in _handlerList: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 18:57:40 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 15 Jan 2013 18:57:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=239501=3A_Merged_fix_from_3=2E3=2E?= Message-ID: <3Ylzm445bjzRC1@mail.python.org> http://hg.python.org/cpython/rev/4fd8c35a05b2 changeset: 81534:4fd8c35a05b2 parent: 81529:340e97ebe911 parent: 81533:3161a94ff73c user: Vinay Sajip date: Tue Jan 15 17:57:18 2013 +0000 summary: Issue #9501: Merged fix from 3.3. files: Lib/logging/__init__.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -708,7 +708,8 @@ # This function can be called during module teardown, when globals are # set to None. If _acquireLock is None, assume this is the case and do # nothing. - if _acquireLock is not None: + if (_acquireLock is not None and _handlerList is not None and + _releaseLock is not None): _acquireLock() try: if wr in _handlerList: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 22:25:12 2013 From: python-checkins at python.org (philip.jenvey) Date: Tue, 15 Jan 2013 22:25:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_thinko?= Message-ID: <3Ym4MX0fjgzS14@mail.python.org> http://hg.python.org/cpython/rev/c044029ede9d changeset: 81535:c044029ede9d user: Philip Jenvey date: Tue Jan 15 13:24:12 2013 -0800 summary: thinko files: Python/fileutils.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Python/fileutils.c b/Python/fileutils.c --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -60,7 +60,7 @@ workaround is also enabled on error, for example if getting the locale failed. - Values of locale_is_ascii: + Values of force_ascii: 1: the workaround is used: _Py_wchar2char() uses encode_ascii_surrogateescape() and _Py_char2wchar() uses -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 22:49:43 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 15 Jan 2013 22:49:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_remove_warning?= =?utf-8?q?_about_tb_circular_reference_=28closes_=237340=29?= Message-ID: <3Ym4vq0DRzzRGV@mail.python.org> http://hg.python.org/cpython/rev/3fa3e7975724 changeset: 81536:3fa3e7975724 branch: 3.3 parent: 81533:3161a94ff73c user: Benjamin Peterson date: Tue Jan 15 16:49:22 2013 -0500 summary: remove warning about tb circular reference (closes #7340) files: Doc/library/sys.rst | 15 --------------- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -215,21 +215,6 @@ a traceback object (see the Reference Manual) which encapsulates the call stack at the point where the exception originally occurred. - .. warning:: - - Assigning the *traceback* return value to a local variable in a function - that is handling an exception will cause a circular reference. Since most - functions don't need access to the traceback, the best solution is to use - something like ``exctype, value = sys.exc_info()[:2]`` to extract only the - exception type and value. If you do need the traceback, make sure to - delete it after use (best done with a :keyword:`try` - ... :keyword:`finally` statement) or to call :func:`exc_info` in a - function that does not itself handle an exception. - - Such cycles are normally automatically reclaimed when garbage collection - is enabled and they become unreachable, but it remains more efficient to - avoid creating cycles. - .. data:: exec_prefix -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 15 22:49:44 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 15 Jan 2013 22:49:44 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4zICgjNzM0MCk=?= Message-ID: <3Ym4vr30C0zS0l@mail.python.org> http://hg.python.org/cpython/rev/d866bbdd68e8 changeset: 81537:d866bbdd68e8 parent: 81535:c044029ede9d parent: 81536:3fa3e7975724 user: Benjamin Peterson date: Tue Jan 15 16:49:35 2013 -0500 summary: merge 3.3 (#7340) files: Doc/library/sys.rst | 15 --------------- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -215,21 +215,6 @@ a traceback object (see the Reference Manual) which encapsulates the call stack at the point where the exception originally occurred. - .. warning:: - - Assigning the *traceback* return value to a local variable in a function - that is handling an exception will cause a circular reference. Since most - functions don't need access to the traceback, the best solution is to use - something like ``exctype, value = sys.exc_info()[:2]`` to extract only the - exception type and value. If you do need the traceback, make sure to - delete it after use (best done with a :keyword:`try` - ... :keyword:`finally` statement) or to call :func:`exc_info` in a - function that does not itself handle an exception. - - Such cycles are normally automatically reclaimed when garbage collection - is enabled and they become unreachable, but it remains more efficient to - avoid creating cycles. - .. data:: exec_prefix -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Wed Jan 16 05:58:30 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 16 Jan 2013 05:58:30 +0100 Subject: [Python-checkins] Daily reference leaks (d866bbdd68e8): sum=11 Message-ID: results for d866bbdd68e8 on branch "default" -------------------------------------------- test_concurrent_futures leaked [2, 1, 1] memory blocks, sum=4 test_site leaked [2, 0, 0] references, sum=2 test_site leaked [2, 2, 1] memory blocks, sum=5 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogFrR2N3', '-x'] From python-checkins at python.org Wed Jan 16 13:02:11 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 13:02:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2NDIy?= =?utf-8?q?=3A_Use_strings_for_rounding_mode_constants_for_better_readabil?= =?utf-8?q?ity?= Message-ID: <3YmRqR4pD7zQSc@mail.python.org> http://hg.python.org/cpython/rev/733bb4fd9888 changeset: 81538:733bb4fd9888 branch: 3.3 parent: 81536:3fa3e7975724 user: Stefan Krah date: Wed Jan 16 12:58:59 2013 +0100 summary: Issue #16422: Use strings for rounding mode constants for better readability and pickling compatibility. files: Lib/test/test_decimal.py | 119 +++++++--------- Misc/NEWS | 3 + Modules/_decimal/_decimal.c | 122 +++++++--------- Modules/_decimal/tests/deccheck.py | 36 +--- 4 files changed, 127 insertions(+), 153 deletions(-) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -78,14 +78,20 @@ d = getattr(context, attr) cls.assertTrue(all(d[s] if s in expected else not d[s] for s in d)) -RoundingModes = { - C: (C.ROUND_UP, C.ROUND_DOWN, C.ROUND_CEILING, C.ROUND_FLOOR, - C.ROUND_HALF_UP, C.ROUND_HALF_DOWN, C.ROUND_HALF_EVEN, - C.ROUND_05UP) if C else None, - P: (P.ROUND_UP, P.ROUND_DOWN, P.ROUND_CEILING, P.ROUND_FLOOR, - P.ROUND_HALF_UP, P.ROUND_HALF_DOWN, P.ROUND_HALF_EVEN, - P.ROUND_05UP) -} +ROUND_UP = P.ROUND_UP +ROUND_DOWN = P.ROUND_DOWN +ROUND_CEILING = P.ROUND_CEILING +ROUND_FLOOR = P.ROUND_FLOOR +ROUND_HALF_UP = P.ROUND_HALF_UP +ROUND_HALF_DOWN = P.ROUND_HALF_DOWN +ROUND_HALF_EVEN = P.ROUND_HALF_EVEN +ROUND_05UP = P.ROUND_05UP + +RoundingModes = [ + ROUND_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR, + ROUND_HALF_UP, ROUND_HALF_DOWN, ROUND_HALF_EVEN, + ROUND_05UP +] # Tests are built around these assumed context defaults. # test_main() restores the original context. @@ -96,7 +102,7 @@ def init(m): if not m: return DefaultTestContext = m.Context( - prec=9, rounding=m.ROUND_HALF_EVEN, traps=dict.fromkeys(Signals[m], 0) + prec=9, rounding=ROUND_HALF_EVEN, traps=dict.fromkeys(Signals[m], 0) ) m.setcontext(DefaultTestContext) @@ -229,14 +235,14 @@ 'xor':'logical_xor'} # Map test-case names to roundings. - self.RoundingDict = {'ceiling' : self.decimal.ROUND_CEILING, - 'down' : self.decimal.ROUND_DOWN, - 'floor' : self.decimal.ROUND_FLOOR, - 'half_down' : self.decimal.ROUND_HALF_DOWN, - 'half_even' : self.decimal.ROUND_HALF_EVEN, - 'half_up' : self.decimal.ROUND_HALF_UP, - 'up' : self.decimal.ROUND_UP, - '05up' : self.decimal.ROUND_05UP} + self.RoundingDict = {'ceiling' : ROUND_CEILING, + 'down' : ROUND_DOWN, + 'floor' : ROUND_FLOOR, + 'half_down' : ROUND_HALF_DOWN, + 'half_even' : ROUND_HALF_EVEN, + 'half_up' : ROUND_HALF_UP, + 'up' : ROUND_UP, + '05up' : ROUND_05UP} # Map the test cases' error names to the actual errors. self.ErrorNames = {'clamped' : self.decimal.Clamped, @@ -2101,9 +2107,6 @@ Inexact = self.decimal.Inexact Rounded = self.decimal.Rounded Clamped = self.decimal.Clamped - ROUND_HALF_EVEN = self.decimal.ROUND_HALF_EVEN - ROUND_DOWN = self.decimal.ROUND_DOWN - ROUND_UP = self.decimal.ROUND_UP with localcontext(Context()) as c: c.prec = 7 @@ -2430,7 +2433,6 @@ def test_int(self): Decimal = self.decimal.Decimal - ROUND_DOWN = self.decimal.ROUND_DOWN for x in range(-250, 250): s = '%0.2f' % (x / 100.0) @@ -2448,7 +2450,6 @@ def test_trunc(self): Decimal = self.decimal.Decimal - ROUND_DOWN = self.decimal.ROUND_DOWN for x in range(-250, 250): s = '%0.2f' % (x / 100.0) @@ -2491,8 +2492,6 @@ def test_create_decimal_from_float(self): Decimal = self.decimal.Decimal Context = self.decimal.Context - ROUND_DOWN = self.decimal.ROUND_DOWN - ROUND_UP = self.decimal.ROUND_UP Inexact = self.decimal.Inexact context = Context(prec=5, rounding=ROUND_DOWN) @@ -2522,7 +2521,6 @@ Decimal = self.decimal.Decimal Context = self.decimal.Context InvalidOperation = self.decimal.InvalidOperation - ROUND_DOWN = self.decimal.ROUND_DOWN c = Context(Emax=99999, Emin=-99999) self.assertEqual( @@ -2723,7 +2721,6 @@ InvalidOperation = self.decimal.InvalidOperation DivisionByZero = self.decimal.DivisionByZero Overflow = self.decimal.Overflow - ROUND_HALF_EVEN = self.decimal.ROUND_HALF_EVEN c1 = Context() c2 = Context(prec=None, rounding=None, Emax=None, Emin=None, @@ -2739,6 +2736,21 @@ assert_signals(self, c, 'traps', [InvalidOperation, DivisionByZero, Overflow]) + @cpython_only + def test_from_legacy_strings(self): + import _testcapi + c = self.decimal.Context() + + for rnd in RoundingModes: + c.rounding = _testcapi.unicode_legacy_string(rnd) + self.assertEqual(c.rounding, rnd) + + s = _testcapi.unicode_legacy_string('') + self.assertRaises(TypeError, setattr, c, 'rounding', s) + + s = _testcapi.unicode_legacy_string('ROUND_\x00UP') + self.assertRaises(TypeError, setattr, c, 'rounding', s) + def test_pickle(self): Context = self.decimal.Context @@ -2762,7 +2774,7 @@ # Test interchangeability combinations = [(C, P), (P, C)] if C else [(P, P)] for dumper, loader in combinations: - for ri, _ in enumerate(RoundingModes[dumper]): + for ri, _ in enumerate(RoundingModes): for fi, _ in enumerate(OrderedSignals[dumper]): for ti, _ in enumerate(OrderedSignals[dumper]): @@ -2776,7 +2788,7 @@ sys.modules['decimal'] = dumper c = dumper.Context( prec=prec, Emin=emin, Emax=emax, - rounding=RoundingModes[dumper][ri], + rounding=RoundingModes[ri], capitals=caps, clamp=clamp, flags=OrderedSignals[dumper][:fi], traps=OrderedSignals[dumper][:ti] @@ -2791,7 +2803,7 @@ self.assertEqual(d.prec, prec) self.assertEqual(d.Emin, emin) self.assertEqual(d.Emax, emax) - self.assertEqual(d.rounding, RoundingModes[loader][ri]) + self.assertEqual(d.rounding, RoundingModes[ri]) self.assertEqual(d.capitals, caps) self.assertEqual(d.clamp, clamp) assert_signals(self, d, 'flags', OrderedSignals[loader][:fi]) @@ -3593,7 +3605,6 @@ Underflow = self.decimal.Underflow Clamped = self.decimal.Clamped Subnormal = self.decimal.Subnormal - ROUND_HALF_EVEN = self.decimal.ROUND_HALF_EVEN def raise_error(context, flag): if self.decimal == C: @@ -3960,17 +3971,6 @@ self.assertRaises(ValueError, setattr, c, 'Emin', 1) self.assertRaises(TypeError, setattr, c, 'Emin', (1,2,3)) - # rounding: always raise TypeError in order to get consistent - # exceptions across implementations. In decimal, rounding - # modes are strings, in _decimal they are integers. The idea - # is to view rounding as an abstract type and not mind the - # implementation details. - # Hence, a user should view the rounding modes as if they - # had been defined in a language that supports abstract - # data types, e.g. ocaml: - # - # type rounding = ROUND_DOWN | ROUND_HALF_UP | ... ;; - # self.assertRaises(TypeError, setattr, c, 'rounding', -1) self.assertRaises(TypeError, setattr, c, 'rounding', 9) self.assertRaises(TypeError, setattr, c, 'rounding', 1.0) @@ -4023,8 +4023,6 @@ decimal = self.decimal Decimal = decimal.Decimal Context = decimal.Context - ROUND_HALF_EVEN = decimal.ROUND_HALF_EVEN - ROUND_DOWN = decimal.ROUND_DOWN Clamped = decimal.Clamped DivisionByZero = decimal.DivisionByZero Inexact = decimal.Inexact @@ -4192,7 +4190,7 @@ c.prec = 425000000 c.Emax = 425000000 c.Emin = -425000000 - c.rounding = self.decimal.ROUND_HALF_DOWN + c.rounding = ROUND_HALF_DOWN c.capitals = 0 c.clamp = 1 for sig in OrderedSignals[self.decimal]: @@ -4584,7 +4582,6 @@ def test_py_rescale(self): # Coverage Decimal = P.Decimal - ROUND_UP = P.ROUND_UP localcontext = P.localcontext with localcontext() as c: @@ -4594,7 +4591,6 @@ def test_py__round(self): # Coverage Decimal = P.Decimal - ROUND_UP = P.ROUND_UP self.assertRaises(ValueError, Decimal("3.1234")._round, 0, ROUND_UP) @@ -4663,11 +4659,6 @@ self.assertEqual(C.DECIMAL128, 128) self.assertEqual(C.IEEE_CONTEXT_MAX_BITS, 512) - # Rounding modes - for i, v in enumerate(RoundingModes[C]): - self.assertEqual(v, i) - self.assertEqual(C.ROUND_TRUNC, 8) - # Conditions for i, v in enumerate(cond): self.assertEqual(v, 1<val)); } + /* Init string constants */ + for (i = 0; i < _PY_DEC_ROUND_GUARD; i++) { + ASSIGN_PTR(round_map[i], PyUnicode_InternFromString(mpd_round_string[i])); + Py_INCREF(round_map[i]); + CHECK_INT(PyModule_AddObject(m, mpd_round_string[i], round_map[i])); + } + /* Add specification version number */ CHECK_INT(PyModule_AddStringConstant(m, "__version__", " 1.70")); diff --git a/Modules/_decimal/tests/deccheck.py b/Modules/_decimal/tests/deccheck.py --- a/Modules/_decimal/tests/deccheck.py +++ b/Modules/_decimal/tests/deccheck.py @@ -158,17 +158,9 @@ C.FloatOperation: P.FloatOperation, } -RoundMap = { - C.ROUND_UP: P.ROUND_UP, - C.ROUND_DOWN: P.ROUND_DOWN, - C.ROUND_CEILING: P.ROUND_CEILING, - C.ROUND_FLOOR: P.ROUND_FLOOR, - C.ROUND_HALF_UP: P.ROUND_HALF_UP, - C.ROUND_HALF_DOWN: P.ROUND_HALF_DOWN, - C.ROUND_HALF_EVEN: P.ROUND_HALF_EVEN, - C.ROUND_05UP: P.ROUND_05UP -} -RoundModes = RoundMap.items() +RoundModes = [C.ROUND_UP, C.ROUND_DOWN, C.ROUND_CEILING, C.ROUND_FLOOR, + C.ROUND_HALF_UP, C.ROUND_HALF_DOWN, C.ROUND_HALF_EVEN, + C.ROUND_05UP] class Context(object): @@ -183,7 +175,7 @@ self.p.prec = self.c.prec self.p.Emin = self.c.Emin self.p.Emax = self.c.Emax - self.p.rounding = RoundMap[self.c.rounding] + self.p.rounding = self.c.rounding self.p.capitals = self.c.capitals self.settraps([sig for sig in self.c.traps if self.c.traps[sig]]) self.setstatus([sig for sig in self.c.flags if self.c.flags[sig]]) @@ -217,12 +209,12 @@ self.p.Emax = val def getround(self): - assert(self.c.rounding == RoundMap[self.p.rounding]) + assert(self.c.rounding == self.p.rounding) return self.c.rounding def setround(self, val): self.c.rounding = val - self.p.rounding = RoundMap[val] + self.p.rounding = val def getcapitals(self): assert(self.c.capitals == self.p.capitals) @@ -627,8 +619,12 @@ context.clear_status() - if not t.contextfunc and i == 0 or \ - convstr and isinstance(op, str): + if op in RoundModes: + t.cop.append(op) + t.pop.append(op) + + elif not t.contextfunc and i == 0 or \ + convstr and isinstance(op, str): try: c = C.Decimal(op) cex = None @@ -662,10 +658,6 @@ t.cop.append(op.c) t.pop.append(op.p) - elif op in RoundModes: - t.cop.append(op[0]) - t.pop.append(op[1]) - else: t.cop.append(op) t.pop.append(op) @@ -809,7 +801,7 @@ log(" prec: %d emin: %d emax: %d", (context.prec, context.Emin, context.Emax)) restr_range = 9999 if context.Emax > 9999 else context.Emax+99 - for rounding in sorted(RoundMap): + for rounding in RoundModes: context.rounding = rounding context.capitals = random.randrange(2) if spec['clamp'] == 'rand': @@ -941,7 +933,7 @@ def test_from_float(method, prec, exprange, restricted_range, itr, stat): """Iterate the __float__ method through many test cases.""" - for rounding in sorted(RoundMap): + for rounding in RoundModes: context.rounding = rounding for i in range(1000): f = randfloat() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 13:02:13 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 13:02:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YmRqT3NHDzRBl@mail.python.org> http://hg.python.org/cpython/rev/f1cba54fcc84 changeset: 81539:f1cba54fcc84 parent: 81537:d866bbdd68e8 parent: 81538:733bb4fd9888 user: Stefan Krah date: Wed Jan 16 13:00:11 2013 +0100 summary: Merge 3.3. files: Lib/test/test_decimal.py | 119 +++++++--------- Misc/NEWS | 3 + Modules/_decimal/_decimal.c | 122 +++++++--------- Modules/_decimal/tests/deccheck.py | 36 +--- 4 files changed, 127 insertions(+), 153 deletions(-) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -78,14 +78,20 @@ d = getattr(context, attr) cls.assertTrue(all(d[s] if s in expected else not d[s] for s in d)) -RoundingModes = { - C: (C.ROUND_UP, C.ROUND_DOWN, C.ROUND_CEILING, C.ROUND_FLOOR, - C.ROUND_HALF_UP, C.ROUND_HALF_DOWN, C.ROUND_HALF_EVEN, - C.ROUND_05UP) if C else None, - P: (P.ROUND_UP, P.ROUND_DOWN, P.ROUND_CEILING, P.ROUND_FLOOR, - P.ROUND_HALF_UP, P.ROUND_HALF_DOWN, P.ROUND_HALF_EVEN, - P.ROUND_05UP) -} +ROUND_UP = P.ROUND_UP +ROUND_DOWN = P.ROUND_DOWN +ROUND_CEILING = P.ROUND_CEILING +ROUND_FLOOR = P.ROUND_FLOOR +ROUND_HALF_UP = P.ROUND_HALF_UP +ROUND_HALF_DOWN = P.ROUND_HALF_DOWN +ROUND_HALF_EVEN = P.ROUND_HALF_EVEN +ROUND_05UP = P.ROUND_05UP + +RoundingModes = [ + ROUND_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR, + ROUND_HALF_UP, ROUND_HALF_DOWN, ROUND_HALF_EVEN, + ROUND_05UP +] # Tests are built around these assumed context defaults. # test_main() restores the original context. @@ -96,7 +102,7 @@ def init(m): if not m: return DefaultTestContext = m.Context( - prec=9, rounding=m.ROUND_HALF_EVEN, traps=dict.fromkeys(Signals[m], 0) + prec=9, rounding=ROUND_HALF_EVEN, traps=dict.fromkeys(Signals[m], 0) ) m.setcontext(DefaultTestContext) @@ -229,14 +235,14 @@ 'xor':'logical_xor'} # Map test-case names to roundings. - self.RoundingDict = {'ceiling' : self.decimal.ROUND_CEILING, - 'down' : self.decimal.ROUND_DOWN, - 'floor' : self.decimal.ROUND_FLOOR, - 'half_down' : self.decimal.ROUND_HALF_DOWN, - 'half_even' : self.decimal.ROUND_HALF_EVEN, - 'half_up' : self.decimal.ROUND_HALF_UP, - 'up' : self.decimal.ROUND_UP, - '05up' : self.decimal.ROUND_05UP} + self.RoundingDict = {'ceiling' : ROUND_CEILING, + 'down' : ROUND_DOWN, + 'floor' : ROUND_FLOOR, + 'half_down' : ROUND_HALF_DOWN, + 'half_even' : ROUND_HALF_EVEN, + 'half_up' : ROUND_HALF_UP, + 'up' : ROUND_UP, + '05up' : ROUND_05UP} # Map the test cases' error names to the actual errors. self.ErrorNames = {'clamped' : self.decimal.Clamped, @@ -2101,9 +2107,6 @@ Inexact = self.decimal.Inexact Rounded = self.decimal.Rounded Clamped = self.decimal.Clamped - ROUND_HALF_EVEN = self.decimal.ROUND_HALF_EVEN - ROUND_DOWN = self.decimal.ROUND_DOWN - ROUND_UP = self.decimal.ROUND_UP with localcontext(Context()) as c: c.prec = 7 @@ -2430,7 +2433,6 @@ def test_int(self): Decimal = self.decimal.Decimal - ROUND_DOWN = self.decimal.ROUND_DOWN for x in range(-250, 250): s = '%0.2f' % (x / 100.0) @@ -2448,7 +2450,6 @@ def test_trunc(self): Decimal = self.decimal.Decimal - ROUND_DOWN = self.decimal.ROUND_DOWN for x in range(-250, 250): s = '%0.2f' % (x / 100.0) @@ -2491,8 +2492,6 @@ def test_create_decimal_from_float(self): Decimal = self.decimal.Decimal Context = self.decimal.Context - ROUND_DOWN = self.decimal.ROUND_DOWN - ROUND_UP = self.decimal.ROUND_UP Inexact = self.decimal.Inexact context = Context(prec=5, rounding=ROUND_DOWN) @@ -2522,7 +2521,6 @@ Decimal = self.decimal.Decimal Context = self.decimal.Context InvalidOperation = self.decimal.InvalidOperation - ROUND_DOWN = self.decimal.ROUND_DOWN c = Context(Emax=99999, Emin=-99999) self.assertEqual( @@ -2723,7 +2721,6 @@ InvalidOperation = self.decimal.InvalidOperation DivisionByZero = self.decimal.DivisionByZero Overflow = self.decimal.Overflow - ROUND_HALF_EVEN = self.decimal.ROUND_HALF_EVEN c1 = Context() c2 = Context(prec=None, rounding=None, Emax=None, Emin=None, @@ -2739,6 +2736,21 @@ assert_signals(self, c, 'traps', [InvalidOperation, DivisionByZero, Overflow]) + @cpython_only + def test_from_legacy_strings(self): + import _testcapi + c = self.decimal.Context() + + for rnd in RoundingModes: + c.rounding = _testcapi.unicode_legacy_string(rnd) + self.assertEqual(c.rounding, rnd) + + s = _testcapi.unicode_legacy_string('') + self.assertRaises(TypeError, setattr, c, 'rounding', s) + + s = _testcapi.unicode_legacy_string('ROUND_\x00UP') + self.assertRaises(TypeError, setattr, c, 'rounding', s) + def test_pickle(self): Context = self.decimal.Context @@ -2762,7 +2774,7 @@ # Test interchangeability combinations = [(C, P), (P, C)] if C else [(P, P)] for dumper, loader in combinations: - for ri, _ in enumerate(RoundingModes[dumper]): + for ri, _ in enumerate(RoundingModes): for fi, _ in enumerate(OrderedSignals[dumper]): for ti, _ in enumerate(OrderedSignals[dumper]): @@ -2776,7 +2788,7 @@ sys.modules['decimal'] = dumper c = dumper.Context( prec=prec, Emin=emin, Emax=emax, - rounding=RoundingModes[dumper][ri], + rounding=RoundingModes[ri], capitals=caps, clamp=clamp, flags=OrderedSignals[dumper][:fi], traps=OrderedSignals[dumper][:ti] @@ -2791,7 +2803,7 @@ self.assertEqual(d.prec, prec) self.assertEqual(d.Emin, emin) self.assertEqual(d.Emax, emax) - self.assertEqual(d.rounding, RoundingModes[loader][ri]) + self.assertEqual(d.rounding, RoundingModes[ri]) self.assertEqual(d.capitals, caps) self.assertEqual(d.clamp, clamp) assert_signals(self, d, 'flags', OrderedSignals[loader][:fi]) @@ -3593,7 +3605,6 @@ Underflow = self.decimal.Underflow Clamped = self.decimal.Clamped Subnormal = self.decimal.Subnormal - ROUND_HALF_EVEN = self.decimal.ROUND_HALF_EVEN def raise_error(context, flag): if self.decimal == C: @@ -3960,17 +3971,6 @@ self.assertRaises(ValueError, setattr, c, 'Emin', 1) self.assertRaises(TypeError, setattr, c, 'Emin', (1,2,3)) - # rounding: always raise TypeError in order to get consistent - # exceptions across implementations. In decimal, rounding - # modes are strings, in _decimal they are integers. The idea - # is to view rounding as an abstract type and not mind the - # implementation details. - # Hence, a user should view the rounding modes as if they - # had been defined in a language that supports abstract - # data types, e.g. ocaml: - # - # type rounding = ROUND_DOWN | ROUND_HALF_UP | ... ;; - # self.assertRaises(TypeError, setattr, c, 'rounding', -1) self.assertRaises(TypeError, setattr, c, 'rounding', 9) self.assertRaises(TypeError, setattr, c, 'rounding', 1.0) @@ -4023,8 +4023,6 @@ decimal = self.decimal Decimal = decimal.Decimal Context = decimal.Context - ROUND_HALF_EVEN = decimal.ROUND_HALF_EVEN - ROUND_DOWN = decimal.ROUND_DOWN Clamped = decimal.Clamped DivisionByZero = decimal.DivisionByZero Inexact = decimal.Inexact @@ -4192,7 +4190,7 @@ c.prec = 425000000 c.Emax = 425000000 c.Emin = -425000000 - c.rounding = self.decimal.ROUND_HALF_DOWN + c.rounding = ROUND_HALF_DOWN c.capitals = 0 c.clamp = 1 for sig in OrderedSignals[self.decimal]: @@ -4584,7 +4582,6 @@ def test_py_rescale(self): # Coverage Decimal = P.Decimal - ROUND_UP = P.ROUND_UP localcontext = P.localcontext with localcontext() as c: @@ -4594,7 +4591,6 @@ def test_py__round(self): # Coverage Decimal = P.Decimal - ROUND_UP = P.ROUND_UP self.assertRaises(ValueError, Decimal("3.1234")._round, 0, ROUND_UP) @@ -4663,11 +4659,6 @@ self.assertEqual(C.DECIMAL128, 128) self.assertEqual(C.IEEE_CONTEXT_MAX_BITS, 512) - # Rounding modes - for i, v in enumerate(RoundingModes[C]): - self.assertEqual(v, i) - self.assertEqual(C.ROUND_TRUNC, 8) - # Conditions for i, v in enumerate(cond): self.assertEqual(v, 1<val)); } + /* Init string constants */ + for (i = 0; i < _PY_DEC_ROUND_GUARD; i++) { + ASSIGN_PTR(round_map[i], PyUnicode_InternFromString(mpd_round_string[i])); + Py_INCREF(round_map[i]); + CHECK_INT(PyModule_AddObject(m, mpd_round_string[i], round_map[i])); + } + /* Add specification version number */ CHECK_INT(PyModule_AddStringConstant(m, "__version__", " 1.70")); diff --git a/Modules/_decimal/tests/deccheck.py b/Modules/_decimal/tests/deccheck.py --- a/Modules/_decimal/tests/deccheck.py +++ b/Modules/_decimal/tests/deccheck.py @@ -158,17 +158,9 @@ C.FloatOperation: P.FloatOperation, } -RoundMap = { - C.ROUND_UP: P.ROUND_UP, - C.ROUND_DOWN: P.ROUND_DOWN, - C.ROUND_CEILING: P.ROUND_CEILING, - C.ROUND_FLOOR: P.ROUND_FLOOR, - C.ROUND_HALF_UP: P.ROUND_HALF_UP, - C.ROUND_HALF_DOWN: P.ROUND_HALF_DOWN, - C.ROUND_HALF_EVEN: P.ROUND_HALF_EVEN, - C.ROUND_05UP: P.ROUND_05UP -} -RoundModes = RoundMap.items() +RoundModes = [C.ROUND_UP, C.ROUND_DOWN, C.ROUND_CEILING, C.ROUND_FLOOR, + C.ROUND_HALF_UP, C.ROUND_HALF_DOWN, C.ROUND_HALF_EVEN, + C.ROUND_05UP] class Context(object): @@ -183,7 +175,7 @@ self.p.prec = self.c.prec self.p.Emin = self.c.Emin self.p.Emax = self.c.Emax - self.p.rounding = RoundMap[self.c.rounding] + self.p.rounding = self.c.rounding self.p.capitals = self.c.capitals self.settraps([sig for sig in self.c.traps if self.c.traps[sig]]) self.setstatus([sig for sig in self.c.flags if self.c.flags[sig]]) @@ -217,12 +209,12 @@ self.p.Emax = val def getround(self): - assert(self.c.rounding == RoundMap[self.p.rounding]) + assert(self.c.rounding == self.p.rounding) return self.c.rounding def setround(self, val): self.c.rounding = val - self.p.rounding = RoundMap[val] + self.p.rounding = val def getcapitals(self): assert(self.c.capitals == self.p.capitals) @@ -627,8 +619,12 @@ context.clear_status() - if not t.contextfunc and i == 0 or \ - convstr and isinstance(op, str): + if op in RoundModes: + t.cop.append(op) + t.pop.append(op) + + elif not t.contextfunc and i == 0 or \ + convstr and isinstance(op, str): try: c = C.Decimal(op) cex = None @@ -662,10 +658,6 @@ t.cop.append(op.c) t.pop.append(op.p) - elif op in RoundModes: - t.cop.append(op[0]) - t.pop.append(op[1]) - else: t.cop.append(op) t.pop.append(op) @@ -809,7 +801,7 @@ log(" prec: %d emin: %d emax: %d", (context.prec, context.Emin, context.Emax)) restr_range = 9999 if context.Emax > 9999 else context.Emax+99 - for rounding in sorted(RoundMap): + for rounding in RoundModes: context.rounding = rounding context.capitals = random.randrange(2) if spec['clamp'] == 'rand': @@ -941,7 +933,7 @@ def test_from_float(method, prec, exprange, restricted_range, itr, stat): """Iterate the __float__ method through many test cases.""" - for rounding in sorted(RoundMap): + for rounding in RoundModes: context.rounding = rounding for i in range(1000): f = randfloat() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 13:43:06 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 13:43:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Change_NEWS_en?= =?utf-8?q?try_to_make_it_somewhat_intelligible=2E?= Message-ID: <3YmSkf389hzMqZ@mail.python.org> http://hg.python.org/cpython/rev/6bfa2cf27b0b changeset: 81540:6bfa2cf27b0b branch: 3.3 parent: 81538:733bb4fd9888 user: Stefan Krah date: Wed Jan 16 13:40:57 2013 +0100 summary: Change NEWS entry to make it somewhat intelligible. files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,8 +150,8 @@ Library ------- -- Issue #16422: Use strings for rounding mode constants for better readability - and pickling compatibility. +- Issue #16422: For compatibility with the Python version, the C version of + decimal now uses strings instead of integers for rounding mode constants. - Issue #15861: tkinter now correctly works with lists and tuples containing strings with whitespaces, backslashes or unbalanced braces. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 13:43:07 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 13:43:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YmSkg68c9zR7M@mail.python.org> http://hg.python.org/cpython/rev/7fd1830d0acd changeset: 81541:7fd1830d0acd parent: 81539:f1cba54fcc84 parent: 81540:6bfa2cf27b0b user: Stefan Krah date: Wed Jan 16 13:41:38 2013 +0100 summary: Merge 3.3. files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -220,8 +220,8 @@ Library ------- -- Issue #16422: Use strings for rounding mode constants for better readability - and pickling compatibility. +- Issue #16422: For compatibility with the Python version, the C version of + decimal now uses strings instead of integers for rounding mode constants. - Issue #15861: tkinter now correctly works with lists and tuples containing strings with whitespaces, backslashes or unbalanced braces. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 13:54:09 2013 From: python-checkins at python.org (nick.coghlan) Date: Wed, 16 Jan 2013 13:54:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Handle_transfer_of_config_to_?= =?utf-8?q?subinterpreters?= Message-ID: <3YmSzP4HZCzMgn@mail.python.org> http://hg.python.org/peps/rev/90f1a0ce0aaa changeset: 4679:90f1a0ce0aaa user: Nick Coghlan date: Wed Jan 16 22:54:01 2013 +1000 summary: Handle transfer of config to subinterpreters files: pep-0432.txt | 39 +++++++++++++++++++++++++++++++++++---- 1 files changed, 35 insertions(+), 4 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -60,10 +60,8 @@ To keep the implementation complexity under control, this PEP does *not* propose wholesale changes to the way the interpreter state is accessed at -runtime, nor does it propose changes to the way subinterpreters are -created after the main interpreter has already been initialized (beyond -any changes needed to make sure they continue working as expected). Changing -the order in which the existing initialization steps occur in order to make +runtime. Changing the order in which the existing initialization steps +occur in order to make the startup sequence easier to maintain is already a substantial change, and attempting to make those other changes at the same time will make the change significantly more invasive and much harder to review. However, such @@ -73,6 +71,7 @@ once this PEP has been implemented. + Background ========== @@ -816,6 +815,38 @@ modified by the interpreter during runtime (except as noted above). +Creating and Configuring Subinterpreters +---------------------------------------- + +As the new configuration settings are stored in the interpreter state, they +need to be initialised when a new subinterpreter is created. This turns out +to be trickier than one might think due to ``PyThreadState_Swap(NULL);`` +(which is fortunately exercised by CPython's own embedding tests, allowing +this problem to be detected during development). + +To provide a straightforward solution for this case, the PEP proposes to +add a new API:: + + Py_InterpreterState *Py_InterpreterState_Main(); + +This will be a counterpart to Py_InterpreterState_Head(), reporting the +oldest currently existing interpreter rather than the newest. If +``Py_NewInterpreter()`` is called from a thread with an existing thread +state, then the interpreter configuration for that thread will be +used when initialising the new subinterpreter. If there is no current +thread state, the configuration from ``Py_InterpreterState_Main()`` +will be used. + +While the existing ``Py_InterpreterState_Head()`` API could be used instead, +that reference changes as subinterpreters are created and destroyed, while +``PyInterpreterState_Main()`` will always refer to the initial interpreter +state created in ``Py_BeginInitialization()``. + +A new constraint is also added to the embedding API: attempting to delete +the main interpreter while subinterpreters still exist will now be a fatal +error. + + Stable ABI ---------- -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 16 14:50:15 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 14:50:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Increase_warni?= =?utf-8?q?ng_level_for_=5Fdecimal=2Eso_and_libmpdec_build_when_using_gcc?= =?utf-8?q?=2E?= Message-ID: <3YmVD72sHkzR8C@mail.python.org> http://hg.python.org/cpython/rev/5a729c08872a changeset: 81542:5a729c08872a branch: 3.3 parent: 81540:6bfa2cf27b0b user: Stefan Krah date: Wed Jan 16 14:45:16 2013 +0100 summary: Increase warning level for _decimal.so and libmpdec build when using gcc. files: setup.py | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1995,6 +1995,11 @@ if not sysconfig.get_config_var('WITH_THREAD'): define_macros.append(('WITHOUT_THREADS', 1)) + # Increase warning level for gcc: + if 'gcc' in cc: + extra_compile_args.extend(['-Wextra', + '-Wno-missing-field-initializers']) + # Uncomment for extra functionality: #define_macros.append(('EXTRA_FUNCTIONALITY', 1)) ext = Extension ( -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 14:50:16 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 14:50:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YmVD85yXKzR8C@mail.python.org> http://hg.python.org/cpython/rev/5c0c6de528dd changeset: 81543:5c0c6de528dd parent: 81541:7fd1830d0acd parent: 81542:5a729c08872a user: Stefan Krah date: Wed Jan 16 14:49:15 2013 +0100 summary: Merge 3.3. files: setup.py | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -2006,6 +2006,11 @@ if not sysconfig.get_config_var('WITH_THREAD'): define_macros.append(('WITHOUT_THREADS', 1)) + # Increase warning level for gcc: + if 'gcc' in cc: + extra_compile_args.extend(['-Wextra', + '-Wno-missing-field-initializers']) + # Uncomment for extra functionality: #define_macros.append(('EXTRA_FUNCTIONALITY', 1)) ext = Extension ( -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 15:19:53 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 15:19:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Remove_trailin?= =?utf-8?q?g_whitespace=2E?= Message-ID: <3YmVtK5qRBzMcy@mail.python.org> http://hg.python.org/cpython/rev/750f44e621aa changeset: 81544:750f44e621aa branch: 3.3 parent: 81542:5a729c08872a user: Stefan Krah date: Wed Jan 16 15:16:10 2013 +0100 summary: Remove trailing whitespace. files: Modules/_decimal/README.txt | 2 +- Modules/_decimal/libmpdec/README.txt | 2 +- Modules/_decimal/libmpdec/io.c | 4 +- Modules/_decimal/libmpdec/literature/bignum.txt | 2 +- Modules/_decimal/libmpdec/literature/matrix-transform.txt | 1 + Modules/_decimal/libmpdec/literature/mulmod-ppro.txt | 2 +- Modules/_decimal/libmpdec/literature/six-step.txt | 1 + Modules/_decimal/libmpdec/literature/umodarith.lisp | 2 +- Modules/_decimal/libmpdec/mpdecimal.c | 6 +- Modules/_decimal/libmpdec/umodarith.h | 2 +- Modules/_decimal/libmpdec/vcstdint.h | 20 +++++----- 11 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Modules/_decimal/README.txt b/Modules/_decimal/README.txt --- a/Modules/_decimal/README.txt +++ b/Modules/_decimal/README.txt @@ -37,7 +37,7 @@ NOTE ==== - + decimal.so is not built from a static libmpdec.a since doing so led to failures on AIX (user report) and Windows (mixing static and dynamic CRTs causes locale problems and more). diff --git a/Modules/_decimal/libmpdec/README.txt b/Modules/_decimal/libmpdec/README.txt --- a/Modules/_decimal/libmpdec/README.txt +++ b/Modules/_decimal/libmpdec/README.txt @@ -79,7 +79,7 @@ mulmod-ppro.txt -> Proof for the x87 FPU modular multiplication from umodarith.h. umodarith.lisp -> ACL2 proofs for many functions from umodarith.h. - + Library Author ============== diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c --- a/Modules/_decimal/libmpdec/io.c +++ b/Modules/_decimal/libmpdec/io.c @@ -352,7 +352,7 @@ case 2: EXTRACT_DIGIT(s, x, 10UL, dot); default: if (s == dot) *s++ = '.'; *s++ = '0' + (char)x; } - + *s = '\0'; return s; } @@ -1059,7 +1059,7 @@ * Not allowed, since _mpd_to_string() never returns this form: * * 3) [sign] '.' digits [exponent-part] - * + * * Input: result->data := original numeric string (ASCII) * result->bytes := strlen(result->data) * result->nchars := strlen(result->data) diff --git a/Modules/_decimal/libmpdec/literature/bignum.txt b/Modules/_decimal/libmpdec/literature/bignum.txt --- a/Modules/_decimal/libmpdec/literature/bignum.txt +++ b/Modules/_decimal/libmpdec/literature/bignum.txt @@ -23,7 +23,7 @@ y = fnt(b) # forward transform of b z = pairwise multiply x[i] and y[i] result = inv_fnt(z) # backward transform of z. - + Extending the maximum transform length (Chinese Remainder Theorem): ------------------------------------------------------------------- diff --git a/Modules/_decimal/libmpdec/literature/matrix-transform.txt b/Modules/_decimal/libmpdec/literature/matrix-transform.txt --- a/Modules/_decimal/libmpdec/literature/matrix-transform.txt +++ b/Modules/_decimal/libmpdec/literature/matrix-transform.txt @@ -245,7 +245,7 @@ which means that all A[k] = A[m * C + n] are in the correct order. --- +-- [1] Joerg Arndt: "Matters Computational" http://www.jjj.de/fxt/ diff --git a/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt b/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt --- a/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt +++ b/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt @@ -251,7 +251,7 @@ apply Qlt_le_trans with (y := 1). qreduce ((2 # 1) ^ (-62) + (2 # 1) ^ (-126)). - + rewrite Qlt_mult_by_z with (z := 85070591730234615865843651857942052864 # 18446744073709551617). ring_simplify. diff --git a/Modules/_decimal/libmpdec/literature/six-step.txt b/Modules/_decimal/libmpdec/literature/six-step.txt --- a/Modules/_decimal/libmpdec/literature/six-step.txt +++ b/Modules/_decimal/libmpdec/literature/six-step.txt @@ -55,7 +55,7 @@ --- +-- [1] David H. Bailey: FFTs in External or Hierarchical Memory http://crd.lbl.gov/~dhbailey/dhbpapers/ diff --git a/Modules/_decimal/libmpdec/literature/umodarith.lisp b/Modules/_decimal/libmpdec/literature/umodarith.lisp --- a/Modules/_decimal/libmpdec/literature/umodarith.lisp +++ b/Modules/_decimal/libmpdec/literature/umodarith.lisp @@ -321,7 +321,7 @@ (defthmd dw-submod-correct (implies (and (< 0 m) (< m base) - (natp a) (< a m) + (natp a) (< a m) (< hi base) (< lo base) (natp m) (natp base) (natp hi) (natp lo)) diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -3119,7 +3119,7 @@ * ----------XX1234 -> sdigits * ----------X1 -> tiny-digits * |- prec -| - * + * * OR * * bdigits > prec AND @@ -5983,7 +5983,7 @@ mpd_qfinalize(result, ctx, status); } -/* +/* * If the exponent is infinite and base equals one, the result is one * with a coefficient of length prec. Otherwise, result is undefined. * Return the value of the comparison against one. @@ -7129,7 +7129,7 @@ goto nanresult; } - /* Let x := _mpd_qreciprocal(b, prec) + /* Let x := _mpd_qreciprocal(b, prec) * Then x is bounded by: * 1) 1/b - 10**(-prec - bdigits) < x < 1/b + 10**(-prec - bdigits) * 2) 1/b - 10**(-adigits - 4) < x < 1/b + 10**(-adigits - 4) diff --git a/Modules/_decimal/libmpdec/umodarith.h b/Modules/_decimal/libmpdec/umodarith.h --- a/Modules/_decimal/libmpdec/umodarith.h +++ b/Modules/_decimal/libmpdec/umodarith.h @@ -93,7 +93,7 @@ return d; } -/* +/* * Reduce double word modulo m. * Restrictions: m != 0 * ACL2 proof: umodarith.lisp: section dw-reduce diff --git a/Modules/_decimal/libmpdec/vcstdint.h b/Modules/_decimal/libmpdec/vcstdint.h --- a/Modules/_decimal/libmpdec/vcstdint.h +++ b/Modules/_decimal/libmpdec/vcstdint.h @@ -1,32 +1,32 @@ // ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// // Copyright (c) 2006-2008 Alexander Chemeris -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. The name of the author may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// /////////////////////////////////////////////////////////////////////////////// #ifndef _MSC_VER // [ @@ -47,7 +47,7 @@ // error C2733: second C linkage of overloaded function 'wmemchr' not allowed #if (_MSC_VER < 1300) && defined(__cplusplus) extern "C++" { -#endif +#endif # include #if (_MSC_VER < 1300) && defined(__cplusplus) } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 15:19:55 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 15:19:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YmVtM3BwLzR7d@mail.python.org> http://hg.python.org/cpython/rev/f87d85f7596c changeset: 81545:f87d85f7596c parent: 81543:5c0c6de528dd parent: 81544:750f44e621aa user: Stefan Krah date: Wed Jan 16 15:19:16 2013 +0100 summary: Merge 3.3. files: Modules/_decimal/README.txt | 2 +- Modules/_decimal/libmpdec/README.txt | 2 +- Modules/_decimal/libmpdec/io.c | 4 +- Modules/_decimal/libmpdec/literature/bignum.txt | 2 +- Modules/_decimal/libmpdec/literature/matrix-transform.txt | 1 + Modules/_decimal/libmpdec/literature/mulmod-ppro.txt | 2 +- Modules/_decimal/libmpdec/literature/six-step.txt | 1 + Modules/_decimal/libmpdec/literature/umodarith.lisp | 2 +- Modules/_decimal/libmpdec/mpdecimal.c | 6 +- Modules/_decimal/libmpdec/umodarith.h | 2 +- Modules/_decimal/libmpdec/vcstdint.h | 20 +++++----- 11 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Modules/_decimal/README.txt b/Modules/_decimal/README.txt --- a/Modules/_decimal/README.txt +++ b/Modules/_decimal/README.txt @@ -37,7 +37,7 @@ NOTE ==== - + decimal.so is not built from a static libmpdec.a since doing so led to failures on AIX (user report) and Windows (mixing static and dynamic CRTs causes locale problems and more). diff --git a/Modules/_decimal/libmpdec/README.txt b/Modules/_decimal/libmpdec/README.txt --- a/Modules/_decimal/libmpdec/README.txt +++ b/Modules/_decimal/libmpdec/README.txt @@ -79,7 +79,7 @@ mulmod-ppro.txt -> Proof for the x87 FPU modular multiplication from umodarith.h. umodarith.lisp -> ACL2 proofs for many functions from umodarith.h. - + Library Author ============== diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c --- a/Modules/_decimal/libmpdec/io.c +++ b/Modules/_decimal/libmpdec/io.c @@ -352,7 +352,7 @@ case 2: EXTRACT_DIGIT(s, x, 10UL, dot); default: if (s == dot) *s++ = '.'; *s++ = '0' + (char)x; } - + *s = '\0'; return s; } @@ -1059,7 +1059,7 @@ * Not allowed, since _mpd_to_string() never returns this form: * * 3) [sign] '.' digits [exponent-part] - * + * * Input: result->data := original numeric string (ASCII) * result->bytes := strlen(result->data) * result->nchars := strlen(result->data) diff --git a/Modules/_decimal/libmpdec/literature/bignum.txt b/Modules/_decimal/libmpdec/literature/bignum.txt --- a/Modules/_decimal/libmpdec/literature/bignum.txt +++ b/Modules/_decimal/libmpdec/literature/bignum.txt @@ -23,7 +23,7 @@ y = fnt(b) # forward transform of b z = pairwise multiply x[i] and y[i] result = inv_fnt(z) # backward transform of z. - + Extending the maximum transform length (Chinese Remainder Theorem): ------------------------------------------------------------------- diff --git a/Modules/_decimal/libmpdec/literature/matrix-transform.txt b/Modules/_decimal/libmpdec/literature/matrix-transform.txt --- a/Modules/_decimal/libmpdec/literature/matrix-transform.txt +++ b/Modules/_decimal/libmpdec/literature/matrix-transform.txt @@ -245,7 +245,7 @@ which means that all A[k] = A[m * C + n] are in the correct order. --- +-- [1] Joerg Arndt: "Matters Computational" http://www.jjj.de/fxt/ diff --git a/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt b/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt --- a/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt +++ b/Modules/_decimal/libmpdec/literature/mulmod-ppro.txt @@ -251,7 +251,7 @@ apply Qlt_le_trans with (y := 1). qreduce ((2 # 1) ^ (-62) + (2 # 1) ^ (-126)). - + rewrite Qlt_mult_by_z with (z := 85070591730234615865843651857942052864 # 18446744073709551617). ring_simplify. diff --git a/Modules/_decimal/libmpdec/literature/six-step.txt b/Modules/_decimal/libmpdec/literature/six-step.txt --- a/Modules/_decimal/libmpdec/literature/six-step.txt +++ b/Modules/_decimal/libmpdec/literature/six-step.txt @@ -55,7 +55,7 @@ --- +-- [1] David H. Bailey: FFTs in External or Hierarchical Memory http://crd.lbl.gov/~dhbailey/dhbpapers/ diff --git a/Modules/_decimal/libmpdec/literature/umodarith.lisp b/Modules/_decimal/libmpdec/literature/umodarith.lisp --- a/Modules/_decimal/libmpdec/literature/umodarith.lisp +++ b/Modules/_decimal/libmpdec/literature/umodarith.lisp @@ -321,7 +321,7 @@ (defthmd dw-submod-correct (implies (and (< 0 m) (< m base) - (natp a) (< a m) + (natp a) (< a m) (< hi base) (< lo base) (natp m) (natp base) (natp hi) (natp lo)) diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -3119,7 +3119,7 @@ * ----------XX1234 -> sdigits * ----------X1 -> tiny-digits * |- prec -| - * + * * OR * * bdigits > prec AND @@ -5983,7 +5983,7 @@ mpd_qfinalize(result, ctx, status); } -/* +/* * If the exponent is infinite and base equals one, the result is one * with a coefficient of length prec. Otherwise, result is undefined. * Return the value of the comparison against one. @@ -7129,7 +7129,7 @@ goto nanresult; } - /* Let x := _mpd_qreciprocal(b, prec) + /* Let x := _mpd_qreciprocal(b, prec) * Then x is bounded by: * 1) 1/b - 10**(-prec - bdigits) < x < 1/b + 10**(-prec - bdigits) * 2) 1/b - 10**(-adigits - 4) < x < 1/b + 10**(-adigits - 4) diff --git a/Modules/_decimal/libmpdec/umodarith.h b/Modules/_decimal/libmpdec/umodarith.h --- a/Modules/_decimal/libmpdec/umodarith.h +++ b/Modules/_decimal/libmpdec/umodarith.h @@ -93,7 +93,7 @@ return d; } -/* +/* * Reduce double word modulo m. * Restrictions: m != 0 * ACL2 proof: umodarith.lisp: section dw-reduce diff --git a/Modules/_decimal/libmpdec/vcstdint.h b/Modules/_decimal/libmpdec/vcstdint.h --- a/Modules/_decimal/libmpdec/vcstdint.h +++ b/Modules/_decimal/libmpdec/vcstdint.h @@ -1,32 +1,32 @@ // ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// // Copyright (c) 2006-2008 Alexander Chemeris -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. The name of the author may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// /////////////////////////////////////////////////////////////////////////////// #ifndef _MSC_VER // [ @@ -47,7 +47,7 @@ // error C2733: second C linkage of overloaded function 'wmemchr' not allowed #if (_MSC_VER < 1300) && defined(__cplusplus) extern "C++" { -#endif +#endif # include #if (_MSC_VER < 1300) && defined(__cplusplus) } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 22:59:07 2013 From: python-checkins at python.org (frank.wierzbicki) Date: Wed, 16 Jan 2013 22:59:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogQ2xvc2VkICMxNjg4?= =?utf-8?q?6=3A_test=5Fdictcomps_no_longer_depends_on_dict_order?= Message-ID: <3Ymj4C0SR3zS6v@mail.python.org> http://hg.python.org/cpython/rev/6d06b223c664 changeset: 81546:6d06b223c664 branch: 2.7 parent: 81531:966887830011 user: Frank Wierzbicki date: Wed Jan 16 13:52:22 2013 -0800 summary: Closed #16886: test_dictcomps no longer depends on dict order files: Lib/test/test_dictcomps.py | 117 ++++++++++++++++-------- 1 files changed, 77 insertions(+), 40 deletions(-) diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -1,54 +1,91 @@ +import unittest -doctests = """ +from test import test_support as support - >>> k = "old value" - >>> { k: None for k in range(10) } - {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None} - >>> k - 'old value' +# For scope testing. +g = "Global variable" - >>> { k: k+10 for k in range(10) } - {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, 8: 18, 9: 19} - >>> g = "Global variable" - >>> { k: g for k in range(10) } - {0: 'Global variable', 1: 'Global variable', 2: 'Global variable', 3: 'Global variable', 4: 'Global variable', 5: 'Global variable', 6: 'Global variable', 7: 'Global variable', 8: 'Global variable', 9: 'Global variable'} +class DictComprehensionTest(unittest.TestCase): - >>> { k: v for k in range(10) for v in range(10) if k == v } - {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + def test_basics(self): + expected = {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, + 8: 18, 9: 19} + actual = {k: k + 10 for k in range(10)} + self.assertEqual(actual, expected) - >>> { k: v for v in range(10) for k in range(v*9, v*10) } - {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + expected = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + actual = {k: v for k in range(10) for v in range(10) if k == v} + self.assertEqual(actual, expected) - >>> { x: y for y, x in ((1, 2), (3, 4)) } = 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + def test_scope_isolation(self): + k = "Local Variable" - >>> { x: y for y, x in ((1, 2), (3, 4)) } += 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {k: None for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(k, "Local Variable") -""" + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {k: v for v in range(10) for k in range(v * 9, v * 10)} + self.assertEqual(k, "Local Variable") + self.assertEqual(actual, expected) -__test__ = {'doctests' : doctests} + def test_scope_isolation_from_global(self): + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {g: None for g in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(g, "Global variable") -def test_main(verbose=None): - import sys - from test import test_support - from test import test_dictcomps - test_support.run_doctest(test_dictcomps, verbose) + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {g: v for v in range(10) for g in range(v * 9, v * 10)} + self.assertEqual(g, "Global variable") + self.assertEqual(actual, expected) - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - test_support.run_doctest(test_dictcomps, verbose) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) + def test_global_visibility(self): + expected = {0: 'Global variable', 1: 'Global variable', + 2: 'Global variable', 3: 'Global variable', + 4: 'Global variable', 5: 'Global variable', + 6: 'Global variable', 7: 'Global variable', + 8: 'Global variable', 9: 'Global variable'} + actual = {k: g for k in range(10)} + self.assertEqual(actual, expected) + + def test_local_visibility(self): + v = "Local variable" + expected = {0: 'Local variable', 1: 'Local variable', + 2: 'Local variable', 3: 'Local variable', + 4: 'Local variable', 5: 'Local variable', + 6: 'Local variable', 7: 'Local variable', + 8: 'Local variable', 9: 'Local variable'} + actual = {k: v for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(v, "Local variable") + + def test_illegal_assignment(self): + with self.assertRaisesRegexp(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} = 5", "", + "exec") + + with self.assertRaisesRegexp(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} += 5", "", + "exec") + + +def test_main(): + support.run_unittest(__name__) if __name__ == "__main__": - test_main(verbose=True) + test_main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 22:59:09 2013 From: python-checkins at python.org (frank.wierzbicki) Date: Wed, 16 Jan 2013 22:59:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogQ2xvc2VkICMxNjg4?= =?utf-8?q?6=3A_test=5Fdictcomps_no_longer_depends_on_dict_order?= Message-ID: <3Ymj4F2HvdzS7b@mail.python.org> http://hg.python.org/cpython/rev/c7dfc307b88e changeset: 81547:c7dfc307b88e branch: 3.2 parent: 81532:8eac88f49cc0 user: Frank Wierzbicki date: Wed Jan 16 13:55:12 2013 -0800 summary: Closed #16886: test_dictcomps no longer depends on dict order files: Lib/test/test_dictcomps.py | 117 ++++++++++++++++-------- 1 files changed, 77 insertions(+), 40 deletions(-) diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -1,54 +1,91 @@ +import unittest -doctests = """ +from test import support - >>> k = "old value" - >>> { k: None for k in range(10) } - {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None} - >>> k - 'old value' +# For scope testing. +g = "Global variable" - >>> { k: k+10 for k in range(10) } - {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, 8: 18, 9: 19} - >>> g = "Global variable" - >>> { k: g for k in range(10) } - {0: 'Global variable', 1: 'Global variable', 2: 'Global variable', 3: 'Global variable', 4: 'Global variable', 5: 'Global variable', 6: 'Global variable', 7: 'Global variable', 8: 'Global variable', 9: 'Global variable'} +class DictComprehensionTest(unittest.TestCase): - >>> { k: v for k in range(10) for v in range(10) if k == v } - {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + def test_basics(self): + expected = {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, + 8: 18, 9: 19} + actual = {k: k + 10 for k in range(10)} + self.assertEqual(actual, expected) - >>> { k: v for v in range(10) for k in range(v*9, v*10) } - {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + expected = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + actual = {k: v for k in range(10) for v in range(10) if k == v} + self.assertEqual(actual, expected) - >>> { x: y for y, x in ((1, 2), (3, 4)) } = 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + def test_scope_isolation(self): + k = "Local Variable" - >>> { x: y for y, x in ((1, 2), (3, 4)) } += 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {k: None for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(k, "Local Variable") -""" + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {k: v for v in range(10) for k in range(v * 9, v * 10)} + self.assertEqual(k, "Local Variable") + self.assertEqual(actual, expected) -__test__ = {'doctests' : doctests} + def test_scope_isolation_from_global(self): + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {g: None for g in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(g, "Global variable") -def test_main(verbose=None): - import sys - from test import support - from test import test_dictcomps - support.run_doctest(test_dictcomps, verbose) + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {g: v for v in range(10) for g in range(v * 9, v * 10)} + self.assertEqual(g, "Global variable") + self.assertEqual(actual, expected) - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_doctest(test_dictcomps, verbose) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) + def test_global_visibility(self): + expected = {0: 'Global variable', 1: 'Global variable', + 2: 'Global variable', 3: 'Global variable', + 4: 'Global variable', 5: 'Global variable', + 6: 'Global variable', 7: 'Global variable', + 8: 'Global variable', 9: 'Global variable'} + actual = {k: g for k in range(10)} + self.assertEqual(actual, expected) + + def test_local_visibility(self): + v = "Local variable" + expected = {0: 'Local variable', 1: 'Local variable', + 2: 'Local variable', 3: 'Local variable', + 4: 'Local variable', 5: 'Local variable', + 6: 'Local variable', 7: 'Local variable', + 8: 'Local variable', 9: 'Local variable'} + actual = {k: v for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(v, "Local variable") + + def test_illegal_assignment(self): + with self.assertRaisesRegex(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} = 5", "", + "exec") + + with self.assertRaisesRegex(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} += 5", "", + "exec") + + +def test_main(): + support.run_unittest(__name__) if __name__ == "__main__": - test_main(verbose=True) + test_main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 22:59:10 2013 From: python-checkins at python.org (frank.wierzbicki) Date: Wed, 16 Jan 2013 22:59:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2316886=3A_merge_with_3=2E2?= Message-ID: <3Ymj4G735vzRv7@mail.python.org> http://hg.python.org/cpython/rev/8ab5bd5f95b3 changeset: 81548:8ab5bd5f95b3 branch: 3.3 parent: 81544:750f44e621aa parent: 81547:c7dfc307b88e user: Frank Wierzbicki date: Wed Jan 16 13:56:54 2013 -0800 summary: #16886: merge with 3.2 files: Lib/test/test_dictcomps.py | 117 ++++++++++++++++-------- 1 files changed, 77 insertions(+), 40 deletions(-) diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -1,54 +1,91 @@ +import unittest -doctests = """ +from test import support - >>> k = "old value" - >>> { k: None for k in range(10) } - {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None} - >>> k - 'old value' +# For scope testing. +g = "Global variable" - >>> { k: k+10 for k in range(10) } - {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, 8: 18, 9: 19} - >>> g = "Global variable" - >>> { k: g for k in range(10) } - {0: 'Global variable', 1: 'Global variable', 2: 'Global variable', 3: 'Global variable', 4: 'Global variable', 5: 'Global variable', 6: 'Global variable', 7: 'Global variable', 8: 'Global variable', 9: 'Global variable'} +class DictComprehensionTest(unittest.TestCase): - >>> { k: v for k in range(10) for v in range(10) if k == v } - {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + def test_basics(self): + expected = {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, + 8: 18, 9: 19} + actual = {k: k + 10 for k in range(10)} + self.assertEqual(actual, expected) - >>> { k: v for v in range(10) for k in range(v*9, v*10) } - {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + expected = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + actual = {k: v for k in range(10) for v in range(10) if k == v} + self.assertEqual(actual, expected) - >>> { x: y for y, x in ((1, 2), (3, 4)) } = 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + def test_scope_isolation(self): + k = "Local Variable" - >>> { x: y for y, x in ((1, 2), (3, 4)) } += 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {k: None for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(k, "Local Variable") -""" + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {k: v for v in range(10) for k in range(v * 9, v * 10)} + self.assertEqual(k, "Local Variable") + self.assertEqual(actual, expected) -__test__ = {'doctests' : doctests} + def test_scope_isolation_from_global(self): + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {g: None for g in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(g, "Global variable") -def test_main(verbose=None): - import sys - from test import support - from test import test_dictcomps - support.run_doctest(test_dictcomps, verbose) + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {g: v for v in range(10) for g in range(v * 9, v * 10)} + self.assertEqual(g, "Global variable") + self.assertEqual(actual, expected) - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_doctest(test_dictcomps, verbose) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) + def test_global_visibility(self): + expected = {0: 'Global variable', 1: 'Global variable', + 2: 'Global variable', 3: 'Global variable', + 4: 'Global variable', 5: 'Global variable', + 6: 'Global variable', 7: 'Global variable', + 8: 'Global variable', 9: 'Global variable'} + actual = {k: g for k in range(10)} + self.assertEqual(actual, expected) + + def test_local_visibility(self): + v = "Local variable" + expected = {0: 'Local variable', 1: 'Local variable', + 2: 'Local variable', 3: 'Local variable', + 4: 'Local variable', 5: 'Local variable', + 6: 'Local variable', 7: 'Local variable', + 8: 'Local variable', 9: 'Local variable'} + actual = {k: v for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(v, "Local variable") + + def test_illegal_assignment(self): + with self.assertRaisesRegex(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} = 5", "", + "exec") + + with self.assertRaisesRegex(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} += 5", "", + "exec") + + +def test_main(): + support.run_unittest(__name__) if __name__ == "__main__": - test_main(verbose=True) + test_main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 22:59:12 2013 From: python-checkins at python.org (frank.wierzbicki) Date: Wed, 16 Jan 2013 22:59:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_=2316886=3A_merge_with_3=2E3?= Message-ID: <3Ymj4J5JwMzRnh@mail.python.org> http://hg.python.org/cpython/rev/d0cef6c90efc changeset: 81549:d0cef6c90efc parent: 81545:f87d85f7596c parent: 81548:8ab5bd5f95b3 user: Frank Wierzbicki date: Wed Jan 16 13:58:14 2013 -0800 summary: #16886: merge with 3.3 files: Lib/test/test_dictcomps.py | 117 ++++++++++++++++-------- 1 files changed, 77 insertions(+), 40 deletions(-) diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -1,54 +1,91 @@ +import unittest -doctests = """ +from test import support - >>> k = "old value" - >>> { k: None for k in range(10) } - {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None} - >>> k - 'old value' +# For scope testing. +g = "Global variable" - >>> { k: k+10 for k in range(10) } - {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, 8: 18, 9: 19} - >>> g = "Global variable" - >>> { k: g for k in range(10) } - {0: 'Global variable', 1: 'Global variable', 2: 'Global variable', 3: 'Global variable', 4: 'Global variable', 5: 'Global variable', 6: 'Global variable', 7: 'Global variable', 8: 'Global variable', 9: 'Global variable'} +class DictComprehensionTest(unittest.TestCase): - >>> { k: v for k in range(10) for v in range(10) if k == v } - {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + def test_basics(self): + expected = {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, + 8: 18, 9: 19} + actual = {k: k + 10 for k in range(10)} + self.assertEqual(actual, expected) - >>> { k: v for v in range(10) for k in range(v*9, v*10) } - {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + expected = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9} + actual = {k: v for k in range(10) for v in range(10) if k == v} + self.assertEqual(actual, expected) - >>> { x: y for y, x in ((1, 2), (3, 4)) } = 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + def test_scope_isolation(self): + k = "Local Variable" - >>> { x: y for y, x in ((1, 2), (3, 4)) } += 5 # doctest: +IGNORE_EXCEPTION_DETAIL - Traceback (most recent call last): - ... - SyntaxError: ... + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {k: None for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(k, "Local Variable") -""" + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {k: v for v in range(10) for k in range(v * 9, v * 10)} + self.assertEqual(k, "Local Variable") + self.assertEqual(actual, expected) -__test__ = {'doctests' : doctests} + def test_scope_isolation_from_global(self): + expected = {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, + 6: None, 7: None, 8: None, 9: None} + actual = {g: None for g in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(g, "Global variable") -def test_main(verbose=None): - import sys - from test import support - from test import test_dictcomps - support.run_doctest(test_dictcomps, verbose) + expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, + 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, + 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, + 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, + 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, + 85: 9, 86: 9, 87: 9, 88: 9, 89: 9} + actual = {g: v for v in range(10) for g in range(v * 9, v * 10)} + self.assertEqual(g, "Global variable") + self.assertEqual(actual, expected) - # verify reference counting - if verbose and hasattr(sys, "gettotalrefcount"): - import gc - counts = [None] * 5 - for i in range(len(counts)): - support.run_doctest(test_dictcomps, verbose) - gc.collect() - counts[i] = sys.gettotalrefcount() - print(counts) + def test_global_visibility(self): + expected = {0: 'Global variable', 1: 'Global variable', + 2: 'Global variable', 3: 'Global variable', + 4: 'Global variable', 5: 'Global variable', + 6: 'Global variable', 7: 'Global variable', + 8: 'Global variable', 9: 'Global variable'} + actual = {k: g for k in range(10)} + self.assertEqual(actual, expected) + + def test_local_visibility(self): + v = "Local variable" + expected = {0: 'Local variable', 1: 'Local variable', + 2: 'Local variable', 3: 'Local variable', + 4: 'Local variable', 5: 'Local variable', + 6: 'Local variable', 7: 'Local variable', + 8: 'Local variable', 9: 'Local variable'} + actual = {k: v for k in range(10)} + self.assertEqual(actual, expected) + self.assertEqual(v, "Local variable") + + def test_illegal_assignment(self): + with self.assertRaisesRegex(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} = 5", "", + "exec") + + with self.assertRaisesRegex(SyntaxError, "can't assign"): + compile("{x: y for y, x in ((1, 2), (3, 4))} += 5", "", + "exec") + + +def test_main(): + support.run_unittest(__name__) if __name__ == "__main__": - test_main(verbose=True) + test_main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 23:11:40 2013 From: python-checkins at python.org (frank.wierzbicki) Date: Wed, 16 Jan 2013 23:11:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Use_unittest?= =?utf-8?q?=2Emain=28=29_in_3=2E3_and_greater?= Message-ID: <3YmjLh5gLfzRnh@mail.python.org> http://hg.python.org/cpython/rev/489f4e716b4b changeset: 81550:489f4e716b4b branch: 3.3 parent: 81548:8ab5bd5f95b3 user: Frank Wierzbicki date: Wed Jan 16 14:09:57 2013 -0800 summary: Use unittest.main() in 3.3 and greater files: Lib/test/test_dictcomps.py | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -84,8 +84,5 @@ "exec") -def test_main(): - support.run_unittest(__name__) - if __name__ == "__main__": - test_main() + unittest.main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 23:11:42 2013 From: python-checkins at python.org (frank.wierzbicki) Date: Wed, 16 Jan 2013 23:11:42 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E3?= Message-ID: <3YmjLk1T1PzRwR@mail.python.org> http://hg.python.org/cpython/rev/0dbd8a357a99 changeset: 81551:0dbd8a357a99 parent: 81549:d0cef6c90efc parent: 81550:489f4e716b4b user: Frank Wierzbicki date: Wed Jan 16 14:10:36 2013 -0800 summary: merge with 3.3 files: Lib/test/test_dictcomps.py | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py --- a/Lib/test/test_dictcomps.py +++ b/Lib/test/test_dictcomps.py @@ -84,8 +84,5 @@ "exec") -def test_main(): - support.run_unittest(__name__) - if __name__ == "__main__": - test_main() + unittest.main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 23:27:10 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 23:27:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzExNzI5?= =?utf-8?q?=3A_Backport_commit_bff052d9_from_libffi_upstream_in_order_to_f?= =?utf-8?q?ix?= Message-ID: <3YmjhZ4RbCzS1s@mail.python.org> http://hg.python.org/cpython/rev/190a115b7748 changeset: 81552:190a115b7748 branch: 3.3 parent: 81550:489f4e716b4b user: Stefan Krah date: Wed Jan 16 23:18:34 2013 +0100 summary: Issue #11729: Backport commit bff052d9 from libffi upstream in order to fix a ctypes build failure with clang. files: Modules/_ctypes/libffi/configure | 6 +++--- Modules/_ctypes/libffi/configure.ac | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/_ctypes/libffi/configure b/Modules/_ctypes/libffi/configure --- a/Modules/_ctypes/libffi/configure +++ b/Modules/_ctypes/libffi/configure @@ -14322,10 +14322,10 @@ $as_echo_n "(cached) " >&6 else - libffi_cv_as_x86_pcrel=yes + libffi_cv_as_x86_pcrel=no echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then - libffi_cv_as_x86_pcrel=no + if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then + libffi_cv_as_x86_pcrel=yes fi fi diff --git a/Modules/_ctypes/libffi/configure.ac b/Modules/_ctypes/libffi/configure.ac --- a/Modules/_ctypes/libffi/configure.ac +++ b/Modules/_ctypes/libffi/configure.ac @@ -303,10 +303,10 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then AC_CACHE_CHECK([assembler supports pc related relocs], libffi_cv_as_x86_pcrel, [ - libffi_cv_as_x86_pcrel=yes + libffi_cv_as_x86_pcrel=no echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then - libffi_cv_as_x86_pcrel=no + if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then + libffi_cv_as_x86_pcrel=yes fi ]) if test "x$libffi_cv_as_x86_pcrel" = xyes; then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 16 23:27:12 2013 From: python-checkins at python.org (stefan.krah) Date: Wed, 16 Jan 2013 23:27:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3Ymjhc0Y4czS75@mail.python.org> http://hg.python.org/cpython/rev/f3e348ab08c6 changeset: 81553:f3e348ab08c6 parent: 81551:0dbd8a357a99 parent: 81552:190a115b7748 user: Stefan Krah date: Wed Jan 16 23:25:41 2013 +0100 summary: Merge 3.3. files: Modules/_ctypes/libffi/configure | 6 +++--- Modules/_ctypes/libffi/configure.ac | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/_ctypes/libffi/configure b/Modules/_ctypes/libffi/configure --- a/Modules/_ctypes/libffi/configure +++ b/Modules/_ctypes/libffi/configure @@ -14322,10 +14322,10 @@ $as_echo_n "(cached) " >&6 else - libffi_cv_as_x86_pcrel=yes + libffi_cv_as_x86_pcrel=no echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then - libffi_cv_as_x86_pcrel=no + if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then + libffi_cv_as_x86_pcrel=yes fi fi diff --git a/Modules/_ctypes/libffi/configure.ac b/Modules/_ctypes/libffi/configure.ac --- a/Modules/_ctypes/libffi/configure.ac +++ b/Modules/_ctypes/libffi/configure.ac @@ -303,10 +303,10 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then AC_CACHE_CHECK([assembler supports pc related relocs], libffi_cv_as_x86_pcrel, [ - libffi_cv_as_x86_pcrel=yes + libffi_cv_as_x86_pcrel=no echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then - libffi_cv_as_x86_pcrel=no + if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then + libffi_cv_as_x86_pcrel=yes fi ]) if test "x$libffi_cv_as_x86_pcrel" = xyes; then -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Thu Jan 17 05:56:47 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 17 Jan 2013 05:56:47 +0100 Subject: [Python-checkins] Daily reference leaks (f3e348ab08c6): sum=0 Message-ID: results for f3e348ab08c6 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogIlOgAX', '-x'] From python-checkins at python.org Thu Jan 17 12:54:11 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 12:54:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Fix_build_with?= =?utf-8?q?_3=2Ex_gcc_versions=2E?= Message-ID: <3Yn3bl06wczS8T@mail.python.org> http://hg.python.org/cpython/rev/d536f34759f5 changeset: 81554:d536f34759f5 branch: 3.3 parent: 81552:190a115b7748 user: Stefan Krah date: Thu Jan 17 12:49:34 2013 +0100 summary: Fix build with 3.x gcc versions. files: setup.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1997,8 +1997,12 @@ # Increase warning level for gcc: if 'gcc' in cc: - extra_compile_args.extend(['-Wextra', - '-Wno-missing-field-initializers']) + cmd = ("echo '' | gcc -Wextra -Wno-missing-field-initializers -E - " + "> /dev/null 2>&1") + ret = os.system(cmd) + if ret >> 8 == 0: + extra_compile_args.extend(['-Wextra', + '-Wno-missing-field-initializers']) # Uncomment for extra functionality: #define_macros.append(('EXTRA_FUNCTIONALITY', 1)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 12:54:12 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 12:54:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3Yn3bm34NbzSB0@mail.python.org> http://hg.python.org/cpython/rev/9638fc96deb7 changeset: 81555:9638fc96deb7 parent: 81553:f3e348ab08c6 parent: 81554:d536f34759f5 user: Stefan Krah date: Thu Jan 17 12:52:42 2013 +0100 summary: Merge 3.3. files: setup.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -2008,8 +2008,12 @@ # Increase warning level for gcc: if 'gcc' in cc: - extra_compile_args.extend(['-Wextra', - '-Wno-missing-field-initializers']) + cmd = ("echo '' | gcc -Wextra -Wno-missing-field-initializers -E - " + "> /dev/null 2>&1") + ret = os.system(cmd) + if ret >> 8 == 0: + extra_compile_args.extend(['-Wextra', + '-Wno-missing-field-initializers']) # Uncomment for extra functionality: #define_macros.append(('EXTRA_FUNCTIONALITY', 1)) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 15:36:02 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 15:36:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE0MTEw?= =?utf-8?q?=3A_Fix_test_failures_on_FreeBSD_if_the_user_is_in_the_wheel_gr?= =?utf-8?q?oup=2E?= Message-ID: <3Yn7BV1rwrzS9Y@mail.python.org> http://hg.python.org/cpython/rev/a94752d75c74 changeset: 81556:a94752d75c74 branch: 3.3 parent: 81554:d536f34759f5 user: Stefan Krah date: Thu Jan 17 15:31:00 2013 +0100 summary: Issue #14110: Fix test failures on FreeBSD if the user is in the wheel group. files: Lib/test/test_os.py | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -49,6 +49,9 @@ else: USING_LINUXTHREADS = False +# Issue #14110: Some tests fail on FreeBSD if the user is in the wheel group. +HAVE_WHEEL_GROUP = sys.platform.startswith('freebsd') and os.getgid() == 0 + # Tests creating TESTFN class FileTests(unittest.TestCase): def setUp(self): @@ -1240,7 +1243,7 @@ if hasattr(os, 'setgid'): def test_setgid(self): - if os.getuid() != 0: + if os.getuid() != 0 and not HAVE_WHEEL_GROUP: self.assertRaises(os.error, os.setgid, 0) self.assertRaises(OverflowError, os.setgid, 1<<32) @@ -1252,7 +1255,7 @@ if hasattr(os, 'setegid'): def test_setegid(self): - if os.getuid() != 0: + if os.getuid() != 0 and not HAVE_WHEEL_GROUP: self.assertRaises(os.error, os.setegid, 0) self.assertRaises(OverflowError, os.setegid, 1<<32) @@ -1272,7 +1275,7 @@ if hasattr(os, 'setregid'): def test_setregid(self): - if os.getuid() != 0: + if os.getuid() != 0 and not HAVE_WHEEL_GROUP: self.assertRaises(os.error, os.setregid, 0, 0) self.assertRaises(OverflowError, os.setregid, 1<<32, 0) self.assertRaises(OverflowError, os.setregid, 0, 1<<32) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 15:36:03 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 15:36:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3Yn7BW4yLTzSD5@mail.python.org> http://hg.python.org/cpython/rev/59ff2d75c836 changeset: 81557:59ff2d75c836 parent: 81555:9638fc96deb7 parent: 81556:a94752d75c74 user: Stefan Krah date: Thu Jan 17 15:34:50 2013 +0100 summary: Merge 3.3. files: Lib/test/test_os.py | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -49,6 +49,9 @@ else: USING_LINUXTHREADS = False +# Issue #14110: Some tests fail on FreeBSD if the user is in the wheel group. +HAVE_WHEEL_GROUP = sys.platform.startswith('freebsd') and os.getgid() == 0 + # Tests creating TESTFN class FileTests(unittest.TestCase): def setUp(self): @@ -1240,7 +1243,7 @@ if hasattr(os, 'setgid'): def test_setgid(self): - if os.getuid() != 0: + if os.getuid() != 0 and not HAVE_WHEEL_GROUP: self.assertRaises(OSError, os.setgid, 0) self.assertRaises(OverflowError, os.setgid, 1<<32) @@ -1252,7 +1255,7 @@ if hasattr(os, 'setegid'): def test_setegid(self): - if os.getuid() != 0: + if os.getuid() != 0 and not HAVE_WHEEL_GROUP: self.assertRaises(OSError, os.setegid, 0) self.assertRaises(OverflowError, os.setegid, 1<<32) @@ -1272,7 +1275,7 @@ if hasattr(os, 'setregid'): def test_setregid(self): - if os.getuid() != 0: + if os.getuid() != 0 and not HAVE_WHEEL_GROUP: self.assertRaises(OSError, os.setregid, 0, 0) self.assertRaises(OverflowError, os.setregid, 1<<32, 0) self.assertRaises(OverflowError, os.setregid, 0, 1<<32) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 15:37:06 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 17 Jan 2013 15:37:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_docstring_typo_in_conc?= =?utf-8?q?urrent=2Efutures=2EFuture?= Message-ID: <3Yn7Ck5GXgzRFH@mail.python.org> http://hg.python.org/cpython/rev/f43cc9987a1f changeset: 81558:f43cc9987a1f user: Eli Bendersky date: Thu Jan 17 06:36:30 2013 -0800 summary: Fix docstring typo in concurrent.futures.Future files: Lib/concurrent/futures/_base.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py --- a/Lib/concurrent/futures/_base.py +++ b/Lib/concurrent/futures/_base.py @@ -331,7 +331,7 @@ return True def cancelled(self): - """Return True if the future has cancelled.""" + """Return True if the future was cancelled.""" with self._condition: return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 17:08:21 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 17:08:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316982=3A_Fix_--wi?= =?utf-8?q?thout-threads_build_failure=2E?= Message-ID: <3Yn9F15D51zLn4@mail.python.org> http://hg.python.org/cpython/rev/8630fa732cf6 changeset: 81559:8630fa732cf6 user: Stefan Krah date: Thu Jan 17 17:07:17 2013 +0100 summary: Issue #16982: Fix --without-threads build failure. files: Modules/_ssl.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2392,15 +2392,17 @@ PyObject *result; /* The high-level ssl.SSLSocket object */ PyObject *ssl_socket; - PyGILState_STATE gstate; const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); - - gstate = PyGILState_Ensure(); +#ifdef WITH_THREAD + PyGILState_STATE gstate = PyGILState_Ensure(); +#endif if (ssl_ctx->set_hostname == NULL) { /* remove race condition in this the call back while if removing the * callback is in progress */ +#ifdef WITH_THREAD PyGILState_Release(gstate); +#endif return SSL_TLSEXT_ERR_OK; } @@ -2449,14 +2451,18 @@ Py_DECREF(result); } +#ifdef WITH_THREAD PyGILState_Release(gstate); +#endif return ret; error: Py_DECREF(ssl_socket); *al = SSL_AD_INTERNAL_ERROR; ret = SSL_TLSEXT_ERR_ALERT_FATAL; +#ifdef WITH_THREAD PyGILState_Release(gstate); +#endif return ret; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 20:45:09 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 20:45:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTg3?= =?utf-8?q?=3A_Fix_definition_of_SHLIB=5FEXT=2E?= Message-ID: <3YnG390DrqzSDp@mail.python.org> http://hg.python.org/cpython/rev/937e9df47ccd changeset: 81560:937e9df47ccd branch: 3.3 parent: 81556:a94752d75c74 user: Stefan Krah date: Thu Jan 17 20:41:56 2013 +0100 summary: Issue #16987: Fix definition of SHLIB_EXT. files: configure | 11 ++++++----- configure.ac | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/configure b/configure --- a/configure +++ b/configure @@ -8384,11 +8384,6 @@ - -cat >>confdefs.h <<_ACEOF -#define SHLIB_EXT "$SO" -_ACEOF - # LDSHARED is the ld *command* used to create shared library # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into @@ -13721,6 +13716,12 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SO" >&5 $as_echo "$SO" >&6; } + +cat >>confdefs.h <<_ACEOF +#define SHLIB_EXT "$SO" +_ACEOF + + # Check whether right shifting a negative integer extends the sign bit # or fills with zeros (like the Cray J90, according to Tim Peters). { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1898,7 +1898,6 @@ AC_SUBST(CCSHARED) AC_SUBST(LINKFORSHARED) -AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).]) # LDSHARED is the ld *command* used to create shared library # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into @@ -3956,6 +3955,8 @@ fi AC_MSG_RESULT($SO) +AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).]) + # Check whether right shifting a negative integer extends the sign bit # or fills with zeros (like the Cray J90, according to Tim Peters). AC_MSG_CHECKING(whether right shift extends the sign bit) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 20:45:11 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 20:45:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YnG3C1V1wzSFw@mail.python.org> http://hg.python.org/cpython/rev/144c82bebf17 changeset: 81561:144c82bebf17 parent: 81559:8630fa732cf6 parent: 81560:937e9df47ccd user: Stefan Krah date: Thu Jan 17 20:44:02 2013 +0100 summary: Merge 3.3. files: configure | 11 ++++++----- configure.ac | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/configure b/configure --- a/configure +++ b/configure @@ -8384,11 +8384,6 @@ - -cat >>confdefs.h <<_ACEOF -#define SHLIB_EXT "$SO" -_ACEOF - # LDSHARED is the ld *command* used to create shared library # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into @@ -13721,6 +13716,12 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SO" >&5 $as_echo "$SO" >&6; } + +cat >>confdefs.h <<_ACEOF +#define SHLIB_EXT "$SO" +_ACEOF + + # Check whether right shifting a negative integer extends the sign bit # or fills with zeros (like the Cray J90, according to Tim Peters). { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1898,7 +1898,6 @@ AC_SUBST(CCSHARED) AC_SUBST(LINKFORSHARED) -AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).]) # LDSHARED is the ld *command* used to create shared library # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into @@ -3956,6 +3955,8 @@ fi AC_MSG_RESULT($SO) +AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).]) + # Check whether right shifting a negative integer extends the sign bit # or fills with zeros (like the Cray J90, according to Tim Peters). AC_MSG_CHECKING(whether right shift extends the sign bit) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 20:57:04 2013 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 17 Jan 2013 20:57:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Rename_create=5Ftransport=28?= =?utf-8?q?=29_to_create=5Fconnection=28=29=2E_Remove_type_argument=2E?= Message-ID: <3YnGJw19bQzSFV@mail.python.org> http://hg.python.org/peps/rev/a68dfdcf7879 changeset: 4680:a68dfdcf7879 user: Guido van Rossum date: Thu Jan 17 11:57:00 2013 -0800 summary: Rename create_transport() to create_connection(). Remove type argument. files: pep-3156.txt | 50 +++++++++++++++++++++++---------------- 1 files changed, 29 insertions(+), 21 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -295,49 +295,57 @@ on success will be a tuple ``(host, port)``. Same implementation remarks as for ``getaddrinfo()``. -- ``create_transport(protocol_factory, host, port, **kwargs)``. - Creates a transport and a protocol and ties them together. Returns - a Future whose result on success is a (transport, protocol) pair. - The protocol is created by calling ``protocol_factory()`` without - arguments(*). Note that when the Future completes, the protocol's - ``connection_made()`` method has not yet been called; that will - happen when the connection handshake is complete. When it is - impossible to connect to the given host and port, the Future will - raise an exception instead. +- ``create_connection(protocol_factory, host, port, **kwargs)``. + Creates a stream connection to a given host and port. This creates + an implementation-dependent Transport to represent the connection, + then calls ``protocol_factory()`` to instantiate (or retrieve) the + user's Protocol implementation, and finally ties the two together. + (See below for the definitions of Transport and Protocol.) The + user's Protocol implementation is created or retrieved by calling + ``protocol_factory()`` without arguments(*). The return value is a + Future whose result on success is the ``(transport, protocol)`` + pair; if a failure prevents the creation of a successful connection, + the Future will have an appropriate exception set. Note that when + the Future completes, the protocol's ``connection_made()`` method + has not yet been called; that will happen when the connection + handshake is complete. (*) There is no requirement that ``protocol_factory`` is a class. If your protocol class needs to have specific arguments passed to its constructor, you can use ``lambda`` or ``functools.partial()``. + You can also pass a trivial ``lambda`` that returns a previously + constructed Protocol instance. Optional keyword arguments: - - ``family``, ``type``, ``proto``, ``flags``: Address familty, - socket type, protcol, and miscellaneous flags to be passed through - to ``getaddrinfo()``. These all default to ``0`` except ``type`` - which defaults to ``socket.SOCK_STREAM``. + - ``family``, ``proto``, ``flags``: Address familty, + protcol, and miscellaneous flags to be passed through + to ``getaddrinfo()``. These all default to ``0``. + (The socket type is always ``SOCK_STREAM``.) - ``ssl``: Pass ``True`` to create an SSL transport (by default a plain TCP is created). Or pass an ``ssl.SSLContext`` object to override the default SSL context object to be used. - TBD: Should this be called create_connection()? - - ``start_serving(protocol_factory, host, port, **kwds)``. Enters a loop that accepts connections. Returns a Future that completes once the loop is set up to serve; its return value is None. Each time a connection is accepted, ``protocol_factory`` is called without - arguments(*) to create a protocol, a transport is created to represent + arguments(*) to create a Protocol, a Transport is created to represent the network side of the connection, and the two are tied together by calling ``protocol.connection_made(transport)``. - (*) See footnote above for ``create_transport()``. + (*) See footnote above for ``create_connection()``. However, since + ``protocol_factory()`` is called once for each new incoming + connection, it is recommended that it return a new Protocol object + each time it is called. Optional keyword arguments: - - ``family``, ``type``, ``proto``, ``flags``: Address familty, - socket type, protcol, and miscellaneous flags to be passed through - to ``getaddrinfo()``. These all default to ``0`` except ``type`` - which defaults to ``socket.SOCK_STREAM``. + - ``family``, ``proto``, ``flags``: Address familty, + protcol, and miscellaneous flags to be passed through + to ``getaddrinfo()``. These all default to ``0``. + (The socket type is always ``SOCK_STREAM``.) TBD: Support SSL? I don't even know how to do that synchronously, and I suppose it needs a certificate. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 17 23:11:51 2013 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 17 Jan 2013 23:11:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Remove_outdate?= =?utf-8?q?d_statement?= Message-ID: <3YnKJR31TQzSDc@mail.python.org> http://hg.python.org/cpython/rev/ce6dc780e69e changeset: 81562:ce6dc780e69e branch: 3.2 parent: 81547:c7dfc307b88e user: Antoine Pitrou date: Thu Jan 17 23:08:03 2013 +0100 summary: Remove outdated statement files: Lib/test/test_capi.py | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -170,7 +170,6 @@ self.pendingcalls_wait(l, n) def test_subinterps(self): - # XXX this test leaks in refleak runs import builtins r, w = os.pipe() code = """if 1: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 23:11:52 2013 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 17 Jan 2013 23:11:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Remove_outdated_statement?= Message-ID: <3YnKJS5gvrzSDc@mail.python.org> http://hg.python.org/cpython/rev/c6276dea445c changeset: 81563:c6276dea445c branch: 3.3 parent: 81560:937e9df47ccd parent: 81562:ce6dc780e69e user: Antoine Pitrou date: Thu Jan 17 23:08:26 2013 +0100 summary: Remove outdated statement files: Lib/test/test_capi.py | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -193,7 +193,6 @@ self.pendingcalls_wait(l, n) def test_subinterps(self): - # XXX this test leaks in refleak runs import builtins r, w = os.pipe() code = """if 1: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 23:11:54 2013 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 17 Jan 2013 23:11:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Remove_outdated_statement?= Message-ID: <3YnKJV1twJzSDp@mail.python.org> http://hg.python.org/cpython/rev/0e191a9d9a13 changeset: 81564:0e191a9d9a13 parent: 81561:144c82bebf17 parent: 81563:c6276dea445c user: Antoine Pitrou date: Thu Jan 17 23:09:07 2013 +0100 summary: Remove outdated statement files: Lib/test/test_capi.py | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -193,7 +193,6 @@ self.pendingcalls_wait(l, n) def test_subinterps(self): - # XXX this test leaks in refleak runs import builtins r, w = os.pipe() code = """if 1: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 23:13:30 2013 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 17 Jan 2013 23:13:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Remove_pointle?= =?utf-8?q?ss_discussion_of_the_lack_of_a_ternary_operator?= Message-ID: <3YnKLL2GZPzSDc@mail.python.org> http://hg.python.org/cpython/rev/af5feb869304 changeset: 81565:af5feb869304 branch: 2.7 parent: 81546:6d06b223c664 user: Antoine Pitrou date: Thu Jan 17 23:10:12 2013 +0100 summary: Remove pointless discussion of the lack of a ternary operator files: Doc/faq/programming.rst | 46 ----------------------------- 1 files changed, 0 insertions(+), 46 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -769,52 +769,6 @@ For versions previous to 2.5 the answer would be 'No'. -.. XXX remove rest? - -In many cases you can mimic ``a ? b : c`` with ``a and b or c``, but there's a -flaw: if *b* is zero (or empty, or ``None`` -- anything that tests false) then -*c* will be selected instead. In many cases you can prove by looking at the -code that this can't happen (e.g. because *b* is a constant or has a type that -can never be false), but in general this can be a problem. - -Tim Peters (who wishes it was Steve Majewski) suggested the following solution: -``(a and [b] or [c])[0]``. Because ``[b]`` is a singleton list it is never -false, so the wrong path is never taken; then applying ``[0]`` to the whole -thing gets the *b* or *c* that you really wanted. Ugly, but it gets you there -in the rare cases where it is really inconvenient to rewrite your code using -'if'. - -The best course is usually to write a simple ``if...else`` statement. Another -solution is to implement the ``?:`` operator as a function:: - - def q(cond, on_true, on_false): - if cond: - if not isfunction(on_true): - return on_true - else: - return on_true() - else: - if not isfunction(on_false): - return on_false - else: - return on_false() - -In most cases you'll pass b and c directly: ``q(a, b, c)``. To avoid evaluating -b or c when they shouldn't be, encapsulate them within a lambda function, e.g.: -``q(a, lambda: b, lambda: c)``. - -It has been asked *why* Python has no if-then-else expression. There are -several answers: many languages do just fine without one; it can easily lead to -less readable code; no sufficiently "Pythonic" syntax has been discovered; a -search of the standard library found remarkably few places where using an -if-then-else expression would make the code more understandable. - -In 2002, :pep:`308` was written proposing several possible syntaxes and the -community was asked to vote on the issue. The vote was inconclusive. Most -people liked one of the syntaxes, but also hated other syntaxes; many votes -implied that people preferred no ternary operator rather than having a syntax -they hated. - Is it possible to write obfuscated one-liners in Python? -------------------------------------------------------- -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 23:37:27 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 23:37:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzExODcw?= =?utf-8?b?OiBTa2lwIHRlc3RfM19qb2luX2luX2ZvcmtlZF9mcm9tX3RocmVhZCgpIG9u?= =?utf-8?q?_HP-UX=2E?= Message-ID: <3YnKsz6BXlzRLf@mail.python.org> http://hg.python.org/cpython/rev/cd54b48946ca changeset: 81566:cd54b48946ca branch: 3.3 parent: 81563:c6276dea445c user: Stefan Krah date: Thu Jan 17 23:29:54 2013 +0100 summary: Issue #11870: Skip test_3_join_in_forked_from_thread() on HP-UX. files: Lib/test/test_threading.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -452,7 +452,7 @@ # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', - 'os2emx') + 'os2emx', 'hp-ux11') def _run_and_join(self, script): script = """if 1: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 17 23:37:29 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 17 Jan 2013 23:37:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YnKt127JhzSDw@mail.python.org> http://hg.python.org/cpython/rev/cb297930d2cf changeset: 81567:cb297930d2cf parent: 81564:0e191a9d9a13 parent: 81566:cd54b48946ca user: Stefan Krah date: Thu Jan 17 23:36:08 2013 +0100 summary: Merge 3.3. files: Lib/test/test_threading.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -451,7 +451,8 @@ # #12316 and #11870), and fork() from a worker thread is known to trigger # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. - platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5') + platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', + 'hp-ux11') def _run_and_join(self, script): script = """if 1: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 00:42:53 2013 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 18 Jan 2013 00:42:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Suggest_that_some_APIs_be_mar?= =?utf-8?q?ked_as_=22transports-only=22=2E?= Message-ID: <3YnMKT5MHlzS5G@mail.python.org> http://hg.python.org/peps/rev/7431ef8732d7 changeset: 4681:7431ef8732d7 user: Guido van Rossum date: Thu Jan 17 15:42:47 2013 -0800 summary: Suggest that some APIs be marked as "transports-only". files: pep-3156.txt | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -439,7 +439,8 @@ TBD: Optional methods are not so good. Perhaps these should be required? It may still depend on the platform which set is more -efficient. +efficient. Another possibility: document these as "for transports +only" and the rest as "for anyone". Callback Sequencing ------------------- -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Fri Jan 18 05:57:40 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 18 Jan 2013 05:57:40 +0100 Subject: [Python-checkins] Daily reference leaks (cb297930d2cf): sum=7 Message-ID: results for cb297930d2cf on branch "default" -------------------------------------------- test_dbm leaked [2, 0, 0] references, sum=2 test_dbm leaked [2, 2, 1] memory blocks, sum=5 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogwdbpH9', '-x'] From python-checkins at python.org Fri Jan 18 06:12:59 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 18 Jan 2013 06:12:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_check_windows_?= =?utf-8?q?fd_validity_=28closes_=2316992=29?= Message-ID: <3YnVfM0jS0zSBJ@mail.python.org> http://hg.python.org/cpython/rev/2adc83b4738f changeset: 81568:2adc83b4738f branch: 3.3 parent: 81566:cd54b48946ca user: Benjamin Peterson date: Fri Jan 18 00:10:24 2013 -0500 summary: check windows fd validity (closes #16992) files: Lib/test/test_signal.py | 11 +++++++++-- Misc/NEWS | 3 +++ Modules/signalmodule.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -222,6 +222,13 @@ signal.signal(7, handler) +class WakeupFDTests(unittest.TestCase): + + def test_invalid_fd(self): + fd = support.make_bad_fd() + self.assertRaises(ValueError, signal.set_wakeup_fd, fd) + + @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class WakeupSignalTests(unittest.TestCase): def check_wakeup(self, test_body, *signals, ordered=True): @@ -864,8 +871,8 @@ def test_main(): try: support.run_unittest(PosixTests, InterProcessSignalTests, - WakeupSignalTests, SiginterruptTest, - ItimerTest, WindowsSignalTests, + WakeupFDTests, WakeupSignalTests, + SiginterruptTest, ItimerTest, WindowsSignalTests, PendingSignalsTests) finally: support.reap_children() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #16992: On Windows in signal.set_wakeup_fd, validate the file + descriptor argument. + - Issue #16422: For compatibility with the Python version, the C version of decimal now uses strings instead of integers for rounding mode constants. diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -427,7 +427,7 @@ return NULL; } #endif - if (fd != -1 && fstat(fd, &buf) != 0) { + if (fd != -1 && (!_PyVerify_fd(fd) || fstat(fd, &buf) != 0)) { PyErr_SetString(PyExc_ValueError, "invalid fd"); return NULL; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 06:13:00 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 18 Jan 2013 06:13:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3YnVfN3DcgzSFq@mail.python.org> http://hg.python.org/cpython/rev/e6cd37d4dad8 changeset: 81569:e6cd37d4dad8 parent: 81567:cb297930d2cf parent: 81568:2adc83b4738f user: Benjamin Peterson date: Fri Jan 18 00:10:37 2013 -0500 summary: merge 3.3 files: Lib/test/test_signal.py | 11 +++++++++-- Misc/NEWS | 3 +++ Modules/signalmodule.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -219,6 +219,13 @@ signal.signal(7, handler) +class WakeupFDTests(unittest.TestCase): + + def test_invalid_fd(self): + fd = support.make_bad_fd() + self.assertRaises(ValueError, signal.set_wakeup_fd, fd) + + @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class WakeupSignalTests(unittest.TestCase): def check_wakeup(self, test_body, *signals, ordered=True): @@ -861,8 +868,8 @@ def test_main(): try: support.run_unittest(PosixTests, InterProcessSignalTests, - WakeupSignalTests, SiginterruptTest, - ItimerTest, WindowsSignalTests, + WakeupFDTests, WakeupSignalTests, + SiginterruptTest, ItimerTest, WindowsSignalTests, PendingSignalsTests) finally: support.reap_children() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -220,6 +220,9 @@ Library ------- +- Issue #16992: On Windows in signal.set_wakeup_fd, validate the file + descriptor argument. + - Issue #16422: For compatibility with the Python version, the C version of decimal now uses strings instead of integers for rounding mode constants. diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -422,7 +422,7 @@ return NULL; } #endif - if (fd != -1 && fstat(fd, &buf) != 0) { + if (fd != -1 && (!_PyVerify_fd(fd) || fstat(fd, &buf) != 0)) { PyErr_SetString(PyExc_ValueError, "invalid fd"); return NULL; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 06:13:01 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 18 Jan 2013 06:13:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_check_windows_?= =?utf-8?q?fd_validity_=28closes_=2316992=29?= Message-ID: <3YnVfP5xYBzSG8@mail.python.org> http://hg.python.org/cpython/rev/1a1989021451 changeset: 81570:1a1989021451 branch: 2.7 parent: 81565:af5feb869304 user: Benjamin Peterson date: Fri Jan 18 00:10:24 2013 -0500 summary: check windows fd validity (closes #16992) files: Lib/test/test_signal.py | 12 ++++++++++-- Misc/NEWS | 3 +++ Modules/signalmodule.c | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -227,6 +227,13 @@ signal.signal(7, handler) +class WakeupFDTests(unittest.TestCase): + + def test_invalid_fd(self): + fd = support.make_bad_fd() + self.assertRaises(ValueError, signal.set_wakeup_fd, fd) + + @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class WakeupSignalTests(unittest.TestCase): TIMEOUT_FULL = 10 @@ -485,8 +492,9 @@ def test_main(): test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, - WakeupSignalTests, SiginterruptTest, - ItimerTest, WindowsSignalTests) + WakeupFDTests, WakeupSignalTests, + SiginterruptTest, ItimerTest, + WindowsSignalTests) if __name__ == "__main__": diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,9 @@ Library ------- +- Issue #16992: On Windows in signal.set_wakeup_fd, validate the file + descriptor argument. + - Issue #15861: tkinter now correctly works with lists and tuples containing strings with whitespaces, backslashes or unbalanced braces. diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -407,7 +407,7 @@ return NULL; } #endif - if (fd != -1 && fstat(fd, &buf) != 0) { + if (fd != -1 && (!_PyVerify_fd(fd) || fstat(fd, &buf) != 0)) { PyErr_SetString(PyExc_ValueError, "invalid fd"); return NULL; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 06:44:55 2013 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 18 Jan 2013 06:44:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogc3VwcG9ydCAtPiB0?= =?utf-8?q?est=5Fsupport?= Message-ID: <3YnWMC6XbtzSFq@mail.python.org> http://hg.python.org/cpython/rev/a028484b5179 changeset: 81571:a028484b5179 branch: 2.7 user: Benjamin Peterson date: Fri Jan 18 00:44:49 2013 -0500 summary: support -> test_support files: Lib/test/test_signal.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -230,7 +230,7 @@ class WakeupFDTests(unittest.TestCase): def test_invalid_fd(self): - fd = support.make_bad_fd() + fd = test_support.make_bad_fd() self.assertRaises(ValueError, signal.set_wakeup_fd, fd) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 12:45:48 2013 From: python-checkins at python.org (victor.stinner) Date: Fri, 18 Jan 2013 12:45:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_updates?= Message-ID: <3YngMc4vqzzR6P@mail.python.org> http://hg.python.org/peps/rev/cdd8a7061c5d changeset: 4682:cdd8a7061c5d user: Victor Stinner date: Fri Jan 18 12:45:30 2013 +0100 summary: PEP 433: updates files: pep-0433.txt | 79 ++++++++++++++++++++++++++++++--------- 1 files changed, 60 insertions(+), 19 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -1,5 +1,5 @@ PEP: 433 -Title: Add cloexec parameter to functions creating file descriptors +Title: Easier suppression of file descriptor inheritance Version: $Revision$ Last-Modified: $Date$ Author: Victor Stinner @@ -176,10 +176,12 @@ the parameter is ``True``, the close-on-exec flag will be set on the new file descriptor. -Add a new function: +Add a new functions: - * ``os.set_cloexec(fd: int, cloexec: bool)``: set or clear the - close-on-exec flag of a file descriptor + * ``os.get_cloexec(fd:int) -> bool``: get the + close-on-exec flag of a file descriptor. Not available on all platforms. + * ``os.set_cloexec(fd:int, cloexec:bool=True)``: set or clear the + close-on-exec flag on a file descriptor. Not available on all platforms. Add a new optional ``cloexec`` parameter to: @@ -227,8 +229,16 @@ Alternatives ============ -Set the close-on-exec flag by default -------------------------------------- +Bikeshedding on the name of the new parameter +--------------------------------------------- + + * ``inherit``, ``inherited``: closer to Windows definition + * ``sensitive`` + * ``sterile``: "Does not produce offspring." + + +Enable file descriptor inheritance by default +--------------------------------------------- Set the close-on-exec flag by default on new file descriptors created by Python. This alternative just changes the default value of the new @@ -427,15 +437,47 @@ Implementation ============== -os.set_cloexec(fd, cloexec) ---------------------------- +os.get_cloexec(fd) +------------------ -Best-effort by definition. Pseudo-code:: +Get the close-on-exec flag of a file descriptor. + +Pseudo-code:: + + if os.name == 'nt': + def get_cloexec(fd): + handle = _winapi._get_osfhandle(fd); + flags = _winapi.GetHandleInformation(handle) + return not(flags & _winapi.HANDLE_FLAG_INHERIT) + else: + try: + import fcntl + except ImportError: + pass + else: + def get_cloexec(fd): + flags = fcntl.fcntl(fd, fcntl.F_GETFD) + return bool(flags & fcntl.FD_CLOEXEC) + + +os.set_cloexec(fd, cloexec=True) +-------------------------------- + +Set or clear the close-on-exec flag on a file descriptor. The flag +is set after the creation of the file descriptor and so it is not +atomic. + +Pseudo-code:: if os.name == 'nt': def set_cloexec(fd, cloexec=True): - SetHandleInformation(fd, HANDLE_FLAG_INHERIT, - int(cloexec)) + handle = _winapi._get_osfhandle(fd); + mask = _winapi.HANDLE_FLAG_INHERIT + if cloexec: + flags = 0 + else: + flags = mask + _winapi.SetHandleInformation(handle, mask, flags) else: fnctl = None ioctl = None @@ -460,11 +502,6 @@ else: flags &= ~FD_CLOEXEC fcntl.fcntl(fd, fcntl.F_SETFD, flags) - else: - def set_cloexec(fd, cloexec=True): - raise NotImplementedError( - "close-on-exec flag is not supported " - "on your platform") ioctl is preferred over fcntl because it requires only one syscall, instead of two syscalls for fcntl. @@ -501,13 +538,15 @@ os.pipe() --------- - * Windows: ``_pipe()`` with ``O_NOINHERIT`` flag [atomic] + * Windows: ``CreatePipe()`` with ``SECURITY_ATTRIBUTES.bInheritHandle=TRUE``, + or ``_pipe()`` with ``O_NOINHERIT`` flag [atomic] * ``pipe2()`` with ``O_CLOEXEC`` flag [atomic] * ``pipe()`` + ``os.set_cloexec(fd, True)`` [best-effort] socket.socket() --------------- + * Windows: ``WSASocket()`` with ``WSA_FLAG_NO_HANDLE_INHERIT`` flag * ``socket()`` with ``SOCK_CLOEXEC`` flag [atomic] * ``socket()`` + ``os.set_cloexec(fd, True)`` [best-effort] @@ -579,8 +618,10 @@ * ``O_CLOEXEC``: available on Linux (2.6.23+), FreeBSD (8.3+), OpenBSD 5.0, QNX, BeOS, next NetBSD release (6.1?). This flag is part of POSIX.1-2008. - * ``socket()``: ``SOCK_CLOEXEC`` flag, available on Linux 2.6.27+, - OpenBSD 5.2, NetBSD 6.0. + * ``SOCK_CLOEXEC`` flag for ``socket()`` and ``socketpair()``, + available on Linux 2.6.27+, OpenBSD 5.2, NetBSD 6.0. + * ``WSA_FLAG_NO_HANDLE_INHERIT`` flag for ``WSASocket()``: supported on + Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24+, OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0. This flag is part of POSIX.1-2008. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Fri Jan 18 13:43:46 2013 From: python-checkins at python.org (lukasz.langa) Date: Fri, 18 Jan 2013 13:43:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogbWF0aC5mc3VtIGRv?= =?utf-8?q?cs_did_not_show_up_because_of_a_misplaced_testsetup_directive?= Message-ID: <3YnhfV669XzSGF@mail.python.org> http://hg.python.org/cpython/rev/2a3884b6ffb5 changeset: 81572:2a3884b6ffb5 branch: 2.7 user: ?ukasz Langa date: Fri Jan 18 13:31:53 2013 +0100 summary: math.fsum docs did not show up because of a misplaced testsetup directive files: Doc/library/math.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -5,6 +5,9 @@ .. module:: math :synopsis: Mathematical functions (sin() etc.). +.. testsetup:: + + from math import fsum This module is always available. It provides access to the mathematical functions defined by the C standard. @@ -82,8 +85,6 @@ .. function:: fsum(iterable) -.. testsetup:: - >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 13:43:48 2013 From: python-checkins at python.org (lukasz.langa) Date: Fri, 18 Jan 2013 13:43:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogbWF0aC5mc3VtIGRv?= =?utf-8?q?cs_did_not_show_up_because_of_a_misplaced_testsetup_directive?= Message-ID: <3YnhfX1gK6zSGF@mail.python.org> http://hg.python.org/cpython/rev/bd0c60461324 changeset: 81573:bd0c60461324 branch: 3.2 parent: 81562:ce6dc780e69e user: ?ukasz Langa date: Fri Jan 18 13:40:43 2013 +0100 summary: math.fsum docs did not show up because of a misplaced testsetup directive files: Doc/library/math.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -4,6 +4,9 @@ .. module:: math :synopsis: Mathematical functions (sin() etc.). +.. testsetup:: + + from math import fsum This module is always available. It provides access to the mathematical functions defined by the C standard. @@ -77,8 +80,6 @@ .. function:: fsum(iterable) -.. testsetup:: - >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 13:43:49 2013 From: python-checkins at python.org (lukasz.langa) Date: Fri, 18 Jan 2013 13:43:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_math=2Efsum_docs_did_not_show_up_because_of_a_misplaced_testse?= =?utf-8?q?tup_directive?= Message-ID: <3YnhfY4KBCzSH1@mail.python.org> http://hg.python.org/cpython/rev/01c79fb996a3 changeset: 81574:01c79fb996a3 branch: 3.3 parent: 81568:2adc83b4738f parent: 81573:bd0c60461324 user: ?ukasz Langa date: Fri Jan 18 13:41:14 2013 +0100 summary: math.fsum docs did not show up because of a misplaced testsetup directive (merged 3.2 fix) files: Doc/library/math.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -4,6 +4,9 @@ .. module:: math :synopsis: Mathematical functions (sin() etc.). +.. testsetup:: + + from math import fsum This module is always available. It provides access to the mathematical functions defined by the C standard. @@ -77,8 +80,6 @@ .. function:: fsum(iterable) -.. testsetup:: - >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 13:43:51 2013 From: python-checkins at python.org (lukasz.langa) Date: Fri, 18 Jan 2013 13:43:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_math=2Efsum_docs_did_not_show_up_because_of_a_misplaced_?= =?utf-8?q?testsetup_directive?= Message-ID: <3Ynhfb03clzSJ5@mail.python.org> http://hg.python.org/cpython/rev/c5508c706293 changeset: 81575:c5508c706293 parent: 81569:e6cd37d4dad8 parent: 81574:01c79fb996a3 user: ?ukasz Langa date: Fri Jan 18 13:42:56 2013 +0100 summary: math.fsum docs did not show up because of a misplaced testsetup directive (merged 3.2 fix through 3.3) files: Doc/library/math.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -4,6 +4,9 @@ .. module:: math :synopsis: Mathematical functions (sin() etc.). +.. testsetup:: + + from math import fsum This module is always available. It provides access to the mathematical functions defined by the C standard. @@ -77,8 +80,6 @@ .. function:: fsum(iterable) -.. testsetup:: - >>> from math import fsum Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 18:59:35 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 18 Jan 2013 18:59:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE2OTc4OiByZXBo?= =?utf-8?q?rase_sentence_and_fix_typo=2E__Initial_patch_by_Tshepang_Lekhon?= =?utf-8?q?khobe=2E?= Message-ID: <3Ynqfv12VGzR9W@mail.python.org> http://hg.python.org/cpython/rev/8886d7ca159b changeset: 81576:8886d7ca159b branch: 2.7 parent: 81572:2a3884b6ffb5 user: Ezio Melotti date: Fri Jan 18 19:55:46 2013 +0200 summary: #16978: rephrase sentence and fix typo. Initial patch by Tshepang Lekhonkhobe. files: Doc/library/threading.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -31,10 +31,10 @@ .. impl-detail:: - Due to the :term:`Global Interpreter Lock`, in CPython only one thread + In CPython, due to the :term:`Global Interpreter Lock`, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). - If you want your application to make better of use of the computational + If you want your application to make better use of the computational resources of multi-core machines, you are advised to use :mod:`multiprocessing`. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 18:59:36 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 18 Jan 2013 18:59:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE2OTc4OiByZXBo?= =?utf-8?q?rase_sentence_and_fix_typo=2E__Initial_patch_by_Tshepang_Lekhon?= =?utf-8?q?khobe=2E?= Message-ID: <3Ynqfw3zw8zSHj@mail.python.org> http://hg.python.org/cpython/rev/4a1a88d25fec changeset: 81577:4a1a88d25fec branch: 3.2 parent: 81573:bd0c60461324 user: Ezio Melotti date: Fri Jan 18 19:55:46 2013 +0200 summary: #16978: rephrase sentence and fix typo. Initial patch by Tshepang Lekhonkhobe. files: Doc/library/threading.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -22,10 +22,10 @@ .. impl-detail:: - Due to the :term:`Global Interpreter Lock`, in CPython only one thread + In CPython, due to the :term:`Global Interpreter Lock`, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). - If you want your application to make better of use of the computational + If you want your application to make better use of the computational resources of multi-core machines, you are advised to use :mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`. However, threading is still an appropriate model if you want to run -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 18:59:37 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 18 Jan 2013 18:59:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2316978=3A_merge_with_3=2E2=2E?= Message-ID: <3Ynqfx6kwczSJh@mail.python.org> http://hg.python.org/cpython/rev/ad0af795c345 changeset: 81578:ad0af795c345 branch: 3.3 parent: 81574:01c79fb996a3 parent: 81577:4a1a88d25fec user: Ezio Melotti date: Fri Jan 18 19:58:47 2013 +0200 summary: #16978: merge with 3.2. files: Doc/library/threading.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -308,10 +308,10 @@ .. impl-detail:: - Due to the :term:`Global Interpreter Lock`, in CPython only one thread + In CPython, due to the :term:`Global Interpreter Lock`, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). - If you want your application to make better of use of the computational + If you want your application to make better use of the computational resources of multi-core machines, you are advised to use :mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`. However, threading is still an appropriate model if you want to run -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 18:59:39 2013 From: python-checkins at python.org (ezio.melotti) Date: Fri, 18 Jan 2013 18:59:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2OTc4OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3Ynqfz2GXKzSJM@mail.python.org> http://hg.python.org/cpython/rev/e1118ff088be changeset: 81579:e1118ff088be parent: 81575:c5508c706293 parent: 81578:ad0af795c345 user: Ezio Melotti date: Fri Jan 18 19:59:13 2013 +0200 summary: #16978: merge with 3.3. files: Doc/library/threading.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -308,10 +308,10 @@ .. impl-detail:: - Due to the :term:`Global Interpreter Lock`, in CPython only one thread + In CPython, due to the :term:`Global Interpreter Lock`, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). - If you want your application to make better of use of the computational + If you want your application to make better use of the computational resources of multi-core machines, you are advised to use :mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`. However, threading is still an appropriate model if you want to run -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 18 21:35:58 2013 From: python-checkins at python.org (jason.coombs) Date: Fri, 18 Jan 2013 21:35:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzE2OTg1OiBSZW1v?= =?utf-8?q?ve_incorrect_phrase_indication_presence_of_non-present_concrete?= =?utf-8?q?_UTC?= Message-ID: <3Ynv7L2c9QzSHT@mail.python.org> http://hg.python.org/cpython/rev/582ecb9a4061 changeset: 81580:582ecb9a4061 branch: 2.7 parent: 81576:8886d7ca159b user: Jason R. Coombs date: Fri Jan 18 15:33:39 2013 -0500 summary: #16985: Remove incorrect phrase indication presence of non-present concrete UTC tzinfo instance. files: Doc/library/datetime.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -1533,7 +1533,7 @@ .. seealso:: `pytz `_ - The standard library has no :class:`tzinfo` instances except for UTC, but + The standard library has no :class:`tzinfo` instances, but there exists a third-party library which brings the *IANA timezone database* (also known as the Olson database) to Python: *pytz*. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 02:36:53 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 19 Jan 2013 02:36:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Show_the_funct?= =?utf-8?q?ion_signature_in_the_docstring?= Message-ID: <3Yp1pY4xlwzSHM@mail.python.org> http://hg.python.org/cpython/rev/0b6cef575090 changeset: 81581:0b6cef575090 branch: 2.7 user: Raymond Hettinger date: Fri Jan 18 17:35:25 2013 -0800 summary: Show the function signature in the docstring files: Modules/_heapqmodule.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -141,7 +141,7 @@ } PyDoc_STRVAR(heappush_doc, -"Push item onto heap, maintaining the heap invariant."); +"heappush(heap, item) -> None. Push item onto heap, maintaining the heap invariant."); static PyObject * heappop(PyObject *self, PyObject *heap) @@ -209,7 +209,7 @@ } PyDoc_STRVAR(heapreplace_doc, -"Pop and return the current smallest value, and add the new item.\n\ +"heapreplace(heap, item) -> value. Pop and return the current smallest value, and add the new item.\n\ \n\ This is more efficient than heappop() followed by heappush(), and can be\n\ more appropriate when using a fixed-size heap. Note that the value\n\ @@ -256,7 +256,7 @@ } PyDoc_STRVAR(heappushpop_doc, -"Push item on the heap, then pop and return the smallest item\n\ +"heappushpop(heap, item) -> value. Push item on the heap, then pop and return the smallest item\n\ from the heap. The combined action runs more efficiently than\n\ heappush() followed by a separate call to heappop()."); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 02:44:37 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 19 Jan 2013 02:44:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Ignore_Mac=27s_Data_Servic?= =?utf-8?q?es_Store?= Message-ID: <3Yp1zT04j7zSHl@mail.python.org> http://hg.python.org/cpython/rev/bd36149b1e6b changeset: 81582:bd36149b1e6b parent: 81579:e1118ff088be user: Raymond Hettinger date: Fri Jan 18 17:44:25 2013 -0800 summary: Ignore Mac's Data Services Store files: .hgignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -1,6 +1,7 @@ .gdb_history .purify .svn/ +DS_Store Makefile$ Makefile.pre$ TAGS$ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 02:54:02 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 19 Jan 2013 02:54:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Show_the_funct?= =?utf-8?q?ion_signature_in_the_docstring?= Message-ID: <3Yp2BL04L1zSJB@mail.python.org> http://hg.python.org/cpython/rev/6f0eb0e3820c changeset: 81583:6f0eb0e3820c branch: 3.3 parent: 81578:ad0af795c345 user: Raymond Hettinger date: Fri Jan 18 17:35:25 2013 -0800 summary: Show the function signature in the docstring files: Modules/_heapqmodule.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -118,7 +118,7 @@ } PyDoc_STRVAR(heappush_doc, -"Push item onto heap, maintaining the heap invariant."); +"heappush(heap, item) -> None. Push item onto heap, maintaining the heap invariant."); static PyObject * heappop(PyObject *self, PyObject *heap) @@ -186,7 +186,7 @@ } PyDoc_STRVAR(heapreplace_doc, -"Pop and return the current smallest value, and add the new item.\n\ +"heapreplace(heap, item) -> value. Pop and return the current smallest value, and add the new item.\n\ \n\ This is more efficient than heappop() followed by heappush(), and can be\n\ more appropriate when using a fixed-size heap. Note that the value\n\ @@ -233,7 +233,7 @@ } PyDoc_STRVAR(heappushpop_doc, -"Push item on the heap, then pop and return the smallest item\n\ +"heappushpop(heap, item) -> value. Push item on the heap, then pop and return the smallest item\n\ from the heap. The combined action runs more efficiently than\n\ heappush() followed by a separate call to heappop()."); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 02:54:03 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 19 Jan 2013 02:54:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge?= Message-ID: <3Yp2BM2y4tzSJV@mail.python.org> http://hg.python.org/cpython/rev/74b0461346f0 changeset: 81584:74b0461346f0 parent: 81582:bd36149b1e6b parent: 81583:6f0eb0e3820c user: Raymond Hettinger date: Fri Jan 18 17:53:18 2013 -0800 summary: merge files: Modules/_heapqmodule.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -118,7 +118,7 @@ } PyDoc_STRVAR(heappush_doc, -"Push item onto heap, maintaining the heap invariant."); +"heappush(heap, item) -> None. Push item onto heap, maintaining the heap invariant."); static PyObject * heappop(PyObject *self, PyObject *heap) @@ -186,7 +186,7 @@ } PyDoc_STRVAR(heapreplace_doc, -"Pop and return the current smallest value, and add the new item.\n\ +"heapreplace(heap, item) -> value. Pop and return the current smallest value, and add the new item.\n\ \n\ This is more efficient than heappop() followed by heappush(), and can be\n\ more appropriate when using a fixed-size heap. Note that the value\n\ @@ -233,7 +233,7 @@ } PyDoc_STRVAR(heappushpop_doc, -"Push item on the heap, then pop and return the smallest item\n\ +"heappushpop(heap, item) -> value. Push item on the heap, then pop and return the smallest item\n\ from the heap. The combined action runs more efficiently than\n\ heappush() followed by a separate call to heappop()."); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 03:08:15 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 19 Jan 2013 03:08:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSWdub3JlIE1hYydz?= =?utf-8?q?_Data_Services_Store?= Message-ID: <3Yp2Vl5WsqzS8T@mail.python.org> http://hg.python.org/cpython/rev/0b6e88da9ea6 changeset: 81585:0b6e88da9ea6 branch: 2.7 parent: 81581:0b6cef575090 user: Raymond Hettinger date: Fri Jan 18 18:07:58 2013 -0800 summary: Ignore Mac's Data Services Store files: .hgignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -1,6 +1,7 @@ .gdb_history .purify .svn/ +.DS_Store Makefile$ Makefile.pre$ TAGS$ -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Sat Jan 19 05:57:49 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 19 Jan 2013 05:57:49 +0100 Subject: [Python-checkins] Daily reference leaks (74b0461346f0): sum=4 Message-ID: results for 74b0461346f0 on branch "default" -------------------------------------------- test_concurrent_futures leaked [2, 1, 1] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogMnqL_T', '-x'] From python-checkins at python.org Sat Jan 19 08:23:48 2013 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 19 Jan 2013 08:23:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Improve_toolti?= =?utf-8?q?ps_by_listing_the_most_common_argument_pattern_first=2E?= Message-ID: <3Yp9Vr0wDczSKD@mail.python.org> http://hg.python.org/cpython/rev/bfe38710d4e6 changeset: 81586:bfe38710d4e6 branch: 2.7 user: Raymond Hettinger date: Fri Jan 18 23:23:11 2013 -0800 summary: Improve tooltips by listing the most common argument pattern first. files: Objects/typeobject.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6679,8 +6679,8 @@ } PyDoc_STRVAR(super_doc, +"super(type, obj) -> bound super object; requires isinstance(obj, type)\n" "super(type) -> unbound super object\n" -"super(type, obj) -> bound super object; requires isinstance(obj, type)\n" "super(type, type2) -> bound super object; requires issubclass(type2, type)\n" "Typical use to call a cooperative superclass method:\n" "class C(B):\n" -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 11:46:35 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Jan 2013 11:46:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE1OTg5?= =?utf-8?q?=3A_Fix_several_occurrences_of_integer_overflow?= Message-ID: <3YpG0q0bq3zSLr@mail.python.org> http://hg.python.org/cpython/rev/974ace29ee2d changeset: 81587:974ace29ee2d branch: 3.2 parent: 81577:4a1a88d25fec user: Serhiy Storchaka date: Sat Jan 19 12:26:26 2013 +0200 summary: Issue #15989: Fix several occurrences of integer overflow when result of PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277. files: Include/longobject.h | 3 ++ Lib/ctypes/test/test_structures.py | 9 ++++++ Lib/test/string_tests.py | 11 +++++++ Lib/test/test_fcntl.py | 21 ++++++++++++++ Lib/test/test_fileio.py | 4 ++ Lib/test/test_io.py | 9 ++++++ Lib/test/test_poll.py | 10 ++++++ Lib/test/test_socket.py | 27 +++++++++++++++-- Modules/_ctypes/stgdict.c | 2 +- Modules/_io/_iomodule.c | 7 ++-- Modules/_io/fileio.c | 2 +- Modules/selectmodule.c | 12 +++++-- Modules/socketmodule.c | 6 ++-- Objects/fileobject.c | 4 +- Objects/longobject.c | 18 ++++++++++++ Objects/unicodeobject.c | 4 +- 16 files changed, 129 insertions(+), 20 deletions(-) diff --git a/Include/longobject.h b/Include/longobject.h --- a/Include/longobject.h +++ b/Include/longobject.h @@ -26,6 +26,9 @@ PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); +#endif PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); /* It may be useful in the future. I've added it in the PyInt -> PyLong diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -1,6 +1,7 @@ import unittest from ctypes import * from struct import calcsize +import _testcapi class SubclassesTest(unittest.TestCase): def test_subclass(self): @@ -199,6 +200,14 @@ "_pack_": -1} self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + # Issue 15989 + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.INT_MAX + 1} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.UINT_MAX + 2} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + def test_initializers(self): class Person(Structure): _fields_ = [("name", c_char*6), diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -5,6 +5,7 @@ import unittest, string, sys, struct from test import support from collections import UserList +import _testcapi class Sequence: def __init__(self, seq='wxyz'): self.seq = seq @@ -1142,6 +1143,16 @@ self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.)) self.checkraises(ValueError, '%10', '__mod__', (42,)) + self.checkraises(OverflowError, '%*s', '__mod__', + (_testcapi.PY_SSIZE_T_MAX + 1, '')) + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.INT_MAX + 1, 1. / 7)) + # Issue 15989 + self.checkraises(OverflowError, '%*s', '__mod__', + (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), '')) + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.UINT_MAX + 1, 1. / 7)) + class X(object): pass self.checkraises(TypeError, 'abc', '__mod__', X()) diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -6,6 +6,7 @@ import os import struct import sys +import _testcapi import unittest from test.support import verbose, TESTFN, unlink, run_unittest, import_module @@ -76,6 +77,26 @@ rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) self.f.close() + def test_fcntl_bad_file(self): + class F: + def __init__(self, fn): + self.fn = fn + def fileno(self): + return self.fn + self.assertRaises(ValueError, fcntl.fcntl, -1, fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(ValueError, fcntl.fcntl, F(-1), fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, 'spam', fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, F('spam'), fcntl.F_SETFL, os.O_NONBLOCK) + # Issue 15989 + self.assertRaises(OverflowError, fcntl.fcntl, _testcapi.INT_MAX + 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, F(_testcapi.INT_MAX + 1), + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, _testcapi.INT_MIN - 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, F(_testcapi.INT_MIN - 1), + fcntl.F_SETFL, os.O_NONBLOCK) + def test_fcntl_64_bit(self): # Issue #1309352: fcntl shouldn't fail when the third arg fits in a # C 'long' but not in a C 'int'. diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -7,6 +7,7 @@ from array import array from weakref import proxy from functools import wraps +import _testcapi from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd from collections import UserList @@ -346,6 +347,9 @@ if sys.platform == 'win32': import msvcrt self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd()) + # Issue 15989 + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1) + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) def testBadModeArgument(self): # verify that we get a sensible error message for bad mode argument diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -31,6 +31,7 @@ import errno import warnings import pickle +import _testcapi from itertools import cycle, count from collections import deque, UserList from test import support @@ -1903,6 +1904,14 @@ t.write("A\rB") self.assertEqual(r.getvalue(), b"XY\nZA\rB") + # Issue 15989 + def test_device_encoding(self): + b = self.BytesIO() + b.fileno = lambda: _testcapi.INT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + b.fileno = lambda: _testcapi.UINT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + def test_encoding(self): # Check the encoding attribute is always set, and valid b = self.BytesIO() diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py --- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -1,6 +1,7 @@ # Test case for the os.poll() function import os, select, random, unittest +import _testcapi from test.support import TESTFN, run_unittest try: @@ -150,6 +151,15 @@ if x != 5: self.fail('Overflow must have occurred') + pollster = select.poll() + # Issue 15989 + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.SHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.USHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1) + def test_main(): run_unittest(PollTests) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -7,6 +7,7 @@ import io import socket import select +import _testcapi import time import traceback import queue @@ -850,11 +851,17 @@ self.assertRaises(ValueError, fp.writable) self.assertRaises(ValueError, fp.seekable) - def testListenBacklog0(self): + def test_listen_backlog(self): + for backlog in 0, -1: + srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + srv.bind((HOST, 0)) + srv.listen(backlog) + srv.close() + + # Issue 15989 srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) - # backlog = 0 - srv.listen(0) + self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) srv.close() @unittest.skipUnless(SUPPORTS_IPV6, 'IPv6 required for this test.') @@ -954,6 +961,11 @@ def _testShutdown(self): self.serv_conn.send(MSG) + # Issue 15989 + self.assertRaises(OverflowError, self.serv_conn.shutdown, + _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, self.serv_conn.shutdown, + 2 + (_testcapi.UINT_MAX + 1)) self.serv_conn.shutdown(2) def testDetach(self): @@ -1067,7 +1079,10 @@ def testSetBlocking(self): # Testing whether set blocking works - self.serv.setblocking(0) + self.serv.setblocking(True) + self.assertIsNone(self.serv.gettimeout()) + self.serv.setblocking(False) + self.assertEqual(self.serv.gettimeout(), 0.0) start = time.time() try: self.serv.accept() @@ -1075,6 +1090,10 @@ pass end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") + # Issue 15989 + if _testcapi.UINT_MAX < _testcapi.ULONG_MAX: + self.serv.setblocking(_testcapi.UINT_MAX + 1) + self.assertIsNone(self.serv.gettimeout()) def _testSetBlocking(self): pass diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -335,7 +335,7 @@ isPacked = PyObject_GetAttrString(type, "_pack_"); if (isPacked) { - pack = PyLong_AsLong(isPacked); + pack = _PyLong_AsInt(isPacked); if (pack < 0 || PyErr_Occurred()) { Py_XDECREF(isPacked); PyErr_SetString(PyExc_ValueError, diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -303,7 +303,8 @@ int text = 0, binary = 0, universal = 0; char rawmode[5], *m; - int line_buffering, isatty; + int line_buffering; + long isatty; PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL; @@ -441,12 +442,12 @@ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE { struct stat st; - long fileno; + int fileno; PyObject *res = PyObject_CallMethod(raw, "fileno", NULL); if (res == NULL) goto error; - fileno = PyLong_AsLong(res); + fileno = _PyLong_AsInt(res); Py_DECREF(res); if (fileno == -1 && PyErr_Occurred()) goto error; diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -240,7 +240,7 @@ return -1; } - fd = PyLong_AsLong(nameobj); + fd = _PyLong_AsInt(nameobj); if (fd < 0) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ValueError, diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -340,10 +340,13 @@ i = pos = 0; while (PyDict_Next(self->dict, &pos, &key, &value)) { - self->ufds[i].fd = PyLong_AsLong(key); + assert(i < self->ufd_len); + /* Never overflow */ + self->ufds[i].fd = (int)PyLong_AsLong(key); self->ufds[i].events = (short)PyLong_AsLong(value); i++; } + assert(i == self->ufd_len); self->ufd_uptodate = 1; return 1; } @@ -359,10 +362,11 @@ poll_register(pollObject *self, PyObject *args) { PyObject *o, *key, *value; - int fd, events = POLLIN | POLLPRI | POLLOUT; + int fd; + short events = POLLIN | POLLPRI | POLLOUT; int err; - if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { + if (!PyArg_ParseTuple(args, "O|h:register", &o, &events)) { return NULL; } @@ -501,7 +505,7 @@ tout = PyNumber_Long(tout); if (!tout) return NULL; - timeout = PyLong_AsLong(tout); + timeout = _PyLong_AsInt(tout); Py_DECREF(tout); if (timeout == -1 && PyErr_Occurred()) return NULL; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1737,7 +1737,7 @@ static PyObject * sock_setblocking(PySocketSockObject *s, PyObject *arg) { - int block; + long block; block = PyLong_AsLong(arg); if (block == -1 && PyErr_Occurred()) @@ -2219,7 +2219,7 @@ int backlog; int res; - backlog = PyLong_AsLong(arg); + backlog = _PyLong_AsInt(arg); if (backlog == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -2822,7 +2822,7 @@ int how; int res; - how = PyLong_AsLong(arg); + how = _PyLong_AsInt(arg); if (how == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS diff --git a/Objects/fileobject.c b/Objects/fileobject.c --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -200,7 +200,7 @@ PyObject *meth; if (PyLong_Check(o)) { - fd = PyLong_AsLong(o); + fd = _PyLong_AsInt(o); } else if ((meth = PyObject_GetAttrString(o, "fileno")) != NULL) { @@ -210,7 +210,7 @@ return -1; if (PyLong_Check(fno)) { - fd = PyLong_AsLong(fno); + fd = _PyLong_AsInt(fno); Py_DECREF(fno); } else { diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -424,6 +424,24 @@ return result; } +/* Get a C int from a long int object or any object that has an __int__ + method. Return -1 and set an error if overflow occurs. */ + +int +_PyLong_AsInt(PyObject *obj) +{ + int overflow; + long result = PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow || result > INT_MAX || result < INT_MIN) { + /* XXX: could be cute and give a different + message for overflow == -1 */ + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C int"); + return -1; + } + return (int)result; +} + /* Get a Py_ssize_t from a long int object. Returns -1 and sets an error condition if overflow occurs. */ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -9640,7 +9640,7 @@ "* wants int"); goto onError; } - width = PyLong_AsLong(v); + width = PyLong_AsSsize_t(v); if (width == -1 && PyErr_Occurred()) goto onError; if (width < 0) { @@ -9677,7 +9677,7 @@ "* wants int"); goto onError; } - prec = PyLong_AsLong(v); + prec = _PyLong_AsInt(v); if (prec == -1 && PyErr_Occurred()) goto onError; if (prec < 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 11:46:36 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Jan 2013 11:46:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2315989=3A_Fix_several_occurrences_of_integer_overflow?= Message-ID: <3YpG0r6vRPzSMt@mail.python.org> http://hg.python.org/cpython/rev/8f10c9eae183 changeset: 81588:8f10c9eae183 branch: 3.3 parent: 81583:6f0eb0e3820c parent: 81587:974ace29ee2d user: Serhiy Storchaka date: Sat Jan 19 12:41:45 2013 +0200 summary: Issue #15989: Fix several occurrences of integer overflow when result of PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277. files: Include/longobject.h | 3 ++ Lib/ctypes/test/test_structures.py | 9 ++++++ Lib/test/string_tests.py | 11 +++++++ Lib/test/test_fcntl.py | 21 ++++++++++++++ Lib/test/test_fileio.py | 4 ++ Lib/test/test_io.py | 9 ++++++ Lib/test/test_poll.py | 10 ++++++ Lib/test/test_posix.py | 5 +++ Lib/test/test_socket.py | 26 +++++++++++++++-- Modules/_ctypes/stgdict.c | 2 +- Modules/_io/fileio.c | 4 +- Modules/_io/textio.c | 2 +- Modules/parsermodule.c | 24 +++++++++++++--- Modules/posixmodule.c | 2 +- Modules/selectmodule.c | 12 +++++-- Modules/socketmodule.c | 6 ++-- Objects/fileobject.c | 4 +- Objects/longobject.c | 18 ++++++++++++ Objects/unicodeobject.c | 4 +- 19 files changed, 151 insertions(+), 25 deletions(-) diff --git a/Include/longobject.h b/Include/longobject.h --- a/Include/longobject.h +++ b/Include/longobject.h @@ -26,6 +26,9 @@ PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); +#endif PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); /* It may be useful in the future. I've added it in the PyInt -> PyLong diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -1,6 +1,7 @@ import unittest from ctypes import * from struct import calcsize +import _testcapi class SubclassesTest(unittest.TestCase): def test_subclass(self): @@ -199,6 +200,14 @@ "_pack_": -1} self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + # Issue 15989 + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.INT_MAX + 1} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.UINT_MAX + 2} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + def test_initializers(self): class Person(Structure): _fields_ = [("name", c_char*6), diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -5,6 +5,7 @@ import unittest, string, sys, struct from test import support from collections import UserList +import _testcapi class Sequence: def __init__(self, seq='wxyz'): self.seq = seq @@ -1206,6 +1207,16 @@ self.checkraises(ValueError, '%%%df' % (2**64), '__mod__', (3.2)) self.checkraises(ValueError, '%%.%df' % (2**64), '__mod__', (3.2)) + self.checkraises(OverflowError, '%*s', '__mod__', + (_testcapi.PY_SSIZE_T_MAX + 1, '')) + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.INT_MAX + 1, 1. / 7)) + # Issue 15989 + self.checkraises(OverflowError, '%*s', '__mod__', + (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), '')) + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.UINT_MAX + 1, 1. / 7)) + class X(object): pass self.checkraises(TypeError, 'abc', '__mod__', X()) diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -6,6 +6,7 @@ import os import struct import sys +import _testcapi import unittest from test.support import verbose, TESTFN, unlink, run_unittest, import_module @@ -76,6 +77,26 @@ rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) self.f.close() + def test_fcntl_bad_file(self): + class F: + def __init__(self, fn): + self.fn = fn + def fileno(self): + return self.fn + self.assertRaises(ValueError, fcntl.fcntl, -1, fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(ValueError, fcntl.fcntl, F(-1), fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, 'spam', fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, F('spam'), fcntl.F_SETFL, os.O_NONBLOCK) + # Issue 15989 + self.assertRaises(OverflowError, fcntl.fcntl, _testcapi.INT_MAX + 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, F(_testcapi.INT_MAX + 1), + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, _testcapi.INT_MIN - 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(OverflowError, fcntl.fcntl, F(_testcapi.INT_MIN - 1), + fcntl.F_SETFL, os.O_NONBLOCK) + def test_fcntl_64_bit(self): # Issue #1309352: fcntl shouldn't fail when the third arg fits in a # C 'long' but not in a C 'int'. diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -8,6 +8,7 @@ from array import array from weakref import proxy from functools import wraps +import _testcapi from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd from collections import UserList @@ -347,6 +348,9 @@ if sys.platform == 'win32': import msvcrt self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd()) + # Issue 15989 + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1) + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) def testBadModeArgument(self): # verify that we get a sensible error message for bad mode argument diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -32,6 +32,7 @@ import unittest import warnings import weakref +import _testcapi from collections import deque, UserList from itertools import cycle, count from test import support @@ -1962,6 +1963,14 @@ os.environ.clear() os.environ.update(old_environ) + # Issue 15989 + def test_device_encoding(self): + b = self.BytesIO() + b.fileno = lambda: _testcapi.INT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + b.fileno = lambda: _testcapi.UINT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + def test_encoding(self): # Check the encoding attribute is always set, and valid b = self.BytesIO() diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py --- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -1,6 +1,7 @@ # Test case for the os.poll() function import os, select, random, unittest +import _testcapi from test.support import TESTFN, run_unittest try: @@ -150,6 +151,15 @@ if x != 5: self.fail('Overflow must have occurred') + pollster = select.poll() + # Issue 15989 + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.SHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.USHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1) + def test_main(): run_unittest(PollTests) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -17,6 +17,7 @@ import tempfile import unittest import warnings +import _testcapi _DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(), support.TESTFN + '-dummy-symlink') @@ -537,6 +538,10 @@ except OSError: pass + # Issue 15989 + self.assertRaises(OverflowError, os.pipe2, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, os.pipe2, _testcapi.UINT_MAX + 1) + def test_utime(self): if hasattr(posix, 'utime'): now = time.time() diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1262,11 +1262,17 @@ for protocol in range(pickle.HIGHEST_PROTOCOL + 1): self.assertRaises(TypeError, pickle.dumps, sock, protocol) - def test_listen_backlog0(self): + def test_listen_backlog(self): + for backlog in 0, -1: + srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + srv.bind((HOST, 0)) + srv.listen(backlog) + srv.close() + + # Issue 15989 srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) - # backlog = 0 - srv.listen(0) + self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) srv.close() @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @@ -1582,6 +1588,11 @@ def _testShutdown(self): self.serv_conn.send(MSG) + # Issue 15989 + self.assertRaises(OverflowError, self.serv_conn.shutdown, + _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, self.serv_conn.shutdown, + 2 + (_testcapi.UINT_MAX + 1)) self.serv_conn.shutdown(2) def testDetach(self): @@ -3555,7 +3566,10 @@ def testSetBlocking(self): # Testing whether set blocking works - self.serv.setblocking(0) + self.serv.setblocking(True) + self.assertIsNone(self.serv.gettimeout()) + self.serv.setblocking(False) + self.assertEqual(self.serv.gettimeout(), 0.0) start = time.time() try: self.serv.accept() @@ -3563,6 +3577,10 @@ pass end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") + # Issue 15989 + if _testcapi.UINT_MAX < _testcapi.ULONG_MAX: + self.serv.setblocking(_testcapi.UINT_MAX + 1) + self.assertIsNone(self.serv.gettimeout()) def _testSetBlocking(self): pass diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -335,7 +335,7 @@ isPacked = PyObject_GetAttrString(type, "_pack_"); if (isPacked) { - pack = PyLong_AsLong(isPacked); + pack = _PyLong_AsInt(isPacked); if (pack < 0 || PyErr_Occurred()) { Py_XDECREF(isPacked); PyErr_SetString(PyExc_ValueError, diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -244,7 +244,7 @@ return -1; } - fd = PyLong_AsLong(nameobj); + fd = _PyLong_AsInt(nameobj); if (fd < 0) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ValueError, @@ -382,7 +382,7 @@ goto error; } - self->fd = PyLong_AsLong(fdobj); + self->fd = _PyLong_AsInt(fdobj); Py_DECREF(fdobj); if (self->fd == -1) { goto error; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -881,7 +881,7 @@ } } else { - int fd = (int) PyLong_AsLong(fileno); + int fd = _PyLong_AsInt(fileno); Py_DECREF(fileno); if (fd == -1 && PyErr_Occurred()) { goto error; diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -725,7 +725,7 @@ /* elem must always be a sequence, however simple */ PyObject* elem = PySequence_GetItem(tuple, i); int ok = elem != NULL; - long type = 0; + int type = 0; char *strn = 0; if (ok) @@ -736,8 +736,14 @@ ok = 0; else { ok = PyLong_Check(temp); - if (ok) - type = PyLong_AS_LONG(temp); + if (ok) { + type = _PyLong_AsInt(temp); + if (type == -1 && PyErr_Occurred()) { + Py_DECREF(temp); + Py_DECREF(elem); + return 0; + } + } Py_DECREF(temp); } } @@ -773,8 +779,16 @@ if (len == 3) { PyObject *o = PySequence_GetItem(elem, 2); if (o != NULL) { - if (PyLong_Check(o)) - *line_num = PyLong_AS_LONG(o); + if (PyLong_Check(o)) { + int num = _PyLong_AsInt(o); + if (num == -1 && PyErr_Occurred()) { + Py_DECREF(o); + Py_DECREF(temp); + Py_DECREF(elem); + return 0; + } + *line_num = num; + } else { PyErr_Format(parser_error, "third item in terminal node must be an" diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -8174,7 +8174,7 @@ int fds[2]; int res; - flags = PyLong_AsLong(arg); + flags = _PyLong_AsInt(arg); if (flags == -1 && PyErr_Occurred()) return NULL; diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -357,10 +357,13 @@ i = pos = 0; while (PyDict_Next(self->dict, &pos, &key, &value)) { - self->ufds[i].fd = PyLong_AsLong(key); + assert(i < self->ufd_len); + /* Never overflow */ + self->ufds[i].fd = (int)PyLong_AsLong(key); self->ufds[i].events = (short)PyLong_AsLong(value); i++; } + assert(i == self->ufd_len); self->ufd_uptodate = 1; return 1; } @@ -376,10 +379,11 @@ poll_register(pollObject *self, PyObject *args) { PyObject *o, *key, *value; - int fd, events = POLLIN | POLLPRI | POLLOUT; + int fd; + short events = POLLIN | POLLPRI | POLLOUT; int err; - if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { + if (!PyArg_ParseTuple(args, "O|h:register", &o, &events)) { return NULL; } @@ -518,7 +522,7 @@ tout = PyNumber_Long(tout); if (!tout) return NULL; - timeout = PyLong_AsLong(tout); + timeout = _PyLong_AsInt(tout); Py_DECREF(tout); if (timeout == -1 && PyErr_Occurred()) return NULL; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2073,7 +2073,7 @@ static PyObject * sock_setblocking(PySocketSockObject *s, PyObject *arg) { - int block; + long block; block = PyLong_AsLong(arg); if (block == -1 && PyErr_Occurred()) @@ -2555,7 +2555,7 @@ int backlog; int res; - backlog = PyLong_AsLong(arg); + backlog = _PyLong_AsInt(arg); if (backlog == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -3712,7 +3712,7 @@ int how; int res; - how = PyLong_AsLong(arg); + how = _PyLong_AsInt(arg); if (how == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS diff --git a/Objects/fileobject.c b/Objects/fileobject.c --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -200,7 +200,7 @@ _Py_IDENTIFIER(fileno); if (PyLong_Check(o)) { - fd = PyLong_AsLong(o); + fd = _PyLong_AsInt(o); } else if ((meth = _PyObject_GetAttrId(o, &PyId_fileno)) != NULL) { @@ -210,7 +210,7 @@ return -1; if (PyLong_Check(fno)) { - fd = PyLong_AsLong(fno); + fd = _PyLong_AsInt(fno); Py_DECREF(fno); } else { diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -434,6 +434,24 @@ return result; } +/* Get a C int from a long int object or any object that has an __int__ + method. Return -1 and set an error if overflow occurs. */ + +int +_PyLong_AsInt(PyObject *obj) +{ + int overflow; + long result = PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow || result > INT_MAX || result < INT_MIN) { + /* XXX: could be cute and give a different + message for overflow == -1 */ + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C int"); + return -1; + } + return (int)result; +} + /* Get a Py_ssize_t from a long int object. Returns -1 and sets an error condition if overflow occurs. */ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13569,7 +13569,7 @@ "* wants int"); goto onError; } - width = PyLong_AsLong(v); + width = PyLong_AsSsize_t(v); if (width == -1 && PyErr_Occurred()) goto onError; if (width < 0) { @@ -13609,7 +13609,7 @@ "* wants int"); goto onError; } - prec = PyLong_AsLong(v); + prec = _PyLong_AsInt(v); if (prec == -1 && PyErr_Occurred()) goto onError; if (prec < 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 11:46:38 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Jan 2013 11:46:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3YpG0t4svHzSMX@mail.python.org> http://hg.python.org/cpython/rev/d67467ff2ed5 changeset: 81589:d67467ff2ed5 parent: 81584:74b0461346f0 parent: 81588:8f10c9eae183 user: Serhiy Storchaka date: Sat Jan 19 12:43:21 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 11:56:50 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Jan 2013 11:56:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE1OTg5?= =?utf-8?q?=3A_Fix_several_occurrences_of_integer_overflow?= Message-ID: <3YpGDf3v3pzSMd@mail.python.org> http://hg.python.org/cpython/rev/d544873d62e9 changeset: 81590:d544873d62e9 branch: 2.7 parent: 81586:bfe38710d4e6 user: Serhiy Storchaka date: Sat Jan 19 12:55:39 2013 +0200 summary: Issue #15989: Fix several occurrences of integer overflow when result of PyInt_AsLong() or PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277. files: Include/intobject.h | 1 + Include/longobject.h | 1 + Lib/ctypes/test/test_structures.py | 9 ++++++ Lib/test/string_tests.py | 15 ++++++++++ Lib/test/test_fcntl.py | 21 ++++++++++++++ Lib/test/test_fileio.py | 4 ++ Lib/test/test_poll.py | 10 ++++++ Lib/test/test_socket.py | 27 +++++++++++++++-- Modules/_ctypes/stgdict.c | 2 +- Modules/_io/_iomodule.c | 7 ++-- Modules/_io/fileio.c | 2 +- Modules/selectmodule.c | 12 +++++-- Modules/socketmodule.c | 6 ++-- Objects/fileobject.c | 8 ++-- Objects/intobject.c | 14 +++++++++ Objects/longobject.c | 18 ++++++++++++ Objects/unicodeobject.c | 8 ++++- 17 files changed, 143 insertions(+), 22 deletions(-) diff --git a/Include/intobject.h b/Include/intobject.h --- a/Include/intobject.h +++ b/Include/intobject.h @@ -40,6 +40,7 @@ PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t); PyAPI_FUNC(long) PyInt_AsLong(PyObject *); PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *); +PyAPI_FUNC(int) _PyInt_AsInt(PyObject *); PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *); #ifdef HAVE_LONG_LONG PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *); diff --git a/Include/longobject.h b/Include/longobject.h --- a/Include/longobject.h +++ b/Include/longobject.h @@ -25,6 +25,7 @@ PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); +PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); /* For use by intobject.c only */ diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -1,6 +1,7 @@ import unittest from ctypes import * from struct import calcsize +import _testcapi class SubclassesTest(unittest.TestCase): def test_subclass(self): @@ -199,6 +200,14 @@ "_pack_": -1} self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + # Issue 15989 + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.INT_MAX + 1} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + d = {"_fields_": [("a", c_byte)], + "_pack_": _testcapi.UINT_MAX + 2} + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) + def test_initializers(self): class Person(Structure): _fields_ = [("name", c_char*6), diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -5,6 +5,7 @@ import unittest, string, sys, struct from test import test_support from UserList import UserList +import _testcapi class Sequence: def __init__(self, seq='wxyz'): self.seq = seq @@ -1113,6 +1114,20 @@ self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.)) self.checkraises(ValueError, '%10', '__mod__', (42,)) + if _testcapi.PY_SSIZE_T_MAX < sys.maxint: + self.checkraises(OverflowError, '%*s', '__mod__', + (_testcapi.PY_SSIZE_T_MAX + 1, '')) + if _testcapi.INT_MAX < sys.maxint: + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.INT_MAX + 1, 1. / 7)) + # Issue 15989 + if 1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1) <= sys.maxint: + self.checkraises(OverflowError, '%*s', '__mod__', + (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), '')) + if _testcapi.UINT_MAX < sys.maxint: + self.checkraises(OverflowError, '%.*f', '__mod__', + (_testcapi.UINT_MAX + 1, 1. / 7)) + class X(object): pass self.checkraises(TypeError, 'abc', '__mod__', X()) diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -6,6 +6,7 @@ import os import struct import sys +import _testcapi import unittest from test.test_support import (verbose, TESTFN, unlink, run_unittest, import_module) @@ -81,6 +82,26 @@ rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) self.f.close() + def test_fcntl_bad_file(self): + class F: + def __init__(self, fn): + self.fn = fn + def fileno(self): + return self.fn + self.assertRaises(ValueError, fcntl.fcntl, -1, fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(ValueError, fcntl.fcntl, F(-1), fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, 'spam', fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(TypeError, fcntl.fcntl, F('spam'), fcntl.F_SETFL, os.O_NONBLOCK) + # Issue 15989 + self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MAX + 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MAX + 1), + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MIN - 1, + fcntl.F_SETFL, os.O_NONBLOCK) + self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MIN - 1), + fcntl.F_SETFL, os.O_NONBLOCK) + def test_fcntl_64_bit(self): # Issue #1309352: fcntl shouldn't fail when the third arg fits in a # C 'long' but not in a C 'int'. diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -10,6 +10,7 @@ from weakref import proxy from functools import wraps from UserList import UserList +import _testcapi from test.test_support import TESTFN, check_warnings, run_unittest, make_bad_fd from test.test_support import py3k_bytes as bytes @@ -343,6 +344,9 @@ if sys.platform == 'win32': import msvcrt self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd()) + # Issue 15989 + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1) + self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) def testBadModeArgument(self): # verify that we get a sensible error message for bad mode argument diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py --- a/Lib/test/test_poll.py +++ b/Lib/test/test_poll.py @@ -1,6 +1,7 @@ # Test case for the os.poll() function import os, select, random, unittest +import _testcapi from test.test_support import TESTFN, run_unittest try: @@ -150,6 +151,15 @@ if x != 5: self.fail('Overflow must have occurred') + pollster = select.poll() + # Issue 15989 + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.SHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.register, 0, + _testcapi.USHRT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1) + def test_main(): run_unittest(PollTests) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -6,6 +6,7 @@ import errno import socket import select +import _testcapi import time import traceback import Queue @@ -700,11 +701,17 @@ def test_sendall_interrupted_with_timeout(self): self.check_sendall_interrupted(True) - def testListenBacklog0(self): + def test_listen_backlog(self): + for backlog in 0, -1: + srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + srv.bind((HOST, 0)) + srv.listen(backlog) + srv.close() + + # Issue 15989 srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) - # backlog = 0 - srv.listen(0) + self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) srv.close() @unittest.skipUnless(SUPPORTS_IPV6, 'IPv6 required for this test.') @@ -808,6 +815,11 @@ def _testShutdown(self): self.serv_conn.send(MSG) + # Issue 15989 + self.assertRaises(OverflowError, self.serv_conn.shutdown, + _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, self.serv_conn.shutdown, + 2 + (_testcapi.UINT_MAX + 1)) self.serv_conn.shutdown(2) @unittest.skipUnless(thread, 'Threading required for this test.') @@ -883,7 +895,10 @@ def testSetBlocking(self): # Testing whether set blocking works - self.serv.setblocking(0) + self.serv.setblocking(True) + self.assertIsNone(self.serv.gettimeout()) + self.serv.setblocking(False) + self.assertEqual(self.serv.gettimeout(), 0.0) start = time.time() try: self.serv.accept() @@ -891,6 +906,10 @@ pass end = time.time() self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.") + # Issue 15989 + if _testcapi.UINT_MAX < _testcapi.ULONG_MAX: + self.serv.setblocking(_testcapi.UINT_MAX + 1) + self.assertIsNone(self.serv.gettimeout()) def _testSetBlocking(self): pass diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -343,7 +343,7 @@ isPacked = PyObject_GetAttrString(type, "_pack_"); if (isPacked) { - pack = PyInt_AsLong(isPacked); + pack = _PyInt_AsInt(isPacked); if (pack < 0 || PyErr_Occurred()) { Py_XDECREF(isPacked); PyErr_SetString(PyExc_ValueError, diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -300,7 +300,8 @@ int text = 0, binary = 0, universal = 0; char rawmode[5], *m; - int line_buffering, isatty; + int line_buffering; + long isatty; PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL; @@ -443,12 +444,12 @@ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE { struct stat st; - long fileno; + int fileno; PyObject *res = PyObject_CallMethod(raw, "fileno", NULL); if (res == NULL) goto error; - fileno = PyInt_AsLong(res); + fileno = _PyInt_AsInt(res); Py_DECREF(res); if (fileno == -1 && PyErr_Occurred()) goto error; diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -211,7 +211,7 @@ return -1; } - fd = PyLong_AsLong(nameobj); + fd = _PyLong_AsInt(nameobj); if (fd < 0) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ValueError, diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -343,10 +343,13 @@ i = pos = 0; while (PyDict_Next(self->dict, &pos, &key, &value)) { - self->ufds[i].fd = PyInt_AsLong(key); + assert(i < self->ufd_len); + /* Never overflow */ + self->ufds[i].fd = (int)PyInt_AsLong(key); self->ufds[i].events = (short)PyInt_AsLong(value); i++; } + assert(i == self->ufd_len); self->ufd_uptodate = 1; return 1; } @@ -362,10 +365,11 @@ poll_register(pollObject *self, PyObject *args) { PyObject *o, *key, *value; - int fd, events = POLLIN | POLLPRI | POLLOUT; + int fd; + short events = POLLIN | POLLPRI | POLLOUT; int err; - if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { + if (!PyArg_ParseTuple(args, "O|h:register", &o, &events)) { return NULL; } @@ -503,7 +507,7 @@ tout = PyNumber_Int(tout); if (!tout) return NULL; - timeout = PyInt_AsLong(tout); + timeout = _PyInt_AsInt(tout); Py_DECREF(tout); if (timeout == -1 && PyErr_Occurred()) return NULL; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1713,7 +1713,7 @@ static PyObject * sock_setblocking(PySocketSockObject *s, PyObject *arg) { - int block; + long block; block = PyInt_AsLong(arg); if (block == -1 && PyErr_Occurred()) @@ -2243,7 +2243,7 @@ int backlog; int res; - backlog = PyInt_AsLong(arg); + backlog = _PyInt_AsInt(arg); if (backlog == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -2894,7 +2894,7 @@ int how; int res; - how = PyInt_AsLong(arg); + how = _PyInt_AsInt(arg); if (how == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS diff --git a/Objects/fileobject.c b/Objects/fileobject.c --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -2659,10 +2659,10 @@ PyObject *meth; if (PyInt_Check(o)) { - fd = PyInt_AsLong(o); + fd = _PyInt_AsInt(o); } else if (PyLong_Check(o)) { - fd = PyLong_AsLong(o); + fd = _PyLong_AsInt(o); } else if ((meth = PyObject_GetAttrString(o, "fileno")) != NULL) { @@ -2672,11 +2672,11 @@ return -1; if (PyInt_Check(fno)) { - fd = PyInt_AsLong(fno); + fd = _PyInt_AsInt(fno); Py_DECREF(fno); } else if (PyLong_Check(fno)) { - fd = PyLong_AsLong(fno); + fd = _PyLong_AsInt(fno); Py_DECREF(fno); } else { diff --git a/Objects/intobject.c b/Objects/intobject.c --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -189,6 +189,20 @@ return val; } +int +_PyInt_AsInt(PyObject *obj) +{ + long result = PyInt_AsLong(obj); + if (result == -1 && PyErr_Occurred()) + return -1; + if (result > INT_MAX || result < INT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C int"); + return -1; + } + return (int)result; +} + Py_ssize_t PyInt_AsSsize_t(register PyObject *op) { diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -339,6 +339,24 @@ return result; } +/* Get a C int from a long int object or any object that has an __int__ + method. Return -1 and set an error if overflow occurs. */ + +int +_PyLong_AsInt(PyObject *obj) +{ + int overflow; + long result = PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow || result > INT_MAX || result < INT_MIN) { + /* XXX: could be cute and give a different + message for overflow == -1 */ + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C int"); + return -1; + } + return (int)result; +} + /* Get a Py_ssize_t from a long int object. Returns -1 and sets an error condition if overflow occurs. */ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8411,7 +8411,9 @@ "* wants int"); goto onError; } - width = PyInt_AsLong(v); + width = PyInt_AsSsize_t(v); + if (width == -1 && PyErr_Occurred()) + goto onError; if (width < 0) { flags |= F_LJUST; width = -width; @@ -8446,7 +8448,9 @@ "* wants int"); goto onError; } - prec = PyInt_AsLong(v); + prec = _PyInt_AsInt(v); + if (prec == -1 && PyErr_Occurred()) + goto onError; if (prec < 0) prec = 0; if (--fmtcnt >= 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 12:40:31 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 19 Jan 2013 12:40:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2OTUz?= =?utf-8?q?=3A_Fix_socket_module_compilation_on_platforms_with_HAVE=5FBROK?= =?utf-8?q?EN=5FPOLL=2E?= Message-ID: <3YpHC36QtYzSLB@mail.python.org> http://hg.python.org/cpython/rev/1d33c79d2f6b changeset: 81591:1d33c79d2f6b branch: 2.7 user: Charles-Fran?ois Natali date: Sat Jan 19 12:15:56 2013 +0100 summary: Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. files: Misc/ACKS | 1 + Misc/NEWS | 3 +++ Modules/selectmodule.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -35,6 +35,7 @@ Ross Andrus Heidi Annexstad ?ric Araujo +Jeffrey Armstrong Jason Asbahr David Ascher Chris AtLee diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -700,6 +700,9 @@ Build ----- +- Issue #16953: Fix socket module compilation on platforms with + HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. + - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. - Issue #15923: fix a mistake in asdl_c.py that resulted in a TypeError after diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1737,7 +1737,7 @@ static PyMethodDef select_methods[] = { {"select", select_select, METH_VARARGS, select_doc}, -#ifdef HAVE_POLL +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) {"poll", select_poll, METH_NOARGS, poll_doc}, #endif /* HAVE_POLL */ {0, 0}, /* sentinel */ @@ -1769,7 +1769,7 @@ PyModule_AddIntConstant(m, "PIPE_BUF", PIPE_BUF); #endif -#if defined(HAVE_POLL) +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) #ifdef __APPLE__ if (select_have_broken_poll()) { if (PyObject_DelAttrString(m, "poll") == -1) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 12:40:33 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 19 Jan 2013 12:40:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2OTUz?= =?utf-8?q?=3A_Fix_socket_module_compilation_on_platforms_with_HAVE=5FBROK?= =?utf-8?q?EN=5FPOLL=2E?= Message-ID: <3YpHC52Q9qzSMm@mail.python.org> http://hg.python.org/cpython/rev/101e821e5e70 changeset: 81592:101e821e5e70 branch: 3.2 parent: 81587:974ace29ee2d user: Charles-Fran?ois Natali date: Sat Jan 19 12:19:10 2013 +0100 summary: Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. files: Misc/ACKS | 1 + Misc/NEWS | 3 +++ Modules/selectmodule.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -41,6 +41,7 @@ Heidi Annexstad ?ric Araujo Alicia Arlen +Jeffrey Armstrong Jason Asbahr David Ascher Chris AtLee diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -849,6 +849,9 @@ Build ----- +- Issue #16953: Fix socket module compilation on platforms with + HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. + - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. - Issue #16593: Have BSD 'make -s' do the right thing, thanks to Daniel Shahaf diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1743,7 +1743,7 @@ static PyMethodDef select_methods[] = { {"select", select_select, METH_VARARGS, select_doc}, -#ifdef HAVE_POLL +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) {"poll", select_poll, METH_NOARGS, poll_doc}, #endif /* HAVE_POLL */ {0, 0}, /* sentinel */ @@ -1788,7 +1788,7 @@ PyModule_AddIntConstant(m, "PIPE_BUF", PIPE_BUF); #endif -#if defined(HAVE_POLL) +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) #ifdef __APPLE__ if (select_have_broken_poll()) { if (PyObject_DelAttrString(m, "poll") == -1) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 12:40:34 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 19 Jan 2013 12:40:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316953=3A_Fix_socket_module_compilation_on_platforms_w?= =?utf-8?q?ith_HAVE=5FBROKEN=5FPOLL=2E?= Message-ID: <3YpHC658q9zSMp@mail.python.org> http://hg.python.org/cpython/rev/f04c97bbb241 changeset: 81593:f04c97bbb241 branch: 3.3 parent: 81588:8f10c9eae183 parent: 81592:101e821e5e70 user: Charles-Fran?ois Natali date: Sat Jan 19 12:21:26 2013 +0100 summary: Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. files: Misc/ACKS | 1 + Misc/NEWS | 3 +++ Modules/selectmodule.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -45,6 +45,7 @@ Heidi Annexstad ?ric Araujo Alicia Arlen +Jeffrey Armstrong Jason Asbahr David Ascher Chris AtLee diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -517,6 +517,9 @@ Build ----- +- Issue #16953: Fix socket module compilation on platforms with + HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. + - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. - Cross compiling needs host and build settings. configure no longer diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -2098,7 +2098,7 @@ static PyMethodDef select_methods[] = { {"select", select_select, METH_VARARGS, select_doc}, -#ifdef HAVE_POLL +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) {"poll", select_poll, METH_NOARGS, poll_doc}, #endif /* HAVE_POLL */ #ifdef HAVE_SYS_DEVPOLL_H @@ -2148,7 +2148,7 @@ PyModule_AddIntConstant(m, "PIPE_BUF", PIPE_BUF); #endif -#if defined(HAVE_POLL) +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) #ifdef __APPLE__ if (select_have_broken_poll()) { if (PyObject_DelAttrString(m, "poll") == -1) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 12:40:36 2013 From: python-checkins at python.org (charles-francois.natali) Date: Sat, 19 Jan 2013 12:40:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316953=3A_Fix_socket_module_compilation_on_platf?= =?utf-8?q?orms_with_HAVE=5FBROKEN=5FPOLL=2E?= Message-ID: <3YpHC80vZSzSN1@mail.python.org> http://hg.python.org/cpython/rev/79912bb1a884 changeset: 81594:79912bb1a884 parent: 81589:d67467ff2ed5 parent: 81593:f04c97bbb241 user: Charles-Fran?ois Natali date: Sat Jan 19 12:39:29 2013 +0100 summary: Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. files: Misc/ACKS | 1 + Misc/NEWS | 3 +++ Modules/selectmodule.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -45,6 +45,7 @@ Heidi Annexstad ?ric Araujo Alicia Arlen +Jeffrey Armstrong Jason Asbahr David Ascher Chris AtLee diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -732,6 +732,9 @@ Build ----- +- Issue #16953: Fix socket module compilation on platforms with + HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. + - Issue #16320: Remove redundant Makefile dependencies for strings and bytes. - Cross compiling needs host and build settings. configure no longer diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -2115,7 +2115,7 @@ static PyMethodDef select_methods[] = { {"select", select_select, METH_VARARGS, select_doc}, -#ifdef HAVE_POLL +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) {"poll", select_poll, METH_NOARGS, poll_doc}, #endif /* HAVE_POLL */ #ifdef HAVE_SYS_DEVPOLL_H @@ -2165,7 +2165,7 @@ PyModule_AddIntConstant(m, "PIPE_BUF", PIPE_BUF); #endif -#if defined(HAVE_POLL) +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) #ifdef __APPLE__ if (select_have_broken_poll()) { if (PyObject_DelAttrString(m, "poll") == -1) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 18:55:41 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 19 Jan 2013 18:55:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_a_few_typo?= =?utf-8?q?s_in_Misc/NEWS=2E?= Message-ID: <3YpRWx0NTWzSKF@mail.python.org> http://hg.python.org/cpython/rev/b17d4d163862 changeset: 81595:b17d4d163862 branch: 2.7 parent: 81591:1d33c79d2f6b user: Ezio Melotti date: Sat Jan 19 19:44:58 2013 +0200 summary: Fix a few typos in Misc/NEWS. files: Misc/NEWS | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,8 +9,8 @@ Core and Builtins ----------------- -- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" - in any mapping, not only in an unicode string. +- Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" + in any mapping, not only in a Unicode string. - Issue #11461: Fix the incremental UTF-16 decoder. Original patch by Amaury Forgeot d'Arc. @@ -27,7 +27,7 @@ now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py - when retreiving a REG_DWORD value. This corrects functions like + when retrieving a REG_DWORD value. This corrects functions like winreg.QueryValueEx that may have been returning truncated values. - Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg @@ -224,7 +224,7 @@ - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. -- Issue 10527: make multiprocessing use poll() instead of select() if available. +- Issue #10527: make multiprocessing use poll() instead of select() if available. - Issue #16485: Now file descriptors are closed if file header patching failed on closing an aifc file. @@ -1232,7 +1232,7 @@ check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the interpreter process. This could cause failures in non-Distutils subprocesses and was unreliable since tests or user programs could modify the interpreter - environment after Distutils set it. Instead, have Distutils set the the + environment after Distutils set it. Instead, have Distutils set the deployment target only in the environment of each build subprocess. It is still possible to globally override the default by setting MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its value must be @@ -1520,7 +1520,7 @@ rather than the Py_IsInitialized flag, avoiding a Fatal Python error in certain circumstances when an import is done in __del__. -- issue #11828: startswith and endswith don't accept None as slice index. +- Issue #11828: startswith and endswith don't accept None as slice index. Patch by Torsten Becker. - Issue #10674: Remove unused 'dictmaker' rule from grammar. @@ -3662,7 +3662,7 @@ Tests ----- -- issue #7728: test_timeout was changed to use ``test_support.bind_port()`` +- Issue #7728: test_timeout was changed to use ``test_support.bind_port()`` instead of a hard coded port. Documentation @@ -5228,7 +5228,7 @@ backporting to maintenance branches. Original patch by Alexander Belopolsky. - Issue #4163: Use unicode-friendly word splitting in the textwrap functions - when given an unicode string. + when given a Unicode string. - Issue #4616: TarFile.utime(): Restore directory times on Windows. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 18:55:42 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 19 Jan 2013 18:55:42 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_a_few_typo?= =?utf-8?q?s_in_Misc/NEWS=2E?= Message-ID: <3YpRWy33FszSKR@mail.python.org> http://hg.python.org/cpython/rev/930d9e8ecb66 changeset: 81596:930d9e8ecb66 branch: 3.2 parent: 81592:101e821e5e70 user: Ezio Melotti date: Sat Jan 19 19:50:34 2013 +0200 summary: Fix a few typos in Misc/NEWS. files: Misc/NEWS | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,7 +10,7 @@ Core and Builtins ----------------- -- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" +- Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in any mapping, not only in a string. - Issue #11461: Fix the incremental UTF-16 decoder. Original patch by @@ -27,7 +27,7 @@ - Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py - when retreiving a REG_DWORD value. This corrects functions like + when retrieving a REG_DWORD value. This corrects functions like winreg.QueryValueEx that may have been returning truncated values. - Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg @@ -242,7 +242,7 @@ - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. -- Issue 10527: make multiprocessing use poll() instead of select() if available. +- Issue #10527: make multiprocessing use poll() instead of select() if available. - Issue #16485: Now file descriptors are closed if file header patching failed on closing an aifc file. @@ -671,7 +671,7 @@ - Issue #14399: zipfile now recognizes that the archive has been modified even if only the comment is changed. In addition, the TypeError that results from - trying to set a non-binary value as a comment is now now raised at the time + trying to set a non-binary value as a comment is now raised at the time the comment is set rather than at the time the zipfile is written. - Issue #7978: socketserver now restarts the select() call when EINTR is @@ -1907,7 +1907,7 @@ check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the interpreter process. This could cause failures in non-Distutils subprocesses and was unreliable since tests or user programs could modify the interpreter - environment after Distutils set it. Instead, have Distutils set the the + environment after Distutils set it. Instead, have Distutils set the deployment target only in the environment of each build subprocess. It is still possible to globally override the default by setting MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its value must be @@ -2172,7 +2172,7 @@ - Issue #11272: On Windows, input() strips '\r' (and not only '\n'), and sys.stdin uses universal newline (replace '\r\n' by '\n'). -- issue #11828: startswith and endswith don't accept None as slice index. Patch +- Issue #11828: startswith and endswith don't accept None as slice index. Patch by Torsten Becker. - Issue #10830: Fix PyUnicode_FromFormatV("%c") for non-BMP characters on -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 18:55:43 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 19 Jan 2013 18:55:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge_Misc/NEWS_fixes_from_3=2E2=2E?= Message-ID: <3YpRWz62pmzSLG@mail.python.org> http://hg.python.org/cpython/rev/4b6e6da29adf changeset: 81597:4b6e6da29adf branch: 3.3 parent: 81593:f04c97bbb241 parent: 81596:930d9e8ecb66 user: Ezio Melotti date: Sat Jan 19 19:54:33 2013 +0200 summary: Merge Misc/NEWS fixes from 3.2. files: Misc/NEWS | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,7 +12,7 @@ Core and Builtins ----------------- -- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" +- Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in any mapping, not only in a string. - Issue #16730: importlib.machinery.FileFinder now no longers raises an @@ -42,7 +42,7 @@ - Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py - when retreiving a REG_DWORD value. This corrects functions like + when retrieving a REG_DWORD value. This corrects functions like winreg.QueryValueEx that may have been returning truncated values. - Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg @@ -206,7 +206,7 @@ - Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. -- Issue 10527: make multiprocessing use poll() instead of select() if available. +- Issue #10527: make multiprocessing use poll() instead of select() if available. - Issue #16688: Now regexes contained backreferences correctly work with non-ASCII strings. Patch by Matthew Barnett. @@ -1390,7 +1390,7 @@ - Issue #14626: Large refactoring of functions / parameters in the os module. Many functions now support "dir_fd" and "follow_symlinks" parameters; - some also support accepting an open file descriptor in place of of a path + some also support accepting an open file descriptor in place of a path string. Added os.support_* collections as LBYL helpers. Removed many functions only previously seen in 3.3 alpha releases (often starting with "f" or "l", or ending with "at"). Originally suggested by Serhiy Storchaka; @@ -2024,7 +2024,7 @@ - Issue #14399: zipfile now recognizes that the archive has been modified even if only the comment is changed. In addition, the TypeError that results from - trying to set a non-binary value as a comment is now now raised at the time + trying to set a non-binary value as a comment is now raised at the time the comment is set rather than at the time the zipfile is written. - trace.CoverageResults.is_ignored_filename() now ignores any name that starts @@ -3664,7 +3664,7 @@ check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the interpreter process. This could cause failures in non-Distutils subprocesses and was unreliable since tests or user programs could modify the interpreter - environment after Distutils set it. Instead, have Distutils set the the + environment after Distutils set it. Instead, have Distutils set the deployment target only in the environment of each build subprocess. It is still possible to globally override the default by setting MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its value must be -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 18:55:45 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 19 Jan 2013 18:55:45 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_Misc/NEWS_fixes_from_3=2E3=2E?= Message-ID: <3YpRX11crZzSLG@mail.python.org> http://hg.python.org/cpython/rev/c03c77a30611 changeset: 81598:c03c77a30611 parent: 81594:79912bb1a884 parent: 81597:4b6e6da29adf user: Ezio Melotti date: Sat Jan 19 19:55:27 2013 +0200 summary: Merge Misc/NEWS fixes from 3.3. files: Misc/NEWS | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,7 +10,7 @@ Core and Builtins ----------------- -- Issue #14850: Now a chamap decoder treates U+FFFE as "undefined mapping" +- Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in any mapping, not only in a string. - Issue #16730: importlib.machinery.FileFinder now no longers raises an @@ -34,7 +34,7 @@ - Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py - when retreiving a REG_DWORD value. This corrects functions like + when retrieving a REG_DWORD value. This corrects functions like winreg.QueryValueEx that may have been returning truncated values. - Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg @@ -1619,7 +1619,7 @@ - Issue #14626: Large refactoring of functions / parameters in the os module. Many functions now support "dir_fd" and "follow_symlinks" parameters; - some also support accepting an open file descriptor in place of of a path + some also support accepting an open file descriptor in place of a path string. Added os.support_* collections as LBYL helpers. Removed many functions only previously seen in 3.3 alpha releases (often starting with "f" or "l", or ending with "at"). Originally suggested by Serhiy Storchaka; @@ -2253,7 +2253,7 @@ - Issue #14399: zipfile now recognizes that the archive has been modified even if only the comment is changed. In addition, the TypeError that results from - trying to set a non-binary value as a comment is now now raised at the time + trying to set a non-binary value as a comment is now raised at the time the comment is set rather than at the time the zipfile is written. - trace.CoverageResults.is_ignored_filename() now ignores any name that starts @@ -3893,7 +3893,7 @@ check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the interpreter process. This could cause failures in non-Distutils subprocesses and was unreliable since tests or user programs could modify the interpreter - environment after Distutils set it. Instead, have Distutils set the the + environment after Distutils set it. Instead, have Distutils set the deployment target only in the environment of each build subprocess. It is still possible to globally override the default by setting MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its value must be -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 19:16:49 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 19 Jan 2013 19:16:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Fix_docstring_?= =?utf-8?q?typo_in_concurrent=2Efutures=2EFuture?= Message-ID: <3YpS0K29dtzSGj@mail.python.org> http://hg.python.org/cpython/rev/fcd1364f13b1 changeset: 81599:fcd1364f13b1 branch: 3.3 parent: 81597:4b6e6da29adf user: Eli Bendersky date: Thu Jan 17 06:36:30 2013 -0800 summary: Fix docstring typo in concurrent.futures.Future files: Lib/concurrent/futures/_base.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py --- a/Lib/concurrent/futures/_base.py +++ b/Lib/concurrent/futures/_base.py @@ -332,7 +332,7 @@ return True def cancelled(self): - """Return True if the future has cancelled.""" + """Return True if the future was cancelled.""" with self._condition: return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 19:16:50 2013 From: python-checkins at python.org (ezio.melotti) Date: Sat, 19 Jan 2013 19:16:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge_the_backported_changest=2E?= Message-ID: <3YpS0L5PWQzSGk@mail.python.org> http://hg.python.org/cpython/rev/48cddcb9c841 changeset: 81600:48cddcb9c841 parent: 81598:c03c77a30611 parent: 81599:fcd1364f13b1 user: Ezio Melotti date: Sat Jan 19 20:16:03 2013 +0200 summary: Null merge the backported changest. files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 20:10:29 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Jan 2013 20:10:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Ensure_that_wi?= =?utf-8?q?dth_and_precision_in_string_formatting_test_have_type_int=2C_no?= =?utf-8?q?t?= Message-ID: <3YpTBF2lk5zSKG@mail.python.org> http://hg.python.org/cpython/rev/a78ebf9aed06 changeset: 81601:a78ebf9aed06 branch: 2.7 parent: 81595:b17d4d163862 user: Serhiy Storchaka date: Sat Jan 19 21:06:35 2013 +0200 summary: Ensure that width and precision in string formatting test have type int, not long. Fix a regression from changeset d544873d62e9 (issue #15989). files: Lib/test/string_tests.py | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -1114,19 +1114,19 @@ self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.)) self.checkraises(ValueError, '%10', '__mod__', (42,)) - if _testcapi.PY_SSIZE_T_MAX < sys.maxint: - self.checkraises(OverflowError, '%*s', '__mod__', - (_testcapi.PY_SSIZE_T_MAX + 1, '')) - if _testcapi.INT_MAX < sys.maxint: - self.checkraises(OverflowError, '%.*f', '__mod__', - (_testcapi.INT_MAX + 1, 1. / 7)) + width = int(_testcapi.PY_SSIZE_T_MAX + 1) + if width <= sys.maxint: + self.checkraises(OverflowError, '%*s', '__mod__', (width, '')) + prec = int(_testcapi.INT_MAX + 1) + if prec <= sys.maxint: + self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7)) # Issue 15989 - if 1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1) <= sys.maxint: - self.checkraises(OverflowError, '%*s', '__mod__', - (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), '')) - if _testcapi.UINT_MAX < sys.maxint: - self.checkraises(OverflowError, '%.*f', '__mod__', - (_testcapi.UINT_MAX + 1, 1. / 7)) + width = int(1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1)) + if width <= sys.maxint: + self.checkraises(OverflowError, '%*s', '__mod__', (width, '')) + prec = int(_testcapi.UINT_MAX + 1) + if prec <= sys.maxint: + self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7)) class X(object): pass self.checkraises(TypeError, 'abc', '__mod__', X()) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 20:27:21 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 19 Jan 2013 20:27:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Ned_takes_care_of_Mac_install?= =?utf-8?q?ers_now?= Message-ID: <3YpTYj6VMwzSKW@mail.python.org> http://hg.python.org/peps/rev/0ea973522cde changeset: 4683:0ea973522cde user: Benjamin Peterson date: Sat Jan 19 14:27:14 2013 -0500 summary: Ned takes care of Mac installers now files: pep-0373.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0373.txt b/pep-0373.txt --- a/pep-0373.txt +++ b/pep-0373.txt @@ -27,7 +27,7 @@ ============================ ================== 2.7 Release Manager Benjamin Peterson Windows installers Martin v. Loewis -Mac installers Ronald Oussoren +Mac installers Ned Deily ============================ ================== -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sat Jan 19 20:31:13 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 19 Jan 2013 20:31:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_tentative_2=2E7=2E4_dates?= Message-ID: <3YpTf91gkszSLX@mail.python.org> http://hg.python.org/peps/rev/d97485fcaa40 changeset: 4684:d97485fcaa40 user: Benjamin Peterson date: Sat Jan 19 14:31:08 2013 -0500 summary: tentative 2.7.4 dates files: pep-0373.txt | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/pep-0373.txt b/pep-0373.txt --- a/pep-0373.txt +++ b/pep-0373.txt @@ -54,6 +54,11 @@ from the initial 2.7 release. This means there will be bugfix releases until 2015. +Planned future release dates: + +- 2.7.4rc1 2013-02-02 +- 2.7.4 2012-02-16 + Dates of previous maintenance releases: - 2.7.1 2010-11-27 -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sat Jan 19 20:58:59 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 19 Jan 2013 20:58:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_remove_unneces?= =?utf-8?q?sary_clearing_of_list?= Message-ID: <3YpVGC3RtKzSK2@mail.python.org> http://hg.python.org/cpython/rev/5b774459571c changeset: 81602:5b774459571c branch: 3.3 parent: 81599:fcd1364f13b1 user: Benjamin Peterson date: Sat Jan 19 14:58:38 2013 -0500 summary: remove unnecessary clearing of list files: Python/pyarena.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-) diff --git a/Python/pyarena.c b/Python/pyarena.c --- a/Python/pyarena.c +++ b/Python/pyarena.c @@ -156,7 +156,6 @@ void PyArena_Free(PyArena *arena) { - int r; assert(arena); #if defined(Py_DEBUG) /* @@ -173,12 +172,6 @@ assert(arena->a_objects->ob_refcnt == 1); */ - /* Clear all the elements from the list. This is necessary - to guarantee that they will be DECREFed. */ - r = PyList_SetSlice(arena->a_objects, - 0, PyList_GET_SIZE(arena->a_objects), NULL); - assert(r == 0); - assert(PyList_GET_SIZE(arena->a_objects) == 0); Py_DECREF(arena->a_objects); free(arena); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 20:59:00 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 19 Jan 2013 20:59:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_remove_unneces?= =?utf-8?q?sary_clearing_of_list?= Message-ID: <3YpVGD64jKzSKY@mail.python.org> http://hg.python.org/cpython/rev/5d03f2d81c50 changeset: 81603:5d03f2d81c50 branch: 2.7 parent: 81601:a78ebf9aed06 user: Benjamin Peterson date: Sat Jan 19 14:58:38 2013 -0500 summary: remove unnecessary clearing of list files: Python/pyarena.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-) diff --git a/Python/pyarena.c b/Python/pyarena.c --- a/Python/pyarena.c +++ b/Python/pyarena.c @@ -159,7 +159,6 @@ void PyArena_Free(PyArena *arena) { - int r; assert(arena); #if defined(Py_DEBUG) /* @@ -176,12 +175,6 @@ assert(arena->a_objects->ob_refcnt == 1); */ - /* Clear all the elements from the list. This is necessary - to guarantee that they will be DECREFed. */ - r = PyList_SetSlice(arena->a_objects, - 0, PyList_GET_SIZE(arena->a_objects), NULL); - assert(r == 0); - assert(PyList_GET_SIZE(arena->a_objects) == 0); Py_DECREF(arena->a_objects); free(arena); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 20:59:02 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 19 Jan 2013 20:59:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3YpVGG1c28zSKl@mail.python.org> http://hg.python.org/cpython/rev/97aabffae393 changeset: 81604:97aabffae393 parent: 81600:48cddcb9c841 parent: 81602:5b774459571c user: Benjamin Peterson date: Sat Jan 19 14:58:51 2013 -0500 summary: merge 3.3 files: Python/pyarena.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-) diff --git a/Python/pyarena.c b/Python/pyarena.c --- a/Python/pyarena.c +++ b/Python/pyarena.c @@ -156,7 +156,6 @@ void PyArena_Free(PyArena *arena) { - int r; assert(arena); #if defined(Py_DEBUG) /* @@ -173,12 +172,6 @@ assert(arena->a_objects->ob_refcnt == 1); */ - /* Clear all the elements from the list. This is necessary - to guarantee that they will be DECREFed. */ - r = PyList_SetSlice(arena->a_objects, - 0, PyList_GET_SIZE(arena->a_objects), NULL); - assert(r == 0); - assert(PyList_GET_SIZE(arena->a_objects) == 0); Py_DECREF(arena->a_objects); free(arena); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 19 22:36:49 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Jan 2013 22:36:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE1OTg5?= =?utf-8?q?=3A_Fix_possible_integer_overflow_in_str_formatting_as_in_unico?= =?utf-8?q?de?= Message-ID: <3YpXR51F88zSLb@mail.python.org> http://hg.python.org/cpython/rev/ee93a89b4e0f changeset: 81605:ee93a89b4e0f branch: 2.7 parent: 81603:5d03f2d81c50 user: Serhiy Storchaka date: Sat Jan 19 23:35:46 2013 +0200 summary: Issue #15989: Fix possible integer overflow in str formatting as in unicode formatting. files: Objects/stringobject.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Objects/stringobject.c b/Objects/stringobject.c --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -4355,7 +4355,9 @@ "* wants int"); goto error; } - width = PyInt_AsLong(v); + width = PyInt_AsSsize_t(v); + if (width == -1 && PyErr_Occurred()) + goto error; if (width < 0) { flags |= F_LJUST; width = -width; @@ -4392,7 +4394,9 @@ "* wants int"); goto error; } - prec = PyInt_AsLong(v); + prec = _PyInt_AsInt(v); + if (prec == -1 && PyErr_Occurred()) + goto error; if (prec < 0) prec = 0; if (--fmtcnt >= 0) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 01:34:02 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 20 Jan 2013 01:34:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Remove_cruft_a?= =?utf-8?q?nd_circumvolutions_from_the_unittest_docs=2E?= Message-ID: <3YpcMZ43RszSKV@mail.python.org> http://hg.python.org/cpython/rev/0a2e8e18ee94 changeset: 81606:0a2e8e18ee94 branch: 3.3 parent: 81602:5b774459571c user: Antoine Pitrou date: Sun Jan 20 01:29:39 2013 +0100 summary: Remove cruft and circumvolutions from the unittest docs. (I would have preferred to post this for review but the bug tracker is pretty much dead at the moment) files: Doc/library/unittest.rst | 261 ++++++-------------------- 1 files changed, 60 insertions(+), 201 deletions(-) diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -11,17 +11,14 @@ (If you are already familiar with the basic concepts of testing, you might want to skip to :ref:`the list of assert methods `.) -The Python unit testing framework, sometimes referred to as "PyUnit," is a -Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in -turn, a Java version of Kent's Smalltalk testing framework. Each is the de -facto standard unit testing framework for its respective language. - -:mod:`unittest` supports test automation, sharing of setup and shutdown code for -tests, aggregation of tests into collections, and independence of the tests from -the reporting framework. The :mod:`unittest` module provides classes that make -it easy to support these qualities for a set of tests. - -To achieve this, :mod:`unittest` supports some important concepts: +The :mod:`unittest` unit testing framework was originally inspired by JUnit +and has a similar flavor as major unit testing frameworks in other +languages. It supports test automation, sharing of setup and shutdown code +for tests, aggregation of tests into collections, and independence of the +tests from the reporting framework. + +To achieve this, :mod:`unittest` supports some important concepts in an +object-oriented way: test fixture A :dfn:`test fixture` represents the preparation needed to perform one or more @@ -30,7 +27,7 @@ process. test case - A :dfn:`test case` is the smallest unit of testing. It checks for a specific + A :dfn:`test case` is the individual unit of testing. It checks for a specific response to a particular set of inputs. :mod:`unittest` provides a base class, :class:`TestCase`, which may be used to create new test cases. @@ -44,43 +41,12 @@ a textual interface, or return a special value to indicate the results of executing the tests. -The test case and test fixture concepts are supported through the -:class:`TestCase` and :class:`FunctionTestCase` classes; the former should be -used when creating new tests, and the latter can be used when integrating -existing test code with a :mod:`unittest`\ -driven framework. When building test -fixtures using :class:`TestCase`, the :meth:`~TestCase.setUp` and -:meth:`~TestCase.tearDown` methods can be overridden to provide initialization -and cleanup for the fixture. With :class:`FunctionTestCase`, existing functions -can be passed to the constructor for these purposes. When the test is run, the -fixture initialization is run first; if it succeeds, the cleanup method is run -after the test has been executed, regardless of the outcome of the test. Each -instance of the :class:`TestCase` will only be used to run a single test method, -so a new fixture is created for each test. - -Test suites are implemented by the :class:`TestSuite` class. This class allows -individual tests and test suites to be aggregated; when the suite is executed, -all tests added directly to the suite and in "child" test suites are run. - -A test runner is an object that provides a single method, -:meth:`~TestRunner.run`, which accepts a :class:`TestCase` or :class:`TestSuite` -object as a parameter, and returns a result object. The class -:class:`TestResult` is provided for use as the result object. :mod:`unittest` -provides the :class:`TextTestRunner` as an example test runner which reports -test results on the standard error stream by default. Alternate runners can be -implemented for other environments (such as graphical environments) without any -need to derive from a specific class. - .. seealso:: Module :mod:`doctest` Another test-support module with a very different flavor. - `unittest2: A backport of new unittest features for Python 2.4-2.6 `_ - Many new features were added to unittest in Python 2.7, including test - discovery. unittest2 allows you to use these features with earlier - versions of Python. - `Simple Smalltalk Testing: With Patterns `_ Kent Beck's original paper on testing frameworks using the pattern shared by :mod:`unittest`. @@ -89,7 +55,7 @@ Third-party unittest frameworks with a lighter-weight syntax for writing tests. For example, ``assert func(10) == 42``. - `The Python Testing Tools Taxonomy `_ + `The Python Testing Tools Taxonomy `_ An extensive list of Python testing tools including functional testing frameworks and mock object libraries. @@ -173,15 +139,8 @@ OK -Instead of :func:`unittest.main`, there are other ways to run the tests with a -finer level of control, less terse output, and no requirement to be run from the -command line. For example, the last two lines may be replaced with:: - - suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions) - unittest.TextTestRunner(verbosity=2).run(suite) - -Running the revised script from the interpreter or another script produces the -following output:: +Passing the ``-v`` option to your test script will instruct :func:`unittest.main` +to enable a higher level of verbosity, and produce the following output:: test_choice (__main__.TestSequenceFunctions) ... ok test_sample (__main__.TestSequenceFunctions) ... ok @@ -359,45 +318,30 @@ To make your own test cases you must write subclasses of :class:`TestCase` or use :class:`FunctionTestCase`. -An instance of a :class:`TestCase`\ -derived class is an object that can -completely run a single test method, together with optional set-up and tidy-up -code. - The testing code of a :class:`TestCase` instance should be entirely self contained, such that it can be run either in isolation or in arbitrary combination with any number of other test cases. -The simplest :class:`TestCase` subclass will simply override the -:meth:`~TestCase.runTest` method in order to perform specific testing code:: +The simplest :class:`TestCase` subclass will simply implement a test method +(i.e. a method whose name starts with ``test``) in order to perform specific +testing code:: import unittest class DefaultWidgetSizeTestCase(unittest.TestCase): - def runTest(self): + def test_default_widget_size(self): widget = Widget('The widget') - self.assertEqual(widget.size(), (50, 50), 'incorrect default size') + self.assertEqual(widget.size(), (50, 50)) Note that in order to test something, we use one of the :meth:`assert\*` methods provided by the :class:`TestCase` base class. If the test fails, an exception will be raised, and :mod:`unittest` will identify the test case as a -:dfn:`failure`. Any other exceptions will be treated as :dfn:`errors`. This -helps you identify where the problem is: :dfn:`failures` are caused by incorrect -results - a 5 where you expected a 6. :dfn:`Errors` are caused by incorrect -code - e.g., a :exc:`TypeError` caused by an incorrect function call. - -The way to run a test case will be described later. For now, note that to -construct an instance of such a test case, we call its constructor without -arguments:: - - testCase = DefaultWidgetSizeTestCase() - -Now, such test cases can be numerous, and their set-up can be repetitive. In -the above case, constructing a :class:`Widget` in each of 100 Widget test case -subclasses would mean unsightly duplication. - -Luckily, we can factor out such set-up code by implementing a method called -:meth:`~TestCase.setUp`, which the testing framework will automatically call for -us when we run the test:: +:dfn:`failure`. Any other exceptions will be treated as :dfn:`errors`. + +Tests can be numerous, and their set-up can be repetitive. Luckily, we +can factor out set-up code by implementing a method called +:meth:`~TestCase.setUp`, which the testing framework will automatically +call for every single test we run:: import unittest @@ -405,23 +349,26 @@ def setUp(self): self.widget = Widget('The widget') - class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): - def runTest(self): + def test_default_widget_size(self): self.assertEqual(self.widget.size(), (50,50), 'incorrect default size') - class WidgetResizeTestCase(SimpleWidgetTestCase): - def runTest(self): + def test_widget_resize(self): self.widget.resize(100,150) self.assertEqual(self.widget.size(), (100,150), 'wrong size after resize') +.. note:: + The order in which the various tests will be run is determined + by sorting the test method names with respect to the built-in + ordering for strings. + If the :meth:`~TestCase.setUp` method raises an exception while the test is -running, the framework will consider the test to have suffered an error, and the -:meth:`~TestCase.runTest` method will not be executed. +running, the framework will consider the test to have suffered an error, and +the test method will not be executed. Similarly, we can provide a :meth:`~TestCase.tearDown` method that tidies up -after the :meth:`~TestCase.runTest` method has been run:: +after the test method has been run:: import unittest @@ -431,59 +378,20 @@ def tearDown(self): self.widget.dispose() - self.widget = None - -If :meth:`~TestCase.setUp` succeeded, the :meth:`~TestCase.tearDown` method will -be run whether :meth:`~TestCase.runTest` succeeded or not. + +If :meth:`~TestCase.setUp` succeeded, :meth:`~TestCase.tearDown` will be +run whether the test method succeeded or not. Such a working environment for the testing code is called a :dfn:`fixture`. -Often, many small test cases will use the same fixture. In this case, we would -end up subclassing :class:`SimpleWidgetTestCase` into many small one-method -classes such as :class:`DefaultWidgetSizeTestCase`. This is time-consuming and -discouraging, so in the same vein as JUnit, :mod:`unittest` provides a simpler -mechanism:: - - import unittest - - class WidgetTestCase(unittest.TestCase): - def setUp(self): - self.widget = Widget('The widget') - - def tearDown(self): - self.widget.dispose() - self.widget = None - - def test_default_size(self): - self.assertEqual(self.widget.size(), (50,50), - 'incorrect default size') - - def test_resize(self): - self.widget.resize(100,150) - self.assertEqual(self.widget.size(), (100,150), - 'wrong size after resize') - -Here we have not provided a :meth:`~TestCase.runTest` method, but have instead -provided two different test methods. Class instances will now each run one of -the :meth:`test_\*` methods, with ``self.widget`` created and destroyed -separately for each instance. When creating an instance we must specify the -test method it is to run. We do this by passing the method name in the -constructor:: - - defaultSizeTestCase = WidgetTestCase('test_default_size') - resizeTestCase = WidgetTestCase('test_resize') - Test case instances are grouped together according to the features they test. :mod:`unittest` provides a mechanism for this: the :dfn:`test suite`, -represented by :mod:`unittest`'s :class:`TestSuite` class:: - - widgetTestSuite = unittest.TestSuite() - widgetTestSuite.addTest(WidgetTestCase('test_default_size')) - widgetTestSuite.addTest(WidgetTestCase('test_resize')) - -For the ease of running tests, as we will see later, it is a good idea to -provide in each test module a callable object that returns a pre-built test -suite:: +represented by :mod:`unittest`'s :class:`TestSuite` class. In most cases, +calling :func:`unittest.main` will do the right thing and collect all the +module's test cases for you, and then execute them. + +However, should you want to customize the building of your test suite, +you can do it yourself:: def suite(): suite = unittest.TestSuite() @@ -491,37 +399,6 @@ suite.addTest(WidgetTestCase('test_resize')) return suite -or even:: - - def suite(): - tests = ['test_default_size', 'test_resize'] - - return unittest.TestSuite(map(WidgetTestCase, tests)) - -Since it is a common pattern to create a :class:`TestCase` subclass with many -similarly named test functions, :mod:`unittest` provides a :class:`TestLoader` -class that can be used to automate the process of creating a test suite and -populating it with individual tests. For example, :: - - suite = unittest.TestLoader().loadTestsFromTestCase(WidgetTestCase) - -will create a test suite that will run ``WidgetTestCase.test_default_size()`` and -``WidgetTestCase.test_resize``. :class:`TestLoader` uses the ``'test'`` method -name prefix to identify test methods automatically. - -Note that the order in which the various test cases will be run is -determined by sorting the test function names with respect to the -built-in ordering for strings. - -Often it is desirable to group suites of test cases together, so as to run tests -for the whole system at once. This is easy, since :class:`TestSuite` instances -can be added to a :class:`TestSuite` just as :class:`TestCase` instances can be -added to a :class:`TestSuite`:: - - suite1 = module1.TheTestSuite() - suite2 = module2.TheTestSuite() - alltests = unittest.TestSuite([suite1, suite2]) - You can place the definitions of test cases and test suites in the same modules as the code they are to test (such as :file:`widget.py`), but there are several advantages to placing the test code in a separate module, such as @@ -564,23 +441,13 @@ assert something.name is not None # ... -one can create an equivalent test case instance as follows:: - - testcase = unittest.FunctionTestCase(testSomething) - -If there are additional set-up and tear-down methods that should be called as -part of the test case's operation, they can also be provided like so:: +one can create an equivalent test case instance as follows, with optional +set-up and tear-down methods:: testcase = unittest.FunctionTestCase(testSomething, setUp=makeSomethingDB, tearDown=deleteSomethingDB) -To make migrating existing test suites easier, :mod:`unittest` supports tests -raising :exc:`AssertionError` to indicate test failure. However, it is -recommended that you use the explicit :meth:`TestCase.fail\*` and -:meth:`TestCase.assert\*` methods instead, as future versions of :mod:`unittest` -may treat :exc:`AssertionError` differently. - .. note:: Even though :class:`FunctionTestCase` can be used to quickly convert an @@ -704,32 +571,24 @@ .. class:: TestCase(methodName='runTest') - Instances of the :class:`TestCase` class represent the smallest testable units + Instances of the :class:`TestCase` class represent the logical test units in the :mod:`unittest` universe. This class is intended to be used as a base class, with specific tests being implemented by concrete subclasses. This class implements the interface needed by the test runner to allow it to drive the - test, and methods that the test code can use to check for and report various + tests, and methods that the test code can use to check for and report various kinds of failure. - Each instance of :class:`TestCase` will run a single test method: the method - named *methodName*. If you remember, we had an earlier example that went - something like this:: - - def suite(): - suite = unittest.TestSuite() - suite.addTest(WidgetTestCase('test_default_size')) - suite.addTest(WidgetTestCase('test_resize')) - return suite - - Here, we create two instances of :class:`WidgetTestCase`, each of which runs a - single test. + Each instance of :class:`TestCase` will run a single base method: the method + named *methodName*. However, the standard implementation of the default + *methodName*, ``runTest()``, will run every method starting with ``test`` + as an individual test, and count successes and failures accordingly. + Therefore, in most uses of :class:`TestCase`, you will neither change + the *methodName* nor reimplement the default ``runTest()`` method. .. versionchanged:: 3.2 - :class:`TestCase` can be instantiated successfully without providing a method - name. This makes it easier to experiment with :class:`TestCase` from the - interactive interpreter. - - *methodName* defaults to :meth:`runTest`. + :class:`TestCase` can be instantiated successfully without providing a + *methodName*. This makes it easier to experiment with :class:`TestCase` + from the interactive interpreter. :class:`TestCase` instances provide three groups of methods: one group used to run the test, another used by the test implementation to check conditions @@ -738,7 +597,6 @@ Methods in the first group (running the test) are: - .. method:: setUp() Method called to prepare the test fixture. This is called immediately @@ -790,10 +648,11 @@ .. method:: run(result=None) - Run the test, collecting the result into the test result object passed as - *result*. If *result* is omitted or ``None``, a temporary result - object is created (by calling the :meth:`defaultTestResult` method) and - used. The result object is returned to :meth:`run`'s caller. + Run the test, collecting the result into the :class:`TestResult` object + passed as *result*. If *result* is omitted or ``None``, a temporary + result object is created (by calling the :meth:`defaultTestResult` + method) and used. The result object is returned to :meth:`run`'s + caller. The same effect may be had by simply calling the :class:`TestCase` instance. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 01:34:04 2013 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 20 Jan 2013 01:34:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Remove_cruft_and_circumvolutions_from_the_unittest_docs?= =?utf-8?q?=2E?= Message-ID: <3YpcMc2TYpzSL6@mail.python.org> http://hg.python.org/cpython/rev/d1e6a48dfb0d changeset: 81607:d1e6a48dfb0d parent: 81604:97aabffae393 parent: 81606:0a2e8e18ee94 user: Antoine Pitrou date: Sun Jan 20 01:31:20 2013 +0100 summary: Remove cruft and circumvolutions from the unittest docs. (I would have preferred to post this for review but the bug tracker is pretty much dead at the moment) files: Doc/library/unittest.rst | 261 ++++++-------------------- 1 files changed, 60 insertions(+), 201 deletions(-) diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -11,17 +11,14 @@ (If you are already familiar with the basic concepts of testing, you might want to skip to :ref:`the list of assert methods `.) -The Python unit testing framework, sometimes referred to as "PyUnit," is a -Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in -turn, a Java version of Kent's Smalltalk testing framework. Each is the de -facto standard unit testing framework for its respective language. - -:mod:`unittest` supports test automation, sharing of setup and shutdown code for -tests, aggregation of tests into collections, and independence of the tests from -the reporting framework. The :mod:`unittest` module provides classes that make -it easy to support these qualities for a set of tests. - -To achieve this, :mod:`unittest` supports some important concepts: +The :mod:`unittest` unit testing framework was originally inspired by JUnit +and has a similar flavor as major unit testing frameworks in other +languages. It supports test automation, sharing of setup and shutdown code +for tests, aggregation of tests into collections, and independence of the +tests from the reporting framework. + +To achieve this, :mod:`unittest` supports some important concepts in an +object-oriented way: test fixture A :dfn:`test fixture` represents the preparation needed to perform one or more @@ -30,7 +27,7 @@ process. test case - A :dfn:`test case` is the smallest unit of testing. It checks for a specific + A :dfn:`test case` is the individual unit of testing. It checks for a specific response to a particular set of inputs. :mod:`unittest` provides a base class, :class:`TestCase`, which may be used to create new test cases. @@ -44,43 +41,12 @@ a textual interface, or return a special value to indicate the results of executing the tests. -The test case and test fixture concepts are supported through the -:class:`TestCase` and :class:`FunctionTestCase` classes; the former should be -used when creating new tests, and the latter can be used when integrating -existing test code with a :mod:`unittest`\ -driven framework. When building test -fixtures using :class:`TestCase`, the :meth:`~TestCase.setUp` and -:meth:`~TestCase.tearDown` methods can be overridden to provide initialization -and cleanup for the fixture. With :class:`FunctionTestCase`, existing functions -can be passed to the constructor for these purposes. When the test is run, the -fixture initialization is run first; if it succeeds, the cleanup method is run -after the test has been executed, regardless of the outcome of the test. Each -instance of the :class:`TestCase` will only be used to run a single test method, -so a new fixture is created for each test. - -Test suites are implemented by the :class:`TestSuite` class. This class allows -individual tests and test suites to be aggregated; when the suite is executed, -all tests added directly to the suite and in "child" test suites are run. - -A test runner is an object that provides a single method, -:meth:`~TestRunner.run`, which accepts a :class:`TestCase` or :class:`TestSuite` -object as a parameter, and returns a result object. The class -:class:`TestResult` is provided for use as the result object. :mod:`unittest` -provides the :class:`TextTestRunner` as an example test runner which reports -test results on the standard error stream by default. Alternate runners can be -implemented for other environments (such as graphical environments) without any -need to derive from a specific class. - .. seealso:: Module :mod:`doctest` Another test-support module with a very different flavor. - `unittest2: A backport of new unittest features for Python 2.4-2.6 `_ - Many new features were added to unittest in Python 2.7, including test - discovery. unittest2 allows you to use these features with earlier - versions of Python. - `Simple Smalltalk Testing: With Patterns `_ Kent Beck's original paper on testing frameworks using the pattern shared by :mod:`unittest`. @@ -89,7 +55,7 @@ Third-party unittest frameworks with a lighter-weight syntax for writing tests. For example, ``assert func(10) == 42``. - `The Python Testing Tools Taxonomy `_ + `The Python Testing Tools Taxonomy `_ An extensive list of Python testing tools including functional testing frameworks and mock object libraries. @@ -173,15 +139,8 @@ OK -Instead of :func:`unittest.main`, there are other ways to run the tests with a -finer level of control, less terse output, and no requirement to be run from the -command line. For example, the last two lines may be replaced with:: - - suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions) - unittest.TextTestRunner(verbosity=2).run(suite) - -Running the revised script from the interpreter or another script produces the -following output:: +Passing the ``-v`` option to your test script will instruct :func:`unittest.main` +to enable a higher level of verbosity, and produce the following output:: test_choice (__main__.TestSequenceFunctions) ... ok test_sample (__main__.TestSequenceFunctions) ... ok @@ -359,45 +318,30 @@ To make your own test cases you must write subclasses of :class:`TestCase` or use :class:`FunctionTestCase`. -An instance of a :class:`TestCase`\ -derived class is an object that can -completely run a single test method, together with optional set-up and tidy-up -code. - The testing code of a :class:`TestCase` instance should be entirely self contained, such that it can be run either in isolation or in arbitrary combination with any number of other test cases. -The simplest :class:`TestCase` subclass will simply override the -:meth:`~TestCase.runTest` method in order to perform specific testing code:: +The simplest :class:`TestCase` subclass will simply implement a test method +(i.e. a method whose name starts with ``test``) in order to perform specific +testing code:: import unittest class DefaultWidgetSizeTestCase(unittest.TestCase): - def runTest(self): + def test_default_widget_size(self): widget = Widget('The widget') - self.assertEqual(widget.size(), (50, 50), 'incorrect default size') + self.assertEqual(widget.size(), (50, 50)) Note that in order to test something, we use one of the :meth:`assert\*` methods provided by the :class:`TestCase` base class. If the test fails, an exception will be raised, and :mod:`unittest` will identify the test case as a -:dfn:`failure`. Any other exceptions will be treated as :dfn:`errors`. This -helps you identify where the problem is: :dfn:`failures` are caused by incorrect -results - a 5 where you expected a 6. :dfn:`Errors` are caused by incorrect -code - e.g., a :exc:`TypeError` caused by an incorrect function call. - -The way to run a test case will be described later. For now, note that to -construct an instance of such a test case, we call its constructor without -arguments:: - - testCase = DefaultWidgetSizeTestCase() - -Now, such test cases can be numerous, and their set-up can be repetitive. In -the above case, constructing a :class:`Widget` in each of 100 Widget test case -subclasses would mean unsightly duplication. - -Luckily, we can factor out such set-up code by implementing a method called -:meth:`~TestCase.setUp`, which the testing framework will automatically call for -us when we run the test:: +:dfn:`failure`. Any other exceptions will be treated as :dfn:`errors`. + +Tests can be numerous, and their set-up can be repetitive. Luckily, we +can factor out set-up code by implementing a method called +:meth:`~TestCase.setUp`, which the testing framework will automatically +call for every single test we run:: import unittest @@ -405,23 +349,26 @@ def setUp(self): self.widget = Widget('The widget') - class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): - def runTest(self): + def test_default_widget_size(self): self.assertEqual(self.widget.size(), (50,50), 'incorrect default size') - class WidgetResizeTestCase(SimpleWidgetTestCase): - def runTest(self): + def test_widget_resize(self): self.widget.resize(100,150) self.assertEqual(self.widget.size(), (100,150), 'wrong size after resize') +.. note:: + The order in which the various tests will be run is determined + by sorting the test method names with respect to the built-in + ordering for strings. + If the :meth:`~TestCase.setUp` method raises an exception while the test is -running, the framework will consider the test to have suffered an error, and the -:meth:`~TestCase.runTest` method will not be executed. +running, the framework will consider the test to have suffered an error, and +the test method will not be executed. Similarly, we can provide a :meth:`~TestCase.tearDown` method that tidies up -after the :meth:`~TestCase.runTest` method has been run:: +after the test method has been run:: import unittest @@ -431,59 +378,20 @@ def tearDown(self): self.widget.dispose() - self.widget = None - -If :meth:`~TestCase.setUp` succeeded, the :meth:`~TestCase.tearDown` method will -be run whether :meth:`~TestCase.runTest` succeeded or not. + +If :meth:`~TestCase.setUp` succeeded, :meth:`~TestCase.tearDown` will be +run whether the test method succeeded or not. Such a working environment for the testing code is called a :dfn:`fixture`. -Often, many small test cases will use the same fixture. In this case, we would -end up subclassing :class:`SimpleWidgetTestCase` into many small one-method -classes such as :class:`DefaultWidgetSizeTestCase`. This is time-consuming and -discouraging, so in the same vein as JUnit, :mod:`unittest` provides a simpler -mechanism:: - - import unittest - - class WidgetTestCase(unittest.TestCase): - def setUp(self): - self.widget = Widget('The widget') - - def tearDown(self): - self.widget.dispose() - self.widget = None - - def test_default_size(self): - self.assertEqual(self.widget.size(), (50,50), - 'incorrect default size') - - def test_resize(self): - self.widget.resize(100,150) - self.assertEqual(self.widget.size(), (100,150), - 'wrong size after resize') - -Here we have not provided a :meth:`~TestCase.runTest` method, but have instead -provided two different test methods. Class instances will now each run one of -the :meth:`test_\*` methods, with ``self.widget`` created and destroyed -separately for each instance. When creating an instance we must specify the -test method it is to run. We do this by passing the method name in the -constructor:: - - defaultSizeTestCase = WidgetTestCase('test_default_size') - resizeTestCase = WidgetTestCase('test_resize') - Test case instances are grouped together according to the features they test. :mod:`unittest` provides a mechanism for this: the :dfn:`test suite`, -represented by :mod:`unittest`'s :class:`TestSuite` class:: - - widgetTestSuite = unittest.TestSuite() - widgetTestSuite.addTest(WidgetTestCase('test_default_size')) - widgetTestSuite.addTest(WidgetTestCase('test_resize')) - -For the ease of running tests, as we will see later, it is a good idea to -provide in each test module a callable object that returns a pre-built test -suite:: +represented by :mod:`unittest`'s :class:`TestSuite` class. In most cases, +calling :func:`unittest.main` will do the right thing and collect all the +module's test cases for you, and then execute them. + +However, should you want to customize the building of your test suite, +you can do it yourself:: def suite(): suite = unittest.TestSuite() @@ -491,37 +399,6 @@ suite.addTest(WidgetTestCase('test_resize')) return suite -or even:: - - def suite(): - tests = ['test_default_size', 'test_resize'] - - return unittest.TestSuite(map(WidgetTestCase, tests)) - -Since it is a common pattern to create a :class:`TestCase` subclass with many -similarly named test functions, :mod:`unittest` provides a :class:`TestLoader` -class that can be used to automate the process of creating a test suite and -populating it with individual tests. For example, :: - - suite = unittest.TestLoader().loadTestsFromTestCase(WidgetTestCase) - -will create a test suite that will run ``WidgetTestCase.test_default_size()`` and -``WidgetTestCase.test_resize``. :class:`TestLoader` uses the ``'test'`` method -name prefix to identify test methods automatically. - -Note that the order in which the various test cases will be run is -determined by sorting the test function names with respect to the -built-in ordering for strings. - -Often it is desirable to group suites of test cases together, so as to run tests -for the whole system at once. This is easy, since :class:`TestSuite` instances -can be added to a :class:`TestSuite` just as :class:`TestCase` instances can be -added to a :class:`TestSuite`:: - - suite1 = module1.TheTestSuite() - suite2 = module2.TheTestSuite() - alltests = unittest.TestSuite([suite1, suite2]) - You can place the definitions of test cases and test suites in the same modules as the code they are to test (such as :file:`widget.py`), but there are several advantages to placing the test code in a separate module, such as @@ -564,23 +441,13 @@ assert something.name is not None # ... -one can create an equivalent test case instance as follows:: - - testcase = unittest.FunctionTestCase(testSomething) - -If there are additional set-up and tear-down methods that should be called as -part of the test case's operation, they can also be provided like so:: +one can create an equivalent test case instance as follows, with optional +set-up and tear-down methods:: testcase = unittest.FunctionTestCase(testSomething, setUp=makeSomethingDB, tearDown=deleteSomethingDB) -To make migrating existing test suites easier, :mod:`unittest` supports tests -raising :exc:`AssertionError` to indicate test failure. However, it is -recommended that you use the explicit :meth:`TestCase.fail\*` and -:meth:`TestCase.assert\*` methods instead, as future versions of :mod:`unittest` -may treat :exc:`AssertionError` differently. - .. note:: Even though :class:`FunctionTestCase` can be used to quickly convert an @@ -704,32 +571,24 @@ .. class:: TestCase(methodName='runTest') - Instances of the :class:`TestCase` class represent the smallest testable units + Instances of the :class:`TestCase` class represent the logical test units in the :mod:`unittest` universe. This class is intended to be used as a base class, with specific tests being implemented by concrete subclasses. This class implements the interface needed by the test runner to allow it to drive the - test, and methods that the test code can use to check for and report various + tests, and methods that the test code can use to check for and report various kinds of failure. - Each instance of :class:`TestCase` will run a single test method: the method - named *methodName*. If you remember, we had an earlier example that went - something like this:: - - def suite(): - suite = unittest.TestSuite() - suite.addTest(WidgetTestCase('test_default_size')) - suite.addTest(WidgetTestCase('test_resize')) - return suite - - Here, we create two instances of :class:`WidgetTestCase`, each of which runs a - single test. + Each instance of :class:`TestCase` will run a single base method: the method + named *methodName*. However, the standard implementation of the default + *methodName*, ``runTest()``, will run every method starting with ``test`` + as an individual test, and count successes and failures accordingly. + Therefore, in most uses of :class:`TestCase`, you will neither change + the *methodName* nor reimplement the default ``runTest()`` method. .. versionchanged:: 3.2 - :class:`TestCase` can be instantiated successfully without providing a method - name. This makes it easier to experiment with :class:`TestCase` from the - interactive interpreter. - - *methodName* defaults to :meth:`runTest`. + :class:`TestCase` can be instantiated successfully without providing a + *methodName*. This makes it easier to experiment with :class:`TestCase` + from the interactive interpreter. :class:`TestCase` instances provide three groups of methods: one group used to run the test, another used by the test implementation to check conditions @@ -738,7 +597,6 @@ Methods in the first group (running the test) are: - .. method:: setUp() Method called to prepare the test fixture. This is called immediately @@ -790,10 +648,11 @@ .. method:: run(result=None) - Run the test, collecting the result into the test result object passed as - *result*. If *result* is omitted or ``None``, a temporary result - object is created (by calling the :meth:`defaultTestResult` method) and - used. The result object is returned to :meth:`run`'s caller. + Run the test, collecting the result into the :class:`TestResult` object + passed as *result*. If *result* is omitted or ``None``, a temporary + result object is created (by calling the :meth:`defaultTestResult` + method) and used. The result object is returned to :meth:`run`'s + caller. The same effect may be had by simply calling the :class:`TestCase` instance. -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Sun Jan 20 05:59:45 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 20 Jan 2013 05:59:45 +0100 Subject: [Python-checkins] Daily reference leaks (d1e6a48dfb0d): sum=7 Message-ID: results for d1e6a48dfb0d on branch "default" -------------------------------------------- test_support leaked [0, -1, 1] references, sum=0 test_support leaked [0, -1, 3] memory blocks, sum=2 test_concurrent_futures leaked [0, 0, -2] memory blocks, sum=-2 test_dbm leaked [2, 0, 0] references, sum=2 test_dbm leaked [2, 2, 1] memory blocks, sum=5 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogIdHnaP', '-x'] From python-checkins at python.org Sun Jan 20 08:22:54 2013 From: python-checkins at python.org (nick.coghlan) Date: Sun, 20 Jan 2013 08:22:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Touch_correct_?= =?utf-8?q?file_in_=27make_touch=27?= Message-ID: <3YpnRL2HZszSLY@mail.python.org> http://hg.python.org/cpython/rev/366492014768 changeset: 81608:366492014768 branch: 3.3 parent: 81606:0a2e8e18ee94 user: Nick Coghlan date: Sun Jan 20 17:22:07 2013 +1000 summary: Touch correct file in 'make touch' files: .hgtouch | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.hgtouch b/.hgtouch --- a/.hgtouch +++ b/.hgtouch @@ -2,11 +2,11 @@ # Define dependencies of generated files that are checked into hg. # The syntax of this file uses make rule dependencies, without actions -Python/importlib.h: Lib/importlib/_bootstrap.py Python/freeze_importlib.py +Python/importlib.h: Lib/importlib/_bootstrap.py Modules/_freeze_importlib.c Include/ast.h: Parser/Python.asdl Parser/asdl.py Parser/asdl_c.py Python/Python-ast.c: Include/ast.h Python/opcode_targets.h: Python/makeopcodetargets.py Lib/opcode.py -Objects/typeslots.inc: Include/typeslots.h Objects/typeslots.py \ No newline at end of file +Objects/typeslots.inc: Include/typeslots.h Objects/typeslots.py -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 08:22:55 2013 From: python-checkins at python.org (nick.coghlan) Date: Sun, 20 Jan 2013 08:22:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_hg_touch_fix_from_3=2E3?= Message-ID: <3YpnRM4xC1zSLY@mail.python.org> http://hg.python.org/cpython/rev/a127165f5546 changeset: 81609:a127165f5546 parent: 81607:d1e6a48dfb0d parent: 81608:366492014768 user: Nick Coghlan date: Sun Jan 20 17:22:42 2013 +1000 summary: Merge hg touch fix from 3.3 files: .hgtouch | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.hgtouch b/.hgtouch --- a/.hgtouch +++ b/.hgtouch @@ -2,11 +2,11 @@ # Define dependencies of generated files that are checked into hg. # The syntax of this file uses make rule dependencies, without actions -Python/importlib.h: Lib/importlib/_bootstrap.py Python/freeze_importlib.py +Python/importlib.h: Lib/importlib/_bootstrap.py Modules/_freeze_importlib.c Include/ast.h: Parser/Python.asdl Parser/asdl.py Parser/asdl_c.py Python/Python-ast.c: Include/ast.h Python/opcode_targets.h: Python/makeopcodetargets.py Lib/opcode.py -Objects/typeslots.inc: Include/typeslots.h Objects/typeslots.py \ No newline at end of file +Objects/typeslots.inc: Include/typeslots.h Objects/typeslots.py -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 11:18:51 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 20 Jan 2013 11:18:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzQxNTM6IHVwZGF0?= =?utf-8?q?e_the_Unicode_howto=2E?= Message-ID: <3YpsLM1Zv2zP3q@mail.python.org> http://hg.python.org/cpython/rev/260a9afd999a changeset: 81610:260a9afd999a branch: 3.2 parent: 81596:930d9e8ecb66 user: Ezio Melotti date: Sun Jan 20 12:16:03 2013 +0200 summary: #4153: update the Unicode howto. files: Doc/howto/unicode.rst | 140 +++++++++++++++-------------- 1 files changed, 74 insertions(+), 66 deletions(-) diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -44,7 +44,7 @@ machines had different codes, however, which led to problems exchanging files. Eventually various commonly used sets of values for the 128--255 range emerged. Some were true standards, defined by the International Standards Organization, -and some were **de facto** conventions that were invented by one company or +and some were *de facto* conventions that were invented by one company or another and managed to catch on. 255 characters aren't very many. For example, you can't fit both the accented @@ -62,8 +62,8 @@ to represent many different characters from many different alphabets; an initial goal was to have Unicode contain the alphabets for every single human language. It turns out that even 16 bits isn't enough to meet that goal, and the modern -Unicode specification uses a wider range of codes, 0 through 1,114,111 (0x10ffff -in base 16). +Unicode specification uses a wider range of codes, 0 through 1,114,111 ( +``0x10FFFF`` in base 16). There's a related ISO standard, ISO 10646. Unicode and ISO 10646 were originally separate efforts, but the specifications were merged with the 1.1 @@ -87,9 +87,11 @@ The Unicode standard describes how characters are represented by **code points**. A code point is an integer value, usually denoted in base 16. In the -standard, a code point is written using the notation U+12ca to mean the -character with value 0x12ca (4,810 decimal). The Unicode standard contains a lot -of tables listing characters and their corresponding code points:: +standard, a code point is written using the notation ``U+12CA`` to mean the +character with value ``0x12ca`` (4,810 decimal). The Unicode standard contains +a lot of tables listing characters and their corresponding code points: + +.. code-block:: none 0061 'a'; LATIN SMALL LETTER A 0062 'b'; LATIN SMALL LETTER B @@ -98,7 +100,7 @@ 007B '{'; LEFT CURLY BRACKET Strictly, these definitions imply that it's meaningless to say 'this is -character U+12ca'. U+12ca is a code point, which represents some particular +character ``U+12CA``'. ``U+12CA`` is a code point, which represents some particular character; in this case, it represents the character 'ETHIOPIC SYLLABLE WI'. In informal contexts, this distinction between code points and characters will sometimes be forgotten. @@ -115,13 +117,15 @@ --------- To summarize the previous section: a Unicode string is a sequence of code -points, which are numbers from 0 through 0x10ffff (1,114,111 decimal). This +points, which are numbers from 0 through ``0x10FFFF`` (1,114,111 decimal). This sequence needs to be represented as a set of bytes (meaning, values from 0 through 255) in memory. The rules for translating a Unicode string into a sequence of bytes are called an **encoding**. The first encoding you might think of is an array of 32-bit integers. In this -representation, the string "Python" would look like this:: +representation, the string "Python" would look like this: + +.. code-block:: none P y t h o n 0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00 @@ -133,10 +137,10 @@ 1. It's not portable; different processors order the bytes differently. 2. It's very wasteful of space. In most texts, the majority of the code points - are less than 127, or less than 255, so a lot of space is occupied by zero + are less than 127, or less than 255, so a lot of space is occupied by ``0x00`` bytes. The above string takes 24 bytes compared to the 6 bytes needed for an ASCII representation. Increased RAM usage doesn't matter too much (desktop - computers have megabytes of RAM, and strings aren't usually that large), but + computers have gigabytes of RAM, and strings aren't usually that large), but expanding our usage of disk and network bandwidth by a factor of 4 is intolerable. @@ -175,14 +179,12 @@ UTF-8 is one of the most commonly used encodings. UTF stands for "Unicode Transformation Format", and the '8' means that 8-bit numbers are used in the -encoding. (There's also a UTF-16 encoding, but it's less frequently used than -UTF-8.) UTF-8 uses the following rules: +encoding. (There are also a UTF-16 and UTF-32 encodings, but they are less +frequently used than UTF-8.) UTF-8 uses the following rules: -1. If the code point is <128, it's represented by the corresponding byte value. -2. If the code point is between 128 and 0x7ff, it's turned into two byte values - between 128 and 255. -3. Code points >0x7ff are turned into three- or four-byte sequences, where each - byte of the sequence is between 128 and 255. +1. If the code point is < 128, it's represented by the corresponding byte value. +2. If the code point is >= 128, it's turned into a sequence of two, three, or + four bytes, where each byte of the sequence is between 128 and 255. UTF-8 has several convenient properties: @@ -192,8 +194,8 @@ processed by C functions such as ``strcpy()`` and sent through protocols that can't handle zero bytes. 3. A string of ASCII text is also valid UTF-8 text. -4. UTF-8 is fairly compact; the majority of code points are turned into two - bytes, and values less than 128 occupy only a single byte. +4. UTF-8 is fairly compact; the majority of commonly used characters can be + represented with one or two bytes. 5. If bytes are corrupted or lost, it's possible to determine the start of the next UTF-8-encoded code point and resynchronize. It's also unlikely that random 8-bit data will look like valid UTF-8. @@ -203,25 +205,25 @@ References ---------- -The Unicode Consortium site at has character charts, a +The `Unicode Consortium site `_ has character charts, a glossary, and PDF versions of the Unicode specification. Be prepared for some -difficult reading. is a chronology of the -origin and development of Unicode. +difficult reading. `A chronology `_ of the +origin and development of Unicode is also available on the site. -To help understand the standard, Jukka Korpela has written an introductory guide -to reading the Unicode character tables, available at -. +To help understand the standard, Jukka Korpela has written `an introductory +guide `_ to reading the +Unicode character tables. -Another good introductory article was written by Joel Spolsky -. +Another `good introductory article `_ +was written by Joel Spolsky. If this introduction didn't make things clear to you, you should try reading this alternate article before continuing. .. Jason Orendorff XXX http://www.jorendorff.com/articles/unicode/ is broken -Wikipedia entries are often helpful; see the entries for "character encoding" - and UTF-8 -, for example. +Wikipedia entries are often helpful; see the entries for "`character encoding +`_" and `UTF-8 +`_, for example. Python's Unicode Support @@ -233,11 +235,11 @@ The String Type --------------- -Since Python 3.0, the language features a ``str`` type that contain Unicode +Since Python 3.0, the language features a :class:`str` type that contain Unicode characters, meaning any string created using ``"unicode rocks!"``, ``'unicode rocks!'``, or the triple-quoted string syntax is stored as Unicode. -To insert a Unicode character that is not part ASCII, e.g., any letters with +To insert a non-ASCII Unicode character, e.g., any letters with accents, one can use escape sequences in their string literals as such:: >>> "\N{GREEK CAPITAL LETTER DELTA}" # Using the character name @@ -247,15 +249,16 @@ >>> "\U00000394" # Using a 32-bit hex value '\u0394' -In addition, one can create a string using the :func:`decode` method of -:class:`bytes`. This method takes an encoding, such as UTF-8, and, optionally, -an *errors* argument. +In addition, one can create a string using the :func:`~bytes.decode` method of +:class:`bytes`. This method takes an *encoding* argument, such as ``UTF-8``, +and optionally, an *errors* argument. The *errors* argument specifies the response when the input string can't be converted according to the encoding's rules. Legal values for this argument are -'strict' (raise a :exc:`UnicodeDecodeError` exception), 'replace' (use U+FFFD, -'REPLACEMENT CHARACTER'), or 'ignore' (just leave the character out of the -Unicode result). The following examples show the differences:: +``'strict'`` (raise a :exc:`UnicodeDecodeError` exception), ``'replace'`` (use +``U+FFFD``, ``REPLACEMENT CHARACTER``), or ``'ignore'`` (just leave the +character out of the Unicode result). +The following examples show the differences:: >>> b'\x80abc'.decode("utf-8", "strict") #doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): @@ -273,8 +276,8 @@ Encodings are specified as strings containing the encoding's name. Python 3.2 comes with roughly 100 different encodings; see the Python Library Reference at :ref:`standard-encodings` for a list. Some encodings have multiple names; for -example, 'latin-1', 'iso_8859_1' and '8859' are all synonyms for the same -encoding. +example, ``'latin-1'``, ``'iso_8859_1'`` and ``'8859``' are all synonyms for +the same encoding. One-character Unicode strings can also be created with the :func:`chr` built-in function, which takes integers and returns a Unicode string of length 1 @@ -290,13 +293,14 @@ Converting to Bytes ------------------- -Another important str method is ``.encode([encoding], [errors='strict'])``, -which returns a ``bytes`` representation of the Unicode string, encoded in the -requested encoding. The ``errors`` parameter is the same as the parameter of -the :meth:`decode` method, with one additional possibility; as well as 'strict', -'ignore', and 'replace' (which in this case inserts a question mark instead of -the unencodable character), you can also pass 'xmlcharrefreplace' which uses -XML's character references. The following example shows the different results:: +The opposite method of :meth:`bytes.decode` is :meth:`str.encode`, +which returns a :class:`bytes` representation of the Unicode string, encoded in the +requested *encoding*. The *errors* parameter is the same as the parameter of +the :meth:`~bytes.decode` method, with one additional possibility; as well as +``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a +question mark instead of the unencodable character), you can also pass +``'xmlcharrefreplace'`` which uses XML's character references. +The following example shows the different results:: >>> u = chr(40960) + 'abcd' + chr(1972) >>> u.encode('utf-8') @@ -313,6 +317,8 @@ >>> u.encode('ascii', 'xmlcharrefreplace') b'ꀀabcd޴' +.. XXX mention the surrogate* error handlers + The low-level routines for registering and accessing the available encodings are found in the :mod:`codecs` module. However, the encoding and decoding functions returned by this module are usually more low-level than is comfortable, so I'm @@ -365,14 +371,14 @@ ``coding: name`` or ``coding=name`` in the comment. If you don't include such a comment, the default encoding used will be UTF-8 as -already mentioned. +already mentioned. See also :pep:`263` for more information. Unicode Properties ------------------ The Unicode specification includes a database of information about code points. -For each code point that's defined, the information includes the character's +For each defined code point, the information includes the character's name, its category, the numeric value if applicable (Unicode has characters representing the Roman numerals and fractions such as one-third and four-fifths). There are also properties related to the code point's use in @@ -392,7 +398,9 @@ # Get numeric value of second character print(unicodedata.numeric(u[1])) -When run, this prints:: +When run, this prints: + +.. code-block:: none 0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE 1 0bf2 No TAMIL NUMBER ONE THOUSAND @@ -413,7 +421,7 @@ References ---------- -The ``str`` type is described in the Python library reference at +The :class:`str` type is described in the Python library reference at :ref:`typesseq`. The documentation for the :mod:`unicodedata` module. @@ -443,16 +451,16 @@ Unicode data is usually converted to a particular encoding before it gets written to disk or sent over a socket. It's possible to do all the work -yourself: open a file, read an 8-bit byte string from it, and convert the string -with ``str(bytes, encoding)``. However, the manual approach is not recommended. +yourself: open a file, read an 8-bit bytes object from it, and convert the string +with ``bytes.decode(encoding)``. However, the manual approach is not recommended. One problem is the multi-byte nature of encodings; one Unicode character can be represented by several bytes. If you want to read the file in arbitrary-sized -chunks (say, 1K or 4K), you need to write error-handling code to catch the case +chunks (say, 1k or 4k), you need to write error-handling code to catch the case where only part of the bytes encoding a single Unicode character are read at the end of a chunk. One solution would be to read the entire file into memory and then perform the decoding, but that prevents you from working with files that -are extremely large; if you need to read a 2Gb file, you need 2Gb of RAM. +are extremely large; if you need to read a 2GB file, you need 2GB of RAM. (More, really, since for at least a moment you'd need to have both the encoded string and its Unicode version in memory.) @@ -460,9 +468,9 @@ of partial coding sequences. The work of implementing this has already been done for you: the built-in :func:`open` function can return a file-like object that assumes the file's contents are in a specified encoding and accepts Unicode -parameters for methods such as ``.read()`` and ``.write()``. This works through +parameters for methods such as :meth:`read` and :meth:`write`. This works through :func:`open`\'s *encoding* and *errors* parameters which are interpreted just -like those in string objects' :meth:`encode` and :meth:`decode` methods. +like those in :meth:`str.encode` and :meth:`bytes.decode`. Reading Unicode from a file is therefore simple:: @@ -478,7 +486,7 @@ f.seek(0) print(repr(f.readline()[:1])) -The Unicode character U+FEFF is used as a byte-order mark (BOM), and is often +The Unicode character ``U+FEFF`` is used as a byte-order mark (BOM), and is often written as the first character of a file in order to assist with autodetection of the file's byte ordering. Some encodings, such as UTF-16, expect a BOM to be present at the start of a file; when such an encoding is used, the BOM will be @@ -520,12 +528,12 @@ filenames. Function :func:`os.listdir`, which returns filenames, raises an issue: should it return -the Unicode version of filenames, or should it return byte strings containing +the Unicode version of filenames, or should it return bytes containing the encoded versions? :func:`os.listdir` will do both, depending on whether you -provided the directory path as a byte string or a Unicode string. If you pass a +provided the directory path as bytes or a Unicode string. If you pass a Unicode string as the path, filenames will be decoded using the filesystem's encoding and a list of Unicode strings will be returned, while passing a byte -path will return the byte string versions of the filenames. For example, +path will return the bytes versions of the filenames. For example, assuming the default filesystem encoding is UTF-8, running the following program:: @@ -559,13 +567,13 @@ The most important tip is: - Software should only work with Unicode strings internally, converting to a - particular encoding on output. + Software should only work with Unicode strings internally, decoding the input + data as soon as possible and encoding the output only at the end. If you attempt to write processing functions that accept both Unicode and byte strings, you will find your program vulnerable to bugs wherever you combine the -two different kinds of strings. There is no automatic encoding or decoding if -you do e.g. ``str + bytes``, a :exc:`TypeError` is raised for this expression. +two different kinds of strings. There is no automatic encoding or decoding: if +you do e.g. ``str + bytes``, a :exc:`TypeError` will be raised. When using data coming from a web browser or some other untrusted source, a common technique is to check for illegal characters in a string before using the -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 11:18:53 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 20 Jan 2013 11:18:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=234153=3A_merge_with_3=2E2=2E?= Message-ID: <3YpsLP035WzR0q@mail.python.org> http://hg.python.org/cpython/rev/572ca3d35c2f changeset: 81611:572ca3d35c2f branch: 3.3 parent: 81608:366492014768 parent: 81610:260a9afd999a user: Ezio Melotti date: Sun Jan 20 12:18:17 2013 +0200 summary: #4153: merge with 3.2. files: Doc/howto/unicode.rst | 143 +++++++++++++++-------------- 1 files changed, 74 insertions(+), 69 deletions(-) diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -44,7 +44,7 @@ machines had different codes, however, which led to problems exchanging files. Eventually various commonly used sets of values for the 128--255 range emerged. Some were true standards, defined by the International Standards Organization, -and some were **de facto** conventions that were invented by one company or +and some were *de facto* conventions that were invented by one company or another and managed to catch on. 255 characters aren't very many. For example, you can't fit both the accented @@ -62,8 +62,8 @@ to represent many different characters from many different alphabets; an initial goal was to have Unicode contain the alphabets for every single human language. It turns out that even 16 bits isn't enough to meet that goal, and the modern -Unicode specification uses a wider range of codes, 0 through 1,114,111 (0x10ffff -in base 16). +Unicode specification uses a wider range of codes, 0 through 1,114,111 ( +``0x10FFFF`` in base 16). There's a related ISO standard, ISO 10646. Unicode and ISO 10646 were originally separate efforts, but the specifications were merged with the 1.1 @@ -87,9 +87,11 @@ The Unicode standard describes how characters are represented by **code points**. A code point is an integer value, usually denoted in base 16. In the -standard, a code point is written using the notation U+12ca to mean the -character with value 0x12ca (4,810 decimal). The Unicode standard contains a lot -of tables listing characters and their corresponding code points:: +standard, a code point is written using the notation ``U+12CA`` to mean the +character with value ``0x12ca`` (4,810 decimal). The Unicode standard contains +a lot of tables listing characters and their corresponding code points: + +.. code-block:: none 0061 'a'; LATIN SMALL LETTER A 0062 'b'; LATIN SMALL LETTER B @@ -98,7 +100,7 @@ 007B '{'; LEFT CURLY BRACKET Strictly, these definitions imply that it's meaningless to say 'this is -character U+12ca'. U+12ca is a code point, which represents some particular +character ``U+12CA``'. ``U+12CA`` is a code point, which represents some particular character; in this case, it represents the character 'ETHIOPIC SYLLABLE WI'. In informal contexts, this distinction between code points and characters will sometimes be forgotten. @@ -115,13 +117,15 @@ --------- To summarize the previous section: a Unicode string is a sequence of code -points, which are numbers from 0 through 0x10ffff (1,114,111 decimal). This +points, which are numbers from 0 through ``0x10FFFF`` (1,114,111 decimal). This sequence needs to be represented as a set of bytes (meaning, values from 0 through 255) in memory. The rules for translating a Unicode string into a sequence of bytes are called an **encoding**. The first encoding you might think of is an array of 32-bit integers. In this -representation, the string "Python" would look like this:: +representation, the string "Python" would look like this: + +.. code-block:: none P y t h o n 0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00 @@ -133,10 +137,10 @@ 1. It's not portable; different processors order the bytes differently. 2. It's very wasteful of space. In most texts, the majority of the code points - are less than 127, or less than 255, so a lot of space is occupied by zero + are less than 127, or less than 255, so a lot of space is occupied by ``0x00`` bytes. The above string takes 24 bytes compared to the 6 bytes needed for an ASCII representation. Increased RAM usage doesn't matter too much (desktop - computers have megabytes of RAM, and strings aren't usually that large), but + computers have gigabytes of RAM, and strings aren't usually that large), but expanding our usage of disk and network bandwidth by a factor of 4 is intolerable. @@ -175,14 +179,12 @@ UTF-8 is one of the most commonly used encodings. UTF stands for "Unicode Transformation Format", and the '8' means that 8-bit numbers are used in the -encoding. (There's also a UTF-16 encoding, but it's less frequently used than -UTF-8.) UTF-8 uses the following rules: +encoding. (There are also a UTF-16 and UTF-32 encodings, but they are less +frequently used than UTF-8.) UTF-8 uses the following rules: -1. If the code point is <128, it's represented by the corresponding byte value. -2. If the code point is between 128 and 0x7ff, it's turned into two byte values - between 128 and 255. -3. Code points >0x7ff are turned into three- or four-byte sequences, where each - byte of the sequence is between 128 and 255. +1. If the code point is < 128, it's represented by the corresponding byte value. +2. If the code point is >= 128, it's turned into a sequence of two, three, or + four bytes, where each byte of the sequence is between 128 and 255. UTF-8 has several convenient properties: @@ -192,8 +194,8 @@ processed by C functions such as ``strcpy()`` and sent through protocols that can't handle zero bytes. 3. A string of ASCII text is also valid UTF-8 text. -4. UTF-8 is fairly compact; the majority of code points are turned into two - bytes, and values less than 128 occupy only a single byte. +4. UTF-8 is fairly compact; the majority of commonly used characters can be + represented with one or two bytes. 5. If bytes are corrupted or lost, it's possible to determine the start of the next UTF-8-encoded code point and resynchronize. It's also unlikely that random 8-bit data will look like valid UTF-8. @@ -203,25 +205,25 @@ References ---------- -The Unicode Consortium site at has character charts, a +The `Unicode Consortium site `_ has character charts, a glossary, and PDF versions of the Unicode specification. Be prepared for some -difficult reading. is a chronology of the -origin and development of Unicode. +difficult reading. `A chronology `_ of the +origin and development of Unicode is also available on the site. -To help understand the standard, Jukka Korpela has written an introductory guide -to reading the Unicode character tables, available at -. +To help understand the standard, Jukka Korpela has written `an introductory +guide `_ to reading the +Unicode character tables. -Another good introductory article was written by Joel Spolsky -. +Another `good introductory article `_ +was written by Joel Spolsky. If this introduction didn't make things clear to you, you should try reading this alternate article before continuing. .. Jason Orendorff XXX http://www.jorendorff.com/articles/unicode/ is broken -Wikipedia entries are often helpful; see the entries for "character encoding" - and UTF-8 -, for example. +Wikipedia entries are often helpful; see the entries for "`character encoding +`_" and `UTF-8 +`_, for example. Python's Unicode Support @@ -233,11 +235,11 @@ The String Type --------------- -Since Python 3.0, the language features a ``str`` type that contain Unicode +Since Python 3.0, the language features a :class:`str` type that contain Unicode characters, meaning any string created using ``"unicode rocks!"``, ``'unicode rocks!'``, or the triple-quoted string syntax is stored as Unicode. -To insert a Unicode character that is not part ASCII, e.g., any letters with +To insert a non-ASCII Unicode character, e.g., any letters with accents, one can use escape sequences in their string literals as such:: >>> "\N{GREEK CAPITAL LETTER DELTA}" # Using the character name @@ -247,15 +249,16 @@ >>> "\U00000394" # Using a 32-bit hex value '\u0394' -In addition, one can create a string using the :func:`decode` method of -:class:`bytes`. This method takes an encoding, such as UTF-8, and, optionally, -an *errors* argument. +In addition, one can create a string using the :func:`~bytes.decode` method of +:class:`bytes`. This method takes an *encoding* argument, such as ``UTF-8``, +and optionally, an *errors* argument. The *errors* argument specifies the response when the input string can't be converted according to the encoding's rules. Legal values for this argument are -'strict' (raise a :exc:`UnicodeDecodeError` exception), 'replace' (use U+FFFD, -'REPLACEMENT CHARACTER'), or 'ignore' (just leave the character out of the -Unicode result). The following examples show the differences:: +``'strict'`` (raise a :exc:`UnicodeDecodeError` exception), ``'replace'`` (use +``U+FFFD``, ``REPLACEMENT CHARACTER``), or ``'ignore'`` (just leave the +character out of the Unicode result). +The following examples show the differences:: >>> b'\x80abc'.decode("utf-8", "strict") #doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): @@ -273,8 +276,8 @@ Encodings are specified as strings containing the encoding's name. Python 3.2 comes with roughly 100 different encodings; see the Python Library Reference at :ref:`standard-encodings` for a list. Some encodings have multiple names; for -example, 'latin-1', 'iso_8859_1' and '8859' are all synonyms for the same -encoding. +example, ``'latin-1'``, ``'iso_8859_1'`` and ``'8859``' are all synonyms for +the same encoding. One-character Unicode strings can also be created with the :func:`chr` built-in function, which takes integers and returns a Unicode string of length 1 @@ -290,13 +293,14 @@ Converting to Bytes ------------------- -Another important str method is ``.encode([encoding], [errors='strict'])``, -which returns a ``bytes`` representation of the Unicode string, encoded in the -requested encoding. The ``errors`` parameter is the same as the parameter of -the :meth:`decode` method, with one additional possibility; as well as 'strict', -'ignore', and 'replace' (which in this case inserts a question mark instead of -the unencodable character), you can also pass 'xmlcharrefreplace' which uses -XML's character references. The following example shows the different results:: +The opposite method of :meth:`bytes.decode` is :meth:`str.encode`, +which returns a :class:`bytes` representation of the Unicode string, encoded in the +requested *encoding*. The *errors* parameter is the same as the parameter of +the :meth:`~bytes.decode` method, with one additional possibility; as well as +``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a +question mark instead of the unencodable character), you can also pass +``'xmlcharrefreplace'`` which uses XML's character references. +The following example shows the different results:: >>> u = chr(40960) + 'abcd' + chr(1972) >>> u.encode('utf-8') @@ -313,6 +317,8 @@ >>> u.encode('ascii', 'xmlcharrefreplace') b'ꀀabcd޴' +.. XXX mention the surrogate* error handlers + The low-level routines for registering and accessing the available encodings are found in the :mod:`codecs` module. However, the encoding and decoding functions returned by this module are usually more low-level than is comfortable, so I'm @@ -365,14 +371,14 @@ ``coding: name`` or ``coding=name`` in the comment. If you don't include such a comment, the default encoding used will be UTF-8 as -already mentioned. +already mentioned. See also :pep:`263` for more information. Unicode Properties ------------------ The Unicode specification includes a database of information about code points. -For each code point that's defined, the information includes the character's +For each defined code point, the information includes the character's name, its category, the numeric value if applicable (Unicode has characters representing the Roman numerals and fractions such as one-third and four-fifths). There are also properties related to the code point's use in @@ -392,7 +398,9 @@ # Get numeric value of second character print(unicodedata.numeric(u[1])) -When run, this prints:: +When run, this prints: + +.. code-block:: none 0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE 1 0bf2 No TAMIL NUMBER ONE THOUSAND @@ -413,7 +421,7 @@ References ---------- -The ``str`` type is described in the Python library reference at +The :class:`str` type is described in the Python library reference at :ref:`textseq`. The documentation for the :mod:`unicodedata` module. @@ -443,16 +451,16 @@ Unicode data is usually converted to a particular encoding before it gets written to disk or sent over a socket. It's possible to do all the work -yourself: open a file, read an 8-bit byte string from it, and convert the string -with ``str(bytes, encoding)``. However, the manual approach is not recommended. +yourself: open a file, read an 8-bit bytes object from it, and convert the string +with ``bytes.decode(encoding)``. However, the manual approach is not recommended. One problem is the multi-byte nature of encodings; one Unicode character can be represented by several bytes. If you want to read the file in arbitrary-sized -chunks (say, 1K or 4K), you need to write error-handling code to catch the case +chunks (say, 1k or 4k), you need to write error-handling code to catch the case where only part of the bytes encoding a single Unicode character are read at the end of a chunk. One solution would be to read the entire file into memory and then perform the decoding, but that prevents you from working with files that -are extremely large; if you need to read a 2Gb file, you need 2Gb of RAM. +are extremely large; if you need to read a 2GB file, you need 2GB of RAM. (More, really, since for at least a moment you'd need to have both the encoded string and its Unicode version in memory.) @@ -460,9 +468,9 @@ of partial coding sequences. The work of implementing this has already been done for you: the built-in :func:`open` function can return a file-like object that assumes the file's contents are in a specified encoding and accepts Unicode -parameters for methods such as ``.read()`` and ``.write()``. This works through +parameters for methods such as :meth:`read` and :meth:`write`. This works through :func:`open`\'s *encoding* and *errors* parameters which are interpreted just -like those in string objects' :meth:`encode` and :meth:`decode` methods. +like those in :meth:`str.encode` and :meth:`bytes.decode`. Reading Unicode from a file is therefore simple:: @@ -478,7 +486,7 @@ f.seek(0) print(repr(f.readline()[:1])) -The Unicode character U+FEFF is used as a byte-order mark (BOM), and is often +The Unicode character ``U+FEFF`` is used as a byte-order mark (BOM), and is often written as the first character of a file in order to assist with autodetection of the file's byte ordering. Some encodings, such as UTF-16, expect a BOM to be present at the start of a file; when such an encoding is used, the BOM will be @@ -520,12 +528,12 @@ filenames. Function :func:`os.listdir`, which returns filenames, raises an issue: should it return -the Unicode version of filenames, or should it return byte strings containing +the Unicode version of filenames, or should it return bytes containing the encoded versions? :func:`os.listdir` will do both, depending on whether you -provided the directory path as a byte string or a Unicode string. If you pass a +provided the directory path as bytes or a Unicode string. If you pass a Unicode string as the path, filenames will be decoded using the filesystem's encoding and a list of Unicode strings will be returned, while passing a byte -path will return the byte string versions of the filenames. For example, +path will return the bytes versions of the filenames. For example, assuming the default filesystem encoding is UTF-8, running the following program:: @@ -559,13 +567,13 @@ The most important tip is: - Software should only work with Unicode strings internally, converting to a - particular encoding on output. + Software should only work with Unicode strings internally, decoding the input + data as soon as possible and encoding the output only at the end. If you attempt to write processing functions that accept both Unicode and byte strings, you will find your program vulnerable to bugs wherever you combine the -two different kinds of strings. There is no automatic encoding or decoding if -you do e.g. ``str + bytes``, a :exc:`TypeError` is raised for this expression. +two different kinds of strings. There is no automatic encoding or decoding: if +you do e.g. ``str + bytes``, a :exc:`TypeError` will be raised. When using data coming from a web browser or some other untrusted source, a common technique is to check for illegal characters in a string before using the @@ -610,7 +618,6 @@ and that the HOWTO only covers 2.x. .. comment Describe Python 3.x support (new section? new document?) -.. comment Additional topic: building Python w/ UCS2 or UCS4 support .. comment Describe use of codecs.StreamRecoder and StreamReaderWriter .. comment @@ -640,5 +647,3 @@ - [ ] Writing Unicode programs - [ ] Do everything in Unicode - [ ] Declaring source code encodings (PEP 263) - - [ ] Other issues - - [ ] Building Python (UCS2, UCS4) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 11:18:54 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 20 Jan 2013 11:18:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzQxNTM6IG1lcmdlIHdpdGggMy4zLg==?= Message-ID: <3YpsLQ5C0zzSMS@mail.python.org> http://hg.python.org/cpython/rev/034e1e076c77 changeset: 81612:034e1e076c77 parent: 81609:a127165f5546 parent: 81611:572ca3d35c2f user: Ezio Melotti date: Sun Jan 20 12:18:34 2013 +0200 summary: #4153: merge with 3.3. files: Doc/howto/unicode.rst | 143 +++++++++++++++-------------- 1 files changed, 74 insertions(+), 69 deletions(-) diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -44,7 +44,7 @@ machines had different codes, however, which led to problems exchanging files. Eventually various commonly used sets of values for the 128--255 range emerged. Some were true standards, defined by the International Standards Organization, -and some were **de facto** conventions that were invented by one company or +and some were *de facto* conventions that were invented by one company or another and managed to catch on. 255 characters aren't very many. For example, you can't fit both the accented @@ -62,8 +62,8 @@ to represent many different characters from many different alphabets; an initial goal was to have Unicode contain the alphabets for every single human language. It turns out that even 16 bits isn't enough to meet that goal, and the modern -Unicode specification uses a wider range of codes, 0 through 1,114,111 (0x10ffff -in base 16). +Unicode specification uses a wider range of codes, 0 through 1,114,111 ( +``0x10FFFF`` in base 16). There's a related ISO standard, ISO 10646. Unicode and ISO 10646 were originally separate efforts, but the specifications were merged with the 1.1 @@ -87,9 +87,11 @@ The Unicode standard describes how characters are represented by **code points**. A code point is an integer value, usually denoted in base 16. In the -standard, a code point is written using the notation U+12ca to mean the -character with value 0x12ca (4,810 decimal). The Unicode standard contains a lot -of tables listing characters and their corresponding code points:: +standard, a code point is written using the notation ``U+12CA`` to mean the +character with value ``0x12ca`` (4,810 decimal). The Unicode standard contains +a lot of tables listing characters and their corresponding code points: + +.. code-block:: none 0061 'a'; LATIN SMALL LETTER A 0062 'b'; LATIN SMALL LETTER B @@ -98,7 +100,7 @@ 007B '{'; LEFT CURLY BRACKET Strictly, these definitions imply that it's meaningless to say 'this is -character U+12ca'. U+12ca is a code point, which represents some particular +character ``U+12CA``'. ``U+12CA`` is a code point, which represents some particular character; in this case, it represents the character 'ETHIOPIC SYLLABLE WI'. In informal contexts, this distinction between code points and characters will sometimes be forgotten. @@ -115,13 +117,15 @@ --------- To summarize the previous section: a Unicode string is a sequence of code -points, which are numbers from 0 through 0x10ffff (1,114,111 decimal). This +points, which are numbers from 0 through ``0x10FFFF`` (1,114,111 decimal). This sequence needs to be represented as a set of bytes (meaning, values from 0 through 255) in memory. The rules for translating a Unicode string into a sequence of bytes are called an **encoding**. The first encoding you might think of is an array of 32-bit integers. In this -representation, the string "Python" would look like this:: +representation, the string "Python" would look like this: + +.. code-block:: none P y t h o n 0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00 @@ -133,10 +137,10 @@ 1. It's not portable; different processors order the bytes differently. 2. It's very wasteful of space. In most texts, the majority of the code points - are less than 127, or less than 255, so a lot of space is occupied by zero + are less than 127, or less than 255, so a lot of space is occupied by ``0x00`` bytes. The above string takes 24 bytes compared to the 6 bytes needed for an ASCII representation. Increased RAM usage doesn't matter too much (desktop - computers have megabytes of RAM, and strings aren't usually that large), but + computers have gigabytes of RAM, and strings aren't usually that large), but expanding our usage of disk and network bandwidth by a factor of 4 is intolerable. @@ -175,14 +179,12 @@ UTF-8 is one of the most commonly used encodings. UTF stands for "Unicode Transformation Format", and the '8' means that 8-bit numbers are used in the -encoding. (There's also a UTF-16 encoding, but it's less frequently used than -UTF-8.) UTF-8 uses the following rules: +encoding. (There are also a UTF-16 and UTF-32 encodings, but they are less +frequently used than UTF-8.) UTF-8 uses the following rules: -1. If the code point is <128, it's represented by the corresponding byte value. -2. If the code point is between 128 and 0x7ff, it's turned into two byte values - between 128 and 255. -3. Code points >0x7ff are turned into three- or four-byte sequences, where each - byte of the sequence is between 128 and 255. +1. If the code point is < 128, it's represented by the corresponding byte value. +2. If the code point is >= 128, it's turned into a sequence of two, three, or + four bytes, where each byte of the sequence is between 128 and 255. UTF-8 has several convenient properties: @@ -192,8 +194,8 @@ processed by C functions such as ``strcpy()`` and sent through protocols that can't handle zero bytes. 3. A string of ASCII text is also valid UTF-8 text. -4. UTF-8 is fairly compact; the majority of code points are turned into two - bytes, and values less than 128 occupy only a single byte. +4. UTF-8 is fairly compact; the majority of commonly used characters can be + represented with one or two bytes. 5. If bytes are corrupted or lost, it's possible to determine the start of the next UTF-8-encoded code point and resynchronize. It's also unlikely that random 8-bit data will look like valid UTF-8. @@ -203,25 +205,25 @@ References ---------- -The Unicode Consortium site at has character charts, a +The `Unicode Consortium site `_ has character charts, a glossary, and PDF versions of the Unicode specification. Be prepared for some -difficult reading. is a chronology of the -origin and development of Unicode. +difficult reading. `A chronology `_ of the +origin and development of Unicode is also available on the site. -To help understand the standard, Jukka Korpela has written an introductory guide -to reading the Unicode character tables, available at -. +To help understand the standard, Jukka Korpela has written `an introductory +guide `_ to reading the +Unicode character tables. -Another good introductory article was written by Joel Spolsky -. +Another `good introductory article `_ +was written by Joel Spolsky. If this introduction didn't make things clear to you, you should try reading this alternate article before continuing. .. Jason Orendorff XXX http://www.jorendorff.com/articles/unicode/ is broken -Wikipedia entries are often helpful; see the entries for "character encoding" - and UTF-8 -, for example. +Wikipedia entries are often helpful; see the entries for "`character encoding +`_" and `UTF-8 +`_, for example. Python's Unicode Support @@ -233,11 +235,11 @@ The String Type --------------- -Since Python 3.0, the language features a ``str`` type that contain Unicode +Since Python 3.0, the language features a :class:`str` type that contain Unicode characters, meaning any string created using ``"unicode rocks!"``, ``'unicode rocks!'``, or the triple-quoted string syntax is stored as Unicode. -To insert a Unicode character that is not part ASCII, e.g., any letters with +To insert a non-ASCII Unicode character, e.g., any letters with accents, one can use escape sequences in their string literals as such:: >>> "\N{GREEK CAPITAL LETTER DELTA}" # Using the character name @@ -247,15 +249,16 @@ >>> "\U00000394" # Using a 32-bit hex value '\u0394' -In addition, one can create a string using the :func:`decode` method of -:class:`bytes`. This method takes an encoding, such as UTF-8, and, optionally, -an *errors* argument. +In addition, one can create a string using the :func:`~bytes.decode` method of +:class:`bytes`. This method takes an *encoding* argument, such as ``UTF-8``, +and optionally, an *errors* argument. The *errors* argument specifies the response when the input string can't be converted according to the encoding's rules. Legal values for this argument are -'strict' (raise a :exc:`UnicodeDecodeError` exception), 'replace' (use U+FFFD, -'REPLACEMENT CHARACTER'), or 'ignore' (just leave the character out of the -Unicode result). The following examples show the differences:: +``'strict'`` (raise a :exc:`UnicodeDecodeError` exception), ``'replace'`` (use +``U+FFFD``, ``REPLACEMENT CHARACTER``), or ``'ignore'`` (just leave the +character out of the Unicode result). +The following examples show the differences:: >>> b'\x80abc'.decode("utf-8", "strict") #doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): @@ -273,8 +276,8 @@ Encodings are specified as strings containing the encoding's name. Python 3.2 comes with roughly 100 different encodings; see the Python Library Reference at :ref:`standard-encodings` for a list. Some encodings have multiple names; for -example, 'latin-1', 'iso_8859_1' and '8859' are all synonyms for the same -encoding. +example, ``'latin-1'``, ``'iso_8859_1'`` and ``'8859``' are all synonyms for +the same encoding. One-character Unicode strings can also be created with the :func:`chr` built-in function, which takes integers and returns a Unicode string of length 1 @@ -290,13 +293,14 @@ Converting to Bytes ------------------- -Another important str method is ``.encode([encoding], [errors='strict'])``, -which returns a ``bytes`` representation of the Unicode string, encoded in the -requested encoding. The ``errors`` parameter is the same as the parameter of -the :meth:`decode` method, with one additional possibility; as well as 'strict', -'ignore', and 'replace' (which in this case inserts a question mark instead of -the unencodable character), you can also pass 'xmlcharrefreplace' which uses -XML's character references. The following example shows the different results:: +The opposite method of :meth:`bytes.decode` is :meth:`str.encode`, +which returns a :class:`bytes` representation of the Unicode string, encoded in the +requested *encoding*. The *errors* parameter is the same as the parameter of +the :meth:`~bytes.decode` method, with one additional possibility; as well as +``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a +question mark instead of the unencodable character), you can also pass +``'xmlcharrefreplace'`` which uses XML's character references. +The following example shows the different results:: >>> u = chr(40960) + 'abcd' + chr(1972) >>> u.encode('utf-8') @@ -313,6 +317,8 @@ >>> u.encode('ascii', 'xmlcharrefreplace') b'ꀀabcd޴' +.. XXX mention the surrogate* error handlers + The low-level routines for registering and accessing the available encodings are found in the :mod:`codecs` module. However, the encoding and decoding functions returned by this module are usually more low-level than is comfortable, so I'm @@ -365,14 +371,14 @@ ``coding: name`` or ``coding=name`` in the comment. If you don't include such a comment, the default encoding used will be UTF-8 as -already mentioned. +already mentioned. See also :pep:`263` for more information. Unicode Properties ------------------ The Unicode specification includes a database of information about code points. -For each code point that's defined, the information includes the character's +For each defined code point, the information includes the character's name, its category, the numeric value if applicable (Unicode has characters representing the Roman numerals and fractions such as one-third and four-fifths). There are also properties related to the code point's use in @@ -392,7 +398,9 @@ # Get numeric value of second character print(unicodedata.numeric(u[1])) -When run, this prints:: +When run, this prints: + +.. code-block:: none 0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE 1 0bf2 No TAMIL NUMBER ONE THOUSAND @@ -413,7 +421,7 @@ References ---------- -The ``str`` type is described in the Python library reference at +The :class:`str` type is described in the Python library reference at :ref:`textseq`. The documentation for the :mod:`unicodedata` module. @@ -443,16 +451,16 @@ Unicode data is usually converted to a particular encoding before it gets written to disk or sent over a socket. It's possible to do all the work -yourself: open a file, read an 8-bit byte string from it, and convert the string -with ``str(bytes, encoding)``. However, the manual approach is not recommended. +yourself: open a file, read an 8-bit bytes object from it, and convert the string +with ``bytes.decode(encoding)``. However, the manual approach is not recommended. One problem is the multi-byte nature of encodings; one Unicode character can be represented by several bytes. If you want to read the file in arbitrary-sized -chunks (say, 1K or 4K), you need to write error-handling code to catch the case +chunks (say, 1k or 4k), you need to write error-handling code to catch the case where only part of the bytes encoding a single Unicode character are read at the end of a chunk. One solution would be to read the entire file into memory and then perform the decoding, but that prevents you from working with files that -are extremely large; if you need to read a 2Gb file, you need 2Gb of RAM. +are extremely large; if you need to read a 2GB file, you need 2GB of RAM. (More, really, since for at least a moment you'd need to have both the encoded string and its Unicode version in memory.) @@ -460,9 +468,9 @@ of partial coding sequences. The work of implementing this has already been done for you: the built-in :func:`open` function can return a file-like object that assumes the file's contents are in a specified encoding and accepts Unicode -parameters for methods such as ``.read()`` and ``.write()``. This works through +parameters for methods such as :meth:`read` and :meth:`write`. This works through :func:`open`\'s *encoding* and *errors* parameters which are interpreted just -like those in string objects' :meth:`encode` and :meth:`decode` methods. +like those in :meth:`str.encode` and :meth:`bytes.decode`. Reading Unicode from a file is therefore simple:: @@ -478,7 +486,7 @@ f.seek(0) print(repr(f.readline()[:1])) -The Unicode character U+FEFF is used as a byte-order mark (BOM), and is often +The Unicode character ``U+FEFF`` is used as a byte-order mark (BOM), and is often written as the first character of a file in order to assist with autodetection of the file's byte ordering. Some encodings, such as UTF-16, expect a BOM to be present at the start of a file; when such an encoding is used, the BOM will be @@ -520,12 +528,12 @@ filenames. Function :func:`os.listdir`, which returns filenames, raises an issue: should it return -the Unicode version of filenames, or should it return byte strings containing +the Unicode version of filenames, or should it return bytes containing the encoded versions? :func:`os.listdir` will do both, depending on whether you -provided the directory path as a byte string or a Unicode string. If you pass a +provided the directory path as bytes or a Unicode string. If you pass a Unicode string as the path, filenames will be decoded using the filesystem's encoding and a list of Unicode strings will be returned, while passing a byte -path will return the byte string versions of the filenames. For example, +path will return the bytes versions of the filenames. For example, assuming the default filesystem encoding is UTF-8, running the following program:: @@ -559,13 +567,13 @@ The most important tip is: - Software should only work with Unicode strings internally, converting to a - particular encoding on output. + Software should only work with Unicode strings internally, decoding the input + data as soon as possible and encoding the output only at the end. If you attempt to write processing functions that accept both Unicode and byte strings, you will find your program vulnerable to bugs wherever you combine the -two different kinds of strings. There is no automatic encoding or decoding if -you do e.g. ``str + bytes``, a :exc:`TypeError` is raised for this expression. +two different kinds of strings. There is no automatic encoding or decoding: if +you do e.g. ``str + bytes``, a :exc:`TypeError` will be raised. When using data coming from a web browser or some other untrusted source, a common technique is to check for illegal characters in a string before using the @@ -610,7 +618,6 @@ and that the HOWTO only covers 2.x. .. comment Describe Python 3.x support (new section? new document?) -.. comment Additional topic: building Python w/ UCS2 or UCS4 support .. comment Describe use of codecs.StreamRecoder and StreamReaderWriter .. comment @@ -640,5 +647,3 @@ - [ ] Writing Unicode programs - [ ] Do everything in Unicode - [ ] Declaring source code encodings (PEP 263) - - [ ] Other issues - - [ ] Building Python (UCS2, UCS4) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 11:31:01 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 20 Jan 2013 11:31:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_Document_the_code-block_d?= =?utf-8?q?irective=2E?= Message-ID: <3YpscP4SbhzS5g@mail.python.org> http://hg.python.org/devguide/rev/3628a1aed4cd changeset: 591:3628a1aed4cd user: Ezio Melotti date: Sun Jan 20 12:30:46 2013 +0200 summary: Document the code-block directive. files: documenting.rst | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/documenting.rst b/documenting.rst --- a/documenting.rst +++ b/documenting.rst @@ -825,6 +825,17 @@ This language is used until the next ``highlightlang`` directive is encountered. +* The ``code-block`` directive can be used to specify the highlight language + of a single code block, e.g.:: + + .. code-block:: c + + #include + + void main() { + printf("Hello world!\n"); + } + * The values normally used for the highlighting language are: * ``python`` (the default) -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Sun Jan 20 15:35:25 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 20 Jan 2013 15:35:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogIzE2NTU3OiB1cGRh?= =?utf-8?q?te_functional_howto_--_=22return_value=22_is_valid_after_PEP_38?= =?utf-8?q?0=2E?= Message-ID: <3Ypz2P3crCzS9C@mail.python.org> http://hg.python.org/cpython/rev/e0de6e6e992e changeset: 81613:e0de6e6e992e branch: 3.3 parent: 81611:572ca3d35c2f user: Ezio Melotti date: Sun Jan 20 16:34:21 2013 +0200 summary: #16557: update functional howto -- "return value" is valid after PEP 380. Initial patch by Ramchandra Apte. files: Doc/howto/functional.rst | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -479,13 +479,10 @@ You could equally write ``for i in generate_ints(5)``, or ``a,b,c = generate_ints(3)``. -Inside a generator function, the ``return`` statement can only be used without a -value, and signals the end of the procession of values; after executing a -``return`` the generator cannot return any further values. ``return`` with a -value, such as ``return 5``, is a syntax error inside a generator function. The -end of the generator's results can also be indicated by raising -:exc:`StopIteration` manually, or by just letting the flow of execution fall off -the bottom of the function. +Inside a generator function, ``return value`` is semantically equivalent to +``raise StopIteration(value)``. If no value is returned or the bottom of the +function is reached, the procession of values ends and the generator cannot +return any further values. You could achieve the effect of generators manually by writing your own class and storing all the local variables of the generator as instance variables. For -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 15:35:26 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 20 Jan 2013 15:35:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzE2NTU3OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3Ypz2Q6T9TzSJq@mail.python.org> http://hg.python.org/cpython/rev/81b2a30da853 changeset: 81614:81b2a30da853 parent: 81612:034e1e076c77 parent: 81613:e0de6e6e992e user: Ezio Melotti date: Sun Jan 20 16:35:09 2013 +0200 summary: #16557: merge with 3.3. files: Doc/howto/functional.rst | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -479,13 +479,10 @@ You could equally write ``for i in generate_ints(5)``, or ``a,b,c = generate_ints(3)``. -Inside a generator function, the ``return`` statement can only be used without a -value, and signals the end of the procession of values; after executing a -``return`` the generator cannot return any further values. ``return`` with a -value, such as ``return 5``, is a syntax error inside a generator function. The -end of the generator's results can also be indicated by raising -:exc:`StopIteration` manually, or by just letting the flow of execution fall off -the bottom of the function. +Inside a generator function, ``return value`` is semantically equivalent to +``raise StopIteration(value)``. If no value is returned or the bottom of the +function is reached, the procession of values ends and the generator cannot +return any further values. You could achieve the effect of generators manually by writing your own class and storing all the local variables of the generator as instance variables. For -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 16:05:35 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 20 Jan 2013 16:05:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_expressions_-?= =?utf-8?q?=3E_arguments?= Message-ID: <3YpzjC11J2zSC0@mail.python.org> http://hg.python.org/cpython/rev/add66b51b890 changeset: 81615:add66b51b890 branch: 3.3 parent: 81613:e0de6e6e992e user: Benjamin Peterson date: Sun Jan 20 10:05:13 2013 -0500 summary: expressions -> arguments files: Doc/tutorial/introduction.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -600,12 +600,12 @@ guess when you have typed the last line). Note that each line within a basic block must be indented by the same amount. -* The :func:`print` function writes the value of the expression(s) it is - given. It differs from just writing the expression you want to write (as we did - earlier in the calculator examples) in the way it handles multiple - expressions, floating point quantities, - and strings. Strings are printed without quotes, and a space is inserted - between items, so you can format things nicely, like this:: +* The :func:`print` function writes the value of the argument(s) it is given. + It differs from just writing the expression you want to write (as we did + earlier in the calculator examples) in the way it handles multiple arguments, + floating point quantities, and strings. Strings are printed without quotes, + and a space is inserted between items, so you can format things nicely, like + this:: >>> i = 256*256 >>> print('The value of i is', i) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 16:05:36 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 20 Jan 2013 16:05:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3YpzjD3dnKzSC0@mail.python.org> http://hg.python.org/cpython/rev/75b9e1a6b7f5 changeset: 81616:75b9e1a6b7f5 parent: 81614:81b2a30da853 parent: 81615:add66b51b890 user: Benjamin Peterson date: Sun Jan 20 10:05:28 2013 -0500 summary: merge 3.3 files: Doc/tutorial/introduction.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -600,12 +600,12 @@ guess when you have typed the last line). Note that each line within a basic block must be indented by the same amount. -* The :func:`print` function writes the value of the expression(s) it is - given. It differs from just writing the expression you want to write (as we did - earlier in the calculator examples) in the way it handles multiple - expressions, floating point quantities, - and strings. Strings are printed without quotes, and a space is inserted - between items, so you can format things nicely, like this:: +* The :func:`print` function writes the value of the argument(s) it is given. + It differs from just writing the expression you want to write (as we did + earlier in the calculator examples) in the way it handles multiple arguments, + floating point quantities, and strings. Strings are printed without quotes, + and a space is inserted between items, so you can format things nicely, like + this:: >>> i = 256*256 >>> print('The value of i is', i) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 16:09:57 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 20 Jan 2013 16:09:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_end_is_a_keywo?= =?utf-8?q?rd_argument?= Message-ID: <3YpzpF4lwQzSCN@mail.python.org> http://hg.python.org/cpython/rev/66a22b6a3414 changeset: 81617:66a22b6a3414 branch: 3.3 parent: 81615:add66b51b890 user: Benjamin Peterson date: Sun Jan 20 10:09:44 2013 -0500 summary: end is a keyword argument files: Doc/tutorial/introduction.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -611,8 +611,8 @@ >>> print('The value of i is', i) The value of i is 65536 - The keyword *end* can be used to avoid the newline after the output, or end - the output with a different string:: + The keyword argument *end* can be used to avoid the newline after the output, + or end the output with a different string:: >>> a, b = 0, 1 >>> while b < 1000: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 16:09:59 2013 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 20 Jan 2013 16:09:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4z?= Message-ID: <3YpzpH0ZKNzM2P@mail.python.org> http://hg.python.org/cpython/rev/e18dd62392f2 changeset: 81618:e18dd62392f2 parent: 81616:75b9e1a6b7f5 parent: 81617:66a22b6a3414 user: Benjamin Peterson date: Sun Jan 20 10:09:51 2013 -0500 summary: merge 3.3 files: Doc/tutorial/introduction.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -611,8 +611,8 @@ >>> print('The value of i is', i) The value of i is 65536 - The keyword *end* can be used to avoid the newline after the output, or end - the output with a different string:: + The keyword argument *end* can be used to avoid the newline after the output, + or end the output with a different string:: >>> a, b = 0, 1 >>> while b < 1000: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 23:31:08 2013 From: python-checkins at python.org (stefan.krah) Date: Sun, 20 Jan 2013 23:31:08 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzczNTM6?= =?utf-8?q?_Remove_references_to_Include/intobject=2Eh_in_the_C-porting_ho?= =?utf-8?q?wto=2E?= Message-ID: <3Yq9bJ2Cq8zR26@mail.python.org> http://hg.python.org/cpython/rev/6df456f8fc6d changeset: 81619:6df456f8fc6d branch: 3.3 parent: 81617:66a22b6a3414 user: Stefan Krah date: Sun Jan 20 23:18:00 2013 +0100 summary: Issue #7353: Remove references to Include/intobject.h in the C-porting howto. files: Doc/howto/cporting.rst | 19 ------------------- 1 files changed, 0 insertions(+), 19 deletions(-) diff --git a/Doc/howto/cporting.rst b/Doc/howto/cporting.rst --- a/Doc/howto/cporting.rst +++ b/Doc/howto/cporting.rst @@ -100,25 +100,6 @@ used in Python 2 was removed. In the C-API, ``PyInt_*`` functions are replaced by their ``PyLong_*`` equivalents. -The best course of action here is using the ``PyInt_*`` functions aliased to -``PyLong_*`` found in :file:`intobject.h`. The abstract ``PyNumber_*`` APIs -can also be used in some cases. :: - - #include "Python.h" - #include "intobject.h" - - static PyObject * - add_ints(PyObject *self, PyObject *args) { - int one, two; - PyObject *result; - - if (!PyArg_ParseTuple(args, "ii:add_ints", &one, &two)) - return NULL; - - return PyInt_FromLong(one + two); - } - - Module initialization and state =============================== -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 23:31:09 2013 From: python-checkins at python.org (stefan.krah) Date: Sun, 20 Jan 2013 23:31:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3Yq9bK4rkRzSDH@mail.python.org> http://hg.python.org/cpython/rev/575eb20cd7d1 changeset: 81620:575eb20cd7d1 parent: 81618:e18dd62392f2 parent: 81619:6df456f8fc6d user: Stefan Krah date: Sun Jan 20 23:19:22 2013 +0100 summary: Merge 3.3. files: Doc/howto/cporting.rst | 19 ------------------- 1 files changed, 0 insertions(+), 19 deletions(-) diff --git a/Doc/howto/cporting.rst b/Doc/howto/cporting.rst --- a/Doc/howto/cporting.rst +++ b/Doc/howto/cporting.rst @@ -100,25 +100,6 @@ used in Python 2 was removed. In the C-API, ``PyInt_*`` functions are replaced by their ``PyLong_*`` equivalents. -The best course of action here is using the ``PyInt_*`` functions aliased to -``PyLong_*`` found in :file:`intobject.h`. The abstract ``PyNumber_*`` APIs -can also be used in some cases. :: - - #include "Python.h" - #include "intobject.h" - - static PyObject * - add_ints(PyObject *self, PyObject *args) { - int one, two; - PyObject *result; - - if (!PyArg_ParseTuple(args, "ii:add_ints", &one, &two)) - return NULL; - - return PyInt_FromLong(one + two); - } - - Module initialization and state =============================== -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 20 23:31:11 2013 From: python-checkins at python.org (stefan.krah) Date: Sun, 20 Jan 2013 23:31:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Backport_6df45?= =?utf-8?q?6f8fc6d=2E?= Message-ID: <3Yq9bM0PNQzSDH@mail.python.org> http://hg.python.org/cpython/rev/96721e364870 changeset: 81621:96721e364870 branch: 2.7 parent: 81605:ee93a89b4e0f user: Stefan Krah date: Sun Jan 20 23:29:28 2013 +0100 summary: Backport 6df456f8fc6d. files: Doc/howto/cporting.rst | 19 ------------------- 1 files changed, 0 insertions(+), 19 deletions(-) diff --git a/Doc/howto/cporting.rst b/Doc/howto/cporting.rst --- a/Doc/howto/cporting.rst +++ b/Doc/howto/cporting.rst @@ -100,25 +100,6 @@ used in Python 2 was removed. In the C-API, ``PyInt_*`` functions are replaced by their ``PyLong_*`` equivalents. -The best course of action here is using the ``PyInt_*`` functions aliased to -``PyLong_*`` found in :file:`intobject.h`. The abstract ``PyNumber_*`` APIs -can also be used in some cases. :: - - #include "Python.h" - #include "intobject.h" - - static PyObject * - add_ints(PyObject *self, PyObject *args) { - int one, two; - PyObject *result; - - if (!PyArg_ParseTuple(args, "ii:add_ints", &one, &two)) - return NULL; - - return PyInt_FromLong(one + two); - } - - Module initialization and state =============================== -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Mon Jan 21 05:58:59 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 21 Jan 2013 05:58:59 +0100 Subject: [Python-checkins] Daily reference leaks (575eb20cd7d1): sum=0 Message-ID: results for 575eb20cd7d1 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogFDdhkV', '-x'] From python-checkins at python.org Mon Jan 21 10:46:21 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 10:46:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2MzM1?= =?utf-8?q?=3A_Fix_integer_overflow_in_unicode-escape_decoder=2E?= Message-ID: <3YqSZP3HzlzSNK@mail.python.org> http://hg.python.org/cpython/rev/7625866f8127 changeset: 81622:7625866f8127 branch: 3.2 parent: 81610:260a9afd999a user: Serhiy Storchaka date: Mon Jan 21 11:38:00 2013 +0200 summary: Issue #16335: Fix integer overflow in unicode-escape decoder. files: Lib/test/test_ucn.py | 16 ++++++++++++++++ Objects/unicodeobject.c | 3 ++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -8,6 +8,7 @@ """#" import unittest +import _testcapi from test import support @@ -141,6 +142,21 @@ str, b"\\NSPACE", 'unicode-escape', 'strict' ) + @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, + "needs UINT_MAX < SIZE_MAX") + def test_issue16335(self): + # very very long bogus character name + try: + x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + except MemoryError: + raise unittest.SkipTest("not enough memory") + self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) + + def test_main(): support.run_unittest(UnicodeNamesTest) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3923,7 +3923,8 @@ /* found a name. look it up in the unicode database */ message = "unknown Unicode character name"; s++; - if (ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr)) + if (s - start - 1 <= INT_MAX && + ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr)) goto store; } } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 10:46:22 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 10:46:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316335=3A_Fix_integer_overflow_in_unicode-escape_decod?= =?utf-8?b?ZXIu?= Message-ID: <3YqSZQ6MtrzSPQ@mail.python.org> http://hg.python.org/cpython/rev/494d341e9143 changeset: 81623:494d341e9143 branch: 3.3 parent: 81619:6df456f8fc6d parent: 81622:7625866f8127 user: Serhiy Storchaka date: Mon Jan 21 11:42:57 2013 +0200 summary: Issue #16335: Fix integer overflow in unicode-escape decoder. files: Lib/test/test_ucn.py | 16 ++++++++++++++++ Objects/unicodeobject.c | 3 ++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -9,6 +9,7 @@ import unittest import unicodedata +import _testcapi from test import support from http.client import HTTPException @@ -215,6 +216,21 @@ str, b"\\NSPACE", 'unicode-escape', 'strict' ) + @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, + "needs UINT_MAX < SIZE_MAX") + def test_issue16335(self): + # very very long bogus character name + try: + x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + except MemoryError: + raise unittest.SkipTest("not enough memory") + self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) + + def test_main(): support.run_unittest(UnicodeNamesTest) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5696,7 +5696,8 @@ /* found a name. look it up in the unicode database */ message = "unknown Unicode character name"; s++; - if (ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), + if (s - start - 1 <= INT_MAX && + ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr, 0)) goto store; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 10:46:24 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 10:46:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316335=3A_Fix_integer_overflow_in_unicode-escape?= =?utf-8?q?_decoder=2E?= Message-ID: <3YqSZS22MmzSPR@mail.python.org> http://hg.python.org/cpython/rev/8488febf7d79 changeset: 81624:8488febf7d79 parent: 81620:575eb20cd7d1 parent: 81623:494d341e9143 user: Serhiy Storchaka date: Mon Jan 21 11:44:40 2013 +0200 summary: Issue #16335: Fix integer overflow in unicode-escape decoder. files: Lib/test/test_ucn.py | 16 ++++++++++++++++ Objects/unicodeobject.c | 3 ++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -9,6 +9,7 @@ import unittest import unicodedata +import _testcapi from test import support from http.client import HTTPException @@ -215,6 +216,21 @@ str, b"\\NSPACE", 'unicode-escape', 'strict' ) + @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, + "needs UINT_MAX < SIZE_MAX") + def test_issue16335(self): + # very very long bogus character name + try: + x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + except MemoryError: + raise unittest.SkipTest("not enough memory") + self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) + + def test_main(): support.run_unittest(UnicodeNamesTest) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5569,7 +5569,8 @@ /* found a name. look it up in the unicode database */ message = "unknown Unicode character name"; s++; - if (ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), + if (s - start - 1 <= INT_MAX && + ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr, 0)) goto store; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 10:49:15 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 10:49:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2MzM1?= =?utf-8?q?=3A_Fix_integer_overflow_in_unicode-escape_decoder=2E?= Message-ID: <3YqSdl18FmzSNf@mail.python.org> http://hg.python.org/cpython/rev/f4d30d1a529e changeset: 81625:f4d30d1a529e branch: 2.7 parent: 81621:96721e364870 user: Serhiy Storchaka date: Mon Jan 21 11:48:24 2013 +0200 summary: Issue #16335: Fix integer overflow in unicode-escape decoder. files: Lib/test/test_ucn.py | 16 ++++++++++++++++ Objects/unicodeobject.c | 3 ++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -8,6 +8,7 @@ """#" import unittest +import _testcapi from test import test_support @@ -137,6 +138,21 @@ unicode, "\\NSPACE", 'unicode-escape', 'strict' ) + @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, + "needs UINT_MAX < SIZE_MAX") + def test_issue16335(self): + # very very long bogus character name + try: + x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}' + except MemoryError: + raise unittest.SkipTest("not enough memory") + self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) + + def test_main(): test_support.run_unittest(UnicodeNamesTest) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2899,7 +2899,8 @@ /* found a name. look it up in the unicode database */ message = "unknown Unicode character name"; s++; - if (ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr)) + if (s - start - 1 <= INT_MAX && + ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr)) goto store; } } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 11:25:43 2013 From: python-checkins at python.org (christian.heimes) Date: Mon, 21 Jan 2013 11:25:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_fix_for_f4d30d?= =?utf-8?q?1a529e?= Message-ID: <3YqTRq2W5czSK8@mail.python.org> http://hg.python.org/cpython/rev/cd8d983c15de changeset: 81626:cd8d983c15de branch: 2.7 user: Christian Heimes date: Mon Jan 21 11:25:27 2013 +0100 summary: fix for f4d30d1a529e Python 2.7 has only assertRaisesRegexp, not assertRaisesRegex files: Lib/test/test_ucn.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -147,7 +147,7 @@ except MemoryError: raise unittest.SkipTest("not enough memory") self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, + self.assertRaisesRegexp(UnicodeError, 'unknown Unicode character name', x.decode, 'unicode-escape' ) -- Repository URL: http://hg.python.org/cpython From christian at python.org Mon Jan 21 11:29:45 2013 From: christian at python.org (Christian Heimes) Date: Mon, 21 Jan 2013 11:29:45 +0100 Subject: [Python-checkins] cpython (3.2): Issue #16335: Fix integer overflow in unicode-escape decoder. In-Reply-To: <3YqSZP3HzlzSNK@mail.python.org> References: <3YqSZP3HzlzSNK@mail.python.org> Message-ID: <50FD1899.6060505@python.org> Am 21.01.2013 10:46, schrieb serhiy.storchaka: > http://hg.python.org/cpython/rev/7625866f8127 > changeset: 81622:7625866f8127 > branch: 3.2 > parent: 81610:260a9afd999a > user: Serhiy Storchaka > date: Mon Jan 21 11:38:00 2013 +0200 > summary: > Issue #16335: Fix integer overflow in unicode-escape decoder. > > files: > Lib/test/test_ucn.py | 16 ++++++++++++++++ > Objects/unicodeobject.c | 3 ++- > 2 files changed, 18 insertions(+), 1 deletions(-) > > > diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py > --- a/Lib/test/test_ucn.py > +++ b/Lib/test/test_ucn.py > @@ -8,6 +8,7 @@ > """#" > > import unittest > +import _testcapi > > from test import support > > @@ -141,6 +142,21 @@ > str, b"\\NSPACE", 'unicode-escape', 'strict' > ) > > + @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, > + "needs UINT_MAX < SIZE_MAX") > + def test_issue16335(self): > + # very very long bogus character name > + try: > + x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' > + except MemoryError: > + raise unittest.SkipTest("not enough memory") > + self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) > + self.assertRaisesRegex(UnicodeError, > + 'unknown Unicode character name', > + x.decode, 'unicode-escape' > + ) > + > + The test requires a lot of memory on my 64bit Linux box. Two of three times the test process was killed by the Kernel's out of memory manager although I have 8 GB physical RAM and 4 GB swap. Can you rewrite the test to use less memory? From python-checkins at python.org Mon Jan 21 12:06:21 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 12:06:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_memory_err?= =?utf-8?q?or_in_test=5Fucn=2E?= Message-ID: <3YqVLj5bLJzMQ1@mail.python.org> http://hg.python.org/cpython/rev/f84a6c89ccbc changeset: 81627:f84a6c89ccbc branch: 3.2 parent: 81622:7625866f8127 user: Serhiy Storchaka date: Mon Jan 21 12:59:13 2013 +0200 summary: Fix memory error in test_ucn. unicode-escape decoder requires memory for result corresponding to input size. Fixes test for issue #16335. files: Lib/test/test_ucn.py | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -148,13 +148,14 @@ # very very long bogus character name try: x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) except MemoryError: raise unittest.SkipTest("not enough memory") - self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 12:06:23 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 12:06:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Fix_memory_error_in_test=5Fucn=2E?= Message-ID: <3YqVLl10GDzPXJ@mail.python.org> http://hg.python.org/cpython/rev/7c2aae472b27 changeset: 81628:7c2aae472b27 branch: 3.3 parent: 81623:494d341e9143 parent: 81627:f84a6c89ccbc user: Serhiy Storchaka date: Mon Jan 21 13:00:11 2013 +0200 summary: Fix memory error in test_ucn. unicode-escape decoder requires memory for result corresponding to input size. Fixes test for issue #16335. files: Lib/test/test_ucn.py | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -222,13 +222,14 @@ # very very long bogus character name try: x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) except MemoryError: raise unittest.SkipTest("not enough memory") - self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 12:06:24 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 12:06:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_memory_error_in_test=5Fucn=2E?= Message-ID: <3YqVLm3X2wzM8H@mail.python.org> http://hg.python.org/cpython/rev/f90d6ce49772 changeset: 81629:f90d6ce49772 parent: 81624:8488febf7d79 parent: 81628:7c2aae472b27 user: Serhiy Storchaka date: Mon Jan 21 13:00:50 2013 +0200 summary: Fix memory error in test_ucn. unicode-escape decoder requires memory for result corresponding to input size. Fixes test for issue #16335. files: Lib/test/test_ucn.py | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -222,13 +222,14 @@ # very very long bogus character name try: x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) except MemoryError: raise unittest.SkipTest("not enough memory") - self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 12:06:25 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 12:06:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_memory_err?= =?utf-8?q?or_in_test=5Fucn=2E?= Message-ID: <3YqVLn69qczMJG@mail.python.org> http://hg.python.org/cpython/rev/38a10d0778d2 changeset: 81630:38a10d0778d2 branch: 2.7 parent: 81626:cd8d983c15de user: Serhiy Storchaka date: Mon Jan 21 13:03:58 2013 +0200 summary: Fix memory error in test_ucn. unicode-escape decoder requires memory for result corresponding to input size. Fixes test for issue #16335. files: Lib/test/test_ucn.py | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -144,13 +144,14 @@ # very very long bogus character name try: x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegexp(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) except MemoryError: raise unittest.SkipTest("not enough memory") - self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegexp(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 12:43:19 2013 From: python-checkins at python.org (giampaolo.rodola) Date: Mon, 21 Jan 2013 12:43:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_adding_myself_to_list_of_?= =?utf-8?q?experts_for_poplib_module?= Message-ID: <3YqW9M0MzNzQv4@mail.python.org> http://hg.python.org/devguide/rev/f0b3f96aa79b changeset: 592:f0b3f96aa79b parent: 590:de93193d7a33 user: Giampaolo Rodola' date: Mon Jan 21 12:42:04 2013 +0100 summary: adding myself to list of experts for poplib module files: experts.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/experts.rst b/experts.rst --- a/experts.rst +++ b/experts.rst @@ -167,7 +167,7 @@ pkgutil platform lemburg plistlib -poplib +poplib giampaolo.rodola posix pprint fdrake profile georg.brandl -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Mon Jan 21 12:43:20 2013 From: python-checkins at python.org (giampaolo.rodola) Date: Mon, 21 Jan 2013 12:43:20 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide_=28merge_default_-=3E_defaul?= =?utf-8?b?dCk6IG1lcmdl?= Message-ID: <3YqW9N3Ky8zS6v@mail.python.org> http://hg.python.org/devguide/rev/139eea239f32 changeset: 593:139eea239f32 parent: 592:f0b3f96aa79b parent: 591:3628a1aed4cd user: Giampaolo Rodola' date: Mon Jan 21 12:43:11 2013 +0100 summary: merge files: documenting.rst | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/documenting.rst b/documenting.rst --- a/documenting.rst +++ b/documenting.rst @@ -825,6 +825,17 @@ This language is used until the next ``highlightlang`` directive is encountered. +* The ``code-block`` directive can be used to specify the highlight language + of a single code block, e.g.:: + + .. code-block:: c + + #include + + void main() { + printf("Hello world!\n"); + } + * The values normally used for the highlighting language are: * ``python`` (the default) -- Repository URL: http://hg.python.org/devguide From storchaka at gmail.com Mon Jan 21 13:08:04 2013 From: storchaka at gmail.com (Serhiy Storchaka) Date: Mon, 21 Jan 2013 14:08:04 +0200 Subject: [Python-checkins] cpython (3.2): Issue #16335: Fix integer overflow in unicode-escape decoder. In-Reply-To: <50FD1899.6060505@python.org> References: <3YqSZP3HzlzSNK@mail.python.org> <50FD1899.6060505@python.org> Message-ID: On 21.01.13 12:29, Christian Heimes wrote: > The test requires a lot of memory on my 64bit Linux box. Two of three > times the test process was killed by the Kernel's out of memory manager > although I have 8 GB physical RAM and 4 GB swap. Can you rewrite the > test to use less memory? No, I can't. 4 GB needed for bytes object, and 4 or 8 GB (depending on platform) additionally needed for its creating. Then unicode-escape requires 4*sizeofunicodechar GB (i.e. 4 GB on 3.3+, 8 GB on narrow build, 16 GB on wide build) for output buffer. Or may be more or less. When I used bigmem decorator, test was skipped even on machine with enough memory (I were tested on x3 snakebite). Current test was passed. May be drop this test at all? From python-checkins at python.org Mon Jan 21 14:04:16 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 14:04:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTkz?= =?utf-8?q?=3A_shutil=2Ewhich=28=29_now_preserves_the_case_of_the_path_and?= =?utf-8?q?_extension?= Message-ID: <3YqXym4DG4zPZ3@mail.python.org> http://hg.python.org/cpython/rev/d2db601a53b3 changeset: 81631:d2db601a53b3 branch: 3.3 parent: 81628:7c2aae472b27 user: Serhiy Storchaka date: Mon Jan 21 15:00:27 2013 +0200 summary: Issue #16993: shutil.which() now preserves the case of the path and extension on Windows. files: Doc/library/shutil.rst | 2 +- Lib/shutil.py | 12 +++++++----- Lib/test/test_shutil.py | 7 ++++--- Misc/NEWS | 3 +++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -335,7 +335,7 @@ directories. For example, on Windows:: >>> shutil.which("python") - 'c:\\python33\\python.exe' + 'C:\\Python33\\python.exe' .. versionadded:: 3.3 diff --git a/Lib/shutil.py b/Lib/shutil.py --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -1093,10 +1093,12 @@ pathext = os.environ.get("PATHEXT", "").split(os.pathsep) # See if the given file matches any of the expected path extensions. # This will allow us to short circuit when given "python.exe". - matches = [cmd for ext in pathext if cmd.lower().endswith(ext.lower())] # If it does match, only test that one, otherwise we have to try # others. - files = [cmd] if matches else [cmd + ext.lower() for ext in pathext] + if any(cmd.lower().endswith(ext.lower()) for ext in pathext): + files = [cmd] + else: + files = [cmd + ext for ext in pathext] else: # On other platforms you don't have things like PATHEXT to tell you # what file suffixes are executable, so just pass on cmd as-is. @@ -1104,9 +1106,9 @@ seen = set() for dir in path: - dir = os.path.normcase(dir) - if not dir in seen: - seen.add(dir) + normdir = os.path.normcase(dir) + if not normdir in seen: + seen.add(normdir) for thefile in files: name = os.path.join(dir, thefile) if _access_check(name, mode): diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1269,12 +1269,13 @@ class TestWhich(unittest.TestCase): def setUp(self): - self.temp_dir = tempfile.mkdtemp() + self.temp_dir = tempfile.mkdtemp(prefix="Tmp") self.addCleanup(shutil.rmtree, self.temp_dir, True) # Give the temp_file an ".exe" suffix for all. # It's needed on Windows and not harmful on other platforms. self.temp_file = tempfile.NamedTemporaryFile(dir=self.temp_dir, - suffix=".exe") + prefix="Tmp", + suffix=".Exe") os.chmod(self.temp_file.name, stat.S_IXUSR) self.addCleanup(self.temp_file.close) self.dir, self.file = os.path.split(self.temp_file.name) @@ -1317,7 +1318,7 @@ # Ask for the file without the ".exe" extension, then ensure that # it gets found properly with the extension. rv = shutil.which(self.temp_file.name[:-4], path=self.dir) - self.assertEqual(self.temp_file.name, rv) + self.assertEqual(rv, self.temp_file.name[:-4] + ".exe") class TestMove(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #16993: shutil.which() now preserves the case of the path and extension + on Windows. + - Issue #16992: On Windows in signal.set_wakeup_fd, validate the file descriptor argument. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 14:04:17 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 14:04:17 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316993=3A_shutil=2Ewhich=28=29_now_preserves_the?= =?utf-8?q?_case_of_the_path_and_extension?= Message-ID: <3YqXyn73wmzPYg@mail.python.org> http://hg.python.org/cpython/rev/5faae2bdf1e0 changeset: 81632:5faae2bdf1e0 parent: 81629:f90d6ce49772 parent: 81631:d2db601a53b3 user: Serhiy Storchaka date: Mon Jan 21 15:01:34 2013 +0200 summary: Issue #16993: shutil.which() now preserves the case of the path and extension on Windows. files: Doc/library/shutil.rst | 2 +- Lib/shutil.py | 12 +++++++----- Lib/test/test_shutil.py | 7 ++++--- Misc/NEWS | 3 +++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -348,7 +348,7 @@ directories. For example, on Windows:: >>> shutil.which("python") - 'c:\\python33\\python.exe' + 'C:\\Python33\\python.exe' .. versionadded:: 3.3 diff --git a/Lib/shutil.py b/Lib/shutil.py --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -1092,10 +1092,12 @@ pathext = os.environ.get("PATHEXT", "").split(os.pathsep) # See if the given file matches any of the expected path extensions. # This will allow us to short circuit when given "python.exe". - matches = [cmd for ext in pathext if cmd.lower().endswith(ext.lower())] # If it does match, only test that one, otherwise we have to try # others. - files = [cmd] if matches else [cmd + ext.lower() for ext in pathext] + if any(cmd.lower().endswith(ext.lower()) for ext in pathext): + files = [cmd] + else: + files = [cmd + ext for ext in pathext] else: # On other platforms you don't have things like PATHEXT to tell you # what file suffixes are executable, so just pass on cmd as-is. @@ -1103,9 +1105,9 @@ seen = set() for dir in path: - dir = os.path.normcase(dir) - if not dir in seen: - seen.add(dir) + normdir = os.path.normcase(dir) + if not normdir in seen: + seen.add(normdir) for thefile in files: name = os.path.join(dir, thefile) if _access_check(name, mode): diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1280,12 +1280,13 @@ class TestWhich(unittest.TestCase): def setUp(self): - self.temp_dir = tempfile.mkdtemp() + self.temp_dir = tempfile.mkdtemp(prefix="Tmp") self.addCleanup(shutil.rmtree, self.temp_dir, True) # Give the temp_file an ".exe" suffix for all. # It's needed on Windows and not harmful on other platforms. self.temp_file = tempfile.NamedTemporaryFile(dir=self.temp_dir, - suffix=".exe") + prefix="Tmp", + suffix=".Exe") os.chmod(self.temp_file.name, stat.S_IXUSR) self.addCleanup(self.temp_file.close) self.dir, self.file = os.path.split(self.temp_file.name) @@ -1328,7 +1329,7 @@ # Ask for the file without the ".exe" extension, then ensure that # it gets found properly with the extension. rv = shutil.which(self.temp_file.name[:-4], path=self.dir) - self.assertEqual(self.temp_file.name, rv) + self.assertEqual(rv, self.temp_file.name[:-4] + ".exe") class TestMove(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -220,6 +220,9 @@ Library ------- +- Issue #16993: shutil.which() now preserves the case of the path and extension + on Windows. + - Issue #16992: On Windows in signal.set_wakeup_fd, validate the file descriptor argument. -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Mon Jan 21 14:50:45 2013 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 21 Jan 2013 14:50:45 +0100 Subject: [Python-checkins] cpython (3.2): Issue #16335: Fix integer overflow in unicode-escape decoder. References: <3YqSZP3HzlzSNK@mail.python.org> <50FD1899.6060505@python.org> Message-ID: <20130121145045.6a4b2f5d@pitrou.net> Le Mon, 21 Jan 2013 14:08:04 +0200, Serhiy Storchaka a ?crit : > > When I used bigmem decorator, test was skipped even on machine with > enough memory (I were tested on x3 snakebite). Current test was > passed. Then perhaps you need to fix your use of the bigmem decorator, or perhaps you forgot to run the tests with -M. Regards Antoine. From storchaka at gmail.com Mon Jan 21 17:24:59 2013 From: storchaka at gmail.com (Serhiy Storchaka) Date: Mon, 21 Jan 2013 18:24:59 +0200 Subject: [Python-checkins] cpython (3.2): Issue #16335: Fix integer overflow in unicode-escape decoder. In-Reply-To: <20130121145045.6a4b2f5d@pitrou.net> References: <3YqSZP3HzlzSNK@mail.python.org> <50FD1899.6060505@python.org> <20130121145045.6a4b2f5d@pitrou.net> Message-ID: On 21.01.13 15:50, Antoine Pitrou wrote: > Le Mon, 21 Jan 2013 14:08:04 +0200, > Serhiy Storchaka a ?crit : >> When I used bigmem decorator, test was skipped even on machine with >> enough memory (I were tested on x3 snakebite). Current test was >> passed. > > Then perhaps you need to fix your use of the bigmem decorator, or > perhaps you forgot to run the tests with -M. Shame on me. I really forgot about -M. From python-checkins at python.org Mon Jan 21 19:30:05 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 19:30:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Add_bigmemtest?= =?utf-8?q?_decorator_to_test_of_issue_=2316335=2E?= Message-ID: <3YqhBj5dRXzMgv@mail.python.org> http://hg.python.org/cpython/rev/ec3a35ab3659 changeset: 81633:ec3a35ab3659 branch: 2.7 parent: 81630:38a10d0778d2 user: Serhiy Storchaka date: Mon Jan 21 20:23:01 2013 +0200 summary: Add bigmemtest decorator to test of issue #16335. files: Lib/test/test_ucn.py | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -8,6 +8,7 @@ """#" import unittest +import sys import _testcapi from test import test_support @@ -140,18 +141,19 @@ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - def test_issue16335(self): + @unittest.skipUnless(_testcapi.UINT_MAX < sys.maxint, + "needs UINT_MAX < sys.maxint") + @test_support.bigmemtest(minsize=_testcapi.UINT_MAX + 1, + memuse=1 + 4 // len(u'\U00010000')) + def test_issue16335(self, size): # very very long bogus character name - try: - x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}' - self.assertEqual(len(x), len(b'\\N{SPACE}') + - (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegexp(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) - except MemoryError: - raise unittest.SkipTest("not enough memory") + x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegexp(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 19:30:07 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 19:30:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Add_bigmemtest?= =?utf-8?q?_decorator_to_test_of_issue_=2316335=2E?= Message-ID: <3YqhBl1dgKzP5Y@mail.python.org> http://hg.python.org/cpython/rev/6e0c3e4136b1 changeset: 81634:6e0c3e4136b1 branch: 3.2 parent: 81627:f84a6c89ccbc user: Serhiy Storchaka date: Mon Jan 21 20:23:58 2013 +0200 summary: Add bigmemtest decorator to test of issue #16335. files: Lib/test/test_ucn.py | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -144,18 +144,17 @@ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - def test_issue16335(self): + @support.bigmemtest(size=_testcapi.UINT_MAX + 1, + memuse=1 + 4 // len('\U00010000'), dry_run=False) + def test_issue16335(self, size): # very very long bogus character name - try: - x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' - self.assertEqual(len(x), len(b'\\N{SPACE}') + - (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) - except MemoryError: - raise unittest.SkipTest("not enough memory") + x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 19:30:08 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 19:30:08 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Use_bigmemtest_decorator_for_test_of_issue_=2316335=2E?= Message-ID: <3YqhBm4FY3zPSS@mail.python.org> http://hg.python.org/cpython/rev/0e622d2cbcf8 changeset: 81635:0e622d2cbcf8 branch: 3.3 parent: 81631:d2db601a53b3 parent: 81634:6e0c3e4136b1 user: Serhiy Storchaka date: Mon Jan 21 20:27:17 2013 +0200 summary: Use bigmemtest decorator for test of issue #16335. files: Lib/test/test_ucn.py | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -218,18 +218,17 @@ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - def test_issue16335(self): + @support.bigmemtest(size=_testcapi.UINT_MAX + 1, + memuse=1 + 1, dry_run=False) + def test_issue16335(self, size): # very very long bogus character name - try: - x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' - self.assertEqual(len(x), len(b'\\N{SPACE}') + - (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) - except MemoryError: - raise unittest.SkipTest("not enough memory") + x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 19:30:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Jan 2013 19:30:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Use_bigmemtest_decorator_for_test_of_issue_=2316335=2E?= Message-ID: <3YqhBp262szMgv@mail.python.org> http://hg.python.org/cpython/rev/cdd1e60d31e5 changeset: 81636:cdd1e60d31e5 parent: 81632:5faae2bdf1e0 parent: 81635:0e622d2cbcf8 user: Serhiy Storchaka date: Mon Jan 21 20:28:02 2013 +0200 summary: Use bigmemtest decorator for test of issue #16335. files: Lib/test/test_ucn.py | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -218,18 +218,17 @@ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - def test_issue16335(self): + @support.bigmemtest(size=_testcapi.UINT_MAX + 1, + memuse=1 + 1, dry_run=False) + def test_issue16335(self, size): # very very long bogus character name - try: - x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' - self.assertEqual(len(x), len(b'\\N{SPACE}') + - (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) - except MemoryError: - raise unittest.SkipTest("not enough memory") + x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) def test_main(): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 20:46:33 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 20:46:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE3MDA3?= =?utf-8?q?=3A_Improved_logging_documentation_based_on_suggestions_in_the_?= =?utf-8?q?issue=2E?= Message-ID: <3Yqjtx6gY6zPQ0@mail.python.org> http://hg.python.org/cpython/rev/871519e1f146 changeset: 81637:871519e1f146 branch: 2.7 parent: 81633:ec3a35ab3659 user: Vinay Sajip date: Mon Jan 21 19:43:51 2013 +0000 summary: Issue #17007: Improved logging documentation based on suggestions in the issue. files: Doc/library/logging.rst | 42 ++++++++++++++++++++-------- 1 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -67,20 +67,30 @@ ``logging.getLogger(__name__)``. That's because in a module, ``__name__`` is the module's name in the Python package namespace. + .. class:: Logger .. attribute:: Logger.propagate - If this evaluates to true, logging messages are passed by this logger and by - its child loggers to the handlers of higher level (ancestor) loggers. - Messages are passed directly to the ancestor loggers' handlers - neither the - level nor filters of the ancestor loggers in question are considered. + If this evaluates to true, events logged to this logger will be passed to the + handlers of higher level (ancestor) loggers, in addition to any handlers + attached to this logger. Messages are passed directly to the ancestor + loggers' handlers - neither the level nor filters of the ancestor loggers in + question are considered. If this evaluates to false, logging messages are not passed to the handlers of ancestor loggers. The constructor sets this attribute to ``True``. + .. note:: If you attach a handler to several loggers, it may emit the same + record multiple times. In general, you should not need to attach a + handler to more than one logger - if you just attach it to the + appropriate logger which is highest in the logger hierarchy, then it + will see all events logged by all descendant loggers, provided that + their propagate setting is left set to ``True``. A common scenario is to + attach handlers only to the root logger, and let propagation take care of + the rest. .. method:: Logger.setLevel(lvl) @@ -227,7 +237,10 @@ .. method:: Logger.filter(record) Applies this logger's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be processed (passed to handlers). If one returns a false value, no + further processing of the record occurs. .. method:: Logger.addHandler(hdlr) @@ -324,7 +337,10 @@ .. method:: Handler.filter(record) Applies this handler's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be emitted. If one returns a false value, the handler will not emit the + record. .. method:: Handler.flush() @@ -477,12 +493,12 @@ yes. If deemed appropriate, the record may be modified in-place by this method. -Note that filters attached to handlers are consulted whenever an event is +Note that filters attached to handlers are consulted before an event is emitted by the handler, whereas filters attached to loggers are consulted -whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`, -etc.) This means that events which have been generated by descendant loggers -will not be filtered by a logger's filter setting, unless the filter has also -been applied to those descendant loggers. +whenever an event is logged (using :meth:`debug`, :meth:`info`, +etc.), before sending an event to handlers. This means that events which have +been generated by descendant loggers will not be filtered by a logger's filter +setting, unless the filter has also been applied to those descendant loggers. You don't actually need to subclass ``Filter``: you can pass any instance which has a ``filter`` method with the same semantics. @@ -516,7 +532,9 @@ record. :param name: The name of the logger used to log the event represented by - this LogRecord. + this LogRecord. Note that this name will always have this + value, even though it may be emitted by a handler attached to + a different (ancestor) logger. :param level: The numeric level of the logging event (one of DEBUG, INFO etc.) Note that this is converted to *two* attributes of the LogRecord: ``levelno`` for the numeric value and ``levelname`` for the -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 20:46:35 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 20:46:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE3MDA3?= =?utf-8?q?=3A_Improved_logging_documentation_based_on_suggestions_in_the_?= =?utf-8?q?issue=2E?= Message-ID: <3Yqjtz3j6KzPSS@mail.python.org> http://hg.python.org/cpython/rev/029785354dbc changeset: 81638:029785354dbc branch: 3.2 parent: 81634:6e0c3e4136b1 user: Vinay Sajip date: Mon Jan 21 19:44:28 2013 +0000 summary: Issue #17007: Improved logging documentation based on suggestions in the issue. files: Doc/library/logging.rst | 41 ++++++++++++++++++++-------- 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -70,16 +70,25 @@ .. attribute:: Logger.propagate - If this evaluates to true, logging messages are passed by this logger and by - its child loggers to the handlers of higher level (ancestor) loggers. - Messages are passed directly to the ancestor loggers' handlers - neither the - level nor filters of the ancestor loggers in question are considered. + If this evaluates to true, events logged to this logger will be passed to the + handlers of higher level (ancestor) loggers, in addition to any handlers + attached to this logger. Messages are passed directly to the ancestor + loggers' handlers - neither the level nor filters of the ancestor loggers in + question are considered. If this evaluates to false, logging messages are not passed to the handlers of ancestor loggers. The constructor sets this attribute to ``True``. + .. note:: If you attach a handler to several loggers, it may emit the same + record multiple times. In general, you should not need to attach a + handler to more than one logger - if you just attach it to the + appropriate logger which is highest in the logger hierarchy, then it + will see all events logged by all descendant loggers, provided that + their propagate setting is left set to ``True``. A common scenario is to + attach handlers only to the root logger, and let propagation take care of + the rest. .. method:: Logger.setLevel(lvl) @@ -252,7 +261,10 @@ .. method:: Logger.filter(record) Applies this logger's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be processed (passed to handlers). If one returns a false value, no + further processing of the record occurs. .. method:: Logger.addHandler(hdlr) @@ -361,7 +373,10 @@ .. method:: Handler.filter(record) Applies this handler's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be emitted. If one returns a false value, the handler will not emit the + record. .. method:: Handler.flush() @@ -531,12 +546,12 @@ yes. If deemed appropriate, the record may be modified in-place by this method. -Note that filters attached to handlers are consulted whenever an event is +Note that filters attached to handlers are consulted before an event is emitted by the handler, whereas filters attached to loggers are consulted -whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`, -etc.) This means that events which have been generated by descendant loggers -will not be filtered by a logger's filter setting, unless the filter has also -been applied to those descendant loggers. +whenever an event is logged (using :meth:`debug`, :meth:`info`, +etc.), before sending an event to handlers. This means that events which have +been generated by descendant loggers will not be filtered by a logger's filter +setting, unless the filter has also been applied to those descendant loggers. You don't actually need to subclass ``Filter``: you can pass any instance which has a ``filter`` method with the same semantics. @@ -580,7 +595,9 @@ record. :param name: The name of the logger used to log the event represented by - this LogRecord. + this LogRecord. Note that this name will always have this + value, even though it may be emitted by a handler attached to + a different (ancestor) logger. :param level: The numeric level of the logging event (one of DEBUG, INFO etc.) Note that this is converted to *two* attributes of the LogRecord: ``levelno`` for the numeric value and ``levelname`` for the -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 20:46:37 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 20:46:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2317007=3A_Merged_doc_update_from_3=2E2=2E?= Message-ID: <3Yqjv10RT4zPHZ@mail.python.org> http://hg.python.org/cpython/rev/1902e86dbb88 changeset: 81639:1902e86dbb88 branch: 3.3 parent: 81635:0e622d2cbcf8 parent: 81638:029785354dbc user: Vinay Sajip date: Mon Jan 21 19:45:27 2013 +0000 summary: Issue #17007: Merged doc update from 3.2. files: Doc/library/logging.rst | 41 ++++++++++++++++++++-------- 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -70,16 +70,25 @@ .. attribute:: Logger.propagate - If this evaluates to true, logging messages are passed by this logger and by - its child loggers to the handlers of higher level (ancestor) loggers. - Messages are passed directly to the ancestor loggers' handlers - neither the - level nor filters of the ancestor loggers in question are considered. + If this evaluates to true, events logged to this logger will be passed to the + handlers of higher level (ancestor) loggers, in addition to any handlers + attached to this logger. Messages are passed directly to the ancestor + loggers' handlers - neither the level nor filters of the ancestor loggers in + question are considered. If this evaluates to false, logging messages are not passed to the handlers of ancestor loggers. The constructor sets this attribute to ``True``. + .. note:: If you attach a handler to several loggers, it may emit the same + record multiple times. In general, you should not need to attach a + handler to more than one logger - if you just attach it to the + appropriate logger which is highest in the logger hierarchy, then it + will see all events logged by all descendant loggers, provided that + their propagate setting is left set to ``True``. A common scenario is to + attach handlers only to the root logger, and let propagation take care of + the rest. .. method:: Logger.setLevel(lvl) @@ -255,7 +264,10 @@ .. method:: Logger.filter(record) Applies this logger's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be processed (passed to handlers). If one returns a false value, no + further processing of the record occurs. .. method:: Logger.addHandler(hdlr) @@ -364,7 +376,10 @@ .. method:: Handler.filter(record) Applies this handler's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be emitted. If one returns a false value, the handler will not emit the + record. .. method:: Handler.flush() @@ -547,12 +562,12 @@ yes. If deemed appropriate, the record may be modified in-place by this method. -Note that filters attached to handlers are consulted whenever an event is +Note that filters attached to handlers are consulted before an event is emitted by the handler, whereas filters attached to loggers are consulted -whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`, -etc.) This means that events which have been generated by descendant loggers -will not be filtered by a logger's filter setting, unless the filter has also -been applied to those descendant loggers. +whenever an event is logged (using :meth:`debug`, :meth:`info`, +etc.), before sending an event to handlers. This means that events which have +been generated by descendant loggers will not be filtered by a logger's filter +setting, unless the filter has also been applied to those descendant loggers. You don't actually need to subclass ``Filter``: you can pass any instance which has a ``filter`` method with the same semantics. @@ -596,7 +611,9 @@ record. :param name: The name of the logger used to log the event represented by - this LogRecord. + this LogRecord. Note that this name will always have this + value, even though it may be emitted by a handler attached to + a different (ancestor) logger. :param level: The numeric level of the logging event (one of DEBUG, INFO etc.) Note that this is converted to *two* attributes of the LogRecord: ``levelno`` for the numeric value and ``levelname`` for the -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 20:46:38 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 20:46:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Closes_=2317007=3A_Merged_doc_update_from_3=2E3=2E?= Message-ID: <3Yqjv24F9LzPSS@mail.python.org> http://hg.python.org/cpython/rev/6110ed94f86d changeset: 81640:6110ed94f86d parent: 81636:cdd1e60d31e5 parent: 81639:1902e86dbb88 user: Vinay Sajip date: Mon Jan 21 19:46:18 2013 +0000 summary: Closes #17007: Merged doc update from 3.3. files: Doc/library/logging.rst | 41 ++++++++++++++++++++-------- 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -70,16 +70,25 @@ .. attribute:: Logger.propagate - If this evaluates to true, logging messages are passed by this logger and by - its child loggers to the handlers of higher level (ancestor) loggers. - Messages are passed directly to the ancestor loggers' handlers - neither the - level nor filters of the ancestor loggers in question are considered. + If this evaluates to true, events logged to this logger will be passed to the + handlers of higher level (ancestor) loggers, in addition to any handlers + attached to this logger. Messages are passed directly to the ancestor + loggers' handlers - neither the level nor filters of the ancestor loggers in + question are considered. If this evaluates to false, logging messages are not passed to the handlers of ancestor loggers. The constructor sets this attribute to ``True``. + .. note:: If you attach a handler to several loggers, it may emit the same + record multiple times. In general, you should not need to attach a + handler to more than one logger - if you just attach it to the + appropriate logger which is highest in the logger hierarchy, then it + will see all events logged by all descendant loggers, provided that + their propagate setting is left set to ``True``. A common scenario is to + attach handlers only to the root logger, and let propagation take care of + the rest. .. method:: Logger.setLevel(lvl) @@ -255,7 +264,10 @@ .. method:: Logger.filter(record) Applies this logger's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be processed (passed to handlers). If one returns a false value, no + further processing of the record occurs. .. method:: Logger.addHandler(hdlr) @@ -364,7 +376,10 @@ .. method:: Handler.filter(record) Applies this handler's filters to the record and returns a true value if the - record is to be processed. + record is to be processed. The filters are consulted in turn, until one of + them returns a false value. If none of them return a false value, the record + will be emitted. If one returns a false value, the handler will not emit the + record. .. method:: Handler.flush() @@ -547,12 +562,12 @@ yes. If deemed appropriate, the record may be modified in-place by this method. -Note that filters attached to handlers are consulted whenever an event is +Note that filters attached to handlers are consulted before an event is emitted by the handler, whereas filters attached to loggers are consulted -whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`, -etc.) This means that events which have been generated by descendant loggers -will not be filtered by a logger's filter setting, unless the filter has also -been applied to those descendant loggers. +whenever an event is logged (using :meth:`debug`, :meth:`info`, +etc.), before sending an event to handlers. This means that events which have +been generated by descendant loggers will not be filtered by a logger's filter +setting, unless the filter has also been applied to those descendant loggers. You don't actually need to subclass ``Filter``: you can pass any instance which has a ``filter`` method with the same semantics. @@ -596,7 +611,9 @@ record. :param name: The name of the logger used to log the event represented by - this LogRecord. + this LogRecord. Note that this name will always have this + value, even though it may be emitted by a handler attached to + a different (ancestor) logger. :param level: The numeric level of the logging event (one of DEBUG, INFO etc.) Note that this is converted to *two* attributes of the LogRecord: ``levelno`` for the numeric value and ``levelname`` for the -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 22:58:45 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 22:58:45 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE3MDA3?= =?utf-8?q?=3A_Made_minor_changes_to_documentation_wording=2E?= Message-ID: <3YqmqT6XfjzPRY@mail.python.org> http://hg.python.org/cpython/rev/8de6f92c89e6 changeset: 81641:8de6f92c89e6 branch: 2.7 parent: 81637:871519e1f146 user: Vinay Sajip date: Mon Jan 21 21:56:35 2013 +0000 summary: Issue #17007: Made minor changes to documentation wording. files: Doc/library/logging.rst | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -83,14 +83,14 @@ The constructor sets this attribute to ``True``. - .. note:: If you attach a handler to several loggers, it may emit the same - record multiple times. In general, you should not need to attach a - handler to more than one logger - if you just attach it to the - appropriate logger which is highest in the logger hierarchy, then it - will see all events logged by all descendant loggers, provided that - their propagate setting is left set to ``True``. A common scenario is to - attach handlers only to the root logger, and let propagation take care of - the rest. + .. note:: If you attach a handler to a logger *and* one or more of its + ancestors, it may emit the same record multiple times. In general, you + should not need to attach a handler to more than one logger - if you just + attach it to the appropriate logger which is highest in the logger + hierarchy, then it will see all events logged by all descendant loggers, + provided that their propagate setting is left set to ``True``. A common + scenario is to attach handlers only to the root logger, and to let + propagation take care of the rest. .. method:: Logger.setLevel(lvl) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 22:58:47 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 22:58:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE3MDA3?= =?utf-8?q?=3A_Made_minor_changes_to_documentation_wording=2E?= Message-ID: <3YqmqW27ktzPRY@mail.python.org> http://hg.python.org/cpython/rev/c8614ec54a63 changeset: 81642:c8614ec54a63 branch: 3.2 parent: 81638:029785354dbc user: Vinay Sajip date: Mon Jan 21 21:57:10 2013 +0000 summary: Issue #17007: Made minor changes to documentation wording. files: Doc/library/logging.rst | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -81,14 +81,14 @@ The constructor sets this attribute to ``True``. - .. note:: If you attach a handler to several loggers, it may emit the same - record multiple times. In general, you should not need to attach a - handler to more than one logger - if you just attach it to the - appropriate logger which is highest in the logger hierarchy, then it - will see all events logged by all descendant loggers, provided that - their propagate setting is left set to ``True``. A common scenario is to - attach handlers only to the root logger, and let propagation take care of - the rest. + .. note:: If you attach a handler to a logger *and* one or more of its + ancestors, it may emit the same record multiple times. In general, you + should not need to attach a handler to more than one logger - if you just + attach it to the appropriate logger which is highest in the logger + hierarchy, then it will see all events logged by all descendant loggers, + provided that their propagate setting is left set to ``True``. A common + scenario is to attach handlers only to the root logger, and to let + propagation take care of the rest. .. method:: Logger.setLevel(lvl) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 22:58:48 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 22:58:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2317007=3A_Merged_minor_changes_from_3=2E2=2E?= Message-ID: <3YqmqX4p83zQvk@mail.python.org> http://hg.python.org/cpython/rev/d0e9f64bd55c changeset: 81643:d0e9f64bd55c branch: 3.3 parent: 81639:1902e86dbb88 parent: 81642:c8614ec54a63 user: Vinay Sajip date: Mon Jan 21 21:58:05 2013 +0000 summary: Issue #17007: Merged minor changes from 3.2. files: Doc/library/logging.rst | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -81,14 +81,14 @@ The constructor sets this attribute to ``True``. - .. note:: If you attach a handler to several loggers, it may emit the same - record multiple times. In general, you should not need to attach a - handler to more than one logger - if you just attach it to the - appropriate logger which is highest in the logger hierarchy, then it - will see all events logged by all descendant loggers, provided that - their propagate setting is left set to ``True``. A common scenario is to - attach handlers only to the root logger, and let propagation take care of - the rest. + .. note:: If you attach a handler to a logger *and* one or more of its + ancestors, it may emit the same record multiple times. In general, you + should not need to attach a handler to more than one logger - if you just + attach it to the appropriate logger which is highest in the logger + hierarchy, then it will see all events logged by all descendant loggers, + provided that their propagate setting is left set to ``True``. A common + scenario is to attach handlers only to the root logger, and to let + propagation take care of the rest. .. method:: Logger.setLevel(lvl) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 21 22:58:50 2013 From: python-checkins at python.org (vinay.sajip) Date: Mon, 21 Jan 2013 22:58:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2317007=3A_Merged_minor_changes_from_3=2E3=2E?= Message-ID: <3YqmqZ0qSjzR1T@mail.python.org> http://hg.python.org/cpython/rev/6877957a5e91 changeset: 81644:6877957a5e91 parent: 81640:6110ed94f86d parent: 81643:d0e9f64bd55c user: Vinay Sajip date: Mon Jan 21 21:58:29 2013 +0000 summary: Issue #17007: Merged minor changes from 3.3. files: Doc/library/logging.rst | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -81,14 +81,14 @@ The constructor sets this attribute to ``True``. - .. note:: If you attach a handler to several loggers, it may emit the same - record multiple times. In general, you should not need to attach a - handler to more than one logger - if you just attach it to the - appropriate logger which is highest in the logger hierarchy, then it - will see all events logged by all descendant loggers, provided that - their propagate setting is left set to ``True``. A common scenario is to - attach handlers only to the root logger, and let propagation take care of - the rest. + .. note:: If you attach a handler to a logger *and* one or more of its + ancestors, it may emit the same record multiple times. In general, you + should not need to attach a handler to more than one logger - if you just + attach it to the appropriate logger which is highest in the logger + hierarchy, then it will see all events logged by all descendant loggers, + provided that their propagate setting is left set to ``True``. A common + scenario is to attach handlers only to the root logger, and to let + propagation take care of the rest. .. method:: Logger.setLevel(lvl) -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Tue Jan 22 06:03:05 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 22 Jan 2013 06:03:05 +0100 Subject: [Python-checkins] Daily reference leaks (6877957a5e91): sum=0 Message-ID: results for 6877957a5e91 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogD6ns7Z', '-x'] From python-checkins at python.org Tue Jan 22 09:33:24 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Jan 2013 09:33:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogRml4IHNodXRpbC53?= =?utf-8?q?hich=28=29_test_for_issue_=2316993=2E?= Message-ID: <3Yr2vm3FzszQr9@mail.python.org> http://hg.python.org/cpython/rev/28282e4e9d04 changeset: 81645:28282e4e9d04 branch: 3.3 parent: 81643:d0e9f64bd55c user: Serhiy Storchaka date: Tue Jan 22 10:31:36 2013 +0200 summary: Fix shutil.which() test for issue #16993. files: Doc/library/shutil.rst | 2 +- Lib/test/test_shutil.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -335,7 +335,7 @@ directories. For example, on Windows:: >>> shutil.which("python") - 'C:\\Python33\\python.exe' + 'C:\\Python33\\python.EXE' .. versionadded:: 3.3 diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1318,7 +1318,7 @@ # Ask for the file without the ".exe" extension, then ensure that # it gets found properly with the extension. rv = shutil.which(self.temp_file.name[:-4], path=self.dir) - self.assertEqual(rv, self.temp_file.name[:-4] + ".exe") + self.assertEqual(rv, self.temp_file.name[:-4] + ".EXE") class TestMove(unittest.TestCase): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 09:33:25 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Jan 2013 09:33:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_shutil=2Ewhich=28=29_test_for_issue_=2316993=2E?= Message-ID: <3Yr2vn5vydzQvk@mail.python.org> http://hg.python.org/cpython/rev/e8f40d4f497c changeset: 81646:e8f40d4f497c parent: 81644:6877957a5e91 parent: 81645:28282e4e9d04 user: Serhiy Storchaka date: Tue Jan 22 10:32:16 2013 +0200 summary: Fix shutil.which() test for issue #16993. files: Doc/library/shutil.rst | 2 +- Lib/test/test_shutil.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -348,7 +348,7 @@ directories. For example, on Windows:: >>> shutil.which("python") - 'C:\\Python33\\python.exe' + 'C:\\Python33\\python.EXE' .. versionadded:: 3.3 diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1329,7 +1329,7 @@ # Ask for the file without the ".exe" extension, then ensure that # it gets found properly with the extension. rv = shutil.which(self.temp_file.name[:-4], path=self.dir) - self.assertEqual(rv, self.temp_file.name[:-4] + ".exe") + self.assertEqual(rv, self.temp_file.name[:-4] + ".EXE") class TestMove(unittest.TestCase): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 14:13:56 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 22 Jan 2013 14:13:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Updated_loggin?= =?utf-8?q?g_HOWTO_with_a_diagram=2E?= Message-ID: <3Yr97S24JHzMd5@mail.python.org> http://hg.python.org/cpython/rev/211ff7f0e96a changeset: 81647:211ff7f0e96a branch: 2.7 parent: 81641:8de6f92c89e6 user: Vinay Sajip date: Tue Jan 22 13:10:58 2013 +0000 summary: Updated logging HOWTO with a diagram. files: Doc/howto/logging.rst | 10 ++++++++++ Doc/howto/logging_flow.png | Bin 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -330,6 +330,9 @@ to output. * Formatters specify the layout of log records in the final output. +Log event information is passed between loggers, handlers, filters and +formatters in a :class:`LogRecord` instance. + Logging is performed by calling methods on instances of the :class:`Logger` class (hereafter called :dfn:`loggers`). Each instance has a name, and they are conceptually arranged in a namespace hierarchy using dots (periods) as @@ -374,6 +377,13 @@ *format* keyword argument. For all options regarding how a format string is constructed, see :ref:`formatter-objects`. +Logging Flow +^^^^^^^^^^^^ + +The flow of log event information in loggers and handlers is illustrated in the +following diagram. + +.. image:: logging_flow.png Loggers ^^^^^^^ diff --git a/Doc/howto/logging_flow.png b/Doc/howto/logging_flow.png new file mode 100755 index 0000000000000000000000000000000000000000..a88382309a18df821496c27863b17caeb68962f7 GIT binary patch [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 14:13:57 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 22 Jan 2013 14:13:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Updated_loggin?= =?utf-8?q?g_HOWTO_with_a_diagram=2E?= Message-ID: <3Yr97T52gHzRFw@mail.python.org> http://hg.python.org/cpython/rev/1ff413ba4414 changeset: 81648:1ff413ba4414 branch: 3.2 parent: 81642:c8614ec54a63 user: Vinay Sajip date: Tue Jan 22 13:12:34 2013 +0000 summary: Updated logging HOWTO with a diagram. files: Doc/howto/logging.rst | 10 ++++++++++ Doc/howto/logging_flow.png | Bin 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -330,6 +330,9 @@ to output. * Formatters specify the layout of log records in the final output. +Log event information is passed between loggers, handlers, filters and +formatters in a :class:`LogRecord` instance. + Logging is performed by calling methods on instances of the :class:`Logger` class (hereafter called :dfn:`loggers`). Each instance has a name, and they are conceptually arranged in a namespace hierarchy using dots (periods) as @@ -374,6 +377,13 @@ *format* keyword argument. For all options regarding how a format string is constructed, see :ref:`formatter-objects`. +Logging Flow +^^^^^^^^^^^^ + +The flow of log event information in loggers and handlers is illustrated in the +following diagram. + +.. image:: logging_flow.png Loggers ^^^^^^^ diff --git a/Doc/howto/logging_flow.png b/Doc/howto/logging_flow.png new file mode 100755 index 0000000000000000000000000000000000000000..a88382309a18df821496c27863b17caeb68962f7 GIT binary patch [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 14:13:59 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 22 Jan 2013 14:13:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merged_documentation_update_from_3=2E2=2E?= Message-ID: <3Yr97W0TgwzNfJ@mail.python.org> http://hg.python.org/cpython/rev/cf3ee6c9303d changeset: 81649:cf3ee6c9303d branch: 3.3 parent: 81645:28282e4e9d04 parent: 81648:1ff413ba4414 user: Vinay Sajip date: Tue Jan 22 13:13:16 2013 +0000 summary: Merged documentation update from 3.2. files: Doc/howto/logging.rst | 10 ++++++++++ Doc/howto/logging_flow.png | Bin 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -330,6 +330,9 @@ to output. * Formatters specify the layout of log records in the final output. +Log event information is passed between loggers, handlers, filters and +formatters in a :class:`LogRecord` instance. + Logging is performed by calling methods on instances of the :class:`Logger` class (hereafter called :dfn:`loggers`). Each instance has a name, and they are conceptually arranged in a namespace hierarchy using dots (periods) as @@ -374,6 +377,13 @@ *format* keyword argument. For all options regarding how a format string is constructed, see :ref:`formatter-objects`. +Logging Flow +^^^^^^^^^^^^ + +The flow of log event information in loggers and handlers is illustrated in the +following diagram. + +.. image:: logging_flow.png Loggers ^^^^^^^ diff --git a/Doc/howto/logging_flow.png b/Doc/howto/logging_flow.png new file mode 100755 index 0000000000000000000000000000000000000000..a88382309a18df821496c27863b17caeb68962f7 GIT binary patch [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 14:14:00 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 22 Jan 2013 14:14:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merged_documentation_update_from_3=2E3=2E?= Message-ID: <3Yr97X37YNzRFQ@mail.python.org> http://hg.python.org/cpython/rev/9240544f3eda changeset: 81650:9240544f3eda parent: 81646:e8f40d4f497c parent: 81649:cf3ee6c9303d user: Vinay Sajip date: Tue Jan 22 13:13:43 2013 +0000 summary: Merged documentation update from 3.3. files: Doc/howto/logging.rst | 10 ++++++++++ Doc/howto/logging_flow.png | Bin 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -330,6 +330,9 @@ to output. * Formatters specify the layout of log records in the final output. +Log event information is passed between loggers, handlers, filters and +formatters in a :class:`LogRecord` instance. + Logging is performed by calling methods on instances of the :class:`Logger` class (hereafter called :dfn:`loggers`). Each instance has a name, and they are conceptually arranged in a namespace hierarchy using dots (periods) as @@ -374,6 +377,13 @@ *format* keyword argument. For all options regarding how a format string is constructed, see :ref:`formatter-objects`. +Logging Flow +^^^^^^^^^^^^ + +The flow of log event information in loggers and handlers is illustrated in the +following diagram. + +.. image:: logging_flow.png Loggers ^^^^^^^ diff --git a/Doc/howto/logging_flow.png b/Doc/howto/logging_flow.png new file mode 100755 index 0000000000000000000000000000000000000000..a88382309a18df821496c27863b17caeb68962f7 GIT binary patch [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 14:59:30 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Jan 2013 14:59:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzE1NTQ2OiBGaXgg?= =?utf-8?q?GzipFile=2Epeek=28=29=27s_handling_of_pathological_input_data?= =?utf-8?q?=2E?= Message-ID: <3YrB8256LVzPYg@mail.python.org> http://hg.python.org/cpython/rev/0f25119ceee8 changeset: 81651:0f25119ceee8 branch: 3.2 parent: 81648:1ff413ba4414 user: Serhiy Storchaka date: Tue Jan 22 15:54:48 2013 +0200 summary: #15546: Fix GzipFile.peek()'s handling of pathological input data. This is a backport of changeset 8c07ff7f882f. files: Lib/gzip.py | 6 ++++-- Misc/NEWS | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -367,8 +367,10 @@ if self.fileobj is None: return b'' try: - # 1024 is the same buffering heuristic used in read() - self._read(max(n, 1024)) + # Ensure that we don't return b"" if we haven't reached EOF. + while self.extrasize == 0: + # 1024 is the same buffering heuristic used in read() + self._read(max(n, 1024)) except EOFError: pass offset = self.offset - self.extrastart diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -466,6 +466,9 @@ - Issue #15424: Add a __sizeof__ implementation for array objects. Patch by Ludwig H?hne. +- Issue #15546: Fix handling of pathological input data in the peek() method + of the GzipFile class. + - Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog ended with '\'. Patch by Roger Serwy. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 14:59:32 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Jan 2013 14:59:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null_merge?= Message-ID: <3YrB840nklzRFw@mail.python.org> http://hg.python.org/cpython/rev/6b1e393ba874 changeset: 81652:6b1e393ba874 branch: 3.3 parent: 81649:cf3ee6c9303d parent: 81651:0f25119ceee8 user: Serhiy Storchaka date: Tue Jan 22 15:56:29 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 14:59:33 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Jan 2013 14:59:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3YrB853VnzzRGs@mail.python.org> http://hg.python.org/cpython/rev/90dd276d3beb changeset: 81653:90dd276d3beb parent: 81650:9240544f3eda parent: 81652:6b1e393ba874 user: Serhiy Storchaka date: Tue Jan 22 15:57:26 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 15:15:39 2013 From: python-checkins at python.org (eli.bendersky) Date: Tue, 22 Jan 2013 15:15:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Add_some_tests?= =?utf-8?q?_for_XPath_numeric_indexing?= Message-ID: <3YrBVg5PskzN9h@mail.python.org> http://hg.python.org/cpython/rev/2e2351733a6f changeset: 81654:2e2351733a6f branch: 3.3 parent: 81652:6b1e393ba874 user: Eli Bendersky date: Tue Jan 22 06:12:54 2013 -0800 summary: Add some tests for XPath numeric indexing files: Lib/test/test_xml_etree.py | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1776,6 +1776,23 @@ # Issue #16922 self.assertEqual(ET.XML('').findtext('empty'), '') + def test_find_xpath(self): + LINEAR_XML = ''' + + + + + + ''' + e = ET.XML(LINEAR_XML) + + # Test for numeric indexing and last() + self.assertEqual(e.find('./tag[1]').attrib['class'], 'a') + self.assertEqual(e.find('./tag[2]').attrib['class'], 'b') + self.assertEqual(e.find('./tag[last()]').attrib['class'], 'd') + self.assertEqual(e.find('./tag[last()-1]').attrib['class'], 'c') + self.assertEqual(e.find('./tag[last()-2]').attrib['class'], 'b') + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 15:15:41 2013 From: python-checkins at python.org (eli.bendersky) Date: Tue, 22 Jan 2013 15:15:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Add_some_tests_for_XPath_numeric_indexing?= Message-ID: <3YrBVj1F1czQyg@mail.python.org> http://hg.python.org/cpython/rev/05b41ae10db8 changeset: 81655:05b41ae10db8 parent: 81653:90dd276d3beb parent: 81654:2e2351733a6f user: Eli Bendersky date: Tue Jan 22 06:15:29 2013 -0800 summary: Add some tests for XPath numeric indexing files: Lib/test/test_xml_etree.py | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1776,6 +1776,23 @@ # Issue #16922 self.assertEqual(ET.XML('').findtext('empty'), '') + def test_find_xpath(self): + LINEAR_XML = ''' + + + + + + ''' + e = ET.XML(LINEAR_XML) + + # Test for numeric indexing and last() + self.assertEqual(e.find('./tag[1]').attrib['class'], 'a') + self.assertEqual(e.find('./tag[2]').attrib['class'], 'b') + self.assertEqual(e.find('./tag[last()]').attrib['class'], 'd') + self.assertEqual(e.find('./tag[last()-1]').attrib['class'], 'c') + self.assertEqual(e.find('./tag[last()-2]').attrib['class'], 'b') + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 16:17:02 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Jan 2013 16:17:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzExNTkw?= =?utf-8?q?51=3A_GzipFile_now_raises_EOFError_when_reading_a_corrupted_fil?= =?utf-8?q?e?= Message-ID: <3YrCsV4PWmzS7X@mail.python.org> http://hg.python.org/cpython/rev/174332b89a0d changeset: 81656:174332b89a0d branch: 3.2 parent: 81651:0f25119ceee8 user: Serhiy Storchaka date: Tue Jan 22 17:01:59 2013 +0200 summary: Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. Added tests for reading truncated gzip and bzip2 files. files: Lib/gzip.py | 72 ++++++++++++++---------------- Lib/test/test_bz2.py | 18 +++++++ Lib/test/test_gzip.py | 15 ++++++ Misc/NEWS | 3 + 4 files changed, 70 insertions(+), 38 deletions(-) diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -33,9 +33,6 @@ # or unsigned. output.write(struct.pack(" self.extrasize: - self._read(readsize) - readsize = min(self.max_read_chunk, readsize * 2) - except EOFError: - if size > self.extrasize: - size = self.extrasize + while size > self.extrasize: + if not self._read(readsize): + if size > self.extrasize: + size = self.extrasize + break + readsize = min(self.max_read_chunk, readsize * 2) offset = self.offset - self.extrastart chunk = self.extrabuf[offset: offset + size] @@ -366,12 +364,9 @@ if self.extrasize == 0: if self.fileobj is None: return b'' - try: - # Ensure that we don't return b"" if we haven't reached EOF. - while self.extrasize == 0: - # 1024 is the same buffering heuristic used in read() - self._read(max(n, 1024)) - except EOFError: + # Ensure that we don't return b"" if we haven't reached EOF. + # 1024 is the same buffering heuristic used in read() + while self.extrasize == 0 and self._read(max(n, 1024)): pass offset = self.offset - self.extrastart remaining = self.extrasize @@ -384,13 +379,14 @@ def _read(self, size=1024): if self.fileobj is None: - raise EOFError("Reached EOF") + return False if self._new_member: # If the _new_member flag is set, we have to # jump to the next member, if there is one. self._init_read() - self._read_gzip_header() + if not self._read_gzip_header(): + return False self.decompress = zlib.decompressobj(-zlib.MAX_WBITS) self._new_member = False @@ -407,7 +403,7 @@ self.fileobj.prepend(self.decompress.unused_data, True) self._read_eof() self._add_read_data( uncompress ) - raise EOFError('Reached EOF') + return False uncompress = self.decompress.decompress(buf) self._add_read_data( uncompress ) @@ -423,6 +419,7 @@ # a new member on the next call self._read_eof() self._new_member = True + return True def _add_read_data(self, data): self.crc = zlib.crc32(data, self.crc) & 0xffffffff @@ -437,8 +434,7 @@ # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. - crc32 = read32(self.fileobj) - isize = read32(self.fileobj) # may exceed 2GB + crc32, isize = struct.unpack(" http://hg.python.org/cpython/rev/87171e88847b changeset: 81657:87171e88847b branch: 3.3 parent: 81654:2e2351733a6f parent: 81656:174332b89a0d user: Serhiy Storchaka date: Tue Jan 22 17:07:49 2013 +0200 summary: Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. Added tests for reading truncated gzip, bzip2, and lzma files. files: Lib/gzip.py | 81 ++++++++++++++---------------- Lib/test/test_bz2.py | 14 +++++ Lib/test/test_gzip.py | 14 +++++ Lib/test/test_lzma.py | 14 +++++ Misc/NEWS | 3 + 5 files changed, 82 insertions(+), 44 deletions(-) diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -65,9 +65,6 @@ # or unsigned. output.write(struct.pack(" self.extrasize: - self._read(readsize) - readsize = min(self.max_read_chunk, readsize * 2) - except EOFError: - if size > self.extrasize: - size = self.extrasize + while size > self.extrasize: + if not self._read(readsize): + if size > self.extrasize: + size = self.extrasize + break + readsize = min(self.max_read_chunk, readsize * 2) offset = self.offset - self.extrastart chunk = self.extrabuf[offset: offset + size] @@ -385,12 +383,9 @@ if self.extrasize <= 0 and self.fileobj is None: return b'' - try: - # For certain input data, a single call to _read() may not return - # any data. In this case, retry until we get some data or reach EOF. - while self.extrasize <= 0: - self._read() - except EOFError: + # For certain input data, a single call to _read() may not return + # any data. In this case, retry until we get some data or reach EOF. + while self.extrasize <= 0 and self._read(): pass if size < 0 or size > self.extrasize: size = self.extrasize @@ -413,12 +408,9 @@ if self.extrasize == 0: if self.fileobj is None: return b'' - try: - # Ensure that we don't return b"" if we haven't reached EOF. - while self.extrasize == 0: - # 1024 is the same buffering heuristic used in read() - self._read(max(n, 1024)) - except EOFError: + # Ensure that we don't return b"" if we haven't reached EOF. + # 1024 is the same buffering heuristic used in read() + while self.extrasize == 0 and self._read(max(n, 1024)): pass offset = self.offset - self.extrastart remaining = self.extrasize @@ -431,13 +423,14 @@ def _read(self, size=1024): if self.fileobj is None: - raise EOFError("Reached EOF") + return False if self._new_member: # If the _new_member flag is set, we have to # jump to the next member, if there is one. self._init_read() - self._read_gzip_header() + if not self._read_gzip_header(): + return False self.decompress = zlib.decompressobj(-zlib.MAX_WBITS) self._new_member = False @@ -454,7 +447,7 @@ self.fileobj.prepend(self.decompress.unused_data, True) self._read_eof() self._add_read_data( uncompress ) - raise EOFError('Reached EOF') + return False uncompress = self.decompress.decompress(buf) self._add_read_data( uncompress ) @@ -470,6 +463,7 @@ # a new member on the next call self._read_eof() self._new_member = True + return True def _add_read_data(self, data): self.crc = zlib.crc32(data, self.crc) & 0xffffffff @@ -484,8 +478,7 @@ # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. - crc32 = read32(self.fileobj) - isize = read32(self.fileobj) # may exceed 2GB + crc32, isize = struct.unpack(" http://hg.python.org/cpython/rev/f2f947cdc5fe changeset: 81658:f2f947cdc5fe parent: 81655:05b41ae10db8 parent: 81657:87171e88847b user: Serhiy Storchaka date: Tue Jan 22 17:11:07 2013 +0200 summary: Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. Added tests for reading truncated gzip, bzip2, and lzma files. files: Lib/gzip.py | 81 ++++++++++++++---------------- Lib/test/test_bz2.py | 13 ++++ Lib/test/test_gzip.py | 14 +++++ Lib/test/test_lzma.py | 14 +++++ Misc/NEWS | 3 + 5 files changed, 81 insertions(+), 44 deletions(-) diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -65,9 +65,6 @@ # or unsigned. output.write(struct.pack(" self.extrasize: - self._read(readsize) - readsize = min(self.max_read_chunk, readsize * 2) - except EOFError: - if size > self.extrasize: - size = self.extrasize + while size > self.extrasize: + if not self._read(readsize): + if size > self.extrasize: + size = self.extrasize + break + readsize = min(self.max_read_chunk, readsize * 2) offset = self.offset - self.extrastart chunk = self.extrabuf[offset: offset + size] @@ -385,12 +383,9 @@ if self.extrasize <= 0 and self.fileobj is None: return b'' - try: - # For certain input data, a single call to _read() may not return - # any data. In this case, retry until we get some data or reach EOF. - while self.extrasize <= 0: - self._read() - except EOFError: + # For certain input data, a single call to _read() may not return + # any data. In this case, retry until we get some data or reach EOF. + while self.extrasize <= 0 and self._read(): pass if size < 0 or size > self.extrasize: size = self.extrasize @@ -413,12 +408,9 @@ if self.extrasize == 0: if self.fileobj is None: return b'' - try: - # Ensure that we don't return b"" if we haven't reached EOF. - while self.extrasize == 0: - # 1024 is the same buffering heuristic used in read() - self._read(max(n, 1024)) - except EOFError: + # Ensure that we don't return b"" if we haven't reached EOF. + # 1024 is the same buffering heuristic used in read() + while self.extrasize == 0 and self._read(max(n, 1024)): pass offset = self.offset - self.extrastart remaining = self.extrasize @@ -431,13 +423,14 @@ def _read(self, size=1024): if self.fileobj is None: - raise EOFError("Reached EOF") + return False if self._new_member: # If the _new_member flag is set, we have to # jump to the next member, if there is one. self._init_read() - self._read_gzip_header() + if not self._read_gzip_header(): + return False self.decompress = zlib.decompressobj(-zlib.MAX_WBITS) self._new_member = False @@ -454,7 +447,7 @@ self.fileobj.prepend(self.decompress.unused_data, True) self._read_eof() self._add_read_data( uncompress ) - raise EOFError('Reached EOF') + return False uncompress = self.decompress.decompress(buf) self._add_read_data( uncompress ) @@ -470,6 +463,7 @@ # a new member on the next call self._read_eof() self._new_member = True + return True def _add_read_data(self, data): self.crc = zlib.crc32(data, self.crc) & 0xffffffff @@ -484,8 +478,7 @@ # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. - crc32 = read32(self.fileobj) - isize = read32(self.fileobj) # may exceed 2GB + crc32, isize = struct.unpack(" http://hg.python.org/cpython/rev/214d8909513d changeset: 81659:214d8909513d branch: 2.7 parent: 81647:211ff7f0e96a user: Serhiy Storchaka date: Tue Jan 22 17:13:26 2013 +0200 summary: Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. Added tests for reading truncated gzip and bzip2 files. files: Lib/gzip.py | 68 ++++++++++++++---------------- Lib/test/test_bz2.py | 18 ++++++++ Lib/test/test_gzip.py | 18 ++++++++ Misc/NEWS | 3 + 4 files changed, 71 insertions(+), 36 deletions(-) diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -21,9 +21,6 @@ # or unsigned. output.write(struct.pack(" self.extrasize: - self._read(readsize) - readsize = min(self.max_read_chunk, readsize * 2) - except EOFError: - if size > self.extrasize: - size = self.extrasize + while size > self.extrasize: + if not self._read(readsize): + if size > self.extrasize: + size = self.extrasize + break + readsize = min(self.max_read_chunk, readsize * 2) offset = self.offset - self.extrastart chunk = self.extrabuf[offset: offset + size] @@ -277,7 +274,7 @@ def _read(self, size=1024): if self.fileobj is None: - raise EOFError, "Reached EOF" + return False if self._new_member: # If the _new_member flag is set, we have to @@ -288,7 +285,7 @@ pos = self.fileobj.tell() # Save current position self.fileobj.seek(0, 2) # Seek to end of file if pos == self.fileobj.tell(): - raise EOFError, "Reached EOF" + return False else: self.fileobj.seek( pos ) # Return to original position @@ -305,9 +302,10 @@ if buf == "": uncompress = self.decompress.flush() + self.fileobj.seek(-len(self.decompress.unused_data), 1) self._read_eof() self._add_read_data( uncompress ) - raise EOFError, 'Reached EOF' + return False uncompress = self.decompress.decompress(buf) self._add_read_data( uncompress ) @@ -317,13 +315,14 @@ # so seek back to the start of the unused data, finish up # this member, and read a new gzip header. # (The number of bytes to seek back is the length of the unused - # data, minus 8 because _read_eof() will rewind a further 8 bytes) - self.fileobj.seek( -len(self.decompress.unused_data)+8, 1) + # data) + self.fileobj.seek(-len(self.decompress.unused_data), 1) # Check the CRC and file size, and set the flag so we read # a new member on the next call self._read_eof() self._new_member = True + return True def _add_read_data(self, data): self.crc = zlib.crc32(data, self.crc) & 0xffffffffL @@ -334,14 +333,11 @@ self.size = self.size + len(data) def _read_eof(self): - # We've read to the end of the file, so we have to rewind in order - # to reread the 8 bytes containing the CRC and the file size. + # We've read to the end of the file. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. - self.fileobj.seek(-8, 1) - crc32 = read32(self.fileobj) - isize = read32(self.fileobj) # may exceed 2GB + crc32, isize = struct.unpack(" http://hg.python.org/cpython/rev/506abee7a764 changeset: 81660:506abee7a764 branch: 2.7 user: Vinay Sajip date: Tue Jan 22 15:57:12 2013 +0000 summary: Added cookbook recipe for structured logging. files: Doc/howto/logging-cookbook.rst | 75 ++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -790,3 +790,78 @@ but your messages will not be RFC 5424-compliant, and your syslog daemon may complain. + +Implementing structured logging +------------------------------- + +Although most logging messages are intended for reading by humans, and thus not +readily machine-parseable, there might be cirumstances where you want to output +messages in a structured format which *is* capable of being parsed by a program +(without needed complex regular expressions to parse the log message). This is +straightforward to achieve using the logging package. There are a number of +ways in which this could be achieved, but the following is a simple approach +which uses JSON to serialise the event in a machine-parseable manner:: + + import json + import logging + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + return '%s >>> %s' % (self.message, json.dumps(self.kwargs)) + + _ = StructuredMessage # optional, to improve readability + + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456)) + +If the above script is run, it prints:: + + message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} + +If you need more specialised processing, you can use a custom JSON encoder, +as in the following complete example:: + + from __future__ import unicode_literals + + import json + import logging + + try: + unicode + except NameError: + unicode = str + + class Encoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, set): + return tuple(o) + elif isinstance(o, unicode): + return o.encode('unicode_escape').decode('ascii') + return super(Encoder, self).default(o) + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + s = Encoder().encode(self.kwargs) + return '%s >>> %s' % (self.message, s) + + _ = StructuredMessage + + def main(): + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', set_value=set([1, 2, 3]), snowman='\u2603')) + + if __name__ == '__main__': + main() + +When the above script is run, it prints:: + + message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 16:58:56 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 22 Jan 2013 16:58:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Added_cookbook?= =?utf-8?q?_recipe_for_structured_logging=2E?= Message-ID: <3YrDnr2lWwzSCp@mail.python.org> http://hg.python.org/cpython/rev/66029d1bd35f changeset: 81661:66029d1bd35f branch: 3.2 parent: 81656:174332b89a0d user: Vinay Sajip date: Tue Jan 22 15:57:39 2013 +0000 summary: Added cookbook recipe for structured logging. files: Doc/howto/logging-cookbook.rst | 75 ++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1588,3 +1588,78 @@ RFC 5424-compliant messages. If you don't, logging may not complain, but your messages will not be RFC 5424-compliant, and your syslog daemon may complain. + +Implementing structured logging +------------------------------- + +Although most logging messages are intended for reading by humans, and thus not +readily machine-parseable, there might be cirumstances where you want to output +messages in a structured format which *is* capable of being parsed by a program +(without needed complex regular expressions to parse the log message). This is +straightforward to achieve using the logging package. There are a number of +ways in which this could be achieved, but the following is a simple approach +which uses JSON to serialise the event in a machine-parseable manner:: + + import json + import logging + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + return '%s >>> %s' % (self.message, json.dumps(self.kwargs)) + + _ = StructuredMessage # optional, to improve readability + + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456)) + +If the above script is run, it prints:: + + message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} + +If you need more specialised processing, you can use a custom JSON encoder, +as in the following complete example:: + + from __future__ import unicode_literals + + import json + import logging + + try: + unicode + except NameError: + unicode = str + + class Encoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, set): + return tuple(o) + elif isinstance(o, unicode): + return o.encode('unicode_escape').decode('ascii') + return super(Encoder, self).default(o) + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + s = Encoder().encode(self.kwargs) + return '%s >>> %s' % (self.message, s) + + _ = StructuredMessage + + def main(): + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', set_value=set([1, 2, 3]), snowman='\u2603')) + + if __name__ == '__main__': + main() + +When the above script is run, it prints:: + + message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 16:58:57 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 22 Jan 2013 16:58:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merged_doc_update_from_3=2E2=2E?= Message-ID: <3YrDns5XGWzP60@mail.python.org> http://hg.python.org/cpython/rev/f4e00073e80c changeset: 81662:f4e00073e80c branch: 3.3 parent: 81657:87171e88847b parent: 81661:66029d1bd35f user: Vinay Sajip date: Tue Jan 22 15:58:14 2013 +0000 summary: Merged doc update from 3.2. files: Doc/howto/logging-cookbook.rst | 75 ++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1615,3 +1615,78 @@ RFC 5424-compliant messages. If you don't, logging may not complain, but your messages will not be RFC 5424-compliant, and your syslog daemon may complain. + +Implementing structured logging +------------------------------- + +Although most logging messages are intended for reading by humans, and thus not +readily machine-parseable, there might be cirumstances where you want to output +messages in a structured format which *is* capable of being parsed by a program +(without needed complex regular expressions to parse the log message). This is +straightforward to achieve using the logging package. There are a number of +ways in which this could be achieved, but the following is a simple approach +which uses JSON to serialise the event in a machine-parseable manner:: + + import json + import logging + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + return '%s >>> %s' % (self.message, json.dumps(self.kwargs)) + + _ = StructuredMessage # optional, to improve readability + + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456)) + +If the above script is run, it prints:: + + message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} + +If you need more specialised processing, you can use a custom JSON encoder, +as in the following complete example:: + + from __future__ import unicode_literals + + import json + import logging + + try: + unicode + except NameError: + unicode = str + + class Encoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, set): + return tuple(o) + elif isinstance(o, unicode): + return o.encode('unicode_escape').decode('ascii') + return super(Encoder, self).default(o) + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + s = Encoder().encode(self.kwargs) + return '%s >>> %s' % (self.message, s) + + _ = StructuredMessage + + def main(): + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', set_value=set([1, 2, 3]), snowman='\u2603')) + + if __name__ == '__main__': + main() + +When the above script is run, it prints:: + + message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 16:58:59 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 22 Jan 2013 16:58:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merged_doc_update_from_3=2E3=2E?= Message-ID: <3YrDnv1fMfzSCk@mail.python.org> http://hg.python.org/cpython/rev/73024d00208f changeset: 81663:73024d00208f parent: 81658:f2f947cdc5fe parent: 81662:f4e00073e80c user: Vinay Sajip date: Tue Jan 22 15:58:34 2013 +0000 summary: Merged doc update from 3.3. files: Doc/howto/logging-cookbook.rst | 75 ++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1613,3 +1613,78 @@ RFC 5424-compliant messages. If you don't, logging may not complain, but your messages will not be RFC 5424-compliant, and your syslog daemon may complain. + +Implementing structured logging +------------------------------- + +Although most logging messages are intended for reading by humans, and thus not +readily machine-parseable, there might be cirumstances where you want to output +messages in a structured format which *is* capable of being parsed by a program +(without needed complex regular expressions to parse the log message). This is +straightforward to achieve using the logging package. There are a number of +ways in which this could be achieved, but the following is a simple approach +which uses JSON to serialise the event in a machine-parseable manner:: + + import json + import logging + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + return '%s >>> %s' % (self.message, json.dumps(self.kwargs)) + + _ = StructuredMessage # optional, to improve readability + + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456)) + +If the above script is run, it prints:: + + message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} + +If you need more specialised processing, you can use a custom JSON encoder, +as in the following complete example:: + + from __future__ import unicode_literals + + import json + import logging + + try: + unicode + except NameError: + unicode = str + + class Encoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, set): + return tuple(o) + elif isinstance(o, unicode): + return o.encode('unicode_escape').decode('ascii') + return super(Encoder, self).default(o) + + class StructuredMessage(object): + def __init__(self, message, **kwargs): + self.message = message + self.kwargs = kwargs + + def __str__(self): + s = Encoder().encode(self.kwargs) + return '%s >>> %s' % (self.message, s) + + _ = StructuredMessage + + def main(): + logging.basicConfig(level=logging.INFO, format='%(message)s') + logging.info(_('message 1', set_value=set([1, 2, 3]), snowman='\u2603')) + + if __name__ == '__main__': + main() + +When the above script is run, it prints:: + + message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 21:50:23 2013 From: python-checkins at python.org (ezio.melotti) Date: Tue, 22 Jan 2013 21:50:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzExMzc5OiByZXBo?= =?utf-8?q?rase_minidom_documentation_to_use_the_term_=22minimal=22_instea?= =?utf-8?q?d_of?= Message-ID: <3YrMG71CTFzPB1@mail.python.org> http://hg.python.org/cpython/rev/c2ae1ed03853 changeset: 81664:c2ae1ed03853 branch: 2.7 parent: 81660:506abee7a764 user: Ezio Melotti date: Tue Jan 22 22:47:57 2013 +0200 summary: #11379: rephrase minidom documentation to use the term "minimal" instead of "lightweight". Patch by ?ric Araujo. files: Doc/library/xml.dom.minidom.rst | 22 +++++++------------- Lib/xml/dom/minidom.py | 5 ++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -1,8 +1,8 @@ -:mod:`xml.dom.minidom` --- Lightweight DOM implementation -========================================================= +:mod:`xml.dom.minidom` --- Minimal DOM implementation +===================================================== .. module:: xml.dom.minidom - :synopsis: Lightweight Document Object Model (DOM) implementation. + :synopsis: Minimal Document Object Model (DOM) implementation. .. moduleauthor:: Paul Prescod .. sectionauthor:: Paul Prescod .. sectionauthor:: Martin v. L?wis @@ -14,17 +14,11 @@ -------------- -:mod:`xml.dom.minidom` is a light-weight implementation of the Document Object -Model interface. It is intended to be simpler than the full DOM and also -significantly smaller. - -.. note:: - - The :mod:`xml.dom.minidom` module provides an implementation of the W3C-DOM, - with an API similar to that in other programming languages. Users who are - unfamiliar with the W3C-DOM interface or who would like to write less code - for processing XML files should consider using the - :mod:`xml.etree.ElementTree` module instead. +:mod:`xml.dom.minidom` is a minimal implementation of the Document Object +Model interface, with an API similar to that in other languages. It is intended +to be simpler than the full DOM and also significantly smaller. Users who are +not already proficient with the DOM should consider using the +:mod:`xml.etree.ElementTree` module for their XML processing instead DOM applications typically start by parsing some XML into a DOM. With :mod:`xml.dom.minidom`, this is done through the parse functions:: diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -1,5 +1,6 @@ -"""\ -minidom.py -- a lightweight DOM implementation. +"""Simple implementation of the Level 1 DOM. + +Namespaces and other minor Level 2 features are also supported. parse("foo.xml") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 21:50:24 2013 From: python-checkins at python.org (ezio.melotti) Date: Tue, 22 Jan 2013 21:50:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogIzExMzc5OiByZXBo?= =?utf-8?q?rase_minidom_documentation_to_use_the_term_=22minimal=22_instea?= =?utf-8?q?d_of?= Message-ID: <3YrMG83xMfzSNk@mail.python.org> http://hg.python.org/cpython/rev/b9c0e050c935 changeset: 81665:b9c0e050c935 branch: 3.2 parent: 81661:66029d1bd35f user: Ezio Melotti date: Tue Jan 22 22:47:57 2013 +0200 summary: #11379: rephrase minidom documentation to use the term "minimal" instead of "lightweight". Patch by ?ric Araujo. files: Doc/library/xml.dom.minidom.rst | 22 +++++++------------- Lib/xml/dom/minidom.py | 5 ++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -1,8 +1,8 @@ -:mod:`xml.dom.minidom` --- Lightweight DOM implementation -========================================================= +:mod:`xml.dom.minidom` --- Minimal DOM implementation +===================================================== .. module:: xml.dom.minidom - :synopsis: Lightweight Document Object Model (DOM) implementation. + :synopsis: Minimal Document Object Model (DOM) implementation. .. moduleauthor:: Paul Prescod .. sectionauthor:: Paul Prescod .. sectionauthor:: Martin v. L?wis @@ -11,17 +11,11 @@ -------------- -:mod:`xml.dom.minidom` is a light-weight implementation of the Document Object -Model interface. It is intended to be simpler than the full DOM and also -significantly smaller. - -.. note:: - - The :mod:`xml.dom.minidom` module provides an implementation of the W3C-DOM, - with an API similar to that in other programming languages. Users who are - unfamiliar with the W3C-DOM interface or who would like to write less code - for processing XML files should consider using the - :mod:`xml.etree.ElementTree` module instead. +:mod:`xml.dom.minidom` is a minimal implementation of the Document Object +Model interface, with an API similar to that in other languages. It is intended +to be simpler than the full DOM and also significantly smaller. Users who are +not already proficient with the DOM should consider using the +:mod:`xml.etree.ElementTree` module for their XML processing instead DOM applications typically start by parsing some XML into a DOM. With :mod:`xml.dom.minidom`, this is done through the parse functions:: diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -1,5 +1,6 @@ -"""\ -minidom.py -- a lightweight DOM implementation. +"""Simple implementation of the Level 1 DOM. + +Namespaces and other minor Level 2 features are also supported. parse("foo.xml") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 21:50:25 2013 From: python-checkins at python.org (ezio.melotti) Date: Tue, 22 Jan 2013 21:50:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_=2311379=3A_merge_with_3=2E2=2E?= Message-ID: <3YrMG96ds8zSPn@mail.python.org> http://hg.python.org/cpython/rev/8ff512910338 changeset: 81666:8ff512910338 branch: 3.3 parent: 81662:f4e00073e80c parent: 81665:b9c0e050c935 user: Ezio Melotti date: Tue Jan 22 22:49:46 2013 +0200 summary: #11379: merge with 3.2. files: Doc/library/xml.dom.minidom.rst | 22 +++++++------------- Lib/xml/dom/minidom.py | 5 ++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -1,8 +1,8 @@ -:mod:`xml.dom.minidom` --- Lightweight DOM implementation -========================================================= +:mod:`xml.dom.minidom` --- Minimal DOM implementation +===================================================== .. module:: xml.dom.minidom - :synopsis: Lightweight Document Object Model (DOM) implementation. + :synopsis: Minimal Document Object Model (DOM) implementation. .. moduleauthor:: Paul Prescod .. sectionauthor:: Paul Prescod .. sectionauthor:: Martin v. L?wis @@ -11,17 +11,11 @@ -------------- -:mod:`xml.dom.minidom` is a light-weight implementation of the Document Object -Model interface. It is intended to be simpler than the full DOM and also -significantly smaller. - -.. note:: - - The :mod:`xml.dom.minidom` module provides an implementation of the W3C-DOM, - with an API similar to that in other programming languages. Users who are - unfamiliar with the W3C-DOM interface or who would like to write less code - for processing XML files should consider using the - :mod:`xml.etree.ElementTree` module instead. +:mod:`xml.dom.minidom` is a minimal implementation of the Document Object +Model interface, with an API similar to that in other languages. It is intended +to be simpler than the full DOM and also significantly smaller. Users who are +not already proficient with the DOM should consider using the +:mod:`xml.etree.ElementTree` module for their XML processing instead DOM applications typically start by parsing some XML into a DOM. With :mod:`xml.dom.minidom`, this is done through the parse functions:: diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -1,5 +1,6 @@ -"""\ -minidom.py -- a lightweight DOM implementation. +"""Simple implementation of the Level 1 DOM. + +Namespaces and other minor Level 2 features are also supported. parse("foo.xml") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 22 21:50:27 2013 From: python-checkins at python.org (ezio.melotti) Date: Tue, 22 Jan 2013 21:50:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogIzExMzc5OiBtZXJnZSB3aXRoIDMuMy4=?= Message-ID: <3YrMGC2LGjzSQ1@mail.python.org> http://hg.python.org/cpython/rev/9a0cd5363c2a changeset: 81667:9a0cd5363c2a parent: 81663:73024d00208f parent: 81666:8ff512910338 user: Ezio Melotti date: Tue Jan 22 22:50:06 2013 +0200 summary: #11379: merge with 3.3. files: Doc/library/xml.dom.minidom.rst | 22 +++++++------------- Lib/xml/dom/minidom.py | 5 ++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -1,8 +1,8 @@ -:mod:`xml.dom.minidom` --- Lightweight DOM implementation -========================================================= +:mod:`xml.dom.minidom` --- Minimal DOM implementation +===================================================== .. module:: xml.dom.minidom - :synopsis: Lightweight Document Object Model (DOM) implementation. + :synopsis: Minimal Document Object Model (DOM) implementation. .. moduleauthor:: Paul Prescod .. sectionauthor:: Paul Prescod .. sectionauthor:: Martin v. L?wis @@ -11,17 +11,11 @@ -------------- -:mod:`xml.dom.minidom` is a light-weight implementation of the Document Object -Model interface. It is intended to be simpler than the full DOM and also -significantly smaller. - -.. note:: - - The :mod:`xml.dom.minidom` module provides an implementation of the W3C-DOM, - with an API similar to that in other programming languages. Users who are - unfamiliar with the W3C-DOM interface or who would like to write less code - for processing XML files should consider using the - :mod:`xml.etree.ElementTree` module instead. +:mod:`xml.dom.minidom` is a minimal implementation of the Document Object +Model interface, with an API similar to that in other languages. It is intended +to be simpler than the full DOM and also significantly smaller. Users who are +not already proficient with the DOM should consider using the +:mod:`xml.etree.ElementTree` module for their XML processing instead DOM applications typically start by parsing some XML into a DOM. With :mod:`xml.dom.minidom`, this is done through the parse functions:: diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -1,5 +1,6 @@ -"""\ -minidom.py -- a lightweight DOM implementation. +"""Simple implementation of the Level 1 DOM. + +Namespaces and other minor Level 2 features are also supported. parse("foo.xml") -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Wed Jan 23 05:58:42 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 23 Jan 2013 05:58:42 +0100 Subject: [Python-checkins] Daily reference leaks (9a0cd5363c2a): sum=2 Message-ID: results for 9a0cd5363c2a on branch "default" -------------------------------------------- test_support leaked [0, -1, 1] references, sum=0 test_support leaked [0, -1, 3] memory blocks, sum=2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogLyRkDw', '-x'] From python-checkins at python.org Wed Jan 23 09:48:05 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 23 Jan 2013 09:48:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTU3?= =?utf-8?q?=3A_shutil=2Ewhich=28=29_no_longer_searches_a_bare_file_name_in?= =?utf-8?q?_the?= Message-ID: <3YrgBF0zV8zSTP@mail.python.org> http://hg.python.org/cpython/rev/f18d11ab53a0 changeset: 81668:f18d11ab53a0 branch: 3.3 parent: 81666:8ff512910338 user: Serhiy Storchaka date: Wed Jan 23 10:44:21 2013 +0200 summary: Issue #16957: shutil.which() no longer searches a bare file name in the current directory on Unix and no longer searches a relative file path with a directory part in PATH directories. Patch by Thomas Kluyver. files: Lib/shutil.py | 11 +++++--- Lib/test/test_shutil.py | 37 ++++++++++++++++++++++------ Misc/NEWS | 4 +++ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Lib/shutil.py b/Lib/shutil.py --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -1077,10 +1077,13 @@ return (os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)) - # Short circuit. If we're given a full path which matches the mode - # and it exists, we're done here. - if _access_check(cmd, mode): - return cmd + # If we're given a path with a directory part, look it up directly rather + # than referring to PATH directories. This includes checking relative to the + # current directory, e.g. ./script + if os.path.dirname(cmd): + if _access_check(cmd, mode): + return cmd + return None path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1285,11 +1285,36 @@ rv = shutil.which(self.file, path=self.dir) self.assertEqual(rv, self.temp_file.name) - def test_full_path_short_circuit(self): + def test_absolute_cmd(self): # When given the fully qualified path to an executable that exists, # it should be returned. rv = shutil.which(self.temp_file.name, path=self.temp_dir) - self.assertEqual(self.temp_file.name, rv) + self.assertEqual(rv, self.temp_file.name) + + def test_relative_cmd(self): + # When given the relative path with a directory part to an executable + # that exists, it should be returned. + base_dir, tail_dir = os.path.split(self.dir) + relpath = os.path.join(tail_dir, self.file) + with support.temp_cwd(path=base_dir): + rv = shutil.which(relpath, path=self.temp_dir) + self.assertEqual(rv, relpath) + # But it shouldn't be searched in PATH directories (issue #16957). + with support.temp_cwd(path=self.dir): + rv = shutil.which(relpath, path=base_dir) + self.assertIsNone(rv) + + def test_cwd(self): + # Issue #16957 + base_dir = os.path.dirname(self.dir) + with support.temp_cwd(path=self.dir): + rv = shutil.which(self.file, path=base_dir) + if sys.platform == "win32": + # Windows: current directory implicitly on PATH + self.assertEqual(rv, os.path.join(os.curdir, self.file)) + else: + # Other platforms: shouldn't match in the current directory. + self.assertIsNone(rv) def test_non_matching_mode(self): # Set the file read-only and ask for writeable files. @@ -1297,15 +1322,11 @@ rv = shutil.which(self.file, path=self.dir, mode=os.W_OK) self.assertIsNone(rv) - def test_relative(self): - old_cwd = os.getcwd() + def test_relative_path(self): base_dir, tail_dir = os.path.split(self.dir) - os.chdir(base_dir) - try: + with support.temp_cwd(path=base_dir): rv = shutil.which(self.file, path=tail_dir) self.assertEqual(rv, os.path.join(tail_dir, self.file)) - finally: - os.chdir(old_cwd) def test_nonexistent_file(self): # Return None when no matching executable file is found on the path. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,10 @@ Library ------- +- Issue #16957: shutil.which() no longer searches a bare file name in the + current directory on Unix and no longer searches a relative file path with + a directory part in PATH directories. Patch by Thomas Kluyver. + - Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 09:48:06 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 23 Jan 2013 09:48:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316957=3A_shutil=2Ewhich=28=29_no_longer_searche?= =?utf-8?q?s_a_bare_file_name_in_the?= Message-ID: <3YrgBG5MXJzSTb@mail.python.org> http://hg.python.org/cpython/rev/7b51568cfbae changeset: 81669:7b51568cfbae parent: 81667:9a0cd5363c2a parent: 81668:f18d11ab53a0 user: Serhiy Storchaka date: Wed Jan 23 10:45:33 2013 +0200 summary: Issue #16957: shutil.which() no longer searches a bare file name in the current directory on Unix and no longer searches a relative file path with a directory part in PATH directories. Patch by Thomas Kluyver. files: Lib/shutil.py | 11 +++++--- Lib/test/test_shutil.py | 37 ++++++++++++++++++++++------ Misc/NEWS | 4 +++ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Lib/shutil.py b/Lib/shutil.py --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -1076,10 +1076,13 @@ return (os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)) - # Short circuit. If we're given a full path which matches the mode - # and it exists, we're done here. - if _access_check(cmd, mode): - return cmd + # If we're given a path with a directory part, look it up directly rather + # than referring to PATH directories. This includes checking relative to the + # current directory, e.g. ./script + if os.path.dirname(cmd): + if _access_check(cmd, mode): + return cmd + return None path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1296,11 +1296,36 @@ rv = shutil.which(self.file, path=self.dir) self.assertEqual(rv, self.temp_file.name) - def test_full_path_short_circuit(self): + def test_absolute_cmd(self): # When given the fully qualified path to an executable that exists, # it should be returned. rv = shutil.which(self.temp_file.name, path=self.temp_dir) - self.assertEqual(self.temp_file.name, rv) + self.assertEqual(rv, self.temp_file.name) + + def test_relative_cmd(self): + # When given the relative path with a directory part to an executable + # that exists, it should be returned. + base_dir, tail_dir = os.path.split(self.dir) + relpath = os.path.join(tail_dir, self.file) + with support.temp_cwd(path=base_dir): + rv = shutil.which(relpath, path=self.temp_dir) + self.assertEqual(rv, relpath) + # But it shouldn't be searched in PATH directories (issue #16957). + with support.temp_cwd(path=self.dir): + rv = shutil.which(relpath, path=base_dir) + self.assertIsNone(rv) + + def test_cwd(self): + # Issue #16957 + base_dir = os.path.dirname(self.dir) + with support.temp_cwd(path=self.dir): + rv = shutil.which(self.file, path=base_dir) + if sys.platform == "win32": + # Windows: current directory implicitly on PATH + self.assertEqual(rv, os.path.join(os.curdir, self.file)) + else: + # Other platforms: shouldn't match in the current directory. + self.assertIsNone(rv) def test_non_matching_mode(self): # Set the file read-only and ask for writeable files. @@ -1308,15 +1333,11 @@ rv = shutil.which(self.file, path=self.dir, mode=os.W_OK) self.assertIsNone(rv) - def test_relative(self): - old_cwd = os.getcwd() + def test_relative_path(self): base_dir, tail_dir = os.path.split(self.dir) - os.chdir(base_dir) - try: + with support.temp_cwd(path=base_dir): rv = shutil.which(self.file, path=tail_dir) self.assertEqual(rv, os.path.join(tail_dir, self.file)) - finally: - os.chdir(old_cwd) def test_nonexistent_file(self): # Return None when no matching executable file is found on the path. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -220,6 +220,10 @@ Library ------- +- Issue #16957: shutil.which() no longer searches a bare file name in the + current directory on Unix and no longer searches a relative file path with + a directory part in PATH directories. Patch by Thomas Kluyver. + - Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 10:32:45 2013 From: python-checkins at python.org (vinay.sajip) Date: Wed, 23 Jan 2013 10:32:45 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Corrected_typo?= =?utf-8?q?=2C_added_comment_in_cookbook_recipe=2E?= Message-ID: <3Yrh9n2n2YzSVM@mail.python.org> http://hg.python.org/cpython/rev/ef5e61ac27ad changeset: 81670:ef5e61ac27ad branch: 2.7 parent: 81664:c2ae1ed03853 user: Vinay Sajip date: Wed Jan 23 09:30:34 2013 +0000 summary: Corrected typo, added comment in cookbook recipe. files: Doc/howto/logging-cookbook.rst | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -797,7 +797,7 @@ Although most logging messages are intended for reading by humans, and thus not readily machine-parseable, there might be cirumstances where you want to output messages in a structured format which *is* capable of being parsed by a program -(without needed complex regular expressions to parse the log message). This is +(without needing complex regular expressions to parse the log message). This is straightforward to achieve using the logging package. There are a number of ways in which this could be achieved, but the following is a simple approach which uses JSON to serialise the event in a machine-parseable manner:: @@ -822,6 +822,9 @@ message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} +Note that the order of items might be different according to the version of +Python used. + If you need more specialised processing, you can use a custom JSON encoder, as in the following complete example:: @@ -830,6 +833,7 @@ import json import logging + # This next bit is to ensure the script runs unchanged on 2.x and 3.x try: unicode except NameError: @@ -852,7 +856,7 @@ s = Encoder().encode(self.kwargs) return '%s >>> %s' % (self.message, s) - _ = StructuredMessage + _ = StructuredMessage # optional, to improve readability def main(): logging.basicConfig(level=logging.INFO, format='%(message)s') @@ -865,3 +869,6 @@ message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} +Note that the order of items might be different according to the version of +Python used. + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 10:32:46 2013 From: python-checkins at python.org (vinay.sajip) Date: Wed, 23 Jan 2013 10:32:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Corrected_typo?= =?utf-8?q?=2C_added_comment_in_cookbook_recipe=2E?= Message-ID: <3Yrh9p5R6rzSVB@mail.python.org> http://hg.python.org/cpython/rev/006d8740e14c changeset: 81671:006d8740e14c branch: 3.2 parent: 81665:b9c0e050c935 user: Vinay Sajip date: Wed Jan 23 09:31:19 2013 +0000 summary: Corrected typo, added comment in cookbook recipe. files: Doc/howto/logging-cookbook.rst | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1595,7 +1595,7 @@ Although most logging messages are intended for reading by humans, and thus not readily machine-parseable, there might be cirumstances where you want to output messages in a structured format which *is* capable of being parsed by a program -(without needed complex regular expressions to parse the log message). This is +(without needing complex regular expressions to parse the log message). This is straightforward to achieve using the logging package. There are a number of ways in which this could be achieved, but the following is a simple approach which uses JSON to serialise the event in a machine-parseable manner:: @@ -1620,6 +1620,9 @@ message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} +Note that the order of items might be different according to the version of +Python used. + If you need more specialised processing, you can use a custom JSON encoder, as in the following complete example:: @@ -1628,6 +1631,7 @@ import json import logging + # This next bit is to ensure the script runs unchanged on 2.x and 3.x try: unicode except NameError: @@ -1650,7 +1654,7 @@ s = Encoder().encode(self.kwargs) return '%s >>> %s' % (self.message, s) - _ = StructuredMessage + _ = StructuredMessage # optional, to improve readability def main(): logging.basicConfig(level=logging.INFO, format='%(message)s') @@ -1663,3 +1667,6 @@ message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} +Note that the order of items might be different according to the version of +Python used. + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 10:32:48 2013 From: python-checkins at python.org (vinay.sajip) Date: Wed, 23 Jan 2013 10:32:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merged_doc_update_from_3=2E2=2E?= Message-ID: <3Yrh9r0vMKzSVP@mail.python.org> http://hg.python.org/cpython/rev/ea459f70e258 changeset: 81672:ea459f70e258 branch: 3.3 parent: 81668:f18d11ab53a0 parent: 81671:006d8740e14c user: Vinay Sajip date: Wed Jan 23 09:32:10 2013 +0000 summary: Merged doc update from 3.2. files: Doc/howto/logging-cookbook.rst | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1622,7 +1622,7 @@ Although most logging messages are intended for reading by humans, and thus not readily machine-parseable, there might be cirumstances where you want to output messages in a structured format which *is* capable of being parsed by a program -(without needed complex regular expressions to parse the log message). This is +(without needing complex regular expressions to parse the log message). This is straightforward to achieve using the logging package. There are a number of ways in which this could be achieved, but the following is a simple approach which uses JSON to serialise the event in a machine-parseable manner:: @@ -1647,6 +1647,9 @@ message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} +Note that the order of items might be different according to the version of +Python used. + If you need more specialised processing, you can use a custom JSON encoder, as in the following complete example:: @@ -1655,6 +1658,7 @@ import json import logging + # This next bit is to ensure the script runs unchanged on 2.x and 3.x try: unicode except NameError: @@ -1677,7 +1681,7 @@ s = Encoder().encode(self.kwargs) return '%s >>> %s' % (self.message, s) - _ = StructuredMessage + _ = StructuredMessage # optional, to improve readability def main(): logging.basicConfig(level=logging.INFO, format='%(message)s') @@ -1690,3 +1694,6 @@ message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} +Note that the order of items might be different according to the version of +Python used. + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 10:32:49 2013 From: python-checkins at python.org (vinay.sajip) Date: Wed, 23 Jan 2013 10:32:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merged_doc_update_from_3=2E3=2E?= Message-ID: <3Yrh9s3j6GzNVg@mail.python.org> http://hg.python.org/cpython/rev/02e7da4c4fe3 changeset: 81673:02e7da4c4fe3 parent: 81669:7b51568cfbae parent: 81672:ea459f70e258 user: Vinay Sajip date: Wed Jan 23 09:32:32 2013 +0000 summary: Merged doc update from 3.3. files: Doc/howto/logging-cookbook.rst | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1620,7 +1620,7 @@ Although most logging messages are intended for reading by humans, and thus not readily machine-parseable, there might be cirumstances where you want to output messages in a structured format which *is* capable of being parsed by a program -(without needed complex regular expressions to parse the log message). This is +(without needing complex regular expressions to parse the log message). This is straightforward to achieve using the logging package. There are a number of ways in which this could be achieved, but the following is a simple approach which uses JSON to serialise the event in a machine-parseable manner:: @@ -1645,6 +1645,9 @@ message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} +Note that the order of items might be different according to the version of +Python used. + If you need more specialised processing, you can use a custom JSON encoder, as in the following complete example:: @@ -1653,6 +1656,7 @@ import json import logging + # This next bit is to ensure the script runs unchanged on 2.x and 3.x try: unicode except NameError: @@ -1675,7 +1679,7 @@ s = Encoder().encode(self.kwargs) return '%s >>> %s' % (self.message, s) - _ = StructuredMessage + _ = StructuredMessage # optional, to improve readability def main(): logging.basicConfig(level=logging.INFO, format='%(message)s') @@ -1688,3 +1692,6 @@ message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} +Note that the order of items might be different according to the version of +Python used. + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 12:01:37 2013 From: python-checkins at python.org (senthil.kumaran) Date: Wed, 23 Jan 2013 12:01:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEyNDEx?= =?utf-8?q?=3A_Fix_to_cgi=2Eparse=5Fmultipart_to_correctly_use_bytes_bound?= =?utf-8?q?aries_and?= Message-ID: <3Yrk8K3sq9zSYF@mail.python.org> http://hg.python.org/cpython/rev/a46a0dafcb7a changeset: 81674:a46a0dafcb7a branch: 3.2 parent: 81671:006d8740e14c user: Senthil Kumaran date: Wed Jan 23 02:50:15 2013 -0800 summary: Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries and bytes data. Patch by Jonas Wagner. files: Lib/cgi.py | 18 +++++++++--------- Lib/test/test_cgi.py | 21 ++++++++++++++++++++- Misc/NEWS | 3 +++ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Lib/cgi.py b/Lib/cgi.py --- a/Lib/cgi.py +++ b/Lib/cgi.py @@ -214,17 +214,17 @@ """ import http.client - boundary = "" + boundary = b"" if 'boundary' in pdict: boundary = pdict['boundary'] if not valid_boundary(boundary): raise ValueError('Invalid boundary in multipart form: %r' % (boundary,)) - nextpart = "--" + boundary - lastpart = "--" + boundary + "--" + nextpart = b"--" + boundary + lastpart = b"--" + boundary + b"--" partdict = {} - terminator = "" + terminator = b"" while terminator != lastpart: bytes = -1 @@ -243,7 +243,7 @@ raise ValueError('Maximum content length exceeded') data = fp.read(bytes) else: - data = "" + data = b"" # Read lines until end of part. lines = [] while 1: @@ -251,7 +251,7 @@ if not line: terminator = lastpart # End outer loop break - if line.startswith("--"): + if line.startswith(b"--"): terminator = line.rstrip() if terminator in (nextpart, lastpart): break @@ -263,12 +263,12 @@ if lines: # Strip final line terminator line = lines[-1] - if line[-2:] == "\r\n": + if line[-2:] == b"\r\n": line = line[:-2] - elif line[-1:] == "\n": + elif line[-1:] == b"\n": line = line[:-1] lines[-1] = line - data = "".join(lines) + data = b"".join(lines) line = headers['content-disposition'] if not line: continue diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -4,6 +4,7 @@ import sys import tempfile import unittest +from collections import namedtuple from io import StringIO, BytesIO class HackedSysModule: @@ -118,6 +119,23 @@ class CgiTests(unittest.TestCase): + def test_parse_multipart(self): + fp = BytesIO(POSTDATA.encode('latin1')) + env = {'boundary': BOUNDARY.encode('latin1'), + 'CONTENT-LENGTH': '558'} + result = cgi.parse_multipart(fp, env) + expected = {'submit': [b' Add '], 'id': [b'1234'], + 'file': [b'Testing 123.\n'], 'title': [b'']} + self.assertEqual(result, expected) + + def test_fieldstorage_properties(self): + fs = cgi.FieldStorage() + self.assertFalse(fs) + self.assertIn("FieldStorage", repr(fs)) + self.assertEqual(list(fs), list(fs.keys())) + fs.list.append(namedtuple('MockFieldStorage', 'name')('fieldvalue')) + self.assertTrue(fs) + def test_escape(self): self.assertEqual("test & string", cgi.escape("test & string")) self.assertEqual("<test string>", cgi.escape("")) @@ -151,7 +169,8 @@ def test_log(self): cgi.log("Testing") - + cgi.logfile = "fail/" + cgi.initlog("%s", "Testing initlog") cgi.logfp = StringIO() cgi.initlog("%s", "Testing initlog 1") cgi.log("%s", "Testing log 2") diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,9 @@ Library ------- +- Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries + and bytes data. Patch by Jonas Wagner. + - Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 12:01:39 2013 From: python-checkins at python.org (senthil.kumaran) Date: Wed, 23 Jan 2013 12:01:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_merge_from_3=2E2?= Message-ID: <3Yrk8M0nTkzSYH@mail.python.org> http://hg.python.org/cpython/rev/59ea872d8b6b changeset: 81675:59ea872d8b6b branch: 3.3 parent: 81672:ea459f70e258 parent: 81674:a46a0dafcb7a user: Senthil Kumaran date: Wed Jan 23 03:00:26 2013 -0800 summary: merge from 3.2 Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries and bytes data. Patch by Jonas Wagner. files: Lib/cgi.py | 18 +++++++++--------- Lib/test/test_cgi.py | 18 ++++++++++++++++++ Misc/NEWS | 3 +++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Lib/cgi.py b/Lib/cgi.py --- a/Lib/cgi.py +++ b/Lib/cgi.py @@ -223,17 +223,17 @@ """ import http.client - boundary = "" + boundary = b"" if 'boundary' in pdict: boundary = pdict['boundary'] if not valid_boundary(boundary): raise ValueError('Invalid boundary in multipart form: %r' % (boundary,)) - nextpart = "--" + boundary - lastpart = "--" + boundary + "--" + nextpart = b"--" + boundary + lastpart = b"--" + boundary + b"--" partdict = {} - terminator = "" + terminator = b"" while terminator != lastpart: bytes = -1 @@ -252,7 +252,7 @@ raise ValueError('Maximum content length exceeded') data = fp.read(bytes) else: - data = "" + data = b"" # Read lines until end of part. lines = [] while 1: @@ -260,7 +260,7 @@ if not line: terminator = lastpart # End outer loop break - if line.startswith("--"): + if line.startswith(b"--"): terminator = line.rstrip() if terminator in (nextpart, lastpart): break @@ -272,12 +272,12 @@ if lines: # Strip final line terminator line = lines[-1] - if line[-2:] == "\r\n": + if line[-2:] == b"\r\n": line = line[:-2] - elif line[-1:] == "\n": + elif line[-1:] == b"\n": line = line[:-1] lines[-1] = line - data = "".join(lines) + data = b"".join(lines) line = headers['content-disposition'] if not line: continue diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -5,6 +5,7 @@ import tempfile import unittest import warnings +from collections import namedtuple from io import StringIO, BytesIO class HackedSysModule: @@ -119,6 +120,23 @@ class CgiTests(unittest.TestCase): + def test_parse_multipart(self): + fp = BytesIO(POSTDATA.encode('latin1')) + env = {'boundary': BOUNDARY.encode('latin1'), + 'CONTENT-LENGTH': '558'} + result = cgi.parse_multipart(fp, env) + expected = {'submit': [b' Add '], 'id': [b'1234'], + 'file': [b'Testing 123.\n'], 'title': [b'']} + self.assertEqual(result, expected) + + def test_fieldstorage_properties(self): + fs = cgi.FieldStorage() + self.assertFalse(fs) + self.assertIn("FieldStorage", repr(fs)) + self.assertEqual(list(fs), list(fs.keys())) + fs.list.append(namedtuple('MockFieldStorage', 'name')('fieldvalue')) + self.assertTrue(fs) + def test_escape(self): # cgi.escape() is deprecated. with warnings.catch_warnings(): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries + and bytes data. Patch by Jonas Wagner. + - Issue #16957: shutil.which() no longer searches a bare file name in the current directory on Unix and no longer searches a relative file path with a directory part in PATH directories. Patch by Thomas Kluyver. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 12:01:40 2013 From: python-checkins at python.org (senthil.kumaran) Date: Wed, 23 Jan 2013 12:01:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_from_3=2E3?= Message-ID: <3Yrk8N4lCFzSXj@mail.python.org> http://hg.python.org/cpython/rev/3d7000549eb1 changeset: 81676:3d7000549eb1 parent: 81673:02e7da4c4fe3 parent: 81675:59ea872d8b6b user: Senthil Kumaran date: Wed Jan 23 03:01:23 2013 -0800 summary: merge from 3.3 Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries and bytes data. Patch by Jonas Wagner. files: Lib/cgi.py | 18 +++++++++--------- Lib/test/test_cgi.py | 18 ++++++++++++++++++ Misc/NEWS | 3 +++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Lib/cgi.py b/Lib/cgi.py --- a/Lib/cgi.py +++ b/Lib/cgi.py @@ -223,17 +223,17 @@ """ import http.client - boundary = "" + boundary = b"" if 'boundary' in pdict: boundary = pdict['boundary'] if not valid_boundary(boundary): raise ValueError('Invalid boundary in multipart form: %r' % (boundary,)) - nextpart = "--" + boundary - lastpart = "--" + boundary + "--" + nextpart = b"--" + boundary + lastpart = b"--" + boundary + b"--" partdict = {} - terminator = "" + terminator = b"" while terminator != lastpart: bytes = -1 @@ -252,7 +252,7 @@ raise ValueError('Maximum content length exceeded') data = fp.read(bytes) else: - data = "" + data = b"" # Read lines until end of part. lines = [] while 1: @@ -260,7 +260,7 @@ if not line: terminator = lastpart # End outer loop break - if line.startswith("--"): + if line.startswith(b"--"): terminator = line.rstrip() if terminator in (nextpart, lastpart): break @@ -272,12 +272,12 @@ if lines: # Strip final line terminator line = lines[-1] - if line[-2:] == "\r\n": + if line[-2:] == b"\r\n": line = line[:-2] - elif line[-1:] == "\n": + elif line[-1:] == b"\n": line = line[:-1] lines[-1] = line - data = "".join(lines) + data = b"".join(lines) line = headers['content-disposition'] if not line: continue diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -5,6 +5,7 @@ import tempfile import unittest import warnings +from collections import namedtuple from io import StringIO, BytesIO class HackedSysModule: @@ -119,6 +120,23 @@ class CgiTests(unittest.TestCase): + def test_parse_multipart(self): + fp = BytesIO(POSTDATA.encode('latin1')) + env = {'boundary': BOUNDARY.encode('latin1'), + 'CONTENT-LENGTH': '558'} + result = cgi.parse_multipart(fp, env) + expected = {'submit': [b' Add '], 'id': [b'1234'], + 'file': [b'Testing 123.\n'], 'title': [b'']} + self.assertEqual(result, expected) + + def test_fieldstorage_properties(self): + fs = cgi.FieldStorage() + self.assertFalse(fs) + self.assertIn("FieldStorage", repr(fs)) + self.assertEqual(list(fs), list(fs.keys())) + fs.list.append(namedtuple('MockFieldStorage', 'name')('fieldvalue')) + self.assertTrue(fs) + def test_escape(self): # cgi.escape() is deprecated. with warnings.catch_warnings(): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -220,6 +220,9 @@ Library ------- +- Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries + and bytes data. Patch by Jonas Wagner. + - Issue #16957: shutil.which() no longer searches a bare file name in the current directory on Unix and no longer searches a relative file path with a directory part in PATH directories. Patch by Thomas Kluyver. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 23 14:38:56 2013 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 23 Jan 2013 14:38:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_revert_=2316672_for_incorr?= =?utf-8?q?ect_semantics?= Message-ID: <3Yrndr1TRkzRJP@mail.python.org> http://hg.python.org/cpython/rev/cd87afe18ff8 changeset: 81677:cd87afe18ff8 user: Benjamin Peterson date: Wed Jan 23 08:38:47 2013 -0500 summary: revert #16672 for incorrect semantics files: Misc/NEWS | 2 -- Python/ceval.c | 7 +++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,8 +50,6 @@ - Issue #15422: Get rid of PyCFunction_New macro. Use PyCFunction_NewEx function (PyCFunction_New func is still present for backward compatibility). -- Issue #16672: Improve performance tracing performance - - Issue #14470: Remove w9xpopen support per PEP 11. - Issue #9856: Replace deprecation warning with raising TypeError diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1277,8 +1277,7 @@ /* line-by-line tracing support */ if (_Py_TracingPossible && - tstate->c_tracefunc != NULL && !tstate->tracing && - f->f_trace != NULL) { + tstate->c_tracefunc != NULL && !tstate->tracing) { int err; /* see maybe_call_line_trace for expository comments */ @@ -3009,7 +3008,7 @@ /* Log traceback info. */ PyTraceBack_Here(f); - if (tstate->c_tracefunc != NULL && f->f_trace != NULL) + if (tstate->c_tracefunc != NULL) call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj, f); fast_block_end: @@ -3128,7 +3127,7 @@ } if (tstate->use_tracing) { - if (tstate->c_tracefunc && f->f_trace != NULL) { + if (tstate->c_tracefunc) { if (why == WHY_RETURN || why == WHY_YIELD) { if (call_trace(tstate->c_tracefunc, tstate->c_traceobj, f, -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Thu Jan 24 06:02:06 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 24 Jan 2013 06:02:06 +0100 Subject: [Python-checkins] Daily reference leaks (cd87afe18ff8): sum=0 Message-ID: results for cd87afe18ff8 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflog0qJWs9', '-x'] From python-checkins at python.org Thu Jan 24 06:20:12 2013 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 24 Jan 2013 06:20:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_two_new_TODOs_=28socket_a?= =?utf-8?q?ddress_and_fork=28=29=29=2E?= Message-ID: <3YsBWw0zY8zRGX@mail.python.org> http://hg.python.org/peps/rev/f2416bc05b06 changeset: 4685:f2416bc05b06 user: Guido van Rossum date: Wed Jan 23 21:20:07 2013 -0800 summary: Add two new TODOs (socket address and fork()). files: pep-3156.txt | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -979,6 +979,14 @@ given a file descriptor. Or when the next scheduled call is. Or the list of file descriptors registered with callbacks. +- Transports may need a method that tries to return the address of the + socket (and another for the peer address). Although these depend on + the socket type and there may not always be a socket; then it should + return None. + +- Need to handle os.fork(). (This may be up to the selector classes + in Tulip's case.) + - We might introduce explicit locks, though these will be a bit of a pain to use, as we can't use the ``with lock: block`` syntax (because to wait for a lock we'd have to use ``yield from``, which -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 24 06:26:43 2013 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 24 Jan 2013 06:26:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_One_more_TODO=3A_pass_socket_?= =?utf-8?q?to_start=5Fserving=28=29=2E?= Message-ID: <3YsBgR2h4yzPNG@mail.python.org> http://hg.python.org/peps/rev/434ec0251c2f changeset: 4686:434ec0251c2f user: Guido van Rossum date: Wed Jan 23 21:26:32 2013 -0800 summary: One more TODO: pass socket to start_serving(). files: pep-3156.txt | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -987,6 +987,9 @@ - Need to handle os.fork(). (This may be up to the selector classes in Tulip's case.) +- Perhaps start_serving() needs a way to pass in an existing socket + (e.g. gunicorn would need this). + - We might introduce explicit locks, though these will be a bit of a pain to use, as we can't use the ``with lock: block`` syntax (because to wait for a lock we'd have to use ``yield from``, which -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 24 12:46:23 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Jan 2013 12:46:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_generating?= =?utf-8?q?_of_sre=5Fconstants=2Eh_on_Python_3=2E?= Message-ID: <3YsM5W70gKzS4t@mail.python.org> http://hg.python.org/cpython/rev/edf4c51c06a3 changeset: 81678:edf4c51c06a3 branch: 3.2 parent: 81674:a46a0dafcb7a user: Serhiy Storchaka date: Thu Jan 24 13:43:02 2013 +0200 summary: Fix generating of sre_constants.h on Python 3. files: Lib/sre_constants.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py --- a/Lib/sre_constants.py +++ b/Lib/sre_constants.py @@ -219,8 +219,7 @@ if __name__ == "__main__": def dump(f, d, prefix): - items = d.items() - items.sort(key=lambda a: a[1]) + items = sorted(d.items(), key=lambda a: a[1]) for k, v in items: f.write("#define %s_%s %s\n" % (prefix, k.upper(), v)) f = open("sre_constants.h", "w") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 12:46:25 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Jan 2013 12:46:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Fix_generating_of_sre=5Fconstants=2Eh_on_Python_3=2E?= Message-ID: <3YsM5Y2XRKzPPD@mail.python.org> http://hg.python.org/cpython/rev/f11da141b44e changeset: 81679:f11da141b44e branch: 3.3 parent: 81675:59ea872d8b6b parent: 81678:edf4c51c06a3 user: Serhiy Storchaka date: Thu Jan 24 13:43:46 2013 +0200 summary: Fix generating of sre_constants.h on Python 3. files: Lib/sre_constants.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py --- a/Lib/sre_constants.py +++ b/Lib/sre_constants.py @@ -219,8 +219,7 @@ if __name__ == "__main__": def dump(f, d, prefix): - items = d.items() - items.sort(key=lambda a: a[1]) + items = sorted(d.items(), key=lambda a: a[1]) for k, v in items: f.write("#define %s_%s %s\n" % (prefix, k.upper(), v)) f = open("sre_constants.h", "w") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 12:46:26 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Jan 2013 12:46:26 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_generating_of_sre=5Fconstants=2Eh_on_Python_3=2E?= Message-ID: <3YsM5Z53c3zS4t@mail.python.org> http://hg.python.org/cpython/rev/2c12a1236fdc changeset: 81680:2c12a1236fdc parent: 81677:cd87afe18ff8 parent: 81679:f11da141b44e user: Serhiy Storchaka date: Thu Jan 24 13:44:18 2013 +0200 summary: Fix generating of sre_constants.h on Python 3. files: Lib/sre_constants.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py --- a/Lib/sre_constants.py +++ b/Lib/sre_constants.py @@ -219,8 +219,7 @@ if __name__ == "__main__": def dump(f, d, prefix): - items = d.items() - items.sort(key=lambda a: a[1]) + items = sorted(d.items(), key=lambda a: a[1]) for k, v in items: f.write("#define %s_%s %s\n" % (prefix, k.upper(), v)) f = open("sre_constants.h", "w") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 15:29:41 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 15:29:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2312323=3A_Strength?= =?utf-8?q?en_error_checking_of_the_position_XPath_selectors?= Message-ID: <3YsQjx6xMRzRJm@mail.python.org> http://hg.python.org/cpython/rev/56a4561600ad changeset: 81681:56a4561600ad user: Eli Bendersky date: Thu Jan 24 06:29:26 2013 -0800 summary: Issue #12323: Strengthen error checking of the position XPath selectors files: Lib/test/test_xml_etree.py | 5 +++++ Lib/xml/etree/ElementPath.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1793,6 +1793,11 @@ self.assertEqual(e.find('./tag[last()-1]').attrib['class'], 'c') self.assertEqual(e.find('./tag[last()-2]').attrib['class'], 'b') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[0]') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[-1]') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()-0]') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()+1]') + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py --- a/Lib/xml/etree/ElementPath.py +++ b/Lib/xml/etree/ElementPath.py @@ -174,7 +174,7 @@ if elem.get(key) == value: yield elem return select - if signature == "-" and not re.match("\d+$", predicate[0]): + if signature == "-" and not re.match("\-?\d+$", predicate[0]): # [tag] tag = predicate[0] def select(context, result): @@ -182,7 +182,7 @@ if elem.find(tag) is not None: yield elem return select - if signature == "-='" and not re.match("\d+$", predicate[0]): + if signature == "-='" and not re.match("\-?\d+$", predicate[0]): # [tag='value'] tag = predicate[0] value = predicate[-1] @@ -196,7 +196,10 @@ if signature == "-" or signature == "-()" or signature == "-()-": # [index] or [last()] or [last()-index] if signature == "-": + # [index] index = int(predicate[0]) - 1 + if index < 0: + raise SyntaxError("XPath position >= 1 expected") else: if predicate[0] != "last": raise SyntaxError("unsupported function") @@ -205,6 +208,8 @@ index = int(predicate[2]) - 1 except ValueError: raise SyntaxError("unsupported expression") + if index > -2: + raise SyntaxError("XPath offset from last() must be negative") else: index = -1 def select(context, result): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 15:40:33 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 24 Jan 2013 15:40:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Since_the_retu?= =?utf-8?q?rn_type_of_format=28=29_is_not_a_Decimal=2C_raise_ValueError_in?= =?utf-8?q?stead_of?= Message-ID: <3YsQyT4tSpzQlT@mail.python.org> http://hg.python.org/cpython/rev/999870e107f7 changeset: 81682:999870e107f7 branch: 3.3 parent: 81679:f11da141b44e user: Stefan Krah date: Thu Jan 24 15:22:33 2013 +0100 summary: Since the return type of format() is not a Decimal, raise ValueError instead of InvalidOperation if the format specification (width, prec) exceeds the internal limits of libmpdec. files: Lib/test/test_decimal.py | 14 ++++---------- Modules/_decimal/_decimal.c | 8 +++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -4971,22 +4971,16 @@ def test_c_format(self): # Restricted input Decimal = C.Decimal - InvalidOperation = C.InvalidOperation - Rounded = C.Rounded - localcontext = C.localcontext HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", [], 9) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", 9) self.assertRaises(TypeError, Decimal(1).__format__, []) - with localcontext() as c: - c.traps[InvalidOperation] = True - c.traps[Rounded] = True - self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") - maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 - self.assertRaises(InvalidOperation, Decimal("1.23456789").__format__, - "=%d.1" % maxsize) + self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") + maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 + self.assertRaises(ValueError, Decimal("1.23456789").__format__, + "=%d.1" % maxsize) def test_c_integral(self): Decimal = C.Decimal diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3222,7 +3222,13 @@ decstring = mpd_qformat_spec(MPD(dec), &spec, CTX(context), &status); if (decstring == NULL) { - dec_addstatus(context, status); + if (status & MPD_Malloc_error) { + PyErr_NoMemory(); + } + else { + PyErr_SetString(PyExc_ValueError, + "format specification exceeds internal limits of _decimal"); + } goto finish; } result = PyUnicode_DecodeUTF8(decstring, strlen(decstring), NULL); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 15:40:35 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 24 Jan 2013 15:40:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YsQyW0W56zRFQ@mail.python.org> http://hg.python.org/cpython/rev/364921b06c5f changeset: 81683:364921b06c5f parent: 81680:2c12a1236fdc parent: 81682:999870e107f7 user: Stefan Krah date: Thu Jan 24 15:37:37 2013 +0100 summary: Merge 3.3. files: Lib/test/test_decimal.py | 14 ++++---------- Modules/_decimal/_decimal.c | 8 +++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -4971,22 +4971,16 @@ def test_c_format(self): # Restricted input Decimal = C.Decimal - InvalidOperation = C.InvalidOperation - Rounded = C.Rounded - localcontext = C.localcontext HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", [], 9) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", 9) self.assertRaises(TypeError, Decimal(1).__format__, []) - with localcontext() as c: - c.traps[InvalidOperation] = True - c.traps[Rounded] = True - self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") - maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 - self.assertRaises(InvalidOperation, Decimal("1.23456789").__format__, - "=%d.1" % maxsize) + self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") + maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 + self.assertRaises(ValueError, Decimal("1.23456789").__format__, + "=%d.1" % maxsize) def test_c_integral(self): Decimal = C.Decimal diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3222,7 +3222,13 @@ decstring = mpd_qformat_spec(MPD(dec), &spec, CTX(context), &status); if (decstring == NULL) { - dec_addstatus(context, status); + if (status & MPD_Malloc_error) { + PyErr_NoMemory(); + } + else { + PyErr_SetString(PyExc_ValueError, + "format specification exceeds internal limits of _decimal"); + } goto finish; } result = PyUnicode_DecodeUTF8(decstring, strlen(decstring), NULL); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 15:40:36 2013 From: python-checkins at python.org (stefan.krah) Date: Thu, 24 Jan 2013 15:40:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?b?KTogTWVyZ2Uu?= Message-ID: <3YsQyX39mnzR86@mail.python.org> http://hg.python.org/cpython/rev/c6b0b96451c6 changeset: 81684:c6b0b96451c6 parent: 81683:364921b06c5f parent: 81681:56a4561600ad user: Stefan Krah date: Thu Jan 24 15:39:55 2013 +0100 summary: Merge. files: Lib/test/test_xml_etree.py | 5 +++++ Lib/xml/etree/ElementPath.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1793,6 +1793,11 @@ self.assertEqual(e.find('./tag[last()-1]').attrib['class'], 'c') self.assertEqual(e.find('./tag[last()-2]').attrib['class'], 'b') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[0]') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[-1]') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()-0]') + self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()+1]') + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py --- a/Lib/xml/etree/ElementPath.py +++ b/Lib/xml/etree/ElementPath.py @@ -174,7 +174,7 @@ if elem.get(key) == value: yield elem return select - if signature == "-" and not re.match("\d+$", predicate[0]): + if signature == "-" and not re.match("\-?\d+$", predicate[0]): # [tag] tag = predicate[0] def select(context, result): @@ -182,7 +182,7 @@ if elem.find(tag) is not None: yield elem return select - if signature == "-='" and not re.match("\d+$", predicate[0]): + if signature == "-='" and not re.match("\-?\d+$", predicate[0]): # [tag='value'] tag = predicate[0] value = predicate[-1] @@ -196,7 +196,10 @@ if signature == "-" or signature == "-()" or signature == "-()-": # [index] or [last()] or [last()-index] if signature == "-": + # [index] index = int(predicate[0]) - 1 + if index < 0: + raise SyntaxError("XPath position >= 1 expected") else: if predicate[0] != "last": raise SyntaxError("unsupported function") @@ -205,6 +208,8 @@ index = int(predicate[2]) - 1 except ValueError: raise SyntaxError("unsupported expression") + if index > -2: + raise SyntaxError("XPath offset from last() must be negative") else: index = -1 def select(context, result): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 16:17:46 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 16:17:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzk3MDg6?= =?utf-8?q?_Fix_support_for_iterparse=28parser=3D=2E=2E=2E=29_argument_per?= =?utf-8?q?_documentation=2E?= Message-ID: <3YsRnQ3N1TzQv4@mail.python.org> http://hg.python.org/cpython/rev/cce526a28f81 changeset: 81685:cce526a28f81 branch: 3.3 parent: 81679:f11da141b44e user: Eli Bendersky date: Thu Jan 24 07:15:19 2013 -0800 summary: Issue #9708: Fix support for iterparse(parser=...) argument per documentation. When _elementtree is imported, iterparse is redefined as a class and the parser argument was ommitted. Fix this, and add a docstring to the class. files: Lib/test/test_xml_etree.py | 6 ++++++ Lib/xml/etree/ElementTree.py | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1881,6 +1881,12 @@ sourcefile = serialize(doc, to_string=False) self.assertEqual(next(ET.iterparse(sourcefile))[0], 'end') + # With an explitit parser too (issue #9708) + sourcefile = serialize(doc, to_string=False) + parser = ET.XMLParser(target=ET.TreeBuilder()) + self.assertEqual(next(ET.iterparse(sourcefile, parser=parser))[0], + 'end') + tree = ET.ElementTree(None) self.assertRaises(AttributeError, tree.iter) diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1737,8 +1737,20 @@ source.close() class iterparse: + """Parses an XML section into an element tree incrementally. + + Reports what?s going on to the user. 'source' is a filename or file + object containing XML data. 'events' is a list of events to report back. + The supported events are the strings "start", "end", "start-ns" and + "end-ns" (the "ns" events are used to get detailed namespace + information). If 'events' is omitted, only "end" events are reported. + 'parser' is an optional parser instance. If not given, the standard + XMLParser parser is used. Returns an iterator providing + (event, elem) pairs. + """ + root = None - def __init__(self, file, events=None): + def __init__(self, file, events=None, parser=None): self._close_file = False if not hasattr(file, 'read'): file = open(file, 'rb') @@ -1748,8 +1760,9 @@ self._index = 0 self._error = None self.root = self._root = None - b = TreeBuilder() - self._parser = XMLParser(b) + if parser is None: + parser = XMLParser(target=TreeBuilder()) + self._parser = parser self._parser._setevents(self._events, events) def __next__(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 16:17:47 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 16:17:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=239708=3A_Fix_support_for_iterparse=28parser=3D?= =?utf-8?q?=2E=2E=2E=29_argument_per_documentation=2E?= Message-ID: <3YsRnR69j7zS43@mail.python.org> http://hg.python.org/cpython/rev/0c9268ac3ffa changeset: 81686:0c9268ac3ffa parent: 81681:56a4561600ad parent: 81685:cce526a28f81 user: Eli Bendersky date: Thu Jan 24 07:15:46 2013 -0800 summary: Issue #9708: Fix support for iterparse(parser=...) argument per documentation. When _elementtree is imported, iterparse is redefined as a class and the parser argument was ommitted. Fix this, and add a docstring to the class. files: Lib/test/test_xml_etree.py | 6 ++++++ Lib/xml/etree/ElementTree.py | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1886,6 +1886,12 @@ sourcefile = serialize(doc, to_string=False) self.assertEqual(next(ET.iterparse(sourcefile))[0], 'end') + # With an explitit parser too (issue #9708) + sourcefile = serialize(doc, to_string=False) + parser = ET.XMLParser(target=ET.TreeBuilder()) + self.assertEqual(next(ET.iterparse(sourcefile, parser=parser))[0], + 'end') + tree = ET.ElementTree(None) self.assertRaises(AttributeError, tree.iter) diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1743,8 +1743,20 @@ source.close() class iterparse: + """Parses an XML section into an element tree incrementally. + + Reports what?s going on to the user. 'source' is a filename or file + object containing XML data. 'events' is a list of events to report back. + The supported events are the strings "start", "end", "start-ns" and + "end-ns" (the "ns" events are used to get detailed namespace + information). If 'events' is omitted, only "end" events are reported. + 'parser' is an optional parser instance. If not given, the standard + XMLParser parser is used. Returns an iterator providing + (event, elem) pairs. + """ + root = None - def __init__(self, file, events=None): + def __init__(self, file, events=None, parser=None): self._close_file = False if not hasattr(file, 'read'): file = open(file, 'rb') @@ -1754,8 +1766,9 @@ self._index = 0 self._error = None self.root = self._root = None - b = TreeBuilder() - self._parser = XMLParser(b) + if parser is None: + parser = XMLParser(target=TreeBuilder()) + self._parser = parser self._parser._setevents(self._events, events) def __next__(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 16:17:49 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 16:17:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_merge_heads?= Message-ID: <3YsRnT3N3szNrc@mail.python.org> http://hg.python.org/cpython/rev/3023849c0c15 changeset: 81687:3023849c0c15 branch: 3.3 parent: 81685:cce526a28f81 parent: 81682:999870e107f7 user: Eli Bendersky date: Thu Jan 24 07:17:05 2013 -0800 summary: merge heads files: Lib/test/test_decimal.py | 14 ++++---------- Modules/_decimal/_decimal.c | 8 +++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -4971,22 +4971,16 @@ def test_c_format(self): # Restricted input Decimal = C.Decimal - InvalidOperation = C.InvalidOperation - Rounded = C.Rounded - localcontext = C.localcontext HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", [], 9) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", 9) self.assertRaises(TypeError, Decimal(1).__format__, []) - with localcontext() as c: - c.traps[InvalidOperation] = True - c.traps[Rounded] = True - self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") - maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 - self.assertRaises(InvalidOperation, Decimal("1.23456789").__format__, - "=%d.1" % maxsize) + self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") + maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 + self.assertRaises(ValueError, Decimal("1.23456789").__format__, + "=%d.1" % maxsize) def test_c_integral(self): Decimal = C.Decimal diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3222,7 +3222,13 @@ decstring = mpd_qformat_spec(MPD(dec), &spec, CTX(context), &status); if (decstring == NULL) { - dec_addstatus(context, status); + if (status & MPD_Malloc_error) { + PyErr_NoMemory(); + } + else { + PyErr_SetString(PyExc_ValueError, + "format specification exceeds internal limits of _decimal"); + } goto finish; } result = PyUnicode_DecodeUTF8(decstring, strlen(decstring), NULL); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 16:17:50 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 16:17:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_heads?= Message-ID: <3YsRnV6Q6jzNrc@mail.python.org> http://hg.python.org/cpython/rev/e393ddb0d290 changeset: 81688:e393ddb0d290 parent: 81686:0c9268ac3ffa parent: 81687:3023849c0c15 user: Eli Bendersky date: Thu Jan 24 07:17:17 2013 -0800 summary: merge heads files: Lib/test/test_decimal.py | 14 ++++---------- Modules/_decimal/_decimal.c | 8 +++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -4971,22 +4971,16 @@ def test_c_format(self): # Restricted input Decimal = C.Decimal - InvalidOperation = C.InvalidOperation - Rounded = C.Rounded - localcontext = C.localcontext HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", [], 9) self.assertRaises(TypeError, Decimal(1).__format__, "=10.10", 9) self.assertRaises(TypeError, Decimal(1).__format__, []) - with localcontext() as c: - c.traps[InvalidOperation] = True - c.traps[Rounded] = True - self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") - maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 - self.assertRaises(InvalidOperation, Decimal("1.23456789").__format__, - "=%d.1" % maxsize) + self.assertRaises(ValueError, Decimal(1).__format__, "<>=10.10") + maxsize = 2**63-1 if HAVE_CONFIG_64 else 2**31-1 + self.assertRaises(ValueError, Decimal("1.23456789").__format__, + "=%d.1" % maxsize) def test_c_integral(self): Decimal = C.Decimal diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3222,7 +3222,13 @@ decstring = mpd_qformat_spec(MPD(dec), &spec, CTX(context), &status); if (decstring == NULL) { - dec_addstatus(context, status); + if (status & MPD_Malloc_error) { + PyErr_NoMemory(); + } + else { + PyErr_SetString(PyExc_ValueError, + "format specification exceeds internal limits of _decimal"); + } goto finish; } result = PyUnicode_DecodeUTF8(decstring, strlen(decstring), NULL); -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 16:17:52 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 16:17:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_null_merge?= Message-ID: <3YsRnX27mtzQv4@mail.python.org> http://hg.python.org/cpython/rev/ac485e1cb0f5 changeset: 81689:ac485e1cb0f5 parent: 81688:e393ddb0d290 parent: 81684:c6b0b96451c6 user: Eli Bendersky date: Thu Jan 24 07:17:29 2013 -0800 summary: null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 16:25:59 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 16:25:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogQ2xhcmlmeSBFVC5p?= =?utf-8?q?terparse_documentation_-_this_function_is_not_supported_by_the?= Message-ID: <3YsRyv0hWKzPgy@mail.python.org> http://hg.python.org/cpython/rev/5b02d622d625 changeset: 81690:5b02d622d625 branch: 3.2 parent: 81678:edf4c51c06a3 user: Eli Bendersky date: Thu Jan 24 07:23:34 2013 -0800 summary: Clarify ET.iterparse documentation - this function is not supported by the C implementation. files: Doc/library/xml.etree.elementtree.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -101,8 +101,9 @@ and ``"end-ns"`` (the "ns" events are used to get detailed namespace information). If *events* is omitted, only ``"end"`` events are reported. *parser* is an optional parser instance. If not given, the standard - :class:`XMLParser` parser is used. Returns an :term:`iterator` providing - ``(event, elem)`` pairs. + :class:`XMLParser` parser is used. *parser* is not supported by + ``cElementTree``. Returns an :term:`iterator` providing ``(event, elem)`` + pairs. .. note:: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 16:28:48 2013 From: python-checkins at python.org (eli.bendersky) Date: Thu, 24 Jan 2013 16:28:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzk3MDg6?= =?utf-8?q?_clarify_doc_of_iterparse_-_cElementTree_doesn=27t_support_the_?= =?utf-8?q?parser?= Message-ID: <3YsS282f7zzPgy@mail.python.org> http://hg.python.org/cpython/rev/8f2edea69d5d changeset: 81691:8f2edea69d5d branch: 2.7 parent: 81670:ef5e61ac27ad user: Eli Bendersky date: Thu Jan 24 07:28:33 2013 -0800 summary: Issue #9708: clarify doc of iterparse - cElementTree doesn't support the parser argument files: Doc/library/xml.etree.elementtree.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -403,8 +403,9 @@ going on to the user. *source* is a filename or file object containing XML data. *events* is a list of events to report back. If omitted, only "end" events are reported. *parser* is an optional parser instance. If not - given, the standard :class:`XMLParser` parser is used. Returns an - :term:`iterator` providing ``(event, elem)`` pairs. + given, the standard :class:`XMLParser` parser is used. *parser* is not + supported by ``cElementTree``. Returns an :term:`iterator` providing + ``(event, elem)`` pairs. .. note:: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 24 19:53:48 2013 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 24 Jan 2013 19:53:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Tweak_TODOs=2E?= Message-ID: <3YsXZh3MG1zSFq@mail.python.org> http://hg.python.org/peps/rev/fca3ee45a828 changeset: 4687:fca3ee45a828 user: Guido van Rossum date: Thu Jan 24 10:53:40 2013 -0800 summary: Tweak TODOs. files: pep-3156.txt | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -982,13 +982,15 @@ - Transports may need a method that tries to return the address of the socket (and another for the peer address). Although these depend on the socket type and there may not always be a socket; then it should - return None. + return None. (Alternatively, there could be a method to return the + socket itself -- but it is conceivable that a transport implements + IP connections without using sockets, and what should it do then?) - Need to handle os.fork(). (This may be up to the selector classes in Tulip's case.) - Perhaps start_serving() needs a way to pass in an existing socket - (e.g. gunicorn would need this). + (e.g. gunicorn would need this). Ditto for create_connection(). - We might introduce explicit locks, though these will be a bit of a pain to use, as we can't use the ``with lock: block`` syntax -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Fri Jan 25 00:35:50 2013 From: python-checkins at python.org (victor.stinner) Date: Fri, 25 Jan 2013 00:35:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_rationale?= Message-ID: <3Ysfr622D0zSG7@mail.python.org> http://hg.python.org/peps/rev/94bec50e4624 changeset: 4688:94bec50e4624 user: Victor Stinner date: Fri Jan 25 00:33:38 2013 +0100 summary: PEP 433: rationale files: pep-0433.txt | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -22,10 +22,25 @@ Rationale ========= -XXX recap briefly what the close-on-exec flag does +A file descriptor has a close-on-exec flag which indicates if the file +descriptor will be inherited or not. -On UNIX, subprocess closes file descriptors greater than 2 by default -since Python 3.2 [#subprocess_close]_. All file descriptors created by +On UNIX, the file descriptor will be closed on the execution of child processes +if the close-on-exec flag is set, the file descriptor is inherited by child +processes if the flag is cleared. + +On Windows, the file descriptor is not inherited if the close-on-exec flag is +set, the file descriptor is inherited by child processes if the flag is cleared +and if ``CreateProcess()`` is called with the *bInheritHandles* parameter set +to ``TRUE`` (when ``subprocess.Popen`` is created with ``close_fds=False`` for +example). + + +Status in Python 3.3 +-------------------- + +On UNIX, the subprocess module closes file descriptors greater than 2 by +default since Python 3.2 [#subprocess_close]_. All file descriptors created by the parent process are automatically closed in the child process. ``xmlrpc.server.SimpleXMLRPCServer`` sets the close-on-exec flag of -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Fri Jan 25 05:57:16 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 25 Jan 2013 05:57:16 +0100 Subject: [Python-checkins] Daily reference leaks (ac485e1cb0f5): sum=0 Message-ID: results for ac485e1cb0f5 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogmQwP12', '-x'] From python-checkins at python.org Fri Jan 25 09:18:03 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Fix_pathext_te?= =?utf-8?q?st_for_shutil=2Ewhich=28=29_which_was?= Message-ID: <3YstQg0BQVzSC2@mail.python.org> http://hg.python.org/cpython/rev/99db73ce8374 changeset: 81692:99db73ce8374 branch: 3.3 parent: 81687:3023849c0c15 user: Serhiy Storchaka date: Thu Jan 24 20:03:49 2013 +0200 summary: Fix pathext test for shutil.which() which was broken after applying the patch for issue #16957. files: Lib/test/test_shutil.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1338,7 +1338,7 @@ def test_pathext_checking(self): # Ask for the file without the ".exe" extension, then ensure that # it gets found properly with the extension. - rv = shutil.which(self.temp_file.name[:-4], path=self.dir) + rv = shutil.which(self.file[:-4], path=self.dir) self.assertEqual(rv, self.temp_file.name[:-4] + ".EXE") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 09:18:04 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_pathext_test_for_shutil=2Ewhich=28=29_which_was?= Message-ID: <3YstQh2kggzSJB@mail.python.org> http://hg.python.org/cpython/rev/ab0ff935126c changeset: 81693:ab0ff935126c parent: 81689:ac485e1cb0f5 parent: 81692:99db73ce8374 user: Serhiy Storchaka date: Thu Jan 24 20:04:37 2013 +0200 summary: Fix pathext test for shutil.which() which was broken after applying the patch for issue #16957. files: Lib/test/test_shutil.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1349,7 +1349,7 @@ def test_pathext_checking(self): # Ask for the file without the ".exe" extension, then ensure that # it gets found properly with the extension. - rv = shutil.which(self.temp_file.name[:-4], path=self.dir) + rv = shutil.which(self.file[:-4], path=self.dir) self.assertEqual(rv, self.temp_file.name[:-4] + ".EXE") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 09:18:05 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogRG9uJ3QgcnVuIHRo?= =?utf-8?q?e_test_for_issue_=2316335_when_-M_is_not_specified=2E?= Message-ID: <3YstQj5d5wzSJl@mail.python.org> http://hg.python.org/cpython/rev/fc21f8e83062 changeset: 81694:fc21f8e83062 branch: 2.7 parent: 81691:8f2edea69d5d user: Serhiy Storchaka date: Fri Jan 25 10:03:12 2013 +0200 summary: Don't run the test for issue #16335 when -M is not specified. Increase memory limit in this test. files: Lib/test/test_ucn.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -144,8 +144,12 @@ @unittest.skipUnless(_testcapi.UINT_MAX < sys.maxint, "needs UINT_MAX < sys.maxint") @test_support.bigmemtest(minsize=_testcapi.UINT_MAX + 1, - memuse=1 + 4 // len(u'\U00010000')) + memuse=2 + 4 // len(u'\U00010000')) def test_issue16335(self, size): + func = self.test_issue16335 + if size < func.minsize: + raise unittest.SkipTest("not enough memory: %.1fG minimum needed" % + (func.minsize * func.memuse / float(1024**3),)) # very very long bogus character name x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}' self.assertEqual(len(x), len(b'\\N{SPACE}') + -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 09:18:07 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null_merge?= Message-ID: <3YstQl1MdRzSG5@mail.python.org> http://hg.python.org/cpython/rev/d0175f782211 changeset: 81695:d0175f782211 branch: 3.3 parent: 81692:99db73ce8374 parent: 81690:5b02d622d625 user: Serhiy Storchaka date: Fri Jan 25 10:09:25 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 09:18:08 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:08 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3YstQm4Hk4zSG5@mail.python.org> http://hg.python.org/cpython/rev/7cc65344b027 changeset: 81696:7cc65344b027 parent: 81693:ab0ff935126c parent: 81695:d0175f782211 user: Serhiy Storchaka date: Fri Jan 25 10:10:45 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 09:18:09 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Increase_the_m?= =?utf-8?q?emory_limit_in_the_test_for_issue_=2316335=2E?= Message-ID: <3YstQn6v1szSJV@mail.python.org> http://hg.python.org/cpython/rev/e3d1b68d34e3 changeset: 81697:e3d1b68d34e3 branch: 3.2 parent: 81690:5b02d622d625 user: Serhiy Storchaka date: Fri Jan 25 10:12:30 2013 +0200 summary: Increase the memory limit in the test for issue #16335. files: Lib/test/test_ucn.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -145,7 +145,7 @@ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") @support.bigmemtest(size=_testcapi.UINT_MAX + 1, - memuse=1 + 4 // len('\U00010000'), dry_run=False) + memuse=2 + 4 // len('\U00010000'), dry_run=False) def test_issue16335(self, size): # very very long bogus character name x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 09:18:11 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Increase_the_memory_limit_in_the_test_for_issue_=2316335=2E?= Message-ID: <3YstQq2Dx9zSJB@mail.python.org> http://hg.python.org/cpython/rev/43907b88ce93 changeset: 81698:43907b88ce93 branch: 3.3 parent: 81695:d0175f782211 parent: 81697:e3d1b68d34e3 user: Serhiy Storchaka date: Fri Jan 25 10:13:37 2013 +0200 summary: Increase the memory limit in the test for issue #16335. files: Lib/test/test_ucn.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -219,7 +219,7 @@ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") @support.bigmemtest(size=_testcapi.UINT_MAX + 1, - memuse=1 + 1, dry_run=False) + memuse=2 + 1, dry_run=False) def test_issue16335(self, size): # very very long bogus character name x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 09:18:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 09:18:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Increase_the_memory_limit_in_the_test_for_issue_=2316335?= =?utf-8?q?=2E?= Message-ID: <3YstQr5HFTzSHd@mail.python.org> http://hg.python.org/cpython/rev/fcdb35b114ab changeset: 81699:fcdb35b114ab parent: 81696:7cc65344b027 parent: 81698:43907b88ce93 user: Serhiy Storchaka date: Fri Jan 25 10:13:57 2013 +0200 summary: Increase the memory limit in the test for issue #16335. files: Lib/test/test_ucn.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -219,7 +219,7 @@ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") @support.bigmemtest(size=_testcapi.UINT_MAX + 1, - memuse=1 + 1, dry_run=False) + memuse=2 + 1, dry_run=False) def test_issue16335(self, size): # very very long bogus character name x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 12:35:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 12:35:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEzNDU0?= =?utf-8?q?=3A_Fix_a_crash_when_deleting_an_iterator_created_by_itertools?= =?utf-8?b?LnRlZSgp?= Message-ID: <3Ysyp81DWWzS81@mail.python.org> http://hg.python.org/cpython/rev/f7e14a1af609 changeset: 81700:f7e14a1af609 branch: 3.2 parent: 81697:e3d1b68d34e3 user: Serhiy Storchaka date: Fri Jan 25 13:19:31 2013 +0200 summary: Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. files: Lib/test/test_itertools.py | 8 ++++++++ Misc/NEWS | 3 +++ Modules/itertoolsmodule.c | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -930,6 +930,14 @@ del a self.assertRaises(ReferenceError, getattr, p, '__class__') + # Issue 13454: Crash when deleting backward iterator from tee() + def test_tee_del_backward(self): + forward, backward = tee(range(20000000)) + for i in forward: + pass + + del backward + def test_StopIteration(self): self.assertRaises(StopIteration, next, zip()) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,9 @@ Library ------- +- Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() + if all other iterators were very advanced before. + - Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries and bytes data. Patch by Jonas Wagner. diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -401,14 +401,31 @@ return 0; } +static void +teedataobject_safe_decref(PyObject *obj) +{ + while (obj && Py_TYPE(obj) == &teedataobject_type && + Py_REFCNT(obj) == 1) { + PyObject *nextlink = ((teedataobject *)obj)->nextlink; + ((teedataobject *)obj)->nextlink = NULL; + Py_DECREF(obj); + obj = nextlink; + } + Py_XDECREF(obj); +} + static int teedataobject_clear(teedataobject *tdo) { int i; + PyObject *tmp; + Py_CLEAR(tdo->it); for (i=0 ; inumread ; i++) Py_CLEAR(tdo->values[i]); - Py_CLEAR(tdo->nextlink); + tmp = tdo->nextlink; + tdo->nextlink = NULL; + teedataobject_safe_decref(tmp); return 0; } @@ -475,6 +492,8 @@ if (to->index >= LINKCELLS) { link = teedataobject_jumplink(to->dataobj); + if (link == NULL) + return NULL; Py_DECREF(to->dataobj); to->dataobj = (teedataobject *)link; to->index = 0; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 12:35:13 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 12:35:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2313454=3A_Fix_a_crash_when_deleting_an_iterator_create?= =?utf-8?q?d_by_itertools=2Etee=28=29?= Message-ID: <3Ysyp943WPzS81@mail.python.org> http://hg.python.org/cpython/rev/eff2a7346243 changeset: 81701:eff2a7346243 branch: 3.3 parent: 81698:43907b88ce93 parent: 81700:f7e14a1af609 user: Serhiy Storchaka date: Fri Jan 25 13:24:47 2013 +0200 summary: Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. files: Lib/test/test_itertools.py | 8 ++++++++ Misc/NEWS | 3 +++ Modules/itertoolsmodule.c | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1267,6 +1267,14 @@ self.pickletest(a, compare=ans) self.pickletest(b, compare=ans) + # Issue 13454: Crash when deleting backward iterator from tee() + def test_tee_del_backward(self): + forward, backward = tee(range(20000000)) + for i in forward: + pass + + del backward + def test_StopIteration(self): self.assertRaises(StopIteration, next, zip()) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() + if all other iterators were very advanced before. + - Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries and bytes data. Patch by Jonas Wagner. diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -473,14 +473,31 @@ return 0; } +static void +teedataobject_safe_decref(PyObject *obj) +{ + while (obj && Py_TYPE(obj) == &teedataobject_type && + Py_REFCNT(obj) == 1) { + PyObject *nextlink = ((teedataobject *)obj)->nextlink; + ((teedataobject *)obj)->nextlink = NULL; + Py_DECREF(obj); + obj = nextlink; + } + Py_XDECREF(obj); +} + static int teedataobject_clear(teedataobject *tdo) { int i; + PyObject *tmp; + Py_CLEAR(tdo->it); for (i=0 ; inumread ; i++) Py_CLEAR(tdo->values[i]); - Py_CLEAR(tdo->nextlink); + tmp = tdo->nextlink; + tdo->nextlink = NULL; + teedataobject_safe_decref(tmp); return 0; } @@ -617,6 +634,8 @@ if (to->index >= LINKCELLS) { link = teedataobject_jumplink(to->dataobj); + if (link == NULL) + return NULL; Py_DECREF(to->dataobj); to->dataobj = (teedataobject *)link; to->index = 0; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 12:35:14 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 12:35:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2313454=3A_Fix_a_crash_when_deleting_an_iterator_?= =?utf-8?q?created_by_itertools=2Etee=28=29?= Message-ID: <3YsypB6shMzS8y@mail.python.org> http://hg.python.org/cpython/rev/02d7a127fdfb changeset: 81702:02d7a127fdfb parent: 81699:fcdb35b114ab parent: 81701:eff2a7346243 user: Serhiy Storchaka date: Fri Jan 25 13:26:55 2013 +0200 summary: Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. files: Lib/test/test_itertools.py | 8 ++++++++ Misc/NEWS | 3 +++ Modules/itertoolsmodule.c | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1267,6 +1267,14 @@ self.pickletest(a, compare=ans) self.pickletest(b, compare=ans) + # Issue 13454: Crash when deleting backward iterator from tee() + def test_tee_del_backward(self): + forward, backward = tee(range(20000000)) + for i in forward: + pass + + del backward + def test_StopIteration(self): self.assertRaises(StopIteration, next, zip()) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -218,6 +218,9 @@ Library ------- +- Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() + if all other iterators were very advanced before. + - Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries and bytes data. Patch by Jonas Wagner. diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -473,14 +473,31 @@ return 0; } +static void +teedataobject_safe_decref(PyObject *obj) +{ + while (obj && Py_TYPE(obj) == &teedataobject_type && + Py_REFCNT(obj) == 1) { + PyObject *nextlink = ((teedataobject *)obj)->nextlink; + ((teedataobject *)obj)->nextlink = NULL; + Py_DECREF(obj); + obj = nextlink; + } + Py_XDECREF(obj); +} + static int teedataobject_clear(teedataobject *tdo) { int i; + PyObject *tmp; + Py_CLEAR(tdo->it); for (i=0 ; inumread ; i++) Py_CLEAR(tdo->values[i]); - Py_CLEAR(tdo->nextlink); + tmp = tdo->nextlink; + tdo->nextlink = NULL; + teedataobject_safe_decref(tmp); return 0; } @@ -617,6 +634,8 @@ if (to->index >= LINKCELLS) { link = teedataobject_jumplink(to->dataobj); + if (link == NULL) + return NULL; Py_DECREF(to->dataobj); to->dataobj = (teedataobject *)link; to->index = 0; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 12:35:16 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 12:35:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzEzNDU0?= =?utf-8?q?=3A_Fix_a_crash_when_deleting_an_iterator_created_by_itertools?= =?utf-8?b?LnRlZSgp?= Message-ID: <3YsypD37nqzSDM@mail.python.org> http://hg.python.org/cpython/rev/62f2d3f6015e changeset: 81703:62f2d3f6015e branch: 2.7 parent: 81694:fc21f8e83062 user: Serhiy Storchaka date: Fri Jan 25 13:31:05 2013 +0200 summary: Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. files: Lib/test/test_itertools.py | 8 ++++++++ Misc/NEWS | 3 +++ Modules/itertoolsmodule.c | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -906,6 +906,14 @@ del a self.assertRaises(ReferenceError, getattr, p, '__class__') + # Issue 13454: Crash when deleting backward iterator from tee() + def test_tee_del_backward(self): + forward, backward = tee(xrange(20000000)) + for i in forward: + pass + + del backward + def test_StopIteration(self): self.assertRaises(StopIteration, izip().next) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,9 @@ Library ------- +- Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() + if all other iterators were very advanced before. + - Issue #1159051: GzipFile now raises EOFError when reading a corrupted file with truncated header or footer. diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -401,14 +401,31 @@ return 0; } +static void +teedataobject_safe_decref(PyObject *obj) +{ + while (obj && Py_TYPE(obj) == &teedataobject_type && + Py_REFCNT(obj) == 1) { + PyObject *nextlink = ((teedataobject *)obj)->nextlink; + ((teedataobject *)obj)->nextlink = NULL; + Py_DECREF(obj); + obj = nextlink; + } + Py_XDECREF(obj); +} + static int teedataobject_clear(teedataobject *tdo) { int i; + PyObject *tmp; + Py_CLEAR(tdo->it); for (i=0 ; inumread ; i++) Py_CLEAR(tdo->values[i]); - Py_CLEAR(tdo->nextlink); + tmp = tdo->nextlink; + tdo->nextlink = NULL; + teedataobject_safe_decref(tmp); return 0; } @@ -475,6 +492,8 @@ if (to->index >= LINKCELLS) { link = teedataobject_jumplink(to->dataobj); + if (link == NULL) + return NULL; Py_DECREF(to->dataobj); to->dataobj = (teedataobject *)link; to->index = 0; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 12:43:48 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 12:43:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Clean_trailing?= =?utf-8?q?_whitespace_in_itertoolsmodule=2Ec=2E?= Message-ID: <3Ysz0475W4zS81@mail.python.org> http://hg.python.org/cpython/rev/68485ac1972a changeset: 81704:68485ac1972a branch: 3.2 parent: 81700:f7e14a1af609 user: Serhiy Storchaka date: Fri Jan 25 13:37:39 2013 +0200 summary: Clean trailing whitespace in itertoolsmodule.c. files: Modules/itertoolsmodule.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2667,17 +2667,17 @@ accumulate_next(accumulateobject *lz) { PyObject *val, *oldtotal, *newtotal; - + val = PyIter_Next(lz->it); if (val == NULL) return NULL; - + if (lz->total == NULL) { Py_INCREF(val); lz->total = val; return lz->total; } - + newtotal = PyNumber_Add(lz->total, val); Py_DECREF(val); if (newtotal == NULL) @@ -2686,7 +2686,7 @@ oldtotal = lz->total; lz->total = newtotal; Py_DECREF(oldtotal); - + Py_INCREF(newtotal); return newtotal; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 12:43:50 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 12:43:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Clean_trailing_whitespace_in_itertoolsmodule=2Ec=2E?= Message-ID: <3Ysz06351YzSDM@mail.python.org> http://hg.python.org/cpython/rev/20c4d55f4b69 changeset: 81705:20c4d55f4b69 branch: 3.3 parent: 81701:eff2a7346243 parent: 81704:68485ac1972a user: Serhiy Storchaka date: Fri Jan 25 13:38:56 2013 +0200 summary: Clean trailing whitespace in itertoolsmodule.c. files: Modules/itertoolsmodule.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -964,7 +964,7 @@ /* Create a new cycle with the iterator tuple, then set * the saved state on it. */ - return Py_BuildValue("O(O)(Oi)", Py_TYPE(lz), + return Py_BuildValue("O(O)(Oi)", Py_TYPE(lz), lz->it, lz->saved, lz->firstpass); } @@ -3154,7 +3154,7 @@ goto err; PyTuple_SET_ITEM(indices, i, index); } - + cycles = PyTuple_New(po->r); if (cycles == NULL) goto err; @@ -3180,7 +3180,7 @@ { PyObject *indices, *cycles, *result; Py_ssize_t n, i; - + if (!PyArg_ParseTuple(state, "O!O!", &PyTuple_Type, &indices, &PyTuple_Type, &cycles)) @@ -3359,18 +3359,18 @@ accumulate_next(accumulateobject *lz) { PyObject *val, *oldtotal, *newtotal; - + val = PyIter_Next(lz->it); if (val == NULL) return NULL; - + if (lz->total == NULL) { Py_INCREF(val); lz->total = val; return lz->total; } - if (lz->binop == NULL) + if (lz->binop == NULL) newtotal = PyNumber_Add(lz->total, val); else newtotal = PyObject_CallFunctionObjArgs(lz->binop, lz->total, val, NULL); @@ -3381,7 +3381,7 @@ oldtotal = lz->total; lz->total = newtotal; Py_DECREF(oldtotal); - + Py_INCREF(newtotal); return newtotal; } @@ -4351,7 +4351,7 @@ static PyObject * zip_longest_reduce(ziplongestobject *lz) { - + /* Create a new tuple with empty sequences where appropriate to pickle. * Then use setstate to set the fillvalue */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 12:43:51 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 12:43:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Clean_trailing_whitespace_in_itertoolsmodule=2Ec=2E?= Message-ID: <3Ysz075jt0zSCp@mail.python.org> http://hg.python.org/cpython/rev/1b9e1dc695ab changeset: 81706:1b9e1dc695ab parent: 81702:02d7a127fdfb parent: 81705:20c4d55f4b69 user: Serhiy Storchaka date: Fri Jan 25 13:40:01 2013 +0200 summary: Clean trailing whitespace in itertoolsmodule.c. files: Modules/itertoolsmodule.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -964,7 +964,7 @@ /* Create a new cycle with the iterator tuple, then set * the saved state on it. */ - return Py_BuildValue("O(O)(Oi)", Py_TYPE(lz), + return Py_BuildValue("O(O)(Oi)", Py_TYPE(lz), lz->it, lz->saved, lz->firstpass); } @@ -3154,7 +3154,7 @@ goto err; PyTuple_SET_ITEM(indices, i, index); } - + cycles = PyTuple_New(po->r); if (cycles == NULL) goto err; @@ -3180,7 +3180,7 @@ { PyObject *indices, *cycles, *result; Py_ssize_t n, i; - + if (!PyArg_ParseTuple(state, "O!O!", &PyTuple_Type, &indices, &PyTuple_Type, &cycles)) @@ -3359,18 +3359,18 @@ accumulate_next(accumulateobject *lz) { PyObject *val, *oldtotal, *newtotal; - + val = PyIter_Next(lz->it); if (val == NULL) return NULL; - + if (lz->total == NULL) { Py_INCREF(val); lz->total = val; return lz->total; } - if (lz->binop == NULL) + if (lz->binop == NULL) newtotal = PyNumber_Add(lz->total, val); else newtotal = PyObject_CallFunctionObjArgs(lz->binop, lz->total, val, NULL); @@ -3381,7 +3381,7 @@ oldtotal = lz->total; lz->total = newtotal; Py_DECREF(oldtotal); - + Py_INCREF(newtotal); return newtotal; } @@ -4351,7 +4351,7 @@ static PyObject * zip_longest_reduce(ziplongestobject *lz) { - + /* Create a new tuple with empty sequences where appropriate to pickle. * Then use setstate to set the fillvalue */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 13:21:12 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 13:21:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogLSBJc3N1ZSAjMTcw?= =?utf-8?q?29=3A_Let_h2py_search_the_multiarch_system_include_directory=2E?= Message-ID: <3YszqD4lqqzQyb@mail.python.org> http://hg.python.org/cpython/rev/5981425cc48e changeset: 81707:5981425cc48e branch: 2.7 parent: 81703:62f2d3f6015e user: doko at python.org date: Fri Jan 25 13:08:27 2013 +0100 summary: - Issue #17029: Let h2py search the multiarch system include directory. files: Makefile.pre.in | 4 ++++ Misc/NEWS | 2 ++ Tools/scripts/h2py.py | 6 ++++++ configure | 4 ++++ configure.ac | 3 +++ 5 files changed, 19 insertions(+), 0 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -86,6 +86,9 @@ # Machine-dependent subdirectories MACHDEP= @MACHDEP@ +# Multiarch directory (may be empty) +MULTIARCH= @MULTIARCH@ + # Install prefix for architecture-independent files prefix= @prefix@ @@ -980,6 +983,7 @@ export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ + if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen python-config: $(srcdir)/Misc/python-config.in diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -706,6 +706,8 @@ Build ----- +- Issue #17029: Let h2py search the multiarch system include directory. + - Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py --- a/Tools/scripts/h2py.py +++ b/Tools/scripts/h2py.py @@ -58,6 +58,12 @@ raise KeyError except KeyError: searchdirs=['/usr/include'] + try: + searchdirs.insert(0, os.path.join('/usr/include', + os.environ['MULTIARCH'])) + except KeyError: + pass + def main(): global filedict diff --git a/configure b/configure --- a/configure +++ b/configure @@ -686,6 +686,7 @@ EGREP GREP CPP +MULTIARCH MAINCC CXX OBJEXT @@ -4281,6 +4282,9 @@ " >&2;} fi +MULTIARCH=$($CC --print-multiarch 2>/dev/null) + + # checks for UNIX variants that set C preprocessor variables diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -603,6 +603,9 @@ ]) fi +MULTIARCH=$($CC --print-multiarch 2>/dev/null) +AC_SUBST(MULTIARCH) + # checks for UNIX variants that set C preprocessor variables AC_USE_SYSTEM_EXTENSIONS -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 13:21:14 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 13:21:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogLSBJc3N1ZSAjMTcw?= =?utf-8?q?29=3A_Let_h2py_search_the_multiarch_system_include_directory=2E?= Message-ID: <3YszqG0jzDzMGr@mail.python.org> http://hg.python.org/cpython/rev/039e17133391 changeset: 81708:039e17133391 branch: 3.2 parent: 81704:68485ac1972a user: doko at python.org date: Fri Jan 25 13:12:29 2013 +0100 summary: - Issue #17029: Let h2py search the multiarch system include directory. files: Makefile.pre.in | 4 ++++ Misc/NEWS | 2 ++ Tools/scripts/h2py.py | 5 +++++ configure | 4 ++++ configure.ac | 3 +++ 5 files changed, 18 insertions(+), 0 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -97,6 +97,9 @@ # Machine-dependent subdirectories MACHDEP= @MACHDEP@ +# Multiarch directory (may be empty) +MULTIARCH= @MULTIARCH@ + # Install prefix for architecture-independent files prefix= @prefix@ @@ -1040,6 +1043,7 @@ export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ + if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen python-config: $(srcdir)/Misc/python-config.in diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -861,6 +861,8 @@ Build ----- +- Issue #17029: Let h2py search the multiarch system include directory. + - Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py --- a/Tools/scripts/h2py.py +++ b/Tools/scripts/h2py.py @@ -50,6 +50,11 @@ searchdirs=os.environ['INCLUDE'].split(';') except KeyError: searchdirs=['/usr/include'] + try: + searchdirs.insert(0, os.path.join('/usr/include', + os.environ['MULTIARCH'])) + except KeyError: + pass def main(): global filedict diff --git a/configure b/configure --- a/configure +++ b/configure @@ -688,6 +688,7 @@ DLLLIBRARY LDLIBRARY LIBRARY +MULTIARCH BUILDEXEEXT EGREP GREP @@ -4750,6 +4751,9 @@ esac;; esac +MULTIARCH=$($CC --print-multiarch 2>/dev/null) + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking LIBRARY" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -593,6 +593,9 @@ esac;; esac +MULTIARCH=$($CC --print-multiarch 2>/dev/null) +AC_SUBST(MULTIARCH) + AC_SUBST(LIBRARY) AC_MSG_CHECKING(LIBRARY) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 13:21:15 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 13:21:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_-_Issue_=2317029=3A_Let_h2py_search_the_multiarch_system_inclu?= =?utf-8?q?de_directory=2E?= Message-ID: <3YszqH3jBHzSHK@mail.python.org> http://hg.python.org/cpython/rev/c97447e36665 changeset: 81709:c97447e36665 branch: 3.3 parent: 81705:20c4d55f4b69 parent: 81708:039e17133391 user: doko at python.org date: Fri Jan 25 13:19:35 2013 +0100 summary: - Issue #17029: Let h2py search the multiarch system include directory. files: Makefile.pre.in | 4 ++++ Misc/NEWS | 2 ++ Tools/scripts/h2py.py | 5 +++++ configure | 4 ++++ configure.ac | 3 +++ 5 files changed, 18 insertions(+), 0 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -97,6 +97,9 @@ # Machine-dependent subdirectories MACHDEP= @MACHDEP@ +# Multiarch directory (may be empty) +MULTIARCH= @MULTIARCH@ + # Install prefix for architecture-independent files prefix= @prefix@ @@ -1119,6 +1122,7 @@ export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ + if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen python-config: $(srcdir)/Misc/python-config.in diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -533,6 +533,8 @@ Build ----- +- Issue #17029: Let h2py search the multiarch system include directory. + - Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py --- a/Tools/scripts/h2py.py +++ b/Tools/scripts/h2py.py @@ -50,6 +50,11 @@ searchdirs=os.environ['INCLUDE'].split(';') except KeyError: searchdirs=['/usr/include'] + try: + searchdirs.insert(0, os.path.join('/usr/include', + os.environ['MULTIARCH'])) + except KeyError: + pass def main(): global filedict diff --git a/configure b/configure --- a/configure +++ b/configure @@ -684,6 +684,7 @@ DLLLIBRARY LDLIBRARY LIBRARY +MULTIARCH BUILDEXEEXT EGREP GREP @@ -5351,6 +5352,9 @@ esac;; esac +MULTIARCH=$($CC --print-multiarch 2>/dev/null) + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking LIBRARY" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -764,6 +764,9 @@ esac;; esac +MULTIARCH=$($CC --print-multiarch 2>/dev/null) +AC_SUBST(MULTIARCH) + AC_SUBST(LIBRARY) AC_MSG_CHECKING(LIBRARY) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 13:21:16 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 13:21:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_-_Issue_=2317029=3A_Let_h2py_search_the_multiarch_system?= =?utf-8?q?_include_directory=2E?= Message-ID: <3YszqK064gzSJX@mail.python.org> http://hg.python.org/cpython/rev/f69eced9ff9d changeset: 81710:f69eced9ff9d parent: 81706:1b9e1dc695ab parent: 81709:c97447e36665 user: doko at python.org date: Fri Jan 25 13:20:46 2013 +0100 summary: - Issue #17029: Let h2py search the multiarch system include directory. files: Makefile.pre.in | 4 ++++ Misc/NEWS | 2 ++ Tools/scripts/h2py.py | 5 +++++ configure | 4 ++++ configure.ac | 3 +++ 5 files changed, 18 insertions(+), 0 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -97,6 +97,9 @@ # Machine-dependent subdirectories MACHDEP= @MACHDEP@ +# Multiarch directory (may be empty) +MULTIARCH= @MULTIARCH@ + # Install prefix for architecture-independent files prefix= @prefix@ @@ -1119,6 +1122,7 @@ export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ + if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen python-config: $(srcdir)/Misc/python-config.in diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -746,6 +746,8 @@ Build ----- +- Issue #17029: Let h2py search the multiarch system include directory. + - Issue #16953: Fix socket module compilation on platforms with HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong. diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py --- a/Tools/scripts/h2py.py +++ b/Tools/scripts/h2py.py @@ -50,6 +50,11 @@ searchdirs=os.environ['INCLUDE'].split(';') except KeyError: searchdirs=['/usr/include'] + try: + searchdirs.insert(0, os.path.join('/usr/include', + os.environ['MULTIARCH'])) + except KeyError: + pass def main(): global filedict diff --git a/configure b/configure --- a/configure +++ b/configure @@ -684,6 +684,7 @@ DLLLIBRARY LDLIBRARY LIBRARY +MULTIARCH BUILDEXEEXT EGREP GREP @@ -5351,6 +5352,9 @@ esac;; esac +MULTIARCH=$($CC --print-multiarch 2>/dev/null) + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking LIBRARY" >&5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -764,6 +764,9 @@ esac;; esac +MULTIARCH=$($CC --print-multiarch 2>/dev/null) +AC_SUBST(MULTIARCH) + AC_SUBST(LIBRARY) AC_MSG_CHECKING(LIBRARY) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 14:07:30 2013 From: python-checkins at python.org (martin.v.loewis) Date: Fri, 25 Jan 2013 14:07:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Drop_support_for_Windows_2?= =?utf-8?q?000=3B_allow_any_XP_API_=28but_not_Vista+=29=2E?= Message-ID: <3Yt0rf1v96zSKX@mail.python.org> http://hg.python.org/cpython/rev/e52df05b496a changeset: 81711:e52df05b496a user: Martin v. L?wis date: Fri Jan 25 14:06:18 2013 +0100 summary: Drop support for Windows 2000; allow any XP API (but not Vista+). Drop SDK version configuration for Tk compilation, to not bind it to W2k anymore. Binding it to XP would conflict with Tk's own binding of tkMenu to W2k. files: Misc/NEWS | 2 + PC/pyconfig.h | 8 +---- PCbuild/build_tkinter.py | 6 +-- Python/random.c | 33 +----------------- Tools/buildbot/external-amd64.bat | 10 ++-- Tools/buildbot/external.bat | 8 ++-- 6 files changed, 16 insertions(+), 51 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -746,6 +746,8 @@ Build ----- +- Drop support for Windows 2000. + - Issue #17029: Let h2py search the multiarch system include directory. - Issue #16953: Fix socket module compilation on platforms with diff --git a/PC/pyconfig.h b/PC/pyconfig.h --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -156,15 +156,9 @@ #endif /* MS_WIN64 */ /* set the version macros for the windows headers */ -#ifdef MS_WINX64 -/* 64 bit only runs on XP or greater */ +/* Python 3.4+ requires Windows XP or greater */ #define Py_WINVER 0x0501 /* _WIN32_WINNT_WINXP */ #define Py_NTDDI NTDDI_WINXP -#else -/* Python 2.6+ requires Windows 2000 or greater */ -#define Py_WINVER 0x0500 /* _WIN32_WINNT_WIN2K */ -#define Py_NTDDI NTDDI_WIN2KSP4 -#endif /* We only set these values when building Python - we don't want to force these values on extensions, as that will affect the prototypes and diff --git a/PCbuild/build_tkinter.py b/PCbuild/build_tkinter.py --- a/PCbuild/build_tkinter.py +++ b/PCbuild/build_tkinter.py @@ -16,11 +16,7 @@ TIX = "tix-8.4.3.x" ROOT = os.path.abspath(os.path.join(here, par, par)) -# Windows 2000 compatibility: WINVER 0x0500 -# http://msdn2.microsoft.com/en-us/library/aa383745.aspx -NMAKE = ('nmake /nologo /f %s ' - 'COMPILERFLAGS=\"-DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=NTDDI_WIN2KSP4\" ' - '%s %s') +NMAKE = ('nmake /nologo /f %s %s %s') def nmake(makefile, command="", **kw): defines = ' '.join(k+'='+str(v) for k, v in kw.items()) diff --git a/Python/random.c b/Python/random.c --- a/Python/random.c +++ b/Python/random.c @@ -12,13 +12,6 @@ #endif #ifdef MS_WINDOWS -typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv,\ - LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType,\ - DWORD dwFlags ); -typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen,\ - BYTE *pbBuffer ); - -static CRYPTGENRANDOM pCryptGenRandom = NULL; /* This handle is never explicitly released. Instead, the operating system will release it when the process terminates. */ static HCRYPTPROV hCryptProv = 0; @@ -26,29 +19,9 @@ static int win32_urandom_init(int raise) { - HINSTANCE hAdvAPI32 = NULL; - CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL; - - /* Obtain handle to the DLL containing CryptoAPI. This should not fail. */ - hAdvAPI32 = GetModuleHandle("advapi32.dll"); - if(hAdvAPI32 == NULL) - goto error; - - /* Obtain pointers to the CryptoAPI functions. This will fail on some early - versions of Win95. */ - pCryptAcquireContext = (CRYPTACQUIRECONTEXTA)GetProcAddress( - hAdvAPI32, "CryptAcquireContextA"); - if (pCryptAcquireContext == NULL) - goto error; - - pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress(hAdvAPI32, - "CryptGenRandom"); - if (pCryptGenRandom == NULL) - goto error; - /* Acquire context */ - if (! pCryptAcquireContext(&hCryptProv, NULL, NULL, - PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + if (!CryptAcquireContext(&hCryptProv, NULL, NULL, + PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) goto error; return 0; @@ -77,7 +50,7 @@ while (size > 0) { chunk = size > INT_MAX ? INT_MAX : size; - if (!pCryptGenRandom(hCryptProv, chunk, buffer)) + if (!CryptGenRandom(hCryptProv, chunk, buffer)) { /* CryptGenRandom() failed */ if (raise) diff --git a/Tools/buildbot/external-amd64.bat b/Tools/buildbot/external-amd64.bat --- a/Tools/buildbot/external-amd64.bat +++ b/Tools/buildbot/external-amd64.bat @@ -6,16 +6,16 @@ if not exist tcltk64\bin\tcl85g.dll ( cd tcl-8.5.11.0\win - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 install + nmake -f makefile.vc DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all + nmake -f makefile.vc DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 install cd ..\.. ) if not exist tcltk64\bin\tk85g.dll ( cd tk-8.5.11.0\win - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 clean - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 all - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 install + nmake -f makefile.vc OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 clean + nmake -f makefile.vc OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 all + nmake -f makefile.vc OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.11.0 install cd ..\.. ) diff --git a/Tools/buildbot/external.bat b/Tools/buildbot/external.bat --- a/Tools/buildbot/external.bat +++ b/Tools/buildbot/external.bat @@ -7,15 +7,15 @@ if not exist tcltk\bin\tcl85g.dll ( @rem all and install need to be separate invocations, otherwise nmakehlp is not found on install cd tcl-8.5.11.0\win - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 INSTALLDIR=..\..\tcltk clean all + nmake -f makefile.vc DEBUG=1 INSTALLDIR=..\..\tcltk clean all nmake -f makefile.vc DEBUG=1 INSTALLDIR=..\..\tcltk install cd ..\.. ) if not exist tcltk\bin\tk85g.dll ( cd tk-8.5.11.0\win - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 clean - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 all - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 install + nmake -f makefile.vc OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 clean + nmake -f makefile.vc OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 all + nmake -f makefile.vc OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.11.0 install cd ..\.. ) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 14:26:30 2013 From: python-checkins at python.org (martin.v.loewis) Date: Fri, 25 Jan 2013 14:26:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Replace_WaitForSingleObjec?= =?utf-8?q?t_with_WaitForSingleObjectEx=2C?= Message-ID: <3Yt1GZ0HdGzSJY@mail.python.org> http://hg.python.org/cpython/rev/b71b6517af63 changeset: 81712:b71b6517af63 user: Martin v. L?wis date: Fri Jan 25 14:25:48 2013 +0100 summary: Replace WaitForSingleObject with WaitForSingleObjectEx, for better WinRT compatibility. files: Modules/_multiprocessing/semaphore.c | 4 ++-- Modules/timemodule.c | 2 +- PC/launcher.c | 2 +- Parser/myreadline.c | 2 +- Python/condvar.h | 2 +- Python/thread_nt.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -43,7 +43,7 @@ { long previous; - switch (WaitForSingleObject(handle, 0)) { + switch (WaitForSingleObjectEx(handle, 0, FALSE)) { case WAIT_OBJECT_0: if (!ReleaseSemaphore(handle, 1, &previous)) return MP_STANDARD_ERROR; @@ -99,7 +99,7 @@ } /* check whether we can acquire without releasing the GIL and blocking */ - if (WaitForSingleObject(self->handle, 0) == WAIT_OBJECT_0) { + if (WaitForSingleObjectEx(self->handle, 0, FALSE) == WAIT_OBJECT_0) { self->last_tid = GetCurrentThreadId(); ++self->count; Py_RETURN_TRUE; diff --git a/Modules/timemodule.c b/Modules/timemodule.c --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -1574,7 +1574,7 @@ DWORD rc; HANDLE hInterruptEvent = _PyOS_SigintEvent(); ResetEvent(hInterruptEvent); - rc = WaitForSingleObject(hInterruptEvent, ul_millis); + rc = WaitForSingleObjectEx(hInterruptEvent, ul_millis, FALSE); if (rc == WAIT_OBJECT_0) { Py_BLOCK_THREADS errno = EINTR; diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -535,7 +535,7 @@ error(RC_CREATE_PROCESS, L"Unable to create process using '%s'", cmdline); AssignProcessToJobObject(job, pi.hProcess); CloseHandle(pi.hThread); - WaitForSingleObject(pi.hProcess, INFINITE); + WaitForSingleObjectEx(pi.hProcess, INFINITE, FALSE); ok = GetExitCodeProcess(pi.hProcess, &rc); if (!ok) error(RC_CREATE_PROCESS, L"Failed to get exit code of process"); diff --git a/Parser/myreadline.c b/Parser/myreadline.c --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -68,7 +68,7 @@ */ if (GetLastError()==ERROR_OPERATION_ABORTED) { hInterruptEvent = _PyOS_SigintEvent(); - switch (WaitForSingleObject(hInterruptEvent, 10)) { + switch (WaitForSingleObjectEx(hInterruptEvent, 10, FALSE)) { case WAIT_OBJECT_0: ResetEvent(hInterruptEvent); return 1; /* Interrupt */ diff --git a/Python/condvar.h b/Python/condvar.h --- a/Python/condvar.h +++ b/Python/condvar.h @@ -242,7 +242,7 @@ * but we are safe because we are using a semaphore wich has an internal * count. */ - wait = WaitForSingleObject(cv->sem, ms); + wait = WaitForSingleObjectEx(cv->sem, ms, FALSE); PyMUTEX_LOCK(cs); if (wait != WAIT_OBJECT_0) --cv->waiting; diff --git a/Python/thread_nt.h b/Python/thread_nt.h --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -130,7 +130,7 @@ DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds) { - return WaitForSingleObject(mutex, milliseconds); + return WaitForSingleObjectEx(mutex, milliseconds, FALSE); } BOOL -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 14:30:03 2013 From: python-checkins at python.org (martin.v.loewis) Date: Fri, 25 Jan 2013 14:30:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Replace_WaitForMultipleObj?= =?utf-8?q?ects_with_WaitForMultipleObjectEx=2C?= Message-ID: <3Yt1Lg2dtCzSJY@mail.python.org> http://hg.python.org/cpython/rev/46ed0a25fb2c changeset: 81713:46ed0a25fb2c user: Martin v. L?wis date: Fri Jan 25 14:29:13 2013 +0100 summary: Replace WaitForMultipleObjects with WaitForMultipleObjectEx, for better WinRT compatibility. files: Modules/_multiprocessing/semaphore.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -118,7 +118,7 @@ Py_BEGIN_ALLOW_THREADS if (sigint_event != NULL) ResetEvent(sigint_event); - res = WaitForMultipleObjects(nhandles, handles, FALSE, full_msecs); + res = WaitForMultipleObjectsEx(nhandles, handles, FALSE, full_msecs, FALSE); Py_END_ALLOW_THREADS /* handle result */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 14:36:02 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 14:36:02 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogLSBJc3N1ZSAjMTU0?= =?utf-8?q?84=3A_Fix_=5FPYTHON=5FPROJECT=5FBASE_for_srcdir_!=3D_builddir_b?= =?utf-8?q?uilds=3B?= Message-ID: <3Yt1TZ0vjDzRC0@mail.python.org> http://hg.python.org/cpython/rev/b2e7c85399f5 changeset: 81714:b2e7c85399f5 branch: 3.3 parent: 81709:c97447e36665 user: doko at python.org date: Fri Jan 25 14:33:33 2013 +0100 summary: - Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; use _PYTHON_PROJECT_BASE in distutils/sysconfig.py. files: Lib/distutils/sysconfig.py | 13 ++++++++----- Misc/NEWS | 3 +++ configure | 2 +- configure.ac | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -24,7 +24,11 @@ # Path to the base directory of the project. On Windows the binary may # live in project/PCBuild9. If we're dealing with an x64 Windows build, # it'll live in project/PCbuild/amd64. -project_base = os.path.dirname(os.path.abspath(sys.executable)) +# set for cross builds +if "_PYTHON_PROJECT_BASE" in os.environ: + project_base = os.path.abspath(os.environ["_PYTHON_PROJECT_BASE"]) +else: + project_base = os.path.dirname(os.path.abspath(sys.executable)) if os.name == "nt" and "pcbuild" in project_base[-8:].lower(): project_base = os.path.abspath(os.path.join(project_base, os.path.pardir)) # PC/VS7.1 @@ -98,7 +102,7 @@ # the build directory may not be the source directory, we # must use "srcdir" from the makefile to find the "Include" # directory. - base = _sys_home or os.path.dirname(os.path.abspath(sys.executable)) + base = _sys_home or project_base if plat_specific: return base if _sys_home: @@ -251,8 +255,7 @@ def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: - return os.path.join(_sys_home or os.path.dirname(sys.executable), - "Makefile") + return os.path.join(_sys_home or project_base, "Makefile") lib_dir = get_python_lib(plat_specific=0, standard_lib=1) config_file = 'config-{}{}'.format(get_python_version(), build_flags) return os.path.join(lib_dir, config_file, 'Makefile') @@ -555,7 +558,7 @@ # testing, for example, we might be running a non-installed python # from a different directory. if python_build and os.name == "posix": - base = os.path.dirname(os.path.abspath(sys.executable)) + base = project_base if (not os.path.isabs(_config_vars['srcdir']) and base != os.getcwd()): # srcdir is relative and we are not in the same directory diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -533,6 +533,9 @@ Build ----- +- Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; + use _PYTHON_PROJECT_BASE in distutils/sysconfig.py. + - Issue #17029: Let h2py search the multiarch system include directory. - Issue #16953: Fix socket module compilation on platforms with diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2942,7 +2942,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 $as_echo "$interp" >&6; } - PYTHON_FOR_BUILD="_PYTHON_PROJECT_BASE=$srcdir"' _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp fi elif test "$cross_compiling" = maybe; then as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -65,7 +65,7 @@ AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) fi AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD="_PYTHON_PROJECT_BASE=$srcdir"' _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp fi elif test "$cross_compiling" = maybe; then AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 14:36:03 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 14:36:03 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_-_Issue_=2315484=3A_Fix_=5FPYTHON=5FPROJECT=5FBASE_for_s?= =?utf-8?q?rcdir_!=3D_builddir_builds=3B?= Message-ID: <3Yt1Tb5B8lzSJY@mail.python.org> http://hg.python.org/cpython/rev/172fec65c882 changeset: 81715:172fec65c882 parent: 81713:46ed0a25fb2c parent: 81714:b2e7c85399f5 user: doko at python.org date: Fri Jan 25 14:35:44 2013 +0100 summary: - Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; use _PYTHON_PROJECT_BASE in distutils/sysconfig.py. files: Lib/distutils/sysconfig.py | 13 ++++++++----- Misc/NEWS | 3 +++ configure | 2 +- configure.ac | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -24,7 +24,11 @@ # Path to the base directory of the project. On Windows the binary may # live in project/PCBuild9. If we're dealing with an x64 Windows build, # it'll live in project/PCbuild/amd64. -project_base = os.path.dirname(os.path.abspath(sys.executable)) +# set for cross builds +if "_PYTHON_PROJECT_BASE" in os.environ: + project_base = os.path.abspath(os.environ["_PYTHON_PROJECT_BASE"]) +else: + project_base = os.path.dirname(os.path.abspath(sys.executable)) if os.name == "nt" and "pcbuild" in project_base[-8:].lower(): project_base = os.path.abspath(os.path.join(project_base, os.path.pardir)) # PC/VS7.1 @@ -98,7 +102,7 @@ # the build directory may not be the source directory, we # must use "srcdir" from the makefile to find the "Include" # directory. - base = _sys_home or os.path.dirname(os.path.abspath(sys.executable)) + base = _sys_home or project_base if plat_specific: return base if _sys_home: @@ -244,8 +248,7 @@ def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: - return os.path.join(_sys_home or os.path.dirname(sys.executable), - "Makefile") + return os.path.join(_sys_home or project_base, "Makefile") lib_dir = get_python_lib(plat_specific=0, standard_lib=1) config_file = 'config-{}{}'.format(get_python_version(), build_flags) return os.path.join(lib_dir, config_file, 'Makefile') @@ -531,7 +534,7 @@ # testing, for example, we might be running a non-installed python # from a different directory. if python_build and os.name == "posix": - base = os.path.dirname(os.path.abspath(sys.executable)) + base = project_base if (not os.path.isabs(_config_vars['srcdir']) and base != os.getcwd()): # srcdir is relative and we are not in the same directory diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -746,6 +746,9 @@ Build ----- +- Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; + use _PYTHON_PROJECT_BASE in distutils/sysconfig.py. + - Drop support for Windows 2000. - Issue #17029: Let h2py search the multiarch system include directory. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2942,7 +2942,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 $as_echo "$interp" >&6; } - PYTHON_FOR_BUILD="_PYTHON_PROJECT_BASE=$srcdir"' _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp fi elif test "$cross_compiling" = maybe; then as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -65,7 +65,7 @@ AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) fi AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD="_PYTHON_PROJECT_BASE=$srcdir"' _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp fi elif test "$cross_compiling" = maybe; then AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 14:44:32 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 14:44:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogLSBJc3N1ZSAjMTYy?= =?utf-8?q?92=3A_Improve_a_comment_for_cross_building_in_configure=2Eac?= Message-ID: <3Yt1gN4w37zSDM@mail.python.org> http://hg.python.org/cpython/rev/4c97d2d464ad changeset: 81716:4c97d2d464ad branch: 3.3 parent: 81714:b2e7c85399f5 user: doko at python.org date: Fri Jan 25 14:44:00 2013 +0100 summary: - Issue #16292: Improve a comment for cross building in configure.ac files: configure | 6 +++--- configure.ac | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure --- a/configure +++ b/configure @@ -3249,9 +3249,9 @@ then # avoid using uname for cross builds if test "$cross_compiling" = yes; then - # ac_sys_system and ac_sys_release are only used for setting - # `define_xopen_source' in the case statement below. For the - # current supported cross builds, this macro is not adjusted. + # ac_sys_system and ac_sys_release are used for setting + # a lot of different things including 'define_xopen_source' + # in the case statement below. case "$host" in *-*-linux*) ac_sys_system=Linux diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -352,9 +352,9 @@ then # avoid using uname for cross builds if test "$cross_compiling" = yes; then - # ac_sys_system and ac_sys_release are only used for setting - # `define_xopen_source' in the case statement below. For the - # current supported cross builds, this macro is not adjusted. + # ac_sys_system and ac_sys_release are used for setting + # a lot of different things including 'define_xopen_source' + # in the case statement below. case "$host" in *-*-linux*) ac_sys_system=Linux -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 14:44:34 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 14:44:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_-_Issue_=2316292=3A_Improve_a_comment_for_cross_building?= =?utf-8?q?_in_configure=2Eac?= Message-ID: <3Yt1gQ11brzSJp@mail.python.org> http://hg.python.org/cpython/rev/4feff8c8250b changeset: 81717:4feff8c8250b parent: 81715:172fec65c882 parent: 81716:4c97d2d464ad user: doko at python.org date: Fri Jan 25 14:44:20 2013 +0100 summary: - Issue #16292: Improve a comment for cross building in configure.ac files: configure | 6 +++--- configure.ac | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure --- a/configure +++ b/configure @@ -3249,9 +3249,9 @@ then # avoid using uname for cross builds if test "$cross_compiling" = yes; then - # ac_sys_system and ac_sys_release are only used for setting - # `define_xopen_source' in the case statement below. For the - # current supported cross builds, this macro is not adjusted. + # ac_sys_system and ac_sys_release are used for setting + # a lot of different things including 'define_xopen_source' + # in the case statement below. case "$host" in *-*-linux*) ac_sys_system=Linux diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -352,9 +352,9 @@ then # avoid using uname for cross builds if test "$cross_compiling" = yes; then - # ac_sys_system and ac_sys_release are only used for setting - # `define_xopen_source' in the case statement below. For the - # current supported cross builds, this macro is not adjusted. + # ac_sys_system and ac_sys_release are used for setting + # a lot of different things including 'define_xopen_source' + # in the case statement below. case "$host" in *-*-linux*) ac_sys_system=Linux -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:15:06 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 15:15:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzkyOTA6?= =?utf-8?q?_In_IDLE_the_sys=2Estd*_streams_now_implement_io=2ETextIOBase?= Message-ID: <3Yt2Lf1RdqzSLy@mail.python.org> http://hg.python.org/cpython/rev/def4cd7e0a9f changeset: 81718:def4cd7e0a9f branch: 2.7 parent: 81707:5981425cc48e user: Serhiy Storchaka date: Fri Jan 25 15:30:35 2013 +0200 summary: Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. files: Lib/idlelib/PyShell.py | 96 +++++++++++++++++++++-------- Lib/idlelib/run.py | 54 ++-------------- Misc/NEWS | 3 + 3 files changed, 82 insertions(+), 71 deletions(-) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -428,10 +428,8 @@ except socket.timeout, err: self.display_no_subprocess_error() return None - # Can't regiter self.tkconsole.stdin, since run.py wants to - # call non-TextIO methods on it (such as getvar) - # XXX should be renamed to "console" - self.rpcclt.register("stdin", self.tkconsole) + self.rpcclt.register("console", self.tkconsole) + self.rpcclt.register("stdin", self.tkconsole.stdin) self.rpcclt.register("stdout", self.tkconsole.stdout) self.rpcclt.register("stderr", self.tkconsole.stderr) self.rpcclt.register("flist", self.tkconsole.flist) @@ -884,10 +882,10 @@ self.save_stderr = sys.stderr self.save_stdin = sys.stdin from idlelib import IOBinding - self.stdin = PseudoInputFile(self) - self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) - self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) - self.console = PseudoFile(self, "console", IOBinding.encoding) + self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding) + self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding) + self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding) + self.console = PseudoOutputFile(self, "console", IOBinding.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr @@ -1279,37 +1277,83 @@ return 'disabled' return super(PyShell, self).rmenu_check_paste() -class PseudoFile(object): +class PseudoFile(io.TextIOBase): def __init__(self, shell, tags, encoding=None): self.shell = shell self.tags = tags self.softspace = 0 - self.encoding = encoding + self._encoding = encoding - def write(self, s): - if not isinstance(s, (basestring, bytearray)): - raise TypeError('must be string, not ' + type(s).__name__) - self.shell.write(s, self.tags) + @property + def encoding(self): + return self._encoding - def writelines(self, lines): - for line in lines: - self.write(line) - - def flush(self): - pass + @property + def name(self): + return '<%s>' % self.tags def isatty(self): return True -class PseudoInputFile(object): - def __init__(self, shell): - self.readline = shell.readline - self.isatty = shell.isatty + +class PseudoOutputFile(PseudoFile): + + def writable(self): + return True def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write + if self.closed: + raise ValueError("write to closed file") + if not isinstance(s, (basestring, bytearray)): + raise TypeError('must be string, not ' + type(s).__name__) + return self.shell.write(s, self.tags) + + +class PseudoInputFile(PseudoFile): + + def __init__(self, shell, tags, encoding=None): + PseudoFile.__init__(self, shell, tags, encoding) + self._line_buffer = '' + + def readable(self): + return True + + def read(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + result = self._line_buffer + self._line_buffer = '' + if size < 0: + while True: + line = self.shell.readline() + if not line: break + result += line + else: + while len(result) < size: + line = self.shell.readline() + if not line: break + result += line + self._line_buffer = result[size:] + result = result[:size] + return result + + def readline(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + line = self._line_buffer or self.shell.readline() + if size < 0: + size = len(line) + self._line_buffer = line[size:] + return line[:size] usage_msg = """\ diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -15,6 +15,8 @@ from idlelib import RemoteObjectBrowser from idlelib import StackViewer from idlelib import rpc +from idlelib import PyShell +from idlelib import IOBinding import __main__ @@ -249,57 +251,19 @@ quitting = True thread.interrupt_main() -class _RPCFile(io.TextIOBase): - """Wrapper class for the RPC proxy to typecheck arguments - that may not support pickling. The base class is there only - to support type tests; all implementations come from the remote - object.""" - - def __init__(self, rpc): - super.__setattr__(self, 'rpc', rpc) - - def __getattribute__(self, name): - # When accessing the 'rpc' attribute, or 'write', use ours - if name in ('rpc', 'write', 'writelines'): - return io.TextIOBase.__getattribute__(self, name) - # Else only look into the remote object only - return getattr(self.rpc, name) - - def __setattr__(self, name, value): - return setattr(self.rpc, name, value) - - @staticmethod - def _ensure_string(func): - def f(self, s): - if not isinstance(s, basestring): - raise TypeError('must be str, not ' + type(s).__name__) - return func(self, s) - return f - -class _RPCOutputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - return self.rpc.write(s) - -class _RPCInputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write - class MyHandler(rpc.RPCHandler): def handle(self): """Override base method""" executive = Executive(self) self.register("exec", executive) - self.console = self.get_remote_proxy("stdin") - sys.stdin = _RPCInputFile(self.console) - sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout")) - sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr")) - from idlelib import IOBinding - sys.stdin.encoding = sys.stdout.encoding = \ - sys.stderr.encoding = IOBinding.encoding + self.console = self.get_remote_proxy("console") + sys.stdin = PyShell.PseudoInputFile(self.console, "stdin", + IOBinding.encoding) + sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout", + IOBinding.encoding) + sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", + IOBinding.encoding) self.interp = self.get_remote_proxy("interp") rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,9 @@ Library ------- +- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase + interface and support all mandatory methods and properties. + - Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:15:07 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 15:15:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzkyOTA6?= =?utf-8?q?_In_IDLE_the_sys=2Estd*_streams_now_implement_io=2ETextIOBase?= Message-ID: <3Yt2Lg5kzgzSM8@mail.python.org> http://hg.python.org/cpython/rev/0d26f3aa7a8f changeset: 81719:0d26f3aa7a8f branch: 3.2 parent: 81708:039e17133391 user: Serhiy Storchaka date: Fri Jan 25 15:30:58 2013 +0200 summary: Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. files: Lib/idlelib/PyShell.py | 90 ++++++++++++++++++++++------- Lib/idlelib/run.py | 57 +++--------------- Misc/NEWS | 3 + 3 files changed, 80 insertions(+), 70 deletions(-) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -417,10 +417,8 @@ except socket.timeout as err: self.display_no_subprocess_error() return None - # Can't regiter self.tkconsole.stdin, since run.py wants to - # call non-TextIO methods on it (such as getvar) - # XXX should be renamed to "console" - self.rpcclt.register("stdin", self.tkconsole) + self.rpcclt.register("console", self.tkconsole) + self.rpcclt.register("stdin", self.tkconsole.stdin) self.rpcclt.register("stdout", self.tkconsole.stdout) self.rpcclt.register("stderr", self.tkconsole.stderr) self.rpcclt.register("flist", self.tkconsole.flist) @@ -860,10 +858,10 @@ self.save_stderr = sys.stderr self.save_stdin = sys.stdin from idlelib import IOBinding - self.stdin = PseudoInputFile(self) - self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) - self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) - self.console = PseudoFile(self, "console", IOBinding.encoding) + self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding) + self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding) + self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding) + self.console = PseudoOutputFile(self, "console", IOBinding.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr @@ -1259,36 +1257,82 @@ return 'disabled' return super().rmenu_check_paste() -class PseudoFile(object): +class PseudoFile(io.TextIOBase): def __init__(self, shell, tags, encoding=None): self.shell = shell self.tags = tags - self.encoding = encoding + self._encoding = encoding + + @property + def encoding(self): + return self._encoding + + @property + def name(self): + return '<%s>' % self.tags + + def isatty(self): + return True + + +class PseudoOutputFile(PseudoFile): + + def writable(self): + return True def write(self, s): + if self.closed: + raise ValueError("write to closed file") if not isinstance(s, str): raise TypeError('must be str, not ' + type(s).__name__) return self.shell.write(s, self.tags) - def writelines(self, lines): - for line in lines: - self.write(line) - def flush(self): - pass +class PseudoInputFile(PseudoFile): - def isatty(self): + def __init__(self, shell, tags, encoding=None): + PseudoFile.__init__(self, shell, tags, encoding) + self._line_buffer = '' + + def readable(self): return True -class PseudoInputFile(object): - def __init__(self, shell): - self.readline = shell.readline - self.isatty = shell.isatty + def read(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + result = self._line_buffer + self._line_buffer = '' + if size < 0: + while True: + line = self.shell.readline() + if not line: break + result += line + else: + while len(result) < size: + line = self.shell.readline() + if not line: break + result += line + self._line_buffer = result[size:] + result = result[:size] + return result - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write + def readline(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + line = self._line_buffer or self.shell.readline() + if size < 0: + size = len(line) + self._line_buffer = line[size:] + return line[:size] usage_msg = """\ diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -15,6 +15,8 @@ from idlelib import RemoteObjectBrowser from idlelib import StackViewer from idlelib import rpc +from idlelib import PyShell +from idlelib import IOBinding import __main__ @@ -262,62 +264,23 @@ quitting = True thread.interrupt_main() -class _RPCFile(io.TextIOBase): - """Wrapper class for the RPC proxy to typecheck arguments - that may not support pickling. The base class is there only - to support type tests; all implementations come from the remote - object.""" - - def __init__(self, rpc): - super.__setattr__(self, 'rpc', rpc) - - def __getattribute__(self, name): - # When accessing the 'rpc' attribute, or 'write', use ours - if name in ('rpc', 'write', 'writelines'): - return io.TextIOBase.__getattribute__(self, name) - # Else only look into the remote object only - return getattr(self.rpc, name) - - def __setattr__(self, name, value): - return setattr(self.rpc, name, value) - - @staticmethod - def _ensure_string(func): - def f(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return func(self, s) - return f - -class _RPCOutputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return self.rpc.write(s) - -class _RPCInputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write - class MyHandler(rpc.RPCHandler): def handle(self): """Override base method""" executive = Executive(self) self.register("exec", executive) - self.console = self.get_remote_proxy("stdin") - sys.stdin = _RPCInputFile(self.console) - sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout")) - sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr")) + self.console = self.get_remote_proxy("console") + sys.stdin = PyShell.PseudoInputFile(self.console, "stdin", + IOBinding.encoding) + sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout", + IOBinding.encoding) + sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", + IOBinding.encoding) + # page help() text to shell. import pydoc # import must be done here to capture i/o binding pydoc.pager = pydoc.plainpager - from idlelib import IOBinding - sys.stdin.encoding = sys.stdout.encoding = \ - sys.stderr.encoding = IOBinding.encoding self.interp = self.get_remote_proxy("interp") rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,9 @@ Library ------- +- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase + interface and support all mandatory methods and properties. + - Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:15:09 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 15:15:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=239290=3A_In_IDLE_the_sys=2Estd*_streams_now_implement_?= =?utf-8?q?io=2ETextIOBase?= Message-ID: <3Yt2Lj2fQnzSM1@mail.python.org> http://hg.python.org/cpython/rev/9dfbd65d5041 changeset: 81720:9dfbd65d5041 branch: 3.3 parent: 81709:c97447e36665 parent: 81719:0d26f3aa7a8f user: Serhiy Storchaka date: Fri Jan 25 15:34:21 2013 +0200 summary: Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. files: Lib/idlelib/PyShell.py | 90 ++++++++++++++++++++++------- Lib/idlelib/run.py | 57 +++--------------- Misc/NEWS | 3 + 3 files changed, 80 insertions(+), 70 deletions(-) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -417,10 +417,8 @@ except socket.timeout as err: self.display_no_subprocess_error() return None - # Can't regiter self.tkconsole.stdin, since run.py wants to - # call non-TextIO methods on it (such as getvar) - # XXX should be renamed to "console" - self.rpcclt.register("stdin", self.tkconsole) + self.rpcclt.register("console", self.tkconsole) + self.rpcclt.register("stdin", self.tkconsole.stdin) self.rpcclt.register("stdout", self.tkconsole.stdout) self.rpcclt.register("stderr", self.tkconsole.stderr) self.rpcclt.register("flist", self.tkconsole.flist) @@ -864,10 +862,10 @@ self.save_stderr = sys.stderr self.save_stdin = sys.stdin from idlelib import IOBinding - self.stdin = PseudoInputFile(self) - self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) - self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) - self.console = PseudoFile(self, "console", IOBinding.encoding) + self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding) + self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding) + self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding) + self.console = PseudoOutputFile(self, "console", IOBinding.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr @@ -1275,36 +1273,82 @@ return 'disabled' return super().rmenu_check_paste() -class PseudoFile(object): +class PseudoFile(io.TextIOBase): def __init__(self, shell, tags, encoding=None): self.shell = shell self.tags = tags - self.encoding = encoding + self._encoding = encoding + + @property + def encoding(self): + return self._encoding + + @property + def name(self): + return '<%s>' % self.tags + + def isatty(self): + return True + + +class PseudoOutputFile(PseudoFile): + + def writable(self): + return True def write(self, s): + if self.closed: + raise ValueError("write to closed file") if not isinstance(s, str): raise TypeError('must be str, not ' + type(s).__name__) return self.shell.write(s, self.tags) - def writelines(self, lines): - for line in lines: - self.write(line) - def flush(self): - pass +class PseudoInputFile(PseudoFile): - def isatty(self): + def __init__(self, shell, tags, encoding=None): + PseudoFile.__init__(self, shell, tags, encoding) + self._line_buffer = '' + + def readable(self): return True -class PseudoInputFile(object): - def __init__(self, shell): - self.readline = shell.readline - self.isatty = shell.isatty + def read(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + result = self._line_buffer + self._line_buffer = '' + if size < 0: + while True: + line = self.shell.readline() + if not line: break + result += line + else: + while len(result) < size: + line = self.shell.readline() + if not line: break + result += line + self._line_buffer = result[size:] + result = result[:size] + return result - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write + def readline(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + line = self._line_buffer or self.shell.readline() + if size < 0: + size = len(line) + self._line_buffer = line[size:] + return line[:size] usage_msg = """\ diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -16,6 +16,8 @@ from idlelib import RemoteObjectBrowser from idlelib import StackViewer from idlelib import rpc +from idlelib import PyShell +from idlelib import IOBinding import __main__ @@ -277,63 +279,24 @@ quitting = True thread.interrupt_main() -class _RPCFile(io.TextIOBase): - """Wrapper class for the RPC proxy to typecheck arguments - that may not support pickling. The base class is there only - to support type tests; all implementations come from the remote - object.""" - - def __init__(self, rpc): - super.__setattr__(self, 'rpc', rpc) - - def __getattribute__(self, name): - # When accessing the 'rpc' attribute, or 'write', use ours - if name in ('rpc', 'write', 'writelines'): - return io.TextIOBase.__getattribute__(self, name) - # Else only look into the remote object only - return getattr(self.rpc, name) - - def __setattr__(self, name, value): - return setattr(self.rpc, name, value) - - @staticmethod - def _ensure_string(func): - def f(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return func(self, s) - return f - -class _RPCOutputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return self.rpc.write(s) - -class _RPCInputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write - class MyHandler(rpc.RPCHandler): def handle(self): """Override base method""" executive = Executive(self) self.register("exec", executive) - self.console = self.get_remote_proxy("stdin") - sys.stdin = _RPCInputFile(self.console) - sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout")) - sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr")) + self.console = self.get_remote_proxy("console") + sys.stdin = PyShell.PseudoInputFile(self.console, "stdin", + IOBinding.encoding) + sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout", + IOBinding.encoding) + sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", + IOBinding.encoding) + sys.displayhook = rpc.displayhook # page help() text to shell. import pydoc # import must be done here to capture i/o binding pydoc.pager = pydoc.plainpager - from idlelib import IOBinding - sys.stdin.encoding = sys.stdout.encoding = \ - sys.stderr.encoding = IOBinding.encoding self.interp = self.get_remote_proxy("interp") rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase + interface and support all mandatory methods and properties. + - Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:15:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 15:15:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=239290=3A_In_IDLE_the_sys=2Estd*_streams_now_impl?= =?utf-8?q?ement_io=2ETextIOBase?= Message-ID: <3Yt2Lk6lRWzSLm@mail.python.org> http://hg.python.org/cpython/rev/458b36fb12bc changeset: 81721:458b36fb12bc parent: 81711:e52df05b496a parent: 81720:9dfbd65d5041 user: Serhiy Storchaka date: Fri Jan 25 15:35:28 2013 +0200 summary: Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. files: Lib/idlelib/PyShell.py | 90 ++++++++++++++++++++++------- Lib/idlelib/run.py | 57 +++--------------- Misc/NEWS | 3 + 3 files changed, 80 insertions(+), 70 deletions(-) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -417,10 +417,8 @@ except socket.timeout as err: self.display_no_subprocess_error() return None - # Can't regiter self.tkconsole.stdin, since run.py wants to - # call non-TextIO methods on it (such as getvar) - # XXX should be renamed to "console" - self.rpcclt.register("stdin", self.tkconsole) + self.rpcclt.register("console", self.tkconsole) + self.rpcclt.register("stdin", self.tkconsole.stdin) self.rpcclt.register("stdout", self.tkconsole.stdout) self.rpcclt.register("stderr", self.tkconsole.stderr) self.rpcclt.register("flist", self.tkconsole.flist) @@ -864,10 +862,10 @@ self.save_stderr = sys.stderr self.save_stdin = sys.stdin from idlelib import IOBinding - self.stdin = PseudoInputFile(self) - self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) - self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) - self.console = PseudoFile(self, "console", IOBinding.encoding) + self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding) + self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding) + self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding) + self.console = PseudoOutputFile(self, "console", IOBinding.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr @@ -1278,36 +1276,82 @@ return 'disabled' return super().rmenu_check_paste() -class PseudoFile(object): +class PseudoFile(io.TextIOBase): def __init__(self, shell, tags, encoding=None): self.shell = shell self.tags = tags - self.encoding = encoding + self._encoding = encoding + + @property + def encoding(self): + return self._encoding + + @property + def name(self): + return '<%s>' % self.tags + + def isatty(self): + return True + + +class PseudoOutputFile(PseudoFile): + + def writable(self): + return True def write(self, s): + if self.closed: + raise ValueError("write to closed file") if not isinstance(s, str): raise TypeError('must be str, not ' + type(s).__name__) return self.shell.write(s, self.tags) - def writelines(self, lines): - for line in lines: - self.write(line) - def flush(self): - pass +class PseudoInputFile(PseudoFile): - def isatty(self): + def __init__(self, shell, tags, encoding=None): + PseudoFile.__init__(self, shell, tags, encoding) + self._line_buffer = '' + + def readable(self): return True -class PseudoInputFile(object): - def __init__(self, shell): - self.readline = shell.readline - self.isatty = shell.isatty + def read(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + result = self._line_buffer + self._line_buffer = '' + if size < 0: + while True: + line = self.shell.readline() + if not line: break + result += line + else: + while len(result) < size: + line = self.shell.readline() + if not line: break + result += line + self._line_buffer = result[size:] + result = result[:size] + return result - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write + def readline(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + line = self._line_buffer or self.shell.readline() + if size < 0: + size = len(line) + self._line_buffer = line[size:] + return line[:size] usage_msg = """\ diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -16,6 +16,8 @@ from idlelib import RemoteObjectBrowser from idlelib import StackViewer from idlelib import rpc +from idlelib import PyShell +from idlelib import IOBinding import __main__ @@ -277,63 +279,24 @@ quitting = True thread.interrupt_main() -class _RPCFile(io.TextIOBase): - """Wrapper class for the RPC proxy to typecheck arguments - that may not support pickling. The base class is there only - to support type tests; all implementations come from the remote - object.""" - - def __init__(self, rpc): - super.__setattr__(self, 'rpc', rpc) - - def __getattribute__(self, name): - # When accessing the 'rpc' attribute, or 'write', use ours - if name in ('rpc', 'write', 'writelines'): - return io.TextIOBase.__getattribute__(self, name) - # Else only look into the remote object only - return getattr(self.rpc, name) - - def __setattr__(self, name, value): - return setattr(self.rpc, name, value) - - @staticmethod - def _ensure_string(func): - def f(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return func(self, s) - return f - -class _RPCOutputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return self.rpc.write(s) - -class _RPCInputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write - class MyHandler(rpc.RPCHandler): def handle(self): """Override base method""" executive = Executive(self) self.register("exec", executive) - self.console = self.get_remote_proxy("stdin") - sys.stdin = _RPCInputFile(self.console) - sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout")) - sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr")) + self.console = self.get_remote_proxy("console") + sys.stdin = PyShell.PseudoInputFile(self.console, "stdin", + IOBinding.encoding) + sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout", + IOBinding.encoding) + sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", + IOBinding.encoding) + sys.displayhook = rpc.displayhook # page help() text to shell. import pydoc # import must be done here to capture i/o binding pydoc.pager = pydoc.plainpager - from idlelib import IOBinding - sys.stdin.encoding = sys.stdout.encoding = \ - sys.stderr.encoding = IOBinding.encoding self.interp = self.get_remote_proxy("interp") rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -218,6 +218,9 @@ Library ------- +- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase + interface and support all mandatory methods and properties. + - Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:15:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 15:15:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3Yt2Lm40GZzSLR@mail.python.org> http://hg.python.org/cpython/rev/de0c36b8549f changeset: 81722:de0c36b8549f branch: 3.3 parent: 81716:4c97d2d464ad parent: 81720:9dfbd65d5041 user: Serhiy Storchaka date: Fri Jan 25 16:08:46 2013 +0200 summary: Merge heads files: Lib/idlelib/PyShell.py | 90 ++++++++++++++++++++++------- Lib/idlelib/run.py | 57 +++--------------- Misc/NEWS | 3 + 3 files changed, 80 insertions(+), 70 deletions(-) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -417,10 +417,8 @@ except socket.timeout as err: self.display_no_subprocess_error() return None - # Can't regiter self.tkconsole.stdin, since run.py wants to - # call non-TextIO methods on it (such as getvar) - # XXX should be renamed to "console" - self.rpcclt.register("stdin", self.tkconsole) + self.rpcclt.register("console", self.tkconsole) + self.rpcclt.register("stdin", self.tkconsole.stdin) self.rpcclt.register("stdout", self.tkconsole.stdout) self.rpcclt.register("stderr", self.tkconsole.stderr) self.rpcclt.register("flist", self.tkconsole.flist) @@ -864,10 +862,10 @@ self.save_stderr = sys.stderr self.save_stdin = sys.stdin from idlelib import IOBinding - self.stdin = PseudoInputFile(self) - self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) - self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) - self.console = PseudoFile(self, "console", IOBinding.encoding) + self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding) + self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding) + self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding) + self.console = PseudoOutputFile(self, "console", IOBinding.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr @@ -1275,36 +1273,82 @@ return 'disabled' return super().rmenu_check_paste() -class PseudoFile(object): +class PseudoFile(io.TextIOBase): def __init__(self, shell, tags, encoding=None): self.shell = shell self.tags = tags - self.encoding = encoding + self._encoding = encoding + + @property + def encoding(self): + return self._encoding + + @property + def name(self): + return '<%s>' % self.tags + + def isatty(self): + return True + + +class PseudoOutputFile(PseudoFile): + + def writable(self): + return True def write(self, s): + if self.closed: + raise ValueError("write to closed file") if not isinstance(s, str): raise TypeError('must be str, not ' + type(s).__name__) return self.shell.write(s, self.tags) - def writelines(self, lines): - for line in lines: - self.write(line) - def flush(self): - pass +class PseudoInputFile(PseudoFile): - def isatty(self): + def __init__(self, shell, tags, encoding=None): + PseudoFile.__init__(self, shell, tags, encoding) + self._line_buffer = '' + + def readable(self): return True -class PseudoInputFile(object): - def __init__(self, shell): - self.readline = shell.readline - self.isatty = shell.isatty + def read(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + result = self._line_buffer + self._line_buffer = '' + if size < 0: + while True: + line = self.shell.readline() + if not line: break + result += line + else: + while len(result) < size: + line = self.shell.readline() + if not line: break + result += line + self._line_buffer = result[size:] + result = result[:size] + return result - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write + def readline(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + line = self._line_buffer or self.shell.readline() + if size < 0: + size = len(line) + self._line_buffer = line[size:] + return line[:size] usage_msg = """\ diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -16,6 +16,8 @@ from idlelib import RemoteObjectBrowser from idlelib import StackViewer from idlelib import rpc +from idlelib import PyShell +from idlelib import IOBinding import __main__ @@ -277,63 +279,24 @@ quitting = True thread.interrupt_main() -class _RPCFile(io.TextIOBase): - """Wrapper class for the RPC proxy to typecheck arguments - that may not support pickling. The base class is there only - to support type tests; all implementations come from the remote - object.""" - - def __init__(self, rpc): - super.__setattr__(self, 'rpc', rpc) - - def __getattribute__(self, name): - # When accessing the 'rpc' attribute, or 'write', use ours - if name in ('rpc', 'write', 'writelines'): - return io.TextIOBase.__getattribute__(self, name) - # Else only look into the remote object only - return getattr(self.rpc, name) - - def __setattr__(self, name, value): - return setattr(self.rpc, name, value) - - @staticmethod - def _ensure_string(func): - def f(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return func(self, s) - return f - -class _RPCOutputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return self.rpc.write(s) - -class _RPCInputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write - class MyHandler(rpc.RPCHandler): def handle(self): """Override base method""" executive = Executive(self) self.register("exec", executive) - self.console = self.get_remote_proxy("stdin") - sys.stdin = _RPCInputFile(self.console) - sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout")) - sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr")) + self.console = self.get_remote_proxy("console") + sys.stdin = PyShell.PseudoInputFile(self.console, "stdin", + IOBinding.encoding) + sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout", + IOBinding.encoding) + sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", + IOBinding.encoding) + sys.displayhook = rpc.displayhook # page help() text to shell. import pydoc # import must be done here to capture i/o binding pydoc.pager = pydoc.plainpager - from idlelib import IOBinding - sys.stdin.encoding = sys.stdout.encoding = \ - sys.stderr.encoding = IOBinding.encoding self.interp = self.get_remote_proxy("interp") rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase + interface and support all mandatory methods and properties. + - Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:15:14 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 15:15:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge_heads?= Message-ID: <3Yt2Lp0plyzSLR@mail.python.org> http://hg.python.org/cpython/rev/6b0a2648dd41 changeset: 81723:6b0a2648dd41 parent: 81717:4feff8c8250b parent: 81721:458b36fb12bc user: Serhiy Storchaka date: Fri Jan 25 16:09:03 2013 +0200 summary: Merge heads files: Lib/idlelib/PyShell.py | 90 ++++++++++++++++++++++------- Lib/idlelib/run.py | 57 +++--------------- Misc/NEWS | 3 + 3 files changed, 80 insertions(+), 70 deletions(-) diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -417,10 +417,8 @@ except socket.timeout as err: self.display_no_subprocess_error() return None - # Can't regiter self.tkconsole.stdin, since run.py wants to - # call non-TextIO methods on it (such as getvar) - # XXX should be renamed to "console" - self.rpcclt.register("stdin", self.tkconsole) + self.rpcclt.register("console", self.tkconsole) + self.rpcclt.register("stdin", self.tkconsole.stdin) self.rpcclt.register("stdout", self.tkconsole.stdout) self.rpcclt.register("stderr", self.tkconsole.stderr) self.rpcclt.register("flist", self.tkconsole.flist) @@ -864,10 +862,10 @@ self.save_stderr = sys.stderr self.save_stdin = sys.stdin from idlelib import IOBinding - self.stdin = PseudoInputFile(self) - self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) - self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) - self.console = PseudoFile(self, "console", IOBinding.encoding) + self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding) + self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding) + self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding) + self.console = PseudoOutputFile(self, "console", IOBinding.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr @@ -1278,36 +1276,82 @@ return 'disabled' return super().rmenu_check_paste() -class PseudoFile(object): +class PseudoFile(io.TextIOBase): def __init__(self, shell, tags, encoding=None): self.shell = shell self.tags = tags - self.encoding = encoding + self._encoding = encoding + + @property + def encoding(self): + return self._encoding + + @property + def name(self): + return '<%s>' % self.tags + + def isatty(self): + return True + + +class PseudoOutputFile(PseudoFile): + + def writable(self): + return True def write(self, s): + if self.closed: + raise ValueError("write to closed file") if not isinstance(s, str): raise TypeError('must be str, not ' + type(s).__name__) return self.shell.write(s, self.tags) - def writelines(self, lines): - for line in lines: - self.write(line) - def flush(self): - pass +class PseudoInputFile(PseudoFile): - def isatty(self): + def __init__(self, shell, tags, encoding=None): + PseudoFile.__init__(self, shell, tags, encoding) + self._line_buffer = '' + + def readable(self): return True -class PseudoInputFile(object): - def __init__(self, shell): - self.readline = shell.readline - self.isatty = shell.isatty + def read(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + result = self._line_buffer + self._line_buffer = '' + if size < 0: + while True: + line = self.shell.readline() + if not line: break + result += line + else: + while len(result) < size: + line = self.shell.readline() + if not line: break + result += line + self._line_buffer = result[size:] + result = result[:size] + return result - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write + def readline(self, size=-1): + if self.closed: + raise ValueError("read from closed file") + if size is None: + size = -1 + elif not isinstance(size, int): + raise TypeError('must be int, not ' + type(size).__name__) + line = self._line_buffer or self.shell.readline() + if size < 0: + size = len(line) + self._line_buffer = line[size:] + return line[:size] usage_msg = """\ diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -16,6 +16,8 @@ from idlelib import RemoteObjectBrowser from idlelib import StackViewer from idlelib import rpc +from idlelib import PyShell +from idlelib import IOBinding import __main__ @@ -277,63 +279,24 @@ quitting = True thread.interrupt_main() -class _RPCFile(io.TextIOBase): - """Wrapper class for the RPC proxy to typecheck arguments - that may not support pickling. The base class is there only - to support type tests; all implementations come from the remote - object.""" - - def __init__(self, rpc): - super.__setattr__(self, 'rpc', rpc) - - def __getattribute__(self, name): - # When accessing the 'rpc' attribute, or 'write', use ours - if name in ('rpc', 'write', 'writelines'): - return io.TextIOBase.__getattribute__(self, name) - # Else only look into the remote object only - return getattr(self.rpc, name) - - def __setattr__(self, name, value): - return setattr(self.rpc, name, value) - - @staticmethod - def _ensure_string(func): - def f(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return func(self, s) - return f - -class _RPCOutputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - if not isinstance(s, str): - raise TypeError('must be str, not ' + type(s).__name__) - return self.rpc.write(s) - -class _RPCInputFile(_RPCFile): - @_RPCFile._ensure_string - def write(self, s): - raise io.UnsupportedOperation("not writable") - writelines = write - class MyHandler(rpc.RPCHandler): def handle(self): """Override base method""" executive = Executive(self) self.register("exec", executive) - self.console = self.get_remote_proxy("stdin") - sys.stdin = _RPCInputFile(self.console) - sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout")) - sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr")) + self.console = self.get_remote_proxy("console") + sys.stdin = PyShell.PseudoInputFile(self.console, "stdin", + IOBinding.encoding) + sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout", + IOBinding.encoding) + sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", + IOBinding.encoding) + sys.displayhook = rpc.displayhook # page help() text to shell. import pydoc # import must be done here to capture i/o binding pydoc.pager = pydoc.plainpager - from idlelib import IOBinding - sys.stdin.encoding = sys.stdout.encoding = \ - sys.stderr.encoding = IOBinding.encoding self.interp = self.get_remote_proxy("interp") rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -218,6 +218,9 @@ Library ------- +- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase + interface and support all mandatory methods and properties. + - Issue #13454: Fix a crash when deleting an iterator created by itertools.tee() if all other iterators were very advanced before. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:15:15 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 15:15:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3Yt2Lq3g1YzSKQ@mail.python.org> http://hg.python.org/cpython/rev/3f58fd3a5e28 changeset: 81724:3f58fd3a5e28 parent: 81723:6b0a2648dd41 parent: 81722:de0c36b8549f user: Serhiy Storchaka date: Fri Jan 25 16:09:51 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:35:28 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 15:35:28 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogLSBJc3N1ZSAjMzc1?= =?utf-8?q?4=3A_fix_typo_in_pthread_AC=5FCACHE=5FVAL=2E?= Message-ID: <3Yt2p84zCyzSLV@mail.python.org> http://hg.python.org/cpython/rev/11a18263ceb7 changeset: 81725:11a18263ceb7 branch: 2.7 parent: 81718:def4cd7e0a9f user: doko at python.org date: Fri Jan 25 15:32:31 2013 +0100 summary: - Issue #3754: fix typo in pthread AC_CACHE_VAL. files: Misc/NEWS | 2 ++ configure | 2 +- configure.ac | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -709,6 +709,8 @@ Build ----- +- Issue #3754: fix typo in pthread AC_CACHE_VAL. + - Issue #17029: Let h2py search the multiarch system include directory. - Issue #16953: Fix socket module compilation on platforms with diff --git a/configure b/configure --- a/configure +++ b/configure @@ -6064,7 +6064,7 @@ # function available. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -pthread" >&5 $as_echo_n "checking whether $CC accepts -pthread... " >&6; } -if ${ac_cv_thread+:} false; then : +if ${ac_cv_pthread+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1365,7 +1365,7 @@ # so we need to run a program to see whether it really made the # function available. AC_MSG_CHECKING(whether $CC accepts -pthread) -AC_CACHE_VAL(ac_cv_thread, +AC_CACHE_VAL(ac_cv_pthread, [ac_save_cc="$CC" CC="$CC -pthread" AC_RUN_IFELSE([AC_LANG_SOURCE([[ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:35:30 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 15:35:30 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogLSBJc3N1ZSAjMzc1?= =?utf-8?q?4=3A_fix_typo_in_pthread_AC=5FCACHE=5FVAL=2E?= Message-ID: <3Yt2pB1KNlzSLx@mail.python.org> http://hg.python.org/cpython/rev/e28b30e6eee6 changeset: 81726:e28b30e6eee6 branch: 3.2 parent: 81719:0d26f3aa7a8f user: doko at python.org date: Fri Jan 25 15:33:25 2013 +0100 summary: - Issue #3754: fix typo in pthread AC_CACHE_VAL. files: Misc/NEWS | 2 ++ configure | 2 +- configure.ac | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -864,6 +864,8 @@ Build ----- +- Issue #3754: fix typo in pthread AC_CACHE_VAL. + - Issue #17029: Let h2py search the multiarch system include directory. - Issue #16953: Fix socket module compilation on platforms with diff --git a/configure b/configure --- a/configure +++ b/configure @@ -6056,7 +6056,7 @@ # function available. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -pthread" >&5 $as_echo_n "checking whether $CC accepts -pthread... " >&6; } -if ${ac_cv_thread+:} false; then : +if ${ac_cv_pthread+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1283,7 +1283,7 @@ # so we need to run a program to see whether it really made the # function available. AC_MSG_CHECKING(whether $CC accepts -pthread) -AC_CACHE_VAL(ac_cv_thread, +AC_CACHE_VAL(ac_cv_pthread, [ac_save_cc="$CC" CC="$CC -pthread" AC_RUN_IFELSE([AC_LANG_SOURCE([[ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:35:31 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 15:35:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_-_Issue_=233754=3A_fix_typo_in_pthread_AC=5FCACHE=5FVAL=2E?= Message-ID: <3Yt2pC4MGvzSLd@mail.python.org> http://hg.python.org/cpython/rev/5464a534e7bd changeset: 81727:5464a534e7bd branch: 3.3 parent: 81722:de0c36b8549f parent: 81726:e28b30e6eee6 user: doko at python.org date: Fri Jan 25 15:34:34 2013 +0100 summary: - Issue #3754: fix typo in pthread AC_CACHE_VAL. files: Misc/NEWS | 2 ++ configure | 2 +- configure.ac | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -536,6 +536,8 @@ Build ----- +- Issue #3754: fix typo in pthread AC_CACHE_VAL. + - Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; use _PYTHON_PROJECT_BASE in distutils/sysconfig.py. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -6713,7 +6713,7 @@ # function available. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -pthread" >&5 $as_echo_n "checking whether $CC accepts -pthread... " >&6; } -if ${ac_cv_thread+:} false; then : +if ${ac_cv_pthread+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1439,7 +1439,7 @@ # so we need to run a program to see whether it really made the # function available. AC_MSG_CHECKING(whether $CC accepts -pthread) -AC_CACHE_VAL(ac_cv_thread, +AC_CACHE_VAL(ac_cv_pthread, [ac_save_cc="$CC" CC="$CC -pthread" AC_RUN_IFELSE([AC_LANG_SOURCE([[ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 15:35:33 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 15:35:33 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_-_Issue_=233754=3A_fix_typo_in_pthread_AC=5FCACHE=5FVAL?= =?utf-8?q?=2E?= Message-ID: <3Yt2pF0bJBzSM2@mail.python.org> http://hg.python.org/cpython/rev/ee48728e3695 changeset: 81728:ee48728e3695 parent: 81724:3f58fd3a5e28 parent: 81727:5464a534e7bd user: doko at python.org date: Fri Jan 25 15:35:12 2013 +0100 summary: - Issue #3754: fix typo in pthread AC_CACHE_VAL. files: Misc/NEWS | 2 ++ configure | 2 +- configure.ac | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -749,6 +749,8 @@ Build ----- +- Issue #3754: fix typo in pthread AC_CACHE_VAL. + - Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; use _PYTHON_PROJECT_BASE in distutils/sysconfig.py. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -6713,7 +6713,7 @@ # function available. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -pthread" >&5 $as_echo_n "checking whether $CC accepts -pthread... " >&6; } -if ${ac_cv_thread+:} false; then : +if ${ac_cv_pthread+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1439,7 +1439,7 @@ # so we need to run a program to see whether it really made the # function available. AC_MSG_CHECKING(whether $CC accepts -pthread) -AC_CACHE_VAL(ac_cv_thread, +AC_CACHE_VAL(ac_cv_pthread, [ac_save_cc="$CC" CC="$CC -pthread" AC_RUN_IFELSE([AC_LANG_SOURCE([[ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 18:03:22 2013 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 25 Jan 2013 18:03:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2MDIx?= =?utf-8?q?33=3A_=27environ=27_is_not_really_available_with_shared_librari?= =?utf-8?q?es_on_OSX?= Message-ID: <3Yt64p26X7zSL0@mail.python.org> http://hg.python.org/cpython/rev/864b9836dae6 changeset: 81729:864b9836dae6 branch: 2.7 parent: 81725:11a18263ceb7 user: Ronald Oussoren date: Fri Jan 25 17:55:39 2013 +0100 summary: Issue #1602133: 'environ' is not really available with shared libraries on OSX There already was a workaround for this for framework builds on OSX, this changeset enables the same workaround for shared libraries. Closes #1602133 files: Misc/NEWS | 3 +++ Modules/posixmodule.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -181,6 +181,9 @@ - Issue #13521: dict.setdefault() now does only one lookup for the given key, making it "atomic" for many purposes. Patch by Filip Gruszczy?ski. +- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) + now fills the ``os.environ`` variable correctly. + - Issue #10538: When using the "s*" code with PyArg_ParseTuple() to fill a Py_buffer structure with data from an object supporting only the old PyBuffer interface, a reference to the source objects is now properly added diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -441,9 +441,10 @@ #endif /* Return a dictionary corresponding to the POSIX environment table */ -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) /* On Darwin/MacOSX a shared library or framework has no access to -** environ directly, we must obtain it with _NSGetEnviron(). +** environ directly, we must obtain it with _NSGetEnviron(). See also +** man environ(7). */ #include static char **environ; @@ -463,7 +464,7 @@ d = PyDict_New(); if (d == NULL) return NULL; -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) if (environ == NULL) environ = *_NSGetEnviron(); #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 18:03:23 2013 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 25 Jan 2013 18:03:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2MDIx?= =?utf-8?q?33=3A_=27environ=27_is_not_really_available_with_shared_librari?= =?utf-8?q?es_on_OSX?= Message-ID: <3Yt64q5VKnzSLb@mail.python.org> http://hg.python.org/cpython/rev/ea9fd9c9c677 changeset: 81730:ea9fd9c9c677 branch: 3.2 parent: 81726:e28b30e6eee6 user: Ronald Oussoren date: Fri Jan 25 17:57:13 2013 +0100 summary: Issue #1602133: 'environ' is not really available with shared libraries on OSX There already was a workaround for this for framework builds on OSX, this changeset enables the same workaround for shared libraries. Closes #1602133 files: Misc/NEWS | 3 +++ Modules/posixmodule.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -197,6 +197,9 @@ - Issue #13521: dict.setdefault() now does only one lookup for the given key, making it "atomic" for many purposes. Patch by Filip Gruszczy?ski. +- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) + now fills the ``os.environ`` variable correctly. + - Issue #14471: Fix a possible buffer overrun in the winreg module. Library diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -501,9 +501,10 @@ #endif /* MS_WINDOWS */ /* Return a dictionary corresponding to the POSIX environment table */ -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) /* On Darwin/MacOSX a shared library or framework has no access to -** environ directly, we must obtain it with _NSGetEnviron(). +** environ directly, we must obtain it with _NSGetEnviron(). See also +** man environ(7). */ #include static char **environ; @@ -528,7 +529,7 @@ d = PyDict_New(); if (d == NULL) return NULL; -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) if (environ == NULL) environ = *_NSGetEnviron(); #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 18:03:25 2013 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 25 Jan 2013 18:03:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=231602133=3A_=27environ=27_is_not_really_available_with?= =?utf-8?q?_shared_libraries_on_OSX?= Message-ID: <3Yt64s1vBDzSLg@mail.python.org> http://hg.python.org/cpython/rev/106d1d79c853 changeset: 81731:106d1d79c853 branch: 3.3 parent: 81727:5464a534e7bd parent: 81730:ea9fd9c9c677 user: Ronald Oussoren date: Fri Jan 25 18:01:05 2013 +0100 summary: Issue #1602133: 'environ' is not really available with shared libraries on OSX (merge from 3.2) There already was a workaround for this for framework builds on OSX, this changeset enables the same workaround for shared libraries. Closes #1602133 files: Misc/NEWS | 3 +++ Modules/posixmodule.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -150,6 +150,9 @@ Library ------- +- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) + now fills the ``os.environ`` variable correctly. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -955,9 +955,10 @@ #endif /* MS_WINDOWS */ /* Return a dictionary corresponding to the POSIX environment table */ -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) /* On Darwin/MacOSX a shared library or framework has no access to -** environ directly, we must obtain it with _NSGetEnviron(). +** environ directly, we must obtain it with _NSGetEnviron(). See also +** man environ(7). */ #include static char **environ; @@ -982,7 +983,7 @@ d = PyDict_New(); if (d == NULL) return NULL; -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) if (environ == NULL) environ = *_NSGetEnviron(); #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 18:03:27 2013 From: python-checkins at python.org (ronald.oussoren) Date: Fri, 25 Jan 2013 18:03:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=231602133=3A_=27environ=27_is_not_really_availabl?= =?utf-8?q?e_with_shared_libraries_on_OSX?= Message-ID: <3Yt64v2mbszSM8@mail.python.org> http://hg.python.org/cpython/rev/b41e3e2bd4cc changeset: 81732:b41e3e2bd4cc parent: 81728:ee48728e3695 parent: 81731:106d1d79c853 user: Ronald Oussoren date: Fri Jan 25 18:02:35 2013 +0100 summary: Issue #1602133: 'environ' is not really available with shared libraries on OSX (merge from 3.3) There already was a workaround for this for framework builds on OSX, this changeset enables the same workaround for shared libraries. Closes #1602133 files: Misc/NEWS | 3 +++ Modules/posixmodule.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -218,6 +218,9 @@ Library ------- +- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) + now fills the ``os.environ`` variable correctly. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -924,9 +924,10 @@ #endif /* MS_WINDOWS */ /* Return a dictionary corresponding to the POSIX environment table */ -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) /* On Darwin/MacOSX a shared library or framework has no access to -** environ directly, we must obtain it with _NSGetEnviron(). +** environ directly, we must obtain it with _NSGetEnviron(). See also +** man environ(7). */ #include static char **environ; @@ -947,7 +948,7 @@ d = PyDict_New(); if (d == NULL) return NULL; -#ifdef WITH_NEXT_FRAMEWORK +#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) if (environ == NULL) environ = *_NSGetEnviron(); #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 18:33:04 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 25 Jan 2013 18:33:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_FIx_a_changed_link_target=2E?= Message-ID: <3Yt6l42QxkzSJF@mail.python.org> http://hg.python.org/peps/rev/dd7757bc7988 changeset: 4689:dd7757bc7988 user: Brett Cannon date: Fri Jan 25 12:32:01 2013 -0500 summary: FIx a changed link target. files: pep-0433.txt | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -231,8 +231,8 @@ functions would need it. For example, ``os.urandom()`` uses a temporary file on UNIX, but it calls a function of Windows API on Windows. Adding a ``cloexec`` parameter to ``os.urandom()`` would - not make sense. See `Set the close-on-exec flag by default`_ for an - incomplete list of functions creating file descriptors. + not make sense. See `Enable file descriptor inheritance by default`_ + for an incomplete list of functions creating file descriptors. * Checking if a module creates file descriptors is difficult. For example, ``os.urandom()`` creates a file descriptor on UNIX to read ``/dev/urandom`` (and closes it at exit), whereas it is implemented @@ -341,8 +341,8 @@ is ``sys.getdefaultcloexec()``, instead of ``False``. When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by -default, we have the same drawbacks than `Set the close-on-exec flag -by default`_ alternative. +default, we have the same drawbacks as the +`Enable file descriptor inheritance by default`_ alternative. There are additionnal drawbacks of having two behaviours depending on ``sys.getdefaultcloexec()`` value: -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Fri Jan 25 18:33:06 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 25 Jan 2013 18:33:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_from_Lennart?= Message-ID: <3Yt6l6154VzSLM@mail.python.org> http://hg.python.org/peps/rev/3c49ad56aae9 changeset: 4690:3c49ad56aae9 user: Brett Cannon date: Fri Jan 25 12:32:59 2013 -0500 summary: Update from Lennart files: pep-0431.txt | 282 +++++++++++++++++++++++--------------- 1 files changed, 171 insertions(+), 111 deletions(-) diff --git a/pep-0431.txt b/pep-0431.txt --- a/pep-0431.txt +++ b/pep-0431.txt @@ -8,7 +8,7 @@ Type: Standards Track Content-Type: text/x-rst Created: 11-Dec-2012 -Post-History: 11-Dec-2012 +Post-History: 11-Dec-2012, 28-Dec-2012 Abstract @@ -26,38 +26,41 @@ -------------------------- The time zone support in Python has no concrete implementation in the -standard library, only a tzinfo baseclass, and since Python 3.2, one concrete -time zone: UTC. To properly support time zones you need to include a database -over all time zones, both current and historical, including daylight saving -changes. But such information changes frequently, so even if we include the -last information in a Python release, that information would be outdated just -a few months later. +standard library outside of a tzinfo baseclass that supports fixed offsets. +To properly support time zones you need to include a database over all time +zones, both current and historical, including daylight saving changes. +But such information changes frequently, so even if we include the last +information in a Python release, that information would be outdated just a +few months later. -Timezone support has therefore only been available through two third-party +Time zone support has therefore only been available through two third-party modules, ``pytz`` and ``dateutil``, both who include and wrap the "zoneinfo" database. This database, also called "tz" or "The Olsen database", is the de-facto standard time zone database over time zones, and it is included in -most variants of Unix operating systems, including OS X. +most Unix and Unix-like operating systems, including OS X. -This gives us the opportunity to include only the code that supports the -zoneinfo data in the standard library, but by default use the operating -systems copy of the data, which typically will be kept updated by the -updating mechanism of the operating system or distribution. +This gives us the opportunity to include the code that supports the zoneinfo +data in the standard library, but by default use the operating system's copy +of the data, which typically will be kept updated by the updating mechanism +of the operating system or distribution. -For those who have an operating system that does not include the tz database, -for example Windows, a distribution containing the latest tz database should -also be available at the Python Package Index, so it can be easily installed -with the Python packaging tools such as ``easy_install`` or ``pip``. This -could also be done on Unices that are no longer receiving updates and -therefore have an outdated database. +For those who have an operating system that does not include the zoneinfo +database, for example Windows, the Python source distribution will include a +copy of the zoneinfo database, and a distribution containing the latest +zoneinfo database will also be available at the Python Package Index, so it +can be easily installed with the Python packaging tools such as +``easy_install`` or ``pip``. This could also be done on Unices that are no +longer receiving updates and therefore have an outdated database. With such a mechanism Python would have full time zone support in the -standard library on most platforms, and a simple package installation would -provide time zone support on those platforms where the tz database isn't -included, such as Windows. +standard library on any platform, and a simple package installation would +provide an updated time zone database on those platforms where the zoneinfo +database isn't included, such as Windows, or on platforms where OS updates +are no longer provided. -The time zone support will be implemented by a new module called ``timezone``, -based on Stuart Bishop's ``pytz`` module. +The time zone support will be implemented by making the ``datetime`` module +into a package, and adding time zone support to ``datetime`` based on Stuart +Bishop's ``pytz`` module. Getting the local time zone @@ -76,16 +79,23 @@ be provided to return the local time zone. The support for this will be made by integrating Lennart Regebro's -``tzlocal`` module into the new ``timezone`` module. +``tzlocal`` module into the new ``datetime`` module. + +For Windows it will look up the local Windows time zone name, and use a +mapping between Windows time zone names and zoneinfo time zone names provided +by the Unicode consortium to convert that to a zoneinfo time zone. + +The mapping should be updated before each major or bugfix release, scripts +for doing so will be provided in the ``Tools/`` directory. Ambiguous times --------------- -When changing over from daylight savings time (DST) the clock is turned back one -hour. This means that the times during that hour happens twice, once without -DST and then once with DST. Similarly, when changing to daylight savings -time, one hour goes missing. +When changing over from daylight savings time (DST) the clock is turned back +one hour. This means that the times during that hour happens twice, once +without DST and then once with DST. Similarly, when changing to daylight +savings time, one hour goes missing. The current time zone API can not differentiate between the two ambiguous times during a change from DST. For example, in Stockholm the time of @@ -96,10 +106,10 @@ unclear which time should be returned:: # This could be either 00:00 or 01:00 UTC: - >>> dt = datetime(2012, 11, 28, 2, 0, tzinfo=timezone('Europe/Stockholm')) + >>> dt = datetime(2012, 10, 28, 2, 0, tzinfo=zoneinfo('Europe/Stockholm')) # But we can not specify which: - >>> dt.astimezone(timezone('UTC')) - datetime.datetime(2012, 11, 28, 1, 0, tzinfo=) + >>> dt.astimezone(zoneinfo('UTC')) + datetime.datetime(2012, 10, 28, 1, 0, tzinfo=) ``pytz`` solved this problem by adding ``is_dst`` parameters to several methods of the tzinfo objects to make it possible to disambiguate times when @@ -108,88 +118,131 @@ This PEP proposes to add these ``is_dst`` parameters to the relevant methods of the ``datetime`` API, and therefore add this functionality directly to ``datetime``. This is likely the hardest part of this PEP as this involves -updating the +updating the C version of the ``datetime`` library with this functionality, +as this involved writing new code, and not just reorganizing existing +external libraries. Implementation API ================== -The new ``timezone``-module ---------------------------- +The zoneinfo database +--------------------- -The public API of the new ``timezone``-module contains one new class, one new -function and one new exception. +The latest version of the zoneinfo database should exist in the +``Lib/tzdata`` directory of the Python source control system. This copy of +the database should be updated before every Python feature and bug-fix +release, but not for releases of Python versions that are in +security-fix-only-mode. -* New class: ``DstTzInfo`` +Scripts to update the database will be provided in ``Tools/``, and the +release instructions will be updated to include this update. - This class provides a concrete implementation of the ``zoneinfo`` base - class that implements DST support. +New configure options ``--enable-internal-timezone-database`` and +``--disable-internal-timezone-database`` will be implemented to enable and +disable the installation of this database when installing from source. A +source install will default to installing them. +Binary installers for systems that have a system-provided zoneinfo database +may skip installing the included database since it would never be used for +these platforms. For other platforms, for example Windows, binary installers +must install the included database. -* New function :``get_timezone(name=None, db=None)`` - This function takes a name string that must be a string specifying a - valid zoneinfo timezone, i.e. "US/Eastern", "Europe/Warsaw" or "Etc/GMT+11". - If not given, the local timezone will be looked up. If an invalid zone name - is given, or the local timezone can not be retrieved, the function raises - `UnknownTimeZoneError`. +Changes in the ``datetime``-module +---------------------------------- - The function also takes an optional path to the location of the zoneinfo - database which should be used. If not specified, the function will check if - the `timezonedata` module is installed, and then use that location or - otherwise use the database in ``/usr/share/zoneinfo``. +The public API of the new time zone support contains one new class, one new +function, one new exception and four new collections. In addition to this, several +methods on the datetime object gets a new ``is_dst`` parameter. - If no database is found an ``UnknownTimeZoneError`` or subclass thereof will - be raised with a message explaining that no zoneinfo database can be found, - but that you can install one with the ``timezonedata`` package. +New class ``DstTzInfo`` +^^^^^^^^^^^^^^^^^^^^^^^^ +This class provides a concrete implementation of the ``zoneinfo`` base +class that implements DST support. -* New Exception: ``UnknownTimeZoneError`` - This exception is raised when giving a time zone specification that can't be - found:: +New function ``zoneinfo(name=None, db_path=None)`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This function takes a name string that must be a string specifying a +valid zoneinfo time zone, i.e. "US/Eastern", "Europe/Warsaw" or "Etc/GMT". +If not given, the local time zone will be looked up. If an invalid zone name +is given, or the local time zone can not be retrieved, the function raises +`UnknownTimeZoneError`. + +The function also takes an optional path to the location of the zoneinfo +database which should be used. If not specified, the function will look for +databases in the following order: + +1. Use the database in ``/usr/share/zoneinfo``, if it exists. + +2. Check if the `tzdata-update` module is installed, and then use that + database. + +3. Use the Python-provided database in ``Lib/tzdata``. + +If no database is found an ``UnknownTimeZoneError`` or subclass thereof will +be raised with a message explaining that no zoneinfo database can be found, +but that you can install one with the ``tzdata-update`` package. + + +New parameter ``is_dst`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +A new ``is_dst`` parameter is added to several methods to handle time +ambiguity during DST changeovers. + +* ``tzinfo.utcoffset(dt, is_dst=False)`` + +* ``tzinfo.dst(dt, is_dst=False)`` + +* ``tzinfo.tzname(dt, is_dst=False)`` + +* ``datetime.astimezone(tz, is_dst=False)`` + +The ``is_dst`` parameter can be ``False`` (default), ``True``, or ``None``. + +``False`` will specify that the given datetime should be interpreted as not +happening during daylight savings time, i.e. that the time specified is after +the change from DST. + +``True`` will specify that the given datetime should be interpreted as happening +during daylight savings time, i.e. that the time specified is before the change +from DST. + +``None`` will raise an ``AmbiguousTimeError`` exception if the time specified +was during a DST change over. It will also raise a ``NonExistentTimeError`` +if a time is specified during the "missing time" in a change to DST. + +New exceptions +^^^^^^^^^^^^^^ + +* ``UnknownTimeZoneError`` + + This exception is a subclass of KeyError and raised when giving a time + zone specification that can't be found:: >>> datetime.Timezone('Europe/New_York') Traceback (most recent call last): ... UnknownTimeZoneError: There is no time zone called 'Europe/New_York' +* ``InvalidTimeError`` -Changes in the ``datetime``-module --------------------------------------- - -A new ``is_dst`` parameter is added to several of the `tzinfo` methods to -handle time ambiguity during DST changeovers. - -* ``tzinfo.utcoffset(self, dt, is_dst=True)`` - -* ``tzinfo.dst(self, dt, is_dst=True)`` - -* ``tzinfo.tzname(self, dt, is_dst=True)`` - -The ``is_dst`` parameter can be ``True`` (default), ``False``, or ``None``. - -``True`` will specify that the given datetime should be interpreted as -happening during daylight savings time, i.e. that the time specified is before -the change from DST. - -``False`` will specify that the given datetime should be interpreted as not -happening during daylight savings time, i.e. that the time specified is after -the change from DST. - -``None`` will raise an ``AmbiguousTimeError`` exception if the time specified -was during a DST change over. It will also raise a ``NonExistentTimeError`` -if a time is specified during the "missing time" in a change to DST. - -There are also two new exceptions: + This exception serves as a base for ``AmbiguousTimeError`` and + ``NonExistentTimeError``, to enable you to trap these two separately. It + will subclass from ValueError, so that you can catch these errors together + with inputs like the 29th of February 2011. * ``AmbiguousTimeError`` - This exception is raised when giving a datetime specification that is - ambiguous while setting ``is_dst`` to None:: + This exception is raised when giving a datetime specification that is ambiguous + while setting ``is_dst`` to None:: - >>> datetime(2012, 11, 28, 2, 0, tzinfo=timezone('Europe/Stockholm'), is_dst=None) - >>> + >>> datetime(2012, 11, 28, 2, 0, tzinfo=zoneinfo('Europe/Stockholm'), is_dst=None) + >>> Traceback (most recent call last): ... AmbiguousTimeError: 2012-10-28 02:00:00 is ambiguous in time zone Europe/Stockholm @@ -197,17 +250,31 @@ * ``NonExistentTimeError`` - This exception is raised when giving a datetime specification that is - non-existent while setting ``is_dst`` to None:: + This exception is raised when giving a datetime specification that is ambiguous + while setting ``is_dst`` to None:: - >>> datetime(2012, 3, 25, 2, 0, tzinfo=timezone('Europe/Stockholm'), is_dst=None) - >>> + >>> datetime(2012, 3, 25, 2, 0, tzinfo=zoneinfo('Europe/Stockholm'), is_dst=None) + >>> Traceback (most recent call last): ... NonExistentTimeError: 2012-03-25 02:00:00 does not exist in time zone Europe/Stockholm -The ``timezonedata``-package +New collections +^^^^^^^^^^^^^^^ + +* ``all_timezones`` is the exhaustive list of the time zone names that can + be used, listed alphabethically. + +* ``all_timezones_set`` is a set of the time zones in ``all_timezones``. + +* ``common_timezones`` is a list of useful, current time zones, listed + alphabethically. + +* ``common_timezones_set`` is a set of the time zones in ``common_timezones``. + + +The ``tzdata-update``-package ----------------------------- The zoneinfo database will be packaged for easy installation with @@ -215,6 +282,10 @@ Python code, and will not contain any Python code except that which is needed for installation. +It will be kept updated with the same tools as the internal database, but +released whenever the ``zoneinfo``-database is updated, and use the same +version schema. + Differences from the ``pytz`` API ================================= @@ -223,28 +294,15 @@ around that ``tzinfo`` doesn't have is_dst. When ``is_dst`` is implemented directly in ``datetime.tzinfo`` they are no longer needed. -* The ``pytz`` method ``timezone()`` is instead called ``get_timezone()`` for - clarity. +* The ``timezone()`` function is called ``zoneinfo()`` to avoid clashing with + the ``timezone`` class introduced in Python 3.2. -* ``get_timezone()`` will return the local time zone if called without - arguments. +* ``zoneinfo()`` will return the local time zone if called without arguments. -* The class ``pytz.StaticTzInfo`` is there to provide the ``is_dst`` support - for static timezones. When ``is_dst`` support is included in - ``datetime.tzinfo`` it is no longer needed. +* The class ``pytz.StaticTzInfo`` is there to provide the ``is_dst`` support for static + time zones. When ``is_dst`` support is included in ``datetime.tzinfo`` it is no longer needed. - -Discussion -========== - -Should the windows installer include the data package? ------------------------------------------------------- - -It has been suggested that the Windows installer should include the data -package. This would mean that an explicit installation would no longer be -needed on Windows. On the other hand, that would mean that many using Windows -would not be aware that the database quickly becomes outdated and would not -keep it updated. +* ``InvalidTimeError`` subclasses from ``ValueError``. Resources @@ -256,6 +314,8 @@ * http://pypi.python.org/pypi/python-dateutil +* http://unicode.org/cldr/data/common/supplemental/windowsZones.xml + Copyright ========= -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Fri Jan 25 18:46:00 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 18:46:00 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogLSBJc3N1ZSAjMTcw?= =?utf-8?q?31=3A_Fix_running_regen_in_cross_builds=2E?= Message-ID: <3Yt7202FwRzSLj@mail.python.org> http://hg.python.org/cpython/rev/ff5cf42136b3 changeset: 81733:ff5cf42136b3 branch: 3.3 parent: 81731:106d1d79c853 user: doko at python.org date: Fri Jan 25 18:45:12 2013 +0100 summary: - Issue #17031: Fix running regen in cross builds. files: Lib/plat-generic/regen | 2 +- Makefile.pre.in | 9 ++++++++- Misc/NEWS | 2 ++ configure | 2 ++ configure.ac | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Lib/plat-generic/regen b/Lib/plat-generic/regen --- a/Lib/plat-generic/regen +++ b/Lib/plat-generic/regen @@ -1,3 +1,3 @@ #! /bin/sh set -v -python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h +eval $PYTHON_FOR_BUILD ../../Tools/scripts/h2py.py -i "'(u_long)'" /usr/include/netinet/in.h diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -203,7 +203,8 @@ PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ -HOST_GNU_TYPE= @host@ +BUILD_GNU_TYPE= @build@ +HOST_GNU_TYPE= @host@ # The task to run while instrument when building the profile-opt target PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck @@ -1123,6 +1124,12 @@ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ + export PYTHON_FOR_BUILD; \ + if [ "$(BUILD_GNU_TYPE)" = "$(HOST_GNU_TYPE)" ]; then \ + PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \ + else \ + PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \ + fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen python-config: $(srcdir)/Misc/python-config.in diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -539,6 +539,8 @@ Build ----- +- Issue #17031: Fix running regen in cross builds. + - Issue #3754: fix typo in pthread AC_CACHE_VAL. - Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2926,6 +2926,8 @@ + + if test "$cross_compiling" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 $as_echo_n "checking for python interpreter for cross build... " >&6; } diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,8 @@ AC_CONFIG_HEADER(pyconfig.h) AC_CANONICAL_HOST +AC_SUBST(build) +AC_SUBST(host) if test "$cross_compiling" = yes; then AC_MSG_CHECKING([for python interpreter for cross build]) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 18:46:01 2013 From: python-checkins at python.org (matthias.klose) Date: Fri, 25 Jan 2013 18:46:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_-_Issue_=2317031=3A_Fix_running_regen_in_cross_builds=2E?= Message-ID: <3Yt7215sD7zSMX@mail.python.org> http://hg.python.org/cpython/rev/1942987921e9 changeset: 81734:1942987921e9 parent: 81732:b41e3e2bd4cc parent: 81733:ff5cf42136b3 user: doko at python.org date: Fri Jan 25 18:45:41 2013 +0100 summary: - Issue #17031: Fix running regen in cross builds. files: Lib/plat-generic/regen | 2 +- Makefile.pre.in | 9 ++++++++- Misc/NEWS | 2 ++ configure | 2 ++ configure.ac | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Lib/plat-generic/regen b/Lib/plat-generic/regen --- a/Lib/plat-generic/regen +++ b/Lib/plat-generic/regen @@ -1,3 +1,3 @@ #! /bin/sh set -v -python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h +eval $PYTHON_FOR_BUILD ../../Tools/scripts/h2py.py -i "'(u_long)'" /usr/include/netinet/in.h diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -203,7 +203,8 @@ PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ -HOST_GNU_TYPE= @host@ +BUILD_GNU_TYPE= @build@ +HOST_GNU_TYPE= @host@ # The task to run while instrument when building the profile-opt target PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck @@ -1123,6 +1124,12 @@ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ + export PYTHON_FOR_BUILD; \ + if [ "$(BUILD_GNU_TYPE)" = "$(HOST_GNU_TYPE)" ]; then \ + PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \ + else \ + PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \ + fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen python-config: $(srcdir)/Misc/python-config.in diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -752,6 +752,8 @@ Build ----- +- Issue #17031: Fix running regen in cross builds. + - Issue #3754: fix typo in pthread AC_CACHE_VAL. - Issue #15484: Fix _PYTHON_PROJECT_BASE for srcdir != builddir builds; diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2926,6 +2926,8 @@ + + if test "$cross_compiling" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 $as_echo_n "checking for python interpreter for cross build... " >&6; } diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,8 @@ AC_CONFIG_HEADER(pyconfig.h) AC_CANONICAL_HOST +AC_SUBST(build) +AC_SUBST(host) if test "$cross_compiling" = yes; then AC_MSG_CHECKING([for python interpreter for cross build]) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 19:49:32 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 25 Jan 2013 19:49:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Touch_up_exception_messagi?= =?utf-8?q?ng?= Message-ID: <3Yt8RJ6v3nzSLv@mail.python.org> http://hg.python.org/cpython/rev/792810303239 changeset: 81735:792810303239 user: Brett Cannon date: Fri Jan 25 13:49:19 2013 -0500 summary: Touch up exception messaging files: Lib/importlib/_bootstrap.py | 8 +- Python/importlib.h | 5906 +++++++++++----------- 2 files changed, 2958 insertions(+), 2956 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -639,21 +639,21 @@ exc_details['name'] = name else: # To prevent having to make all messages have a conditional name. - name = 'bytecode' + name = '' if path is not None: exc_details['path'] = path magic = data[:4] raw_timestamp = data[4:8] raw_size = data[8:12] if magic != _MAGIC_BYTES: - msg = 'bad magic number in {!r}: {!r}'.format(name, magic) + msg = 'incomplete magic number in {!r}: {!r}'.format(name, magic) raise ImportError(msg, **exc_details) elif len(raw_timestamp) != 4: - message = 'bad timestamp in {!r}'.format(name) + message = 'incomplete timestamp in {!r}'.format(name) _verbose_message(message) raise EOFError(message) elif len(raw_size) != 4: - message = 'bad size in {!r}'.format(name) + message = 'incomplete size in {!r}'.format(name) _verbose_message(message) raise EOFError(message) if source_stats is not None: diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 19:57:24 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 25 Jan 2013 19:57:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316972=3A_Have_sit?= =?utf-8?q?e=2Eaddpackage=28=29_consider_known_paths_even_when?= Message-ID: <3Yt8cN07cWzSM9@mail.python.org> http://hg.python.org/cpython/rev/2c0197c95ec6 changeset: 81736:2c0197c95ec6 user: Brett Cannon date: Fri Jan 25 13:57:16 2013 -0500 summary: Issue #16972: Have site.addpackage() consider known paths even when none are explicitly passed in. files: Lib/site.py | 2 +- Misc/NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/site.py b/Lib/site.py --- a/Lib/site.py +++ b/Lib/site.py @@ -146,7 +146,7 @@ and add that to known_paths, or execute it if it starts with 'import '. """ if known_paths is None: - _init_pathinfo() + known_paths = _init_pathinfo() reset = 1 else: reset = 0 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -218,6 +218,9 @@ Library ------- +- Issue #180022: Have site.addpackage() consider already known paths even when + none are explicitly passed in. Bug report and fix by Kirill. + - Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) now fills the ``os.environ`` variable correctly. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 20:13:52 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 25 Jan 2013 20:13:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide=3A_I_don=27t_want_to_deal_wi?= =?utf-8?q?th_the_warnings_module_anymore=2E?= Message-ID: <3Yt8zN1wc0zSMx@mail.python.org> http://hg.python.org/devguide/rev/176190493186 changeset: 594:176190493186 parent: 566:3dc14c30667e user: Brett Cannon date: Fri Jan 25 14:13:34 2013 -0500 summary: I don't want to deal with the warnings module anymore. files: experts.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/experts.rst b/experts.rst --- a/experts.rst +++ b/experts.rst @@ -237,7 +237,7 @@ urllib orsenthil uu uuid -warnings brett.cannon +warnings wave weakref fdrake, pitrou webbrowser georg.brandl -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Fri Jan 25 20:13:54 2013 From: python-checkins at python.org (brett.cannon) Date: Fri, 25 Jan 2013 20:13:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?devguide_=28merge_default_-=3E_defaul?= =?utf-8?b?dCk6IG1lcmdl?= Message-ID: <3Yt8zQ1bKCzSMm@mail.python.org> http://hg.python.org/devguide/rev/1311495c7958 changeset: 595:1311495c7958 parent: 594:176190493186 parent: 593:139eea239f32 user: Brett Cannon date: Fri Jan 25 14:13:48 2013 -0500 summary: merge files: buildbots.rst | 2 +- committing.rst | 18 ++++- conf.py | 2 +- devcycle.rst | 9 ++- developers.rst | 3 + docquality.rst | 15 ++-- documenting.rst | 47 ++++++++++----- experts.rst | 4 +- faq.rst | 6 ++ index.rst | 105 +++++++++++++++++++++-------------- langchanges.rst | 13 ++- patch.rst | 8 +- runtests.rst | 14 +++- setup.rst | 17 +++-- tracker.rst | 6 +- triaging.rst | 10 ++- 16 files changed, 181 insertions(+), 98 deletions(-) diff --git a/buildbots.rst b/buildbots.rst --- a/buildbots.rst +++ b/buildbots.rst @@ -54,7 +54,7 @@ --------- A subset of the buildbots are marked "stable". They are taken into account -when making a new release. The rule is that no stable buildbot must witness +when making a new release. The rule is that all stable builders must be free of persistent failures when the release is cut. It is absolutely **vital** that core developers fix any issue they introduce on the stable buildbots, as soon as possible. diff --git a/committing.rst b/committing.rst --- a/committing.rst +++ b/committing.rst @@ -19,15 +19,15 @@ Patch Checklist --------------- -Here's the simple patch checklist that ``make patchcheck`` (or ``./python.exe +Here's the simple patch checklist that ``make patchcheck`` (or ``./python.exe Tools/scripts/patchcheck.py`` on Windows) will run through on a system that uses the makefile to build Python: * Are there any whitespace problems in Python files? - (using Tools/scripts/reindent.py) + (using ``Tools/scripts/reindent.py``) * Are there any whitespace problems in C files? * Are there any whitespace problems in the documentation? - (using Tools/scripts/reindent-rst.py) + (using ``Tools/scripts/reindent-rst.py``) * Has the documentation been updated? * Has the test suite been updated? * Has ``Misc/NEWS`` been updated? @@ -35,6 +35,7 @@ * Has ``configure`` been regenerated, if necessary? * Has ``pyconfig.h.in`` been regenerated, if necessary? * Has the test suite been run? +* Are there any reference leaks? Note that the automated patch check can't actually *answer* all of these questions, and even if it could, it still wouldn't know whether or not @@ -306,17 +307,24 @@ # Fix any conflicts; compile; run the test suite hg commit +.. index:: null merging + .. note:: - *If the patch shouldn't be ported* from Python 3.3 to Python 3.4, you must - also make it explicit: merge the changes but revert them before committing:: + If the patch should *not* be ported from Python 3.3 to Python 3.4, you must + also make this explicit by doing a *null merge*: merge the changes but + revert them before committing:: hg update default hg merge 3.3 hg revert -ar default + hg resolve -am # needed only if the merge created conflicts hg commit This is necessary so that the merge gets recorded; otherwise, somebody else will have to make a decision about your patch when they try to merge. + (Using a three-way merge tool generally makes the ``hg resolve`` step + in the above unnecessary; also see `this bug report + `__.) When you have finished your porting work (you can port several patches one after another in your local repository), you can push **all** outstanding diff --git a/conf.py b/conf.py --- a/conf.py +++ b/conf.py @@ -26,7 +26,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo'] -intersphinx_mapping = {'python': ('http://docs.python.org/py3k', None)} +intersphinx_mapping = {'python': ('http://docs.python.org/3', None)} todo_include_todos = True # Add any paths that contain templates here, relative to this directory. diff --git a/devcycle.rst b/devcycle.rst --- a/devcycle.rst +++ b/devcycle.rst @@ -65,7 +65,8 @@ -------------------- A branch for a previous feature release, currently being maintained for bug -fixes. There are currently two of them in activity: one for Python 3.x and +fixes. There are usually two maintenance branches at any given time: one for +Python 3.x and one for Python 2.x. At some point in the future, Python 2.x will be closed for bug fixes and there will be only one maintenance branch left. @@ -75,8 +76,8 @@ etc.). For both rules, only rare exceptions are accepted and **must** be discussed first. -When a new maintenance branch is created (after a new *minor version* is -released), the old maintenance branch on that major version (e.g. 3.2.x +Sometime after a new maintenance branch is created (after a new *minor version* +is released), the old maintenance branch on that major version (e.g. 3.2.x after 3.3 gets released) will go into :ref:`security mode `, usually after one last maintenance release at the discretion of the release manager. @@ -96,6 +97,8 @@ actual security patches have been applied to the branch. +.. _listbranch: + Summary ------- diff --git a/developers.rst b/developers.rst --- a/developers.rst +++ b/developers.rst @@ -24,6 +24,9 @@ Permissions History ------------------- +- Serhiy Storchaka was given push privileges on Dec 26 2012 by GFB, for general + contributions, on recommendation by Trent Nelson. + - Chris Jerdonek was given push privileges on Sep 24 2012 by GFB, for general contributions, on recommendation by Ezio Melotti. diff --git a/docquality.rst b/docquality.rst --- a/docquality.rst +++ b/docquality.rst @@ -10,13 +10,14 @@ :ref:`Documenting Python ` covers the details of how Python's documentation works. It includes an explanation of the markup used (although you can figure a lot -out simply by looking at pre-existing documentation) and how to build the -documentation (which allows you to see how your changes will look along with -validating that your new markup is correct). +out simply by looking at pre-existing documentation) and :ref:`how to build +` the documentation (which allows you to see how your changes +will look along with validating that your new markup is correct). -The current in-development version of the documentation can be viewed at -http://docs.python.org/dev/. This version is regenerated from source once -a day. +The documentation built from the :ref:`in-development ` and +:ref:`maintenance ` branches can be viewed from +http://docs.python.org/dev/. The in-development and most recent 2.x and 3.x +maintenance :ref:`branches ` are rebuilt once per day. If you would like a technical documentation style guide, the `Apple Publications Style Guide @@ -73,7 +74,7 @@ The Developer's Guide uses the same process as the main Python documentation, except for some small differences. The source lives in a `separate -repository`_. Bug reports and and patches should be submitted to the `python +repository`_. Bug reports and patches should be submitted to the `python bug tracker`_ using the ``devguide`` component. Changes to the devguide are normally published within a day, on a schedule that may be different from the main documentation. diff --git a/documenting.rst b/documenting.rst --- a/documenting.rst +++ b/documenting.rst @@ -1,5 +1,6 @@ .. _documenting: +================== Documenting Python ================== @@ -17,8 +18,6 @@ :ref:`CPython Mercurial repository `. .. _reStructuredText: http://docutils.sf.net/rst.html -.. _docutils: http://docutils.sf.net/ -.. _Sphinx: http://sphinx.pocoo.org/ .. note:: @@ -826,6 +825,17 @@ This language is used until the next ``highlightlang`` directive is encountered. +* The ``code-block`` directive can be used to specify the highlight language + of a single code block, e.g.:: + + .. code-block:: c + + #include + + void main() { + printf("Hello world!\n"); + } + * The values normally used for the highlighting language are: * ``python`` (the default) @@ -1628,28 +1638,30 @@ Building the documentation ========================== -You need to have Python 2.4 or higher installed; the toolset used to build the -docs is written in Python. It is called *Sphinx*, it is not included in this -tree, but maintained separately. Also needed are the docutils, supplying the -base markup that Sphinx uses, Jinja, a templating engine, and optionally -Pygments, a code highlighter. +You need to have Python 2.4 or higher installed. The toolset used to build +the docs is written in Python and is called Sphinx_. Sphinx is maintained +separately and is not included in this tree. Also needed are docutils_, +supplying the base markup that Sphinx uses; Jinja_, a templating engine; and +optionally Pygments_, a code highlighter. + +To build the documentation, follow the instructions from one of the sections +below. You can view the documentation after building the HTML by pointing +a browser at the file :file:`Doc/build/html/index.html`. Using make ---------- -Luckily, a Makefile has been prepared so that on Unix, provided you have -installed Python and Subversion, you can just go to your :ref:`clone of the -CPython Mercurial repository ` and run :: +On Unix, if you have Subversion installed, run the following from the root of +your :ref:`repository clone `:: cd Doc make html -to check out the necessary toolset in the :file:`tools/` subdirectory and build -the HTML output files. To view the generated HTML, point your favorite browser -at the top-level index :file:`build/html/index.html` after running "make". - -Available make targets are: +or alternatively ``make -C Doc html``. This checks out the needed toolset +in the :file:`Doc/tools/` directory and builds the output as HTML. + +Available :command:`make` targets are: * "html", which builds standalone HTML files for offline viewing. @@ -1719,3 +1731,8 @@ where `` is one of html, text, latex, or htmlhelp (for explanations see the make targets above). + +.. _docutils: http://docutils.sourceforge.net/ +.. _Jinja: http://jinja.pocoo.org/ +.. _Pygments: http://pygments.org/ +.. _Sphinx: http://sphinx-doc.org/ diff --git a/experts.rst b/experts.rst --- a/experts.rst +++ b/experts.rst @@ -140,7 +140,7 @@ logging vinay.sajip lzma nadeem.vawda macpath -mailbox +mailbox petri.lehtinen mailcap marshal math mark.dickinson, rhettinger, stutzbach @@ -167,7 +167,7 @@ pkgutil platform lemburg plistlib -poplib +poplib giampaolo.rodola posix pprint fdrake profile georg.brandl diff --git a/faq.rst b/faq.rst --- a/faq.rst +++ b/faq.rst @@ -25,6 +25,10 @@ .. _StackOverflow: http://stackoverflow.com/ .. _Freenode: http://freenode.net/ + +.. index:: + single: PEP process; in FAQ + .. _suggesting-changes: Where should I suggest new features and language changes? @@ -48,6 +52,8 @@ For some examples on language changes that were accepted please read `Justifying Python Language Changes`_. +See also the :ref:`langchanges` section of this guide. + .. _python-ideas: http://mail.python.org/mailman/listinfo/python-ideas .. _issue tracker: http://bugs.python.org .. _PEP Index: http://www.python.org/dev/peps diff --git a/index.rst b/index.rst --- a/index.rst +++ b/index.rst @@ -1,55 +1,38 @@ +======================== Python Developer's Guide ======================== -.. toctree:: - :hidden: - - setup - help - patch - runtests - coverage - docquality - documenting - silencewarnings - fixingissues - tracker - triaging - communication - coredev - developers - committing - devcycle - buildbots - - stdlibchanges - langchanges - - experts - emacs - gdb - grammar - compiler - faq +This guide is a comprehensive resource for :ref:`contributing ` +to Python_ -- for both new and experienced contributors. It is +:ref:`maintained ` by the same community +that maintains Python. We welcome your contributions to Python! Quick Start ----------- -Here is a list of the basic steps necessary to get set up and make a patch: +Here are the basic steps needed to get :ref:`set up ` and contribute a +patch: -1. Get :ref:`a clone of CPython ` with ``hg clone - http://hg.python.org/cpython``. -2. On UNIX, run ``./configure --with-pydebug && make -j2`` to - :ref:`build Python `. +1. :ref:`Get the source code `:: - On :ref:`Windows `, load the project file + hg clone http://hg.python.org/cpython + +2. :ref:`Build Python `. On :ref:`UNIX `:: + + ./configure --with-pydebug && make -j2 + + On :ref:`Windows `, open the solution file :file:`PCbuild\\pcbuild.sln` in Visual Studio, select :menuselection:`Debug`, and :menuselection:`Build --> Build Solution`. -3. :doc:`Run the tests ` with ``./python -m test -j3`` (use - :file:`./python.exe` on :ref:`most ` Mac OS X systems and - :file:`PCbuild\\python_d.exe` on Windows; replace ``test`` with - ``test.regrtest`` for 2.7). +3. :doc:`Run the tests `:: + + ./python -m test -j3 + + On :ref:`most ` Mac OS X systems, replace :file:`./python` + with :file:`./python.exe`. On Windows, use :file:`PCbuild\\python_d.exe` or + check the :ref:`Windows instructions `. With Python 2.7, + replace ``test`` with ``test.regrtest``. 4. Make the :doc:`patch `. 5. Submit it to the `issue tracker`_. @@ -66,6 +49,8 @@ * PEPs_ (Python Enhancement Proposals) +.. _contributing: + Contributing ------------ @@ -122,6 +107,7 @@ Also refer to :ref:`suggesting-changes` in the FAQ. + Other Interpreter Implementations --------------------------------- @@ -167,6 +153,7 @@ * :doc:`faq` * :doc:`developers` + Additional Resources -------------------- @@ -183,15 +170,51 @@ * :ref:`Search this guide ` + +.. _contents: + +Full Table of Contents +---------------------- + +.. toctree:: + :numbered: + + setup + help + patch + runtests + coverage + docquality + documenting + silencewarnings + fixingissues + tracker + triaging + communication + coredev + developers + committing + devcycle + buildbots + stdlibchanges + langchanges + experts + emacs + gdb + grammar + compiler + faq + + .. _Buildbot status: http://python.org/dev/buildbot/ .. _Firefox search engine plug-in: http://www.python.org/dev/searchplugin/ .. _Misc directory: http://hg.python.org/cpython/file/default/Misc .. _PEPs: http://www.python.org/dev/peps .. _python.org maintenance: http://python.org/dev/pydotorg/ +.. _Python: http://www.python.org/ .. _Python Mentors: http://pythonmentors.com/ .. _PyPy: http://www.pypy.org/ .. _Jython: http://www.jython.org/ .. _IronPython: http://ironpython.net/ .. _Stackless: http://www.stackless.com/ .. _Issue tracker: http://bugs.python.org/ - diff --git a/langchanges.rst b/langchanges.rst --- a/langchanges.rst +++ b/langchanges.rst @@ -25,7 +25,7 @@ is to ask on :ref:`python-list or python-ideas `. You can also go through Python's stdlib and find examples of code which would benefit from your proposed change (which helps communicate the usefulness of your change to -others). +others). For further guidance, see :ref:`suggesting-changes` in the FAQ. Your proposed change also needs to be *Pythonic*. While Guido is the only person who can truly classify something as Pythonic, you can read the `Zen of @@ -34,11 +34,14 @@ .. _Zen of Python: http://www.python.org/dev/peps/pep-0020/ -Process -------- +.. index:: PEP process + +PEP Process +----------- Once you are certain you have a language change proposal which will appeal to -the general Python community, you can being the process of officially proposing -the change. +the general Python community, you can begin the process of officially proposing +the change. This process is the Python Enhancement Proposal (PEP) process. +:PEP:`1` describes it in detail. You will first need a PEP that you will present to python-ideas. You may be a little hazy on the technical details as various core developers can help with diff --git a/patch.rst b/patch.rst --- a/patch.rst +++ b/patch.rst @@ -139,9 +139,11 @@ than there are people capable of reviewing your patch. Getting your patch reviewed requires a reviewer to have the spare time and motivation to look at your patch (we cannot force anyone to review patches). If your patch has -not received any notice from reviewers (i.e., no comment made) after a -substantial amount of time then you may -email python-dev at python.org asking for someone to take a look at your patch. +not received any notice from reviewers (i.e., no comment made) after one +month, first "ping" the issue on the `issue tracker`_ to remind the nosy list +that the patch needs a review. If you don't get a response within a few days +after pinging the issue, then you can try emailing python-dev at python.org asking +for someone to review your patch. When someone does manage to find the time to look at your patch they will most likely make comments about how it can be improved (don't worry, even core diff --git a/runtests.rst b/runtests.rst --- a/runtests.rst +++ b/runtests.rst @@ -18,10 +18,11 @@ ./python -m test -If you are using Python 2.7, then use the following instead as the basis -for the commands in this section:: - - ./python -m test.regrtest +You may need to change this command as follows throughout this section. +On :ref:`most ` Mac OS X systems, replace :file:`./python` +with :file:`./python.exe`. On Windows, use :file:`PCbuild\\python_d.exe` or +check the detailed :ref:`Windows instructions `. If using +Python 2.7, replace ``test`` with ``test.regrtest``. If you don't have easy access to a command line, you can run the test suite from a Python or IDLE shell:: @@ -70,6 +71,11 @@ The ``-uall`` flag allows the use of all available resources so as to not skip tests requiring, e.g., Internet access. +To check for reference leaks (only needed if you modified C code), use the +``-R`` flag. For example, ``-R 3:2`` will first run the test 3 times to settle +down the reference count, and then run it 2 more times to verify if there are +any leaks. + You can also execute the ``Tools/scripts/run_tests.py`` script as found in a CPython checkout. The script tries to balance speed with thoroughness. But if you want the most thorough tests you should use the strenuous approach shown diff --git a/setup.rst b/setup.rst --- a/setup.rst +++ b/setup.rst @@ -1,15 +1,16 @@ -.. _setup: - -Getting Set Up -============== +=============== +Getting Started +=============== These instructions cover how to get a working copy of the source code and a compiled version of the CPython interpreter (CPython is the version of Python available from http://www.python.org/). It also gives an overview of the directory structure of the CPython source code. -.. contents:: +.. _setup: +Getting Set Up +============== Version Control Setup --------------------- @@ -121,6 +122,8 @@ more Python code than C. +.. _unix-compiling: + UNIX '''' @@ -150,7 +153,7 @@ Otherwise the build failed and thus should be fixed (at least with a bug being filed on the `issue tracker`_). -.. _python.exe: +.. _mac-python.exe: Once CPython is done building you will then have a working build that can be run in-place; ``./python`` on most machines (and what is used in @@ -216,6 +219,8 @@ Visual Studio, or choosing Start Debugging from the Debug menu, will launch the interpreter. +.. _win-python.exe: + If you want to launch the compiled interpreter from the command-line, the path varies according to the build. For a 32-bit build in debug mode, you have to invoke ``PCBuild\python_d.exe``, for a 64-bit build in debug mode, diff --git a/tracker.rst b/tracker.rst --- a/tracker.rst +++ b/tracker.rst @@ -1,3 +1,7 @@ +============== +Issue Tracking +============== + .. _tracker: Using the Issue Tracker @@ -46,7 +50,7 @@ * if you have JavaScript enabled, you can use the **Nosy List** field to search developers that can help with the issue by entering the name of the affected module, operating system, or interest area. -* least but not last, you have to describe the problem in detail, including +* last but not least, you have to describe the problem in detail, including what you expected to happen and what did happen, in the **Comment** field. Be sure to include whether any extension modules were involved, and what hardware and software platform you were using (including version information diff --git a/triaging.rst b/triaging.rst --- a/triaging.rst +++ b/triaging.rst @@ -256,11 +256,12 @@ Mercurial Repository '''''''''''''''''''' HTTP link to a Mercurial repository that contains a patch for the issue. -The `Create Patch` button will then compute a diff for the head revision -of the remote branch, and attach the diff to the issue. +A :guilabel:`Create Patch` button will appear that computes a diff for the +head revision of the remote branch and attaches it to the issue. The button +supports only CPython_ patches. -If you don't indicate a remote branch, ``default`` is used. You can -indicate a remote branch adding ``#BRANCH`` at the end of the URL. +If you don't indicate a remote branch, ``default`` is used. You can +indicate a remote branch by adding ``#BRANCH`` to the end of the URL. Generating Special Links in a Comment ------------------------------------- @@ -290,6 +291,7 @@ the Devguide, this page, and this section respectively. +.. _CPython: http://hg.python.org/cpython/file/default/ .. _Doc: http://hg.python.org/cpython/file/default/Doc/ .. _Grammar: http://hg.python.org/cpython/file/default/Grammar/ .. _Lib: http://hg.python.org/cpython/file/default/Lib/ -- Repository URL: http://hg.python.org/devguide From python-checkins at python.org Fri Jan 25 22:43:56 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 22:43:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2OTc1?= =?utf-8?q?=3A_Fix_error_handling_bug_in_the_escape-decode_decoder=2E?= Message-ID: <3YtDJX5l3VzSNf@mail.python.org> http://hg.python.org/cpython/rev/5970c90dd8d1 changeset: 81737:5970c90dd8d1 branch: 2.7 parent: 81729:864b9836dae6 user: Serhiy Storchaka date: Fri Jan 25 23:30:50 2013 +0200 summary: Issue #16975: Fix error handling bug in the escape-decode decoder. files: Lib/test/test_codecs.py | 44 +++++++++++++++++++++++++++++ Misc/NEWS | 2 + Objects/stringobject.c | 4 ++ 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -730,6 +730,50 @@ def test_empty(self): self.assertEqual(codecs.escape_decode(""), ("", 0)) + def test_raw(self): + for b in ''.join(map(chr, range(256))): + if b != '\\': + self.assertEqual(codecs.escape_decode(b + '0'), + (b + '0', 2)) + + def test_escape(self): + self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) + self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) + self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) + self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) + self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) + self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) + self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) + self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) + self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) + self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) + self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) + self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) + self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) + self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) + self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) + self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) + for b in ''.join(map(chr, range(256))): + if b not in '\n"\'\\abtnvfr01234567x': + self.assertEqual(codecs.escape_decode('\\' + b), + ('\\' + b, 2)) + + def test_errors(self): + self.assertRaises(ValueError, codecs.escape_decode, br"\x") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") + self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, codecs.escape_decode, br"\x0") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + class RecodingTest(unittest.TestCase): def test_recoding(self): f = StringIO.StringIO() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,8 @@ Core and Builtins ----------------- +- Issue #16975: Fix error handling bug in the escape-decode decoder. + - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in any mapping, not only in a Unicode string. diff --git a/Objects/stringobject.c b/Objects/stringobject.c --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -726,6 +726,10 @@ errors); goto failed; } + /* skip \x */ + if (s < end && isxdigit(Py_CHARMASK(s[0]))) + s++; /* and a hexdigit */ + break; #ifndef Py_USING_UNICODE case 'u': case 'U': -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 22:43:58 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 22:43:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2OTc1?= =?utf-8?q?=3A_Fix_error_handling_bug_in_the_escape-decode_bytes_decoder?= =?utf-8?q?=2E?= Message-ID: <3YtDJZ30BrzSNm@mail.python.org> http://hg.python.org/cpython/rev/22594c5060eb changeset: 81738:22594c5060eb branch: 3.2 parent: 81730:ea9fd9c9c677 user: Serhiy Storchaka date: Fri Jan 25 23:31:43 2013 +0200 summary: Issue #16975: Fix error handling bug in the escape-decode bytes decoder. files: Lib/test/test_codecs.py | 44 +++++++++++++++++++++++++++++ Misc/NEWS | 2 + Objects/bytesobject.c | 4 ++ 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -805,6 +805,50 @@ def test_empty(self): self.assertEqual(codecs.escape_decode(""), (b"", 0)) + def test_raw(self): + for b in range(256): + if b != b'\\'[0]: + self.assertEqual(codecs.escape_decode(bytes([b]) + b'0'), + (bytes([b]) + b'0', 2)) + + def test_escape(self): + self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) + self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) + self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) + self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) + self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) + self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) + self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) + self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) + self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) + self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) + self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) + self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) + self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) + self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) + self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) + self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) + for b in range(256): + if b not in b'\n"\'\\abtnvfr01234567x': + self.assertEqual(codecs.escape_decode(b'\\' + bytes([b])), + (b'\\' + bytes([b]), 2)) + + def test_errors(self): + self.assertRaises(ValueError, codecs.escape_decode, br"\x") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") + self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, codecs.escape_decode, br"\x0") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + class RecodingTest(unittest.TestCase): def test_recoding(self): f = io.BytesIO() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #16975: Fix error handling bug in the escape-decode bytes decoder. + - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in any mapping, not only in a string. diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -484,6 +484,10 @@ errors); goto failed; } + /* skip \x */ + if (s < end && Py_ISXDIGIT(s[0])) + s++; /* and a hexdigit */ + break; default: *p++ = '\\'; s--; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 22:43:59 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 22:43:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316975=3A_Fix_error_handling_bug_in_the_escape-decode_?= =?utf-8?q?bytes_decoder=2E?= Message-ID: <3YtDJb73qdzSNf@mail.python.org> http://hg.python.org/cpython/rev/580d536cc910 changeset: 81739:580d536cc910 branch: 3.3 parent: 81733:ff5cf42136b3 parent: 81738:22594c5060eb user: Serhiy Storchaka date: Fri Jan 25 23:32:41 2013 +0200 summary: Issue #16975: Fix error handling bug in the escape-decode bytes decoder. files: Lib/test/test_codecs.py | 44 +++++++++++++++++++++++++++++ Misc/NEWS | 2 + Objects/bytesobject.c | 4 ++ 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -927,6 +927,50 @@ def test_empty(self): self.assertEqual(codecs.escape_decode(""), (b"", 0)) + def test_raw(self): + for b in range(256): + if b != b'\\'[0]: + self.assertEqual(codecs.escape_decode(bytes([b]) + b'0'), + (bytes([b]) + b'0', 2)) + + def test_escape(self): + self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) + self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) + self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) + self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) + self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) + self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) + self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) + self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) + self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) + self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) + self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) + self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) + self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) + self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) + self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) + self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) + for b in range(256): + if b not in b'\n"\'\\abtnvfr01234567x': + self.assertEqual(codecs.escape_decode(b'\\' + bytes([b])), + (b'\\' + bytes([b]), 2)) + + def test_errors(self): + self.assertRaises(ValueError, codecs.escape_decode, br"\x") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") + self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, codecs.escape_decode, br"\x0") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + class RecodingTest(unittest.TestCase): def test_recoding(self): f = io.BytesIO() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #16975: Fix error handling bug in the escape-decode bytes decoder. + - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in any mapping, not only in a string. diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -480,6 +480,10 @@ errors); goto failed; } + /* skip \x */ + if (s < end && Py_ISXDIGIT(s[0])) + s++; /* and a hexdigit */ + break; default: *p++ = '\\'; s--; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 22:44:01 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 22:44:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316975=3A_Fix_error_handling_bug_in_the_escape-d?= =?utf-8?q?ecode_bytes_decoder=2E?= Message-ID: <3YtDJd407gzSNj@mail.python.org> http://hg.python.org/cpython/rev/513b728695fc changeset: 81740:513b728695fc parent: 81736:2c0197c95ec6 parent: 81739:580d536cc910 user: Serhiy Storchaka date: Fri Jan 25 23:33:22 2013 +0200 summary: Issue #16975: Fix error handling bug in the escape-decode bytes decoder. files: Lib/test/test_codecs.py | 44 +++++++++++++++++++++++++++++ Misc/NEWS | 2 + Objects/bytesobject.c | 4 ++ 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -927,6 +927,50 @@ def test_empty(self): self.assertEqual(codecs.escape_decode(""), (b"", 0)) + def test_raw(self): + for b in range(256): + if b != b'\\'[0]: + self.assertEqual(codecs.escape_decode(bytes([b]) + b'0'), + (bytes([b]) + b'0', 2)) + + def test_escape(self): + self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) + self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) + self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) + self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) + self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) + self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) + self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) + self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) + self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) + self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) + self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) + self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) + self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) + self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) + self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) + self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) + self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) + self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) + for b in range(256): + if b not in b'\n"\'\\abtnvfr01234567x': + self.assertEqual(codecs.escape_decode(b'\\' + bytes([b])), + (b'\\' + bytes([b]), 2)) + + def test_errors(self): + self.assertRaises(ValueError, codecs.escape_decode, br"\x") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") + self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, codecs.escape_decode, br"\x0") + self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + class RecodingTest(unittest.TestCase): def test_recoding(self): f = io.BytesIO() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #16975: Fix error handling bug in the escape-decode bytes decoder. + - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" in any mapping, not only in a string. diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -489,6 +489,10 @@ errors); goto failed; } + /* skip \x */ + if (s < end && Py_ISXDIGIT(s[0])) + s++; /* and a hexdigit */ + break; default: *p++ = '\\'; s--; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 22:54:39 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 22:54:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTgw?= =?utf-8?q?=3A_Fix_processing_of_escaped_non-ascii_bytes_in_the?= Message-ID: <3YtDXv4JKPzSNS@mail.python.org> http://hg.python.org/cpython/rev/dcbc16afd6bc changeset: 81741:dcbc16afd6bc branch: 3.3 parent: 81739:580d536cc910 user: Serhiy Storchaka date: Fri Jan 25 23:52:21 2013 +0200 summary: Issue #16980: Fix processing of escaped non-ascii bytes in the unicode-escape-decode decoder. files: Misc/NEWS | 3 +++ Objects/unicodeobject.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #16980: Fix processing of escaped non-ascii bytes in the + unicode-escape-decode decoder. + - Issue #16975: Fix error handling bug in the escape-decode bytes decoder. - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5725,7 +5725,7 @@ } else { WRITECHAR('\\'); - WRITECHAR(s[-1]); + WRITECHAR((unsigned char)s[-1]); } break; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 22:54:41 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Jan 2013 22:54:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316980=3A_Fix_processing_of_escaped_non-ascii_by?= =?utf-8?q?tes_in_the?= Message-ID: <3YtDXx0KtKzSNh@mail.python.org> http://hg.python.org/cpython/rev/d8c2ce63f5a4 changeset: 81742:d8c2ce63f5a4 parent: 81740:513b728695fc parent: 81741:dcbc16afd6bc user: Serhiy Storchaka date: Fri Jan 25 23:53:29 2013 +0200 summary: Issue #16980: Fix processing of escaped non-ascii bytes in the unicode-escape-decode decoder. files: Misc/NEWS | 3 +++ Objects/unicodeobject.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #16980: Fix processing of escaped non-ascii bytes in the + unicode-escape-decode decoder. + - Issue #16975: Fix error handling bug in the escape-decode bytes decoder. - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5598,7 +5598,7 @@ } else { WRITECHAR('\\'); - WRITECHAR(s[-1]); + WRITECHAR((unsigned char)s[-1]); } break; } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Fri Jan 25 23:09:13 2013 From: python-checkins at python.org (victor.stinner) Date: Fri, 25 Jan 2013 23:09:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_add_command_line_o?= =?utf-8?q?ption_and_environment_variable?= Message-ID: <3YtDsj0f98zSNx@mail.python.org> http://hg.python.org/peps/rev/2eba0c902a56 changeset: 4691:2eba0c902a56 user: Victor Stinner date: Fri Jan 25 23:07:44 2013 +0100 summary: PEP 433: add command line option and environment variable files: pep-0433.txt | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -329,20 +329,20 @@ library. This alternative is based on the `Proposal`_ and adds extra changes. -Add new functions: +New functions, command line argument and environment variable: * ``sys.getdefaultcloexec() -> bool``: get the default value of the - close-on-exec flag for new file descriptor - * ``sys.setdefaultcloexec(cloexec: bool)``: enable or disable - close-on-exec flag, the state of the flag can be overriden in each - function creating a file descriptor + *cloexec* parameter + * ``sys.setdefaultcloexec()``, ``-e`` command line option, ``PYTHONCLOEXEC`` + environment variable (if set): set the default value of the *cloexec* + parameter to ``True`` The major change is that the default value of the ``cloexec`` parameter is ``sys.getdefaultcloexec()``, instead of ``False``. -When ``sys.setdefaultcloexec(True)`` is called to set close-on-exec by -default, we have the same drawbacks as the -`Enable file descriptor inheritance by default`_ alternative. +When ``sys.setdefaultcloexec()`` is called to set close-on-exec by default, we +have the same drawbacks as the `Enable file descriptor inheritance by default`_ +alternative. There are additionnal drawbacks of having two behaviours depending on ``sys.getdefaultcloexec()`` value: -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Sat Jan 26 00:11:49 2013 From: python-checkins at python.org (brian.curtin) Date: Sat, 26 Jan 2013 00:11:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_=2316769=2E_Remove_out?= =?utf-8?q?dated_Visual_Studio_project_directories_for_VC6=2C_VS7=2E1=2C?= Message-ID: <3YtGFx3QZCzSNt@mail.python.org> http://hg.python.org/cpython/rev/01bbac9369e8 changeset: 81743:01bbac9369e8 user: Brian Curtin date: Fri Jan 25 17:11:34 2013 -0600 summary: Fix #16769. Remove outdated Visual Studio project directories for VC6, VS7.1, and VS8. files: Misc/NEWS | 2 + PC/VC6/_ctypes.dsp | 131 - PC/VC6/_ctypes_test.dsp | 99 - PC/VC6/_elementtree.dsp | 111 - PC/VC6/_msi.dsp | 99 - PC/VC6/_multiprocessing.dsp | 107 - PC/VC6/_socket.dsp | 99 - PC/VC6/_sqlite3.dsp | 131 - PC/VC6/_ssl.dsp | 89 - PC/VC6/_ssl.mak | 22 - PC/VC6/_testcapi.dsp | 99 - PC/VC6/_tkinter.dsp | 103 - PC/VC6/build_ssl.py | 228 - PC/VC6/build_tkinter.py | 81 - PC/VC6/bz2.dsp | 99 - PC/VC6/make_versioninfo.dsp | 108 - PC/VC6/pcbuild.dsw | 293 - PC/VC6/pyexpat.dsp | 111 - PC/VC6/python.dsp | 100 - PC/VC6/pythoncore.dsp | 780 ---- PC/VC6/pythonw.dsp | 101 - PC/VC6/readme.txt | 192 - PC/VC6/rmpyc.py | 25 - PC/VC6/rt.bat | 41 - PC/VC6/select.dsp | 99 - PC/VC6/tcl852.patch | 11 - PC/VC6/unicodedata.dsp | 99 - PC/VC6/winsound.dsp | 99 - PC/VS7.1/Uninstal.wse | 514 -- PC/VS7.1/_ctypes.vcproj | 311 - PC/VS7.1/_ctypes_test.vcproj | 242 - PC/VS7.1/_elementtree.vcproj | 264 - PC/VS7.1/_msi.vcproj | 252 - PC/VS7.1/_socket.vcproj | 254 - PC/VS7.1/_sqlite3.vcproj | 283 - PC/VS7.1/_ssl.mak | 38 - PC/VS7.1/_ssl.vcproj | 84 - PC/VS7.1/_testcapi.vcproj | 247 - PC/VS7.1/_tkinter.vcproj | 261 - PC/VS7.1/amd64_ml64.bat | 17 - PC/VS7.1/build_ssl.bat | 12 - PC/VS7.1/build_ssl.py | 181 - PC/VS7.1/bz2.vcproj | 271 - PC/VS7.1/db.build | 10 - PC/VS7.1/field3.py | 35 - PC/VS7.1/installer.bmp | Bin PC/VS7.1/make_buildinfo.c | 92 - PC/VS7.1/make_buildinfo.vcproj | 122 - PC/VS7.1/make_versioninfo.vcproj | 142 - PC/VS7.1/pcbuild.sln | 271 - PC/VS7.1/pyexpat.vcproj | 263 - PC/VS7.1/python.build | 20 - PC/VS7.1/python.iss | 340 - PC/VS7.1/python.vcproj | 274 - PC/VS7.1/python20.wse | 3112 ------------------ PC/VS7.1/pythoncore.vcproj | 826 ---- PC/VS7.1/pythonw.vcproj | 261 - PC/VS7.1/readme.txt | 337 - PC/VS7.1/rmpyc.py | 25 - PC/VS7.1/rt.bat | 52 - PC/VS7.1/select.vcproj | 258 - PC/VS7.1/unicodedata.vcproj | 247 - PC/VS7.1/winsound.vcproj | 251 - PC/VS8.0/_ctypes.vcproj | 705 ---- PC/VS8.0/_ctypes_test.vcproj | 521 --- PC/VS8.0/_elementtree.vcproj | 613 --- PC/VS8.0/_hashlib.vcproj | 537 --- PC/VS8.0/_msi.vcproj | 529 --- PC/VS8.0/_multiprocessing.vcproj | 545 --- PC/VS8.0/_socket.vcproj | 537 --- PC/VS8.0/_sqlite3.vcproj | 613 --- PC/VS8.0/_ssl.vcproj | 537 --- PC/VS8.0/_testcapi.vcproj | 521 --- PC/VS8.0/_tkinter.vcproj | 541 --- PC/VS8.0/bdist_wininst.vcproj | 270 - PC/VS8.0/build.bat | 17 - PC/VS8.0/build_env.bat | 1 - PC/VS8.0/build_pgo.bat | 41 - PC/VS8.0/build_ssl.bat | 12 - PC/VS8.0/build_ssl.py | 277 - PC/VS8.0/build_tkinter.py | 85 - PC/VS8.0/bz2.vcproj | 581 --- PC/VS8.0/debug.vsprops | 15 - PC/VS8.0/env.bat | 5 - PC/VS8.0/field3.py | 35 - PC/VS8.0/idle.bat | 15 - PC/VS8.0/kill_python.c | 178 - PC/VS8.0/kill_python.vcproj | 279 - PC/VS8.0/make_buildinfo.c | 116 - PC/VS8.0/make_buildinfo.vcproj | 101 - PC/VS8.0/make_versioninfo.vcproj | 324 - PC/VS8.0/pcbuild.sln | 555 --- PC/VS8.0/pginstrument.vsprops | 34 - PC/VS8.0/pgupdate.vsprops | 14 - PC/VS8.0/pyd.vsprops | 28 - PC/VS8.0/pyd_d.vsprops | 36 - PC/VS8.0/pyexpat.vcproj | 553 --- PC/VS8.0/pyproject.vsprops | 87 - PC/VS8.0/python.vcproj | 637 --- PC/VS8.0/pythoncore.vcproj | 1921 ----------- PC/VS8.0/pythonw.vcproj | 618 --- PC/VS8.0/release.vsprops | 15 - PC/VS8.0/rmpyc.py | 25 - PC/VS8.0/rt.bat | 52 - PC/VS8.0/select.vcproj | 537 --- PC/VS8.0/sqlite3.vcproj | 537 --- PC/VS8.0/sqlite3.vsprops | 14 - PC/VS8.0/ssl.vcproj | 189 - PC/VS8.0/unicodedata.vcproj | 533 --- PC/VS8.0/winsound.vcproj | 523 --- PC/VS8.0/x64.vsprops | 22 - 111 files changed, 2 insertions(+), 29207 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -760,6 +760,8 @@ Build ----- +- Issue #16769: Remove outdated Visual Studio projects. + - Issue #17031: Fix running regen in cross builds. - Issue #3754: fix typo in pthread AC_CACHE_VAL. diff --git a/PC/VC6/_ctypes.dsp b/PC/VC6/_ctypes.dsp deleted file mode 100644 --- a/PC/VC6/_ctypes.dsp +++ /dev/null @@ -1,131 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_ctypes" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_ctypes - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_ctypes.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_ctypes.mak" CFG="_ctypes - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_ctypes - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_ctypes - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_ctypes" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_ctypes - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_ctypes" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_ctypes - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_ctypes" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_ctypes - Win32 Release" -# Name "_ctypes - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\_ctypes.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\callbacks.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\callproc.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\cfield.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\libffi_msvc\ffi.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\malloc_closure.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\libffi_msvc\prep_cif.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\stgdict.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\libffi_msvc\win32.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_ctypes_test.dsp b/PC/VC6/_ctypes_test.dsp deleted file mode 100644 --- a/PC/VC6/_ctypes_test.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_ctypes_test" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_ctypes_test - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_ctypes_test.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_ctypes_test.mak" CFG="_ctypes_test - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_ctypes_test - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_ctypes_test - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_ctypes_test" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_ctypes_test - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_ctypes_test" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes_test.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_ctypes_test - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_ctypes_test" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes_test_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_ctypes_test - Win32 Release" -# Name "_ctypes_test - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\_ctypes_test.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_elementtree.dsp b/PC/VC6/_elementtree.dsp deleted file mode 100644 --- a/PC/VC6/_elementtree.dsp +++ /dev/null @@ -1,111 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_elementtree" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_elementtree - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_elementtree.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_elementtree.mak" CFG="_elementtree - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_elementtree - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_elementtree - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_elementtree" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_elementtree - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_elementtree" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d100000" /subsystem:windows /dll /debug /machine:I386 /out:"./_elementtree.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_elementtree - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_elementtree" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d100000" /subsystem:windows /dll /debug /machine:I386 /out:"./_elementtree_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_elementtree - Win32 Release" -# Name "_elementtree - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_elementtree.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlparse.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlrole.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmltok.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_msi.dsp b/PC/VC6/_msi.dsp deleted file mode 100644 --- a/PC/VC6/_msi.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_msi" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_msi - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_msi.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_msi.mak" CFG="_msi - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_msi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_msi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_msi" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_msi - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_msi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_msi.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_msi - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_msi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_msi_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_msi - Win32 Release" -# Name "_msi - Win32 Debug" -# Begin Source File - -SOURCE=..\..\PC\_msi.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_multiprocessing.dsp b/PC/VC6/_multiprocessing.dsp deleted file mode 100644 --- a/PC/VC6/_multiprocessing.dsp +++ /dev/null @@ -1,107 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_multiprocessing" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_multiprocessing - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_multiprocessing.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_multiprocessing.mak" CFG="_multiprocessing - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_multiprocessing - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_multiprocessing - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_multiprocessing" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_multiprocessing - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_multiprocessing" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_multiprocessing.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_multiprocessing - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_multiprocessing" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1d0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_multiprocessing_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_multiprocessing - Win32 Release" -# Name "_multiprocessing - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_multiprocessing\multiprocessing.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_multiprocessing\semaphore.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_multiprocessing\win32_functions.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_socket.dsp b/PC/VC6/_socket.dsp deleted file mode 100644 --- a/PC/VC6/_socket.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_socket" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_socket - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_socket.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_socket.mak" CFG="_socket - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_socket - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_socket - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_socket" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_socket - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_socket" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_socket.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_socket - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_socket" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_socket_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_socket - Win32 Release" -# Name "_socket - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\socketmodule.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_sqlite3.dsp b/PC/VC6/_sqlite3.dsp deleted file mode 100644 --- a/PC/VC6/_sqlite3.dsp +++ /dev/null @@ -1,131 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_sqlite3" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_sqlite3 - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_sqlite3.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_sqlite3.mak" CFG="_sqlite3 - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_sqlite3 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_sqlite3 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_sqlite3" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_sqlite3 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_sqlite3" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\sqlite-source-3.3.4\sqlite3.lib /nologo /base:"0x1e180000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sqlite3.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_sqlite3 - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_sqlite3" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\sqlite-source-3.3.4\sqlite3.lib /nologo /base:"0x1e180000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sqlite3_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_sqlite3 - Win32 Release" -# Name "_sqlite3 - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\cache.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\connection.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\cursor.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\microprotocols.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\prepare_protocol.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\row.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\statement.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\util.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_ssl.dsp b/PC/VC6/_ssl.dsp deleted file mode 100644 --- a/PC/VC6/_ssl.dsp +++ /dev/null @@ -1,89 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_ssl" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) External Target" 0x0106 - -CFG=_ssl - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_ssl.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_ssl.mak" CFG="_ssl - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_ssl - Win32 Release" (based on "Win32 (x86) External Target") -!MESSAGE "_ssl - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "_ssl - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "_ssl.exe" -# PROP BASE Bsc_Name "_ssl.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_ssl" -# PROP Cmd_Line "python build_ssl.py" -# PROP Rebuild_Opt "-a" -# PROP Target_File "_ssl.pyd" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "x86-temp-debug\_ssl" -# PROP BASE Intermediate_Dir "x86-temp-debug\_ssl" -# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "_ssl_d.pyd" -# PROP BASE Bsc_Name "_ssl_d.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_ssl" -# PROP Cmd_Line "python_d -u build_ssl.py -d" -# PROP Rebuild_Opt "-a" -# PROP Target_File "_ssl_d.pyd" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ENDIF - -# Begin Target - -# Name "_ssl - Win32 Release" -# Name "_ssl - Win32 Debug" - -!IF "$(CFG)" == "_ssl - Win32 Release" - -!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" - -!ENDIF - -# Begin Source File - -SOURCE=..\..\Modules\_ssl.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_ssl.mak b/PC/VC6/_ssl.mak deleted file mode 100644 --- a/PC/VC6/_ssl.mak +++ /dev/null @@ -1,22 +0,0 @@ - -!IFDEF DEBUG -MODULE=_ssl_d.pyd -TEMP_DIR=x86-temp-debug/_ssl -CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32 -LFLAGS=/nodefaultlib:"msvcrt" -!ELSE -MODULE=_ssl.pyd -TEMP_DIR=x86-temp-release/_ssl -CFLAGS=/Ox /MD /LD /DWIN32 -LFLAGS= -!ENDIF - -INCLUDES=-I ../../Include -I .. -I $(SSL_DIR)/inc32 -SSL_LIB_DIR=$(SSL_DIR)/out32 -LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib - -SOURCE=../../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib - -$(MODULE): $(SOURCE) ../*.h ../../Include/*.h - @if not exist "$(TEMP_DIR)/." mkdir "$(TEMP_DIR)" - cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS) $(LFLAGS) diff --git a/PC/VC6/_testcapi.dsp b/PC/VC6/_testcapi.dsp deleted file mode 100644 --- a/PC/VC6/_testcapi.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_testcapi" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_testcapi - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_testcapi.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_testcapi.mak" CFG="_testcapi - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_testcapi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_testcapi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_testcapi" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_testcapi - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_testcapi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /machine:I386 /out:"./_testcapi.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_testcapi - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_testcapi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /debug /machine:I386 /out:"./_testcapi_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_testcapi - Win32 Release" -# Name "_testcapi - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_testcapimodule.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_tkinter.dsp b/PC/VC6/_tkinter.dsp deleted file mode 100644 --- a/PC/VC6/_tkinter.dsp +++ /dev/null @@ -1,103 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_tkinter" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_tkinter - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_tkinter.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_tkinter.mak" CFG="_tkinter - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_tkinter - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_tkinter - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_tkinter" -# PROP Scc_LocalPath "..\..\.." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_tkinter - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_tkinter" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\..\tcltk\lib\tk85g.lib ..\..\..\tcltk\lib\tcl85g.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_tkinter - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_tkinter" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\..\tcltk\lib\tk85.lib ..\..\..\tcltk\lib\tcl85.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter.pyd" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_tkinter - Win32 Release" -# Name "_tkinter - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_tkinter.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\tkappinit.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/build_ssl.py b/PC/VC6/build_ssl.py deleted file mode 100644 --- a/PC/VC6/build_ssl.py +++ /dev/null @@ -1,228 +0,0 @@ -# Script for building the _ssl module for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for _ssl.pyd itself. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PC/VC6 directory. -# -# it should configure and build SSL, then build the ssl Python extension -# without intervention. - -# Modified by Christian Heimes -# Now this script supports pre-generated makefiles and assembly files. -# Developers don't need an installation of Perl anymore to build Python. A svn -# checkout from our svn repository is enough. - -import os, sys, re, shutil - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen('"%s" -e "use Win32;"' % perl) - fh.read() - rc = fh.close() - if rc: - continue - return perl - print("Can not find a suitable PERL:") - if perls: - print(" the following perl interpreters were found:") - for p in perls: - print(" ", p) - print(" None of these versions appear suitable for building OpenSSL") - else: - print(" NO perl interpreters were found on this machine at all!") - print(" Please install ActivePerl and ensure it appears on your path") - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - # note: do not abspath s; the build will fail if any - # higher up directory name has spaces in it. - fnames = os.listdir(s) - except OSError: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print("Found an SSL directory at '%s'" % (best_name,)) - else: - print("Could not find an SSL directory in '%s'" % (sources,)) - sys.stdout.flush() - return best_name - -def fix_makefile(makefile): - """Fix some stuff in all makefiles - """ - if not os.path.isfile(makefile): - return - with open(makefile) as fin: - lines = fin.readlines() - with open(makefile, 'w') as fout: - for line in lines: - if line.startswith("PERL="): - continue - if line.startswith("CP="): - line = "CP=copy\n" - if line.startswith("MKDIR="): - line = "MKDIR=mkdir\n" - if line.startswith("CFLAG="): - line = line.strip() - for algo in ("RC5", "MDC2", "IDEA"): - noalgo = " -DOPENSSL_NO_%s" % algo - if noalgo not in line: - line = line + noalgo - line = line + '\n' - fout.write(line) - -def run_configure(configure, do_script): - print("perl Configure "+configure) - os.system("perl Configure "+configure) - print(do_script) - os.system(do_script) - -def cmp(f1, f2): - bufsize = 1024 * 8 - with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True - -def copy(src, dst): - if os.path.isfile(dst) and cmp(src, dst): - return - shutil.copy(src, dst) - -def main(): - debug = "-d" in sys.argv - build_all = "-a" in sys.argv - if 1: # Win32 - arch = "x86" - configure = "VC-WIN32" - do_script = "ms\\do_nasm" - makefile="ms\\nt.mak" - m32 = makefile - dirsuffix = "32" - configure += " no-idea no-rc5 no-mdc2" - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl: - print("Found a working perl at '%s'" % (perl,)) - else: - print("No Perl installation was found. Existing Makefiles are used.") - sys.stdout.flush() - # Look for SSL 3 levels up from PC/VC6 - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("..\\..\\..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - if perl is None: - print("Perl is required to build the makefiles!") - sys.exit(1) - - print("Creating the makefiles...") - sys.stdout.flush() - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.dirname(perl) + \ - os.pathsep + \ - os.environ["PATH"] - run_configure(configure, do_script) - if debug: - print("OpenSSL debug builds aren't supported.") - #if arch=="x86" and debug: - # # the do_masm script in openssl doesn't generate a debug - # # build makefile so we generate it here: - # os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile) - - fix_makefile(makefile) - copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) - copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) - - # If the assembler files don't exist in tmpXX, copy them there - if perl is None and os.path.exists("asm"+dirsuffix): - if not os.path.exists("tmp"+dirsuffix): - os.mkdir("tmp"+dirsuffix) - for f in os.listdir("asm"+dirsuffix): - if not f.endswith(".asm"): continue - if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue - shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix) - - # Now run make. - copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h") - copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h") - - #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) - makeCommand = "nmake /nologo -f \"%s\"" % makefile - print("Executing ssl makefiles:", makeCommand) - sys.stdout.flush() - rc = os.system(makeCommand) - if rc: - print("Executing "+makefile+" failed") - print(rc) - sys.exit(rc) - finally: - os.chdir(old_cd) - # And finally, we can build the _ssl module itself for Python. - defs = "SSL_DIR=%s" % (ssl_dir,) - if debug: - defs = defs + " " + "DEBUG=1" - rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) - sys.exit(rc) - -if __name__=='__main__': - main() diff --git a/PC/VC6/build_tkinter.py b/PC/VC6/build_tkinter.py deleted file mode 100644 --- a/PC/VC6/build_tkinter.py +++ /dev/null @@ -1,81 +0,0 @@ -import os -import sys -import subprocess - -TCL_MAJOR = 8 -TCL_MINOR = 5 -TCL_PATCH = 2 - -TIX_MAJOR = 8 -TIX_MINOR = 4 -TIX_PATCH = 3 - -def abspath(name): - par = os.path.pardir - return os.path.abspath(os.path.join(__file__, par, par, par, par, name)) - -TCL_DIR = abspath("tcl%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH)) -TK_DIR = abspath("tk%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH)) -TIX_DIR = abspath("tix%d.%d.%d" % (TIX_MAJOR, TIX_MINOR, TIX_PATCH)) -OUT_DIR = abspath("tcltk") - -def have_args(*a): - return any(s in sys.argv[1:] for s in a) - -def enter(dir): - os.chdir(os.path.join(dir, "win")) - -def main(): - debug = have_args("-d", "--debug") - clean = have_args("clean") - install = have_args("install") - tcl = have_args("tcl") - tk = have_args("tk") - tix = have_args("tix") - if not(tcl) and not(tk) and not(tix): - tcl = tk = tix = True - - def nmake(makefile, *a): - args = ["nmake", "/nologo", "/f", makefile, "DEBUG=%d" % debug] - args.extend(a) - subprocess.check_call(args) - - if tcl: - enter(TCL_DIR) - def nmake_tcl(*a): - nmake("makefile.vc", *a) - if clean: - nmake_tcl("clean") - elif install: - nmake_tcl("install", "INSTALLDIR=" + OUT_DIR) - else: - nmake_tcl() - - if tk: - enter(TK_DIR) - def nmake_tk(*a): - nmake("makefile.vc", "TCLDIR=" + TCL_DIR, *a) - if clean: - nmake_tk("clean") - elif install: - nmake_tk("install", "INSTALLDIR=" + OUT_DIR) - else: - nmake_tk() - - if tix: - enter(TIX_DIR) - def nmake_tix(*a): - nmake("python.mak", - "TCL_MAJOR=%d" % TCL_MAJOR, - "TCL_MINOR=%d" % TCL_MINOR, - "TCL_PATCH=%d" % TCL_PATCH, - "MACHINE=IX86", *a) - if clean: - nmake_tix("clean") - elif install: - nmake_tix("install", "INSTALL_DIR=" + OUT_DIR) - else: - nmake_tix() - -if __name__ == '__main__': - main() diff --git a/PC/VC6/bz2.dsp b/PC/VC6/bz2.dsp deleted file mode 100644 --- a/PC/VC6/bz2.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="bz2" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=bz2 - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "bz2.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "bz2.mak" CFG="bz2 - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "bz2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "bz2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "bz2" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "bz2 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\bz2" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" -# SUBTRACT LINK32 /pdb:none /nodefaultlib - -!ELSEIF "$(CFG)" == "bz2 - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\bz2" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "bz2 - Win32 Release" -# Name "bz2 - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\bz2module.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/make_versioninfo.dsp b/PC/VC6/make_versioninfo.dsp deleted file mode 100644 --- a/PC/VC6/make_versioninfo.dsp +++ /dev/null @@ -1,108 +0,0 @@ -# Microsoft Developer Studio Project File - Name="make_versioninfo" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=make_versioninfo - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "make_versioninfo.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "make_versioninfo.mak" CFG="make_versioninfo - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "make_versioninfo - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "make_versioninfo - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "make_versioninfo" -# PROP Scc_LocalPath ".." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "make_versioninfo - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\make_versioninfo" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none -# Begin Custom Build -InputPath=.\make_versioninfo.exe -SOURCE="$(InputPath)" - -"..\pythonnt_rc.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - .\make_versioninfo.exe >..\pythonnt_rc.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "make_versioninfo - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\make_versioninfo" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\..\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 /out:"./make_versioninfo_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none -# Begin Custom Build -InputPath=.\make_versioninfo_d.exe -SOURCE="$(InputPath)" - -"..\pythonnt_rc_d.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - .\make_versioninfo_d.exe >..\pythonnt_rc_d.h - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "make_versioninfo - Win32 Release" -# Name "make_versioninfo - Win32 Debug" -# Begin Source File - -SOURCE=..\make_versioninfo.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/pcbuild.dsw b/PC/VC6/pcbuild.dsw deleted file mode 100644 --- a/PC/VC6/pcbuild.dsw +++ /dev/null @@ -1,293 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "_ctypes"=".\_ctypes.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_ctypes_test"=".\_ctypes_test.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "_elementtree"=".\_elementtree.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "_msi"=".\_msi.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_multiprocessing"=".\_multiprocessing.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_socket"=".\_socket.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_sqlite3"=".\_sqlite3.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "_ssl"=".\_ssl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency - Begin Project Dependency - Project_Dep_Name python - End Project Dependency - Begin Project Dependency - End Project Dependency -}}} - -############################################################################### - -Project: "_testcapi"=".\_testcapi.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_tkinter"=".\_tkinter.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "bz2"=".\bz2.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "make_versioninfo"=".\make_versioninfo.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "pyexpat"=".\pyexpat.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "python"=".\python.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "pythoncore"=".\pythoncore.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name make_versioninfo - End Project Dependency -}}} - -############################################################################### - -Project: "pythonw"=".\pythonw.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "select"=".\select.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "unicodedata"=".\unicodedata.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################## - -Project: "winsound"=".\winsound.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - - diff --git a/PC/VC6/pyexpat.dsp b/PC/VC6/pyexpat.dsp deleted file mode 100644 --- a/PC/VC6/pyexpat.dsp +++ /dev/null @@ -1,111 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pyexpat" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pyexpat - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pyexpat.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pyexpat.mak" CFG="pyexpat - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pyexpat - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pyexpat - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "pyexpat" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pyexpat - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pyexpat" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D100000" /subsystem:windows /dll /debug /machine:I386 /out:"./pyexpat.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pyexpat - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pyexpat" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "HAVE_EXPAT_H" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D100000" /subsystem:windows /dll /debug /machine:I386 /out:"./pyexpat_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pyexpat - Win32 Release" -# Name "pyexpat - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\pyexpat.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlparse.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlrole.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmltok.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/python.dsp b/PC/VC6/python.dsp deleted file mode 100644 --- a/PC/VC6/python.dsp +++ /dev/null @@ -1,100 +0,0 @@ -# Microsoft Developer Studio Project File - Name="python" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=python - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "python.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "python.mak" CFG="python - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "python - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "python - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "python" -# PROP Scc_LocalPath ".." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "python - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\python" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "python - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\python" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "....\\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /stack:0x200000 /subsystem:console /debug /machine:I386 /out:"./python_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "python - Win32 Release" -# Name "python - Win32 Debug" -# Begin Source File - -SOURCE=..\pycon.ico -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\python.c -# End Source File -# Begin Source File - -SOURCE=..\python_exe.rc -# End Source File -# End Target -# End Project diff --git a/PC/VC6/pythoncore.dsp b/PC/VC6/pythoncore.dsp deleted file mode 100644 --- a/PC/VC6/pythoncore.dsp +++ /dev/null @@ -1,780 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pythoncore" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pythoncore - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pythoncore.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pythoncore.mak" CFG="pythoncore - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pythoncore - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pythoncore - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "pythoncore" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pythoncore - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pythoncore" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_DL_EXPORT" /YX /FD /Zm200 /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\..\Include" /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python34.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pythoncore" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "USE_DL_EXPORT" /D "WIN32" /D "_WINDOWS" /YX /FD /Zm200 /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\..\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python34_d.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pythoncore - Win32 Release" -# Name "pythoncore - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_bisectmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_cn.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_hk.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_iso2022.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_jp.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_kr.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_tw.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_codecsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_collectionsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_csv.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_datetimemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_functoolsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_heapqmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\_iomodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_json.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_localemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_lsprof.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_math.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_pickle.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_randommodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sre.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_struct.c -# End Source File -# Begin Source File - -SOURCE=..\..\PC\_subprocess.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_threadmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_time.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\_warnings.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_weakref.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\abstract.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\accu.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\acceler.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\adler32.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\arraymodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\asdl.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\ast.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\atexitmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\audioop.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\binascii.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\bitset.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\bltinmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\boolobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\bufferedio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\bytearrayobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\bytes_methods.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\bytesio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\bytesobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\capsule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\cellobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\ceval.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\classobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cmathmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\codecs.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\codeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\compile.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\complexobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\compress.c -# End Source File -# Begin Source File - -SOURCE=..\config.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\crc32.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\dynamic_annotations.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\deflate.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\descrobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\dictobject.c -# End Source File -# Begin Source File - -SOURCE=..\dl_nt.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\dtoa.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\dynload_win.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\enumobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\errnomodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\errors.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\exceptions.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\fileio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\fileobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\fileutils.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\firstsets.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\floatobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\formatter_unicode.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\frameobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\frozen.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\funcobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\future.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\gcmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\genobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getargs.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\getbuildinfo.c -# ADD CPP /D BUILD=46 -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getcompiler.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getcopyright.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getopt.c -# End Source File -# Begin Source File - -SOURCE=..\getpathp.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getplatform.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getversion.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\graminit.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\grammar.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\grammar1.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\gzio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\import.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\importdl.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\infback.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\inffast.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\inflate.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\inftrees.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\iobase.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\iterobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\itertoolsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\listnode.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\listobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\longobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\main.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\marshal.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\mathmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\md5module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\memoryobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\metagrammar.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\methodobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\mmapmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\modsupport.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\moduleobject.c -# End Source File -# Begin Source File - -SOURCE=..\msvcrtmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\multibytecodec.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\myreadline.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\mysnprintf.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\mystrtoul.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\node.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\object.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\obmalloc.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\operator.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\parser.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\parsermodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\parsetok.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\peephole.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\posixmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pyarena.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pyctype.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pyfpe.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pymath.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pystate.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pystrcmp.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pystrtod.c -# End Source File -# Begin Source File - -SOURCE="..\..\Python\Python-ast.c" -# End Source File -# Begin Source File - -SOURCE=..\python_nt.rc -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pythonrun.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pytime.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\random.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\rangeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\rotatingtree.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\setobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\sha1module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\sha256module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\sha512module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\signalmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\sliceobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\stringio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\structmember.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\structseq.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\symtable.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\symtablemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\sysmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\textio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\thread.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\timemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\tokenizer.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\traceback.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\trees.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\tupleobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\typeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\uncompr.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\unicodectype.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\unicodeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\weakrefobject.c -# End Source File -# Begin Source File - -SOURCE=..\winreg.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\xxsubtype.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zipimport.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlibmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\zutil.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/pythonw.dsp b/PC/VC6/pythonw.dsp deleted file mode 100644 --- a/PC/VC6/pythonw.dsp +++ /dev/null @@ -1,101 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pythonw" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=pythonw - Win32 Alpha Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pythonw.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pythonw.mak" CFG="pythonw - Win32 Alpha Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pythonw - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "pythonw - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "pythonw" -# PROP Scc_LocalPath "..\pc" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pythonw - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pythonw" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d000000" /subsystem:windows /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pythonw - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pythonw" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d000000" /subsystem:windows /debug /machine:I386 /out:"./pythonw_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pythonw - Win32 Release" -# Name "pythonw - Win32 Debug" -# Begin Source File - -SOURCE=..\python_exe.rc -# End Source File -# Begin Source File - -SOURCE=..\WinMain.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/readme.txt b/PC/VC6/readme.txt deleted file mode 100644 --- a/PC/VC6/readme.txt +++ /dev/null @@ -1,192 +0,0 @@ -Building Python using VC++ 6.0 or 5.0 -------------------------------------- -This directory is used to build Python for Win32 platforms, e.g. Windows -2000 and XP. It requires Microsoft Visual C++ 6.x or 5.x and Platform -SDK February 2003 Edition (Core SDK). -(For other Windows platforms and compilers, see ../readme.txt.) - -All you need to do is open the workspace "pcbuild.dsw" in MSVC++, select -the Debug or Release setting (using Build -> Set Active Configuration...), -and build the projects. - -The proper order to build subprojects: - -1) pythoncore (this builds the main Python DLL and library files, - python34.{dll, lib} in Release mode) - -2) python (this builds the main Python executable, - python.exe in Release mode) - -3) the other subprojects, as desired or needed (note: you probably don't - want to build most of the other subprojects, unless you're building an - entire Python distribution from scratch, or specifically making changes - to the subsystems they implement; see SUBPROJECTS below) - -When using the Debug setting, the output files have a _d added to -their name: python34_d.dll, python_d.exe, pyexpat_d.pyd, and so on. - -SUBPROJECTS ------------ -These subprojects should build out of the box. Subprojects other than the -main ones (pythoncore, python, pythonw) generally build a DLL (renamed to -.pyd) from a specific module so that users don't have to load the code -supporting that module unless they import the module. - -pythoncore - .dll and .lib -python - .exe -pythonw - pythonw.exe, a variant of python.exe that doesn't pop up a DOS box -_msi - _msi.c. You need to install Windows Installer SDK to build this module. -_socket - socketmodule.c -_testcapi - tests of the Python C API, run via Lib/test/test_capi.py, and - implemented by module Modules/_testcapimodule.c -pyexpat - Python wrapper for accelerated XML parsing, which incorporates stable - code from the Expat project: http://sourceforge.net/projects/expat/ -select - selectmodule.c -unicodedata - large tables of Unicode data -winsound - play sounds (typically .wav files) under Windows - -The following subprojects will generally NOT build out of the box. They -wrap code Python doesn't control, and you'll need to download the base -packages first and unpack them into siblings of PCbuilds's parent -directory; for example, if your PCbuild is .......\dist\src\PCbuild\, -unpack into new subdirectories of dist\. - -_tkinter - Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.5.2. - - Get source - ---------- - In the dist directory, run - svn export http://svn.python.org/projects/external/tcl-8.5.2.1 tcl8.5.2 - svn export http://svn.python.org/projects/external/tk-8.5.2.0 tk8.5.2 - svn export http://svn.python.org/projects/external/tix-8.4.3.1 tix8.4.3 - - Debug Build - ----------- - To build debug version, add DEBUG=1 to all nmake call bellow. - - Build Tcl first (done here w/ MSVC 6 on Win2K) - --------------- - If your environment doesn't have struct _stat64, you need to apply - tcl852.patch in this directory to dist\tcl8.5.2\generic\tcl.h. - - cd dist\tcl8.5.2\win - run vcvars32.bat - nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - Optional: run tests, via - nmake -f makefile.vc test - - all.tcl: Total 24242 Passed 23358 Skipped 877 Failed 7 - Sourced 137 Test Files. - Files with failing tests: exec.test http.test io.test main.test string.test stri - ngObj.test - - Build Tk - -------- - cd dist\tk8.5.2\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.5.2 - nmake -f makefile.vc TCLDIR=..\..\tcl8.5.2 INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - XXX I have no idea whether "nmake -f makefile.vc test" passed or - XXX failed. It popped up tons of little windows, and did lots of - XXX stuff, and nothing blew up. - - Build Tix - --------- - cd dist\tix8.4.3\win - nmake -f python.mak TCL_MAJOR=8 TCL_MINOR=5 TCL_PATCH=2 MACHINE=IX86 DEBUG=0 - nmake -f python.mak TCL_MAJOR=8 TCL_MINOR=5 TCL_PATCH=2 MACHINE=IX86 DEBUG=0 INSTALL_DIR=..\..\tcltk install - -bz2 - Python wrapper for the libbz2 compression library. Homepage - http://www.bzip.org/ - Download the source from the python.org copy into the dist - directory: - - svn export http://svn.python.org/projects/external/bzip2-1.0.6 - - And requires building bz2 first. - - cd dist\bzip2-1.0.6 - nmake -f makefile.msc - - All of this managed to build bzip2-1.0.6\libbz2.lib, which the Python - project links in. - - -_sqlite3 - Python wrapper for SQLite library. - - Get the source code through - - svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 - - To use the extension module in a Python build tree, copy sqlite3.dll into - the PC/VC6 folder. - - -_ssl - Python wrapper for the secure sockets library. - - Get the latest source code for OpenSSL from - http://www.openssl.org - - You (probably) don't want the "engine" code. For example, don't get - openssl-engine-0.9.6g.tar.gz - - Unpack into the "dist" directory, retaining the folder name from - the archive - for example, the latest stable OpenSSL will install as - dist/openssl-1.0.1c - - You need to use version 1.0.1c of OpenSSL. - - You can install the NASM assembler from - http://www.nasm.us/ - for x86 builds. Put nasmw.exe anywhere in your PATH. - Note: recent releases of nasm only have nasm.exe. Just rename it to - nasmw.exe. - - You can also install ActivePerl from - http://www.activestate.com/activeperl/ - if you like to use the official sources instead of the files from - python's subversion repository. The svn version contains pre-build - makefiles and assembly files. - - The MSVC project simply invokes PC/VC6/build_ssl.py to perform - the build. This Python script locates and builds your OpenSSL - installation, then invokes a simple makefile to build the final .pyd. - - build_ssl.py attempts to catch the most common errors (such as not - being able to find OpenSSL sources, or not being able to find a Perl - that works with OpenSSL) and give a reasonable error message. - If you have a problem that doesn't seem to be handled correctly - (eg, you know you have ActivePerl but we can't find it), please take - a peek at build_ssl.py and suggest patches. Note that build_ssl.py - should be able to be run directly from the command-line. - - build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do - this by hand. - - -YOUR OWN EXTENSION DLLs ------------------------ -If you want to create your own extension module DLL, there's an example -with easy-to-follow instructions in ../PC/example/; read the file -readme.txt there first. diff --git a/PC/VC6/rmpyc.py b/PC/VC6/rmpyc.py deleted file mode 100644 --- a/PC/VC6/rmpyc.py +++ /dev/null @@ -1,25 +0,0 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../../Lib") -print npyc, ".pyc deleted,", npyo, ".pyo deleted" diff --git a/PC/VC6/rt.bat b/PC/VC6/rt.bat deleted file mode 100755 --- a/PC/VC6/rt.bat +++ /dev/null @@ -1,41 +0,0 @@ - at rem Run Tests. Run the regression test suite. - at rem Usage: rt [-d] [-O] [-q] regrtest_args - at rem -d Run Debug build (python_d.exe). Else release build. - at rem -O Run python.exe or python_d.exe (see -d) with -O. - at rem -q "quick" -- normally the tests are run twice, the first time - at rem after deleting all the .py[co] files reachable from Lib/. - at rem -q runs the tests just once, and without deleting .py[co] files. - at rem All leading instances of these switches are shifted off, and - at rem whatever remains is passed to regrtest.py. For example, - at rem rt -O -d -x test_thread - at rem runs - at rem python_d -O ../../lib/test/regrtest.py -x test_thread - at rem twice, and - at rem rt -q -g test_binascii - at rem runs - at rem python_d ../../lib/test/regrtest.py -g test_binascii - at rem to generate the expected-output file for binascii quickly. - at set _exe=python - at set _qmode=no - at set _dashO= - at goto CheckOpts -:Again - at shift -:CheckOpts - at if "%1"=="-O" set _dashO=-O - at if "%1"=="-O" goto Again - at if "%1"=="-q" set _qmode=yes - at if "%1"=="-q" goto Again - at if "%1"=="-d" set _exe=python_d - at if "%1"=="-d" goto Again - at if "%_qmode%"=="yes" goto Qmode - at echo Deleting .pyc/.pyo files ... -@%_exe% rmpyc.py -%_exe% %_dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 - at echo About to run again without deleting .pyc/.pyo first: - at pause -:Qmode -%_exe% %_dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 - at set _exe= - at set _qmode= - at set _dashO= diff --git a/PC/VC6/select.dsp b/PC/VC6/select.dsp deleted file mode 100644 --- a/PC/VC6/select.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="select" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=select - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "select.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "select.mak" CFG="select - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "select - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "select - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "select" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "select - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\select" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./select.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "select - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\select" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt" /out:"./select_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "select - Win32 Release" -# Name "select - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\selectmodule.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/tcl852.patch b/PC/VC6/tcl852.patch deleted file mode 100644 --- a/PC/VC6/tcl852.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- tcl8.5.2\generic\tcl.h Fri Jun 13 03:35:39 2008 -+++ tcl8.5.2\generic\tcl.h Sun Jan 4 16:52:30 2009 -@@ -367,7 +367,7 @@ - typedef struct stati64 Tcl_StatBuf; - # define TCL_LL_MODIFIER "L" - # else /* __BORLANDC__ */ --# if _MSC_VER < 1400 && !defined(_M_IX86) -+# if _MSC_VER < 1400 /*&& !defined(_M_IX86)*/ - typedef struct _stati64 Tcl_StatBuf; - # else - typedef struct _stat64 Tcl_StatBuf; diff --git a/PC/VC6/unicodedata.dsp b/PC/VC6/unicodedata.dsp deleted file mode 100644 --- a/PC/VC6/unicodedata.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="unicodedata" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=unicodedata - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "unicodedata.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "unicodedata.mak" CFG="unicodedata - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "unicodedata - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "unicodedata - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "unicodedata" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "unicodedata - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\unicodedata" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D120000" /dll /machine:I386 /out:"./unicodedata.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "unicodedata - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\unicodedata" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D120000" /dll /debug /machine:I386 /out:"./unicodedata_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "unicodedata - Win32 Release" -# Name "unicodedata - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\unicodedata.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/winsound.dsp b/PC/VC6/winsound.dsp deleted file mode 100644 --- a/PC/VC6/winsound.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="winsound" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=winsound - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "winsound.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "winsound.mak" CFG="winsound - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "winsound - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "winsound - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "winsound" -# PROP Scc_LocalPath "..\pc" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "winsound - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\winsound" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib winmm.lib user32.lib /nologo /base:"0x1D160000" /dll /machine:I386 /out:"./winsound.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "winsound - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\winsound" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib winmm.lib /nologo /base:"0x1D160000" /dll /debug /machine:I386 /out:"./winsound_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "winsound - Win32 Release" -# Name "winsound - Win32 Debug" -# Begin Source File - -SOURCE=..\winsound.c -# End Source File -# End Target -# End Project diff --git a/PC/VS7.1/Uninstal.wse b/PC/VS7.1/Uninstal.wse deleted file mode 100644 --- a/PC/VS7.1/Uninstal.wse +++ /dev/null @@ -1,514 +0,0 @@ -Document Type: WSE -item: Global - Version=8.14 - Flags=00000100 - Split=1420 - Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - Copy Default=1 - Japanese Font Name=MS Gothic - Japanese Font Size=10 - Start Gradient=0 0 255 - End Gradient=0 0 0 - Windows Flags=00000000000000000000101000001000 - Message Font=MS Sans Serif - Font Size=8 - Disk Label=GLBS - Disk Filename=INSTALL - Patch Flags=0000000000000001 - Patch Threshold=200 - Patch Memory=4096 - Per-User Version ID=1 - Crystal Format=10111100101100000010001001001001 - Step View=&Properties -end -item: Remark - Text=Note from Tim: This is a verbatim copy of Wise's Uninstal.wse, altered at the end to write -end -item: Remark - Text=uninstall info under HKCU instead of HKLM if our DOADMIN var is false. -end -item: Remark -end -item: Remark - Text= Install Support for uninstalling the application. -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%_LOGFILE_PATH_% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH%\UNWISE.EXE -end -item: Compiler Variable If - Variable=_EXE_OS_TYPE_ - Value=WIN32 -end -item: Install File - Source=%_WISE_%\UNWISE32.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable Else -end -item: Install File - Source=%_WISE_%\UNWISE.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install Support for multiple languages -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_PATH% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_LANG%\UNWISE.INI -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=C - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_C_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=D - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_D_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=E - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DEU - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_E_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DEU - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=F - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.PTG - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_F_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.PTG - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=G - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_G_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=H - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_H_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=I - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ITA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_I_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ITA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=J - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DAN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_J_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DAN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=K - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FIN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_K_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FIN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=L - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ISL - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_L_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ISL - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=M - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NLD - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_M_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NLD - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=N - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NOR - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_N_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NOR - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=O - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.SVE - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_O_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.SVE - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=P - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.JPN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_P_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.JPN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install the add/remove or uninstall icon -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH% - Flags=00010100 -end -item: Set Variable - Variable=INST_LOG_PATH - Value=%_LOGFILE_PATH_% - Flags=00010100 -end -item: Check Configuration - Flags=10111011 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Remark - Text=Write uninstall info under HKLM. This if/else/end block added by Tim. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=2 -end -item: Else Statement -end -item: Remark - Text=The same, but write under HKCU instead. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=1 -end -item: End Block -end -item: Else Statement -end -item: Add ProgMan Icon - Group=%GROUP% - Icon Name=Uninstall %APPTITLE% - Command Line=%UNINSTALL_PATH% %INST_LOG_PATH% -end -item: End Block -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit Registry - Total Keys=2 - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%COMPANY% - Value Name=RegCompany - Root=2 - end - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%NAME% - Value Name=RegOwner - Root=2 - end -end -item: End Block -end -item: End Block -end diff --git a/PC/VS7.1/_ctypes.vcproj b/PC/VS7.1/_ctypes.vcproj deleted file mode 100644 --- a/PC/VS7.1/_ctypes.vcproj +++ /dev/null @@ -1,311 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_ctypes_test.vcproj b/PC/VS7.1/_ctypes_test.vcproj deleted file mode 100644 --- a/PC/VS7.1/_ctypes_test.vcproj +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_elementtree.vcproj b/PC/VS7.1/_elementtree.vcproj deleted file mode 100644 --- a/PC/VS7.1/_elementtree.vcproj +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_msi.vcproj b/PC/VS7.1/_msi.vcproj deleted file mode 100644 --- a/PC/VS7.1/_msi.vcproj +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_socket.vcproj b/PC/VS7.1/_socket.vcproj deleted file mode 100644 --- a/PC/VS7.1/_socket.vcproj +++ /dev/null @@ -1,254 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_sqlite3.vcproj b/PC/VS7.1/_sqlite3.vcproj deleted file mode 100644 --- a/PC/VS7.1/_sqlite3.vcproj +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_ssl.mak b/PC/VS7.1/_ssl.mak deleted file mode 100644 --- a/PC/VS7.1/_ssl.mak +++ /dev/null @@ -1,38 +0,0 @@ -EXTRA_LIBS= - -!IFDEF DEBUG -SUFFIX=_d.pyd -TEMP=x86-temp-debug/ -CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32 -SSL_LIB_DIR=$(SSL_DIR)/out32.dbg -!ELSE -SUFFIX=.pyd -TEMP=x86-temp-release/ -CFLAGS=/Ox /MD /LD /DWIN32 -SSL_LIB_DIR=$(SSL_DIR)/out32 -!ENDIF - -INCLUDES=-I ../../Include -I ../../PC -I $(SSL_DIR)/inc32 - -SSL_LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /LIBPATH:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib -SSL_SOURCE=../../Modules/_ssl.c - -HASH_LIBS=gdi32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib -HASH_SOURCE=../../Modules/_hashopenssl.c - -all: _ssl$(SUFFIX) _hashlib$(SUFFIX) - -# Split compile/link into two steps to better support VSExtComp -_ssl$(SUFFIX): $(SSL_SOURCE) $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib ../../PC/*.h ../../Include/*.h - @if not exist "$(TEMP)/_ssl/." mkdir "$(TEMP)/_ssl" - cl /nologo /c $(SSL_SOURCE) $(CFLAGS) /Fo$(TEMP)\_ssl\$*.obj $(INCLUDES) - link /nologo @<< - /dll /out:_ssl$(SUFFIX) $(TEMP)\_ssl\$*.obj $(SSL_LIBS) $(EXTRA_LIBS) -<< - -_hashlib$(SUFFIX): $(HASH_SOURCE) $(SSL_LIB_DIR)/libeay32.lib ../../PC/*.h ../../Include/*.h - @if not exist "$(TEMP)/_hashlib/." mkdir "$(TEMP)/_hashlib" - cl /nologo /c $(HASH_SOURCE) $(CFLAGS) $(EXTRA_CFLAGS) /Fo$(TEMP)\_hashlib\$*.obj $(INCLUDES) - link /nologo @<< - /dll /out:_hashlib$(SUFFIX) $(HASH_LIBS) $(EXTRA_LIBS) $(TEMP)\_hashlib\$*.obj -<< diff --git a/PC/VS7.1/_ssl.vcproj b/PC/VS7.1/_ssl.vcproj deleted file mode 100644 --- a/PC/VS7.1/_ssl.vcproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_testcapi.vcproj b/PC/VS7.1/_testcapi.vcproj deleted file mode 100644 --- a/PC/VS7.1/_testcapi.vcproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_tkinter.vcproj b/PC/VS7.1/_tkinter.vcproj deleted file mode 100644 --- a/PC/VS7.1/_tkinter.vcproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/amd64_ml64.bat b/PC/VS7.1/amd64_ml64.bat deleted file mode 100644 --- a/PC/VS7.1/amd64_ml64.bat +++ /dev/null @@ -1,17 +0,0 @@ - at echo off -rem Try to find the AMD64 assembler and call it with the supplied arguments. - -set MLEXE=Microsoft Platform SDK\Bin\Win64\x86\AMD64\ml64.EXE - -rem For the environment variables see also -rem http://msdn.microsoft.com/library/en-us/win64/win64/wow64_implementation_details.asp - -if exist "%ProgramFiles%\%MLEXE%" ( - set ML64="%ProgramFiles%\%MLEXE%" -) else if exist "%ProgramW6432%\%MLEXE%" ( - set ML64="%ProgramW6432%\%MLEXE%" -) else ( - set ML64=ml64.exe -) - -%ML64% %* diff --git a/PC/VS7.1/build_ssl.bat b/PC/VS7.1/build_ssl.bat deleted file mode 100644 --- a/PC/VS7.1/build_ssl.bat +++ /dev/null @@ -1,12 +0,0 @@ -if "%1" == "ReleaseAMD64" call "%MSSdk%\SetEnv" /XP64 /RETAIL - - at echo off -if not defined HOST_PYTHON ( - if %1 EQU Debug ( - set HOST_PYTHON=python_d.exe - ) ELSE ( - set HOST_PYTHON=python.exe - ) -) -%HOST_PYTHON% build_ssl.py %1 %2 - diff --git a/PC/VS7.1/build_ssl.py b/PC/VS7.1/build_ssl.py deleted file mode 100644 --- a/PC/VS7.1/build_ssl.py +++ /dev/null @@ -1,181 +0,0 @@ -# Script for building the _ssl and _hashlib modules for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for the actual _ssl.pyd and _hashlib.pyd DLLs. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PCBuild directory. -# -# it should configure and build SSL, then build the _ssl and _hashlib -# Python extensions without intervention. - -import os, sys, re - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen(perl + ' -e "use Win32;"') - fh.read() - rc = fh.close() - if rc: - continue - return perl - print "Can not find a suitable PERL:" - if perls: - print " the following perl interpreters were found:" - for p in perls: - print " ", p - print " None of these versions appear suitable for building OpenSSL" - else: - print " NO perl interpreters were found on this machine at all!" - print " Please install ActivePerl and ensure it appears on your path" - print "The Python SSL module was not built" - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - # note: do not abspath s; the build will fail if any - # higher up directory name has spaces in it. - fnames = os.listdir(s) - except OSError: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print "Found an SSL directory at '%s'" % (best_name,) - else: - print "Could not find an SSL directory in '%s'" % (sources,) - sys.stdout.flush() - return best_name - -def run_configure(configure, do_script): - os.system("perl Configure "+configure) - os.system(do_script) - -def main(): - build_all = "-a" in sys.argv - if sys.argv[1] == "Release": - arch = "x86" - debug = False - configure = "VC-WIN32" - do_script = "ms\\do_masm" - makefile = "ms\\nt.mak" - elif sys.argv[1] == "Debug": - arch = "x86" - debug = True - configure = "VC-WIN32" - do_script = "ms\\do_masm" - makefile="ms\\d32.mak" - elif sys.argv[1] == "ReleaseItanium": - arch = "ia64" - debug = False - configure = "VC-WIN64I" - do_script = "ms\\do_win64i" - makefile = "ms\\nt.mak" - os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" - elif sys.argv[1] == "ReleaseAMD64": - arch="amd64" - debug=False - configure = "VC-WIN64A" - do_script = "ms\\do_win64a" - makefile = "ms\\nt.mak" - os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl is None: - sys.exit(1) - - print "Found a working perl at '%s'" % (perl,) - sys.stdout.flush() - # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("..\\..\\..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - print "Creating the makefiles..." - sys.stdout.flush() - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.dirname(perl) + \ - os.pathsep + \ - os.environ["PATH"] - run_configure(configure, do_script) - if arch=="x86" and debug: - # the do_masm script in openssl doesn't generate a debug - # build makefile so we generate it here: - os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile) - - # Now run make. - makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) - print "Executing ssl makefiles:", makeCommand - sys.stdout.flush() - rc = os.system(makeCommand) - if rc: - print "Executing "+makefile+" failed" - print rc - sys.exit(rc) - finally: - os.chdir(old_cd) - # And finally, we can build the _ssl module itself for Python. - defs = "SSL_DIR=\"%s\"" % (ssl_dir,) - if debug: - defs = defs + " " + "DEBUG=1" - if arch in ('amd64', 'ia64'): - defs = defs + " EXTRA_CFLAGS=/GS- EXTRA_LIBS=bufferoverflowU.lib" - makeCommand = 'nmake /nologo -f _ssl.mak ' + defs + " " + make_flags - print "Executing:", makeCommand - sys.stdout.flush() - rc = os.system(makeCommand) - sys.exit(rc) - -if __name__=='__main__': - main() diff --git a/PC/VS7.1/bz2.vcproj b/PC/VS7.1/bz2.vcproj deleted file mode 100644 --- a/PC/VS7.1/bz2.vcproj +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/db.build b/PC/VS7.1/db.build deleted file mode 100644 --- a/PC/VS7.1/db.build +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/PC/VS7.1/field3.py b/PC/VS7.1/field3.py deleted file mode 100644 --- a/PC/VS7.1/field3.py +++ /dev/null @@ -1,35 +0,0 @@ -# An absurd workaround for the lack of arithmetic in MS's resource compiler. -# After building Python, run this, then paste the output into the appropriate -# part of PC\python_nt.rc. -# Example output: -# -# * For 2.3a0, -# * PY_MICRO_VERSION = 0 -# * PY_RELEASE_LEVEL = 'alpha' = 0xA -# * PY_RELEASE_SERIAL = 1 -# * -# * and 0*1000 + 10*10 + 1 = 101. -# */ -# #define FIELD3 101 - -import sys - -major, minor, micro, level, serial = sys.version_info -levelnum = {'alpha': 0xA, - 'beta': 0xB, - 'candidate': 0xC, - 'final': 0xF, - }[level] -string = sys.version.split()[0] # like '2.3a0' - -print " * For %s," % string -print " * PY_MICRO_VERSION = %d" % micro -print " * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)) -print " * PY_RELEASE_SERIAL = %d" % serial -print " *" - -field3 = micro * 1000 + levelnum * 10 + serial - -print " * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3) -print " */" -print "#define FIELD3", field3 diff --git a/PC/VS7.1/installer.bmp b/PC/VS7.1/installer.bmp deleted file mode 100644 Binary file PC/VS7.1/installer.bmp has changed diff --git a/PC/VS7.1/make_buildinfo.c b/PC/VS7.1/make_buildinfo.c deleted file mode 100644 --- a/PC/VS7.1/make_buildinfo.c +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -#include -#include - -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PC\VS7.1\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\..\\Modules\\getbuildinfo.c instead. - - Currently, subwcrev.exe is found from the registry entries - of TortoiseSVN. - - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. - -*/ - -int make_buildinfo2() -{ - struct _stat st; - HKEY hTortoise; - char command[500]; - DWORD type, size; - if (_stat(".svn", &st) < 0) - return 0; - /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ - if (_stat("no_subwcrev", &st) == 0) - return 0; - if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && - RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) - /* Tortoise not installed */ - return 0; - command[0] = '"'; /* quote the path to the executable */ - size = sizeof(command) - 1; - if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || - type != REG_SZ) - /* Registry corrupted */ - return 0; - strcat(command, "bin\\subwcrev.exe"); - if (_stat(command+1, &st) < 0) - /* subwcrev.exe not part of the release */ - return 0; - strcat(command, "\" ..\\.. ..\\..\\Modules\\getbuildinfo.c getbuildinfo2.c"); - puts(command); fflush(stdout); - if (system(command) < 0) - return 0; - return 1; -} - -int main(int argc, char*argv[]) -{ - char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - int do_unlink, result; - if (argc != 2) { - fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat(command, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat(command, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat(command, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat(command, "-MD "); - strcat(command, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } - - if ((do_unlink = make_buildinfo2())) - strcat(command, "getbuildinfo2.c -DSUBWCREV "); - else - strcat(command, "..\\..\\Modules\\getbuildinfo.c"); - strcat(command, " -Fogetbuildinfo.o -I..\\..\\Include -I..\\..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) - unlink("getbuildinfo2.c"); - if (result < 0) - return EXIT_FAILURE; - return 0; -} diff --git a/PC/VS7.1/make_buildinfo.vcproj b/PC/VS7.1/make_buildinfo.vcproj deleted file mode 100644 --- a/PC/VS7.1/make_buildinfo.vcproj +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/make_versioninfo.vcproj b/PC/VS7.1/make_versioninfo.vcproj deleted file mode 100644 --- a/PC/VS7.1/make_versioninfo.vcproj +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/pcbuild.sln b/PC/VS7.1/pcbuild.sln deleted file mode 100644 --- a/PC/VS7.1/pcbuild.sln +++ /dev/null @@ -1,271 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_socket", "_socket.vcproj", "{324F66C2-44D0-4D50-B979-F9DAE7FD36DB}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ssl", "_ssl.vcproj", "{8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} = {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testcapi", "_testcapi.vcproj", "{59CBF474-9E06-4C50-9142-C44A118BB447}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_tkinter", "_tkinter.vcproj", "{5B51DFF7-5DC0-41F8-8791-A4AB7114A151}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bz2", "bz2.vcproj", "{AC557788-6354-43F7-BE05-C9C8C59A344A}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_versioninfo", "make_versioninfo.vcproj", "{F0E0541E-F17D-430B-97C4-93ADF0DD284E}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pyexpat", "pyexpat.vcproj", "{7E551393-3C43-47F8-9F3F-5BC368A6C487}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" - ProjectSection(ProjectDependencies) = postProject - {F0E0541E-F17D-430B-97C4-93ADF0DD284E} = {F0E0541E-F17D-430B-97C4-93ADF0DD284E} - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select", "select.vcproj", "{97239A56-DBC0-41D2-BC14-C87D9B97D63B}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicodedata", "unicodedata.vcproj", "{FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winsound", "winsound.vcproj", "{51F35FAE-FB92-4B2C-9187-1542C065AD77}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_elementtree", "_elementtree.vcproj", "{1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buildinfo.vcproj", "{C73F0EC1-358B-4177-940F-0846AC8B04CD}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_msi", "_msi.vcproj", "{2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes", "_ctypes.vcproj", "{F22F40F4-D318-40DC-96B3-88DC81CE0894}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "_ctypes_test.vcproj", "{8CF334D9-4F82-42EB-97AF-83592C5AFD2F}" - ProjectSection(ProjectDependencies) = postProject - {F22F40F4-D318-40DC-96B3-88DC81CE0894} = {F22F40F4-D318-40DC-96B3-88DC81CE0894} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{2FF0A312-22F9-4C34-B070-842916DE27A9}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - ReleaseAMD64 = ReleaseAMD64 - ReleaseItanium = ReleaseItanium - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Debug.ActiveCfg = Debug|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Debug.Build.0 = Debug|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Release.ActiveCfg = Release|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Release.Build.0 = Release|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Debug.ActiveCfg = Debug|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Debug.Build.0 = Debug|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Release.ActiveCfg = Release|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Release.Build.0 = Release|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Debug.ActiveCfg = Debug|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Debug.Build.0 = Debug|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Release.ActiveCfg = Release|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Release.Build.0 = Release|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Debug.ActiveCfg = Debug|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Debug.Build.0 = Debug|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Release.ActiveCfg = Release|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Release.Build.0 = Release|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Debug.ActiveCfg = Debug|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Debug.Build.0 = Debug|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Release.ActiveCfg = Release|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Release.Build.0 = Release|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug.ActiveCfg = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug.Build.0 = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium.Build.0 = Release|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Debug.ActiveCfg = Debug|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Debug.Build.0 = Debug|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Release.ActiveCfg = Release|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Release.Build.0 = Release|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug.ActiveCfg = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug.Build.0 = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release.ActiveCfg = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug.ActiveCfg = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug.Build.0 = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release.ActiveCfg = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug.ActiveCfg = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug.Build.0 = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release.ActiveCfg = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug.ActiveCfg = Debug|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug.Build.0 = Debug|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release.ActiveCfg = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release.Build.0 = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug.ActiveCfg = Debug|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug.Build.0 = Debug|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release.ActiveCfg = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release.Build.0 = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug.ActiveCfg = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug.Build.0 = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseAMD64.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium.ActiveCfg = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug.ActiveCfg = Debug|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug.Build.0 = Debug|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release.ActiveCfg = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release.Build.0 = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug.ActiveCfg = Debug|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug.Build.0 = Debug|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release.ActiveCfg = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release.Build.0 = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug.ActiveCfg = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug.Build.0 = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug.ActiveCfg = Debug|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug.Build.0 = Debug|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release.ActiveCfg = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug.ActiveCfg = Debug|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug.Build.0 = Debug|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release.ActiveCfg = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release.Build.0 = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug.ActiveCfg = Debug|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug.Build.0 = Debug|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release.ActiveCfg = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release.Build.0 = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug.ActiveCfg = Debug|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug.Build.0 = Debug|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release.ActiveCfg = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release.Build.0 = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - EndGlobalSection - GlobalSection(SolutionItems) = postSolution - ..\Modules\getbuildinfo.c = ..\Modules\getbuildinfo.c - readme.txt = readme.txt - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/PC/VS7.1/pyexpat.vcproj b/PC/VS7.1/pyexpat.vcproj deleted file mode 100644 --- a/PC/VS7.1/pyexpat.vcproj +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/python.build b/PC/VS7.1/python.build deleted file mode 100644 --- a/PC/VS7.1/python.build +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/python.iss b/PC/VS7.1/python.iss deleted file mode 100644 --- a/PC/VS7.1/python.iss +++ /dev/null @@ -1,340 +0,0 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -; This is the whole ball of wax for an Inno installer for Python. -; To use, download Inno Setup from http://www.jrsoftware.org/isdl.htm/, -; install it, and double-click on this file. That launches the Inno -; script compiler. The GUI is extemely simple, and has only one button -; you may not recognize instantly: click it. You're done. It builds -; the installer into PCBuild/Python-2.2a1.exe. Size and speed of the -; installer are competitive with the Wise installer; Inno uninstall -; seems much quicker than Wise (but also feebler, and the uninstall -; log is in some un(human)readable binary format). -; -; What's Done -; ----------- -; All the usual Windows Python files are installed by this now. -; All the usual Windows Python Start menu entries are created and -; work fine. -; .py, .pyw, .pyc and .pyo extensions are registered. -; PROBLEM: Inno uninstall does not restore their previous registry -; associations (if any). Wise did. This will make life -; difficult for alpha (etc) testers. -; The Python install is fully functional for "typical" uses. -; -; What's Not Done -; --------------- -; None of "Mark Hammond's" registry entries are written. -; No installation of files is done into the system dir: -; The MS DLLs aren't handled at all by this yet. -; Python22.dll is unpacked into the main Python dir. -; -; Inno can't do different things on NT/2000 depending on whether the user -; has Admin privileges, so I don't know how to "solve" either of those, -; short of building two installers (one *requiring* Admin privs, the -; other not doing anything that needs Admin privs). -; -; Inno has no concept of variables, so lots of lines in this file need -; to be fiddled by hand across releases. Simplest way out: stick this -; file in a giant triple-quoted r-string (note that backslashes are -; required all over the place here -- forward slashes DON'T WORK in -; Inno), and use %(yadda)s string interpolation to do substitutions; i.e., -; write a very simple Python program to *produce* this script. - -[Setup] -AppName=Python and combined Win32 Extensions -AppVerName=Python 2.2.2 and combined Win32 Extensions 150 -AppId=Python 2.2.2.150 -AppVersion=2.2.2.150 -AppCopyright=Python is Copyright ? 2001 Python Software Foundation. Win32 Extensions are Copyright ? 1996-2001 Greg Stein and Mark Hammond. - -; Default install dir; value of {app} later (unless user overrides). -; {sd} = system root drive, probably "C:". -DefaultDirName={sd}\Python22 -;DefaultDirName={pf}\Python - -; Start menu folder name; value of {group} later (unless user overrides). -DefaultGroupName=Python 2.2 - -; Point SourceDir to one above PCBuild = src. -; means this script can run unchanged from anyone's CVS tree, no matter -; what they called the top-level directories. -SourceDir=. -OutputDir=.. -OutputBaseFilename=Python-2.2.2-Win32-150-Setup - -AppPublisher=PythonLabs at Digital Creations -AppPublisherURL=http://www.python.org -AppSupportURL=http://www.python.org -AppUpdatesURL=http://www.python.org - -AlwaysCreateUninstallIcon=true -ChangesAssociations=true -UninstallLogMode=new -AllowNoIcons=true -AdminPrivilegesRequired=true -UninstallDisplayIcon={app}\pyc.ico -WizardDebug=false - -; The fewer screens the better; leave these commented. - -Compression=bzip -InfoBeforeFile=LICENSE.txt -;InfoBeforeFile=Misc\NEWS - -; uncomment the following line if you want your installation to run on NT 3.51 too. -; MinVersion=4,3.51 - -[Types] -Name: normal; Description: Select desired components; Flags: iscustom - -[Components] -Name: main; Description: Python and Win32 Extensions; Types: normal -Name: docs; Description: Python documentation (HTML); Types: normal -Name: tk; Description: TCL/TK, tkinter, and Idle; Types: normal -Name: tools; Description: Python utility scripts (Tools\); Types: normal -Name: test; Description: Python test suite (Lib\test\); Types: normal - -[Tasks] -Name: extensions; Description: Register file associations (.py, .pyw, .pyc, .pyo); Components: main; Check: IsAdminLoggedOn - -[Files] -; Caution: Using forward slashes instead screws up in amazing ways. -; Unknown: By the time Components (and other attrs) are added to these lines, they're -; going to get awfully long. But don't see a way to continue logical lines across -; physical lines. - -Source: LICENSE.txt; DestDir: {app}; CopyMode: alwaysoverwrite -Source: README.txt; DestDir: {app}; CopyMode: alwaysoverwrite -Source: News.txt; DestDir: {app}; CopyMode: alwaysoverwrite -Source: *.ico; DestDir: {app}; CopyMode: alwaysoverwrite; Components: main - -Source: python.exe; DestDir: {app}; CopyMode: alwaysoverwrite; Components: main -Source: pythonw.exe; DestDir: {app}; CopyMode: alwaysoverwrite; Components: main - - -Source: DLLs\tcl83.dll; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: tk -Source: DLLs\tk83.dll; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: tk -Source: tcl\*.*; DestDir: {app}\tcl; CopyMode: alwaysoverwrite; Components: tk; Flags: recursesubdirs - -Source: sysdir\python22.dll; DestDir: {sys}; CopyMode: alwaysskipifsameorolder; Components: main; Flags: sharedfile restartreplace -Source: sysdir\PyWinTypes22.dll; DestDir: {sys}; CopyMode: alwaysskipifsameorolder; Components: main; Flags: restartreplace sharedfile -Source: sysdir\pythoncom22.dll; DestDir: {sys}; CopyMode: alwaysskipifsameorolder; Components: main; Flags: restartreplace sharedfile - -Source: DLLs\_socket.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_socket.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_sre.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_sre.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_symtable.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_symtable.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_testcapi.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_testcapi.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_tkinter.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: tk -Source: libs\_tkinter.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: tk - -Source: DLLs\mmap.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\mmap.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\parser.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\parser.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\pyexpat.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\pyexpat.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\select.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\select.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\unicodedata.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\unicodedata.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\winreg.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\winreg.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\winsound.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\winsound.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\zlib.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\zlib.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: libs\python22.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\expat.dll; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main - - - -Source: Lib\*.py; DestDir: {app}\Lib; CopyMode: alwaysoverwrite; Components: main -Source: Lib\compiler\*.*; DestDir: {app}\Lib\compiler; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\distutils\*.*; DestDir: {app}\Lib\distutils; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\email\*.*; DestDir: {app}\Lib\email; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\encodings\*.*; DestDir: {app}\Lib\encodings; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\hotshot\*.*; DestDir: {app}\Lib\hotshot; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\lib-old\*.*; DestDir: {app}\Lib\lib-old; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\xml\*.*; DestDir: {app}\Lib\xml; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\hotshot\*.*; DestDir: {app}\Lib\hotshot; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\test\*.*; DestDir: {app}\Lib\test; CopyMode: alwaysoverwrite; Components: test; Flags: recursesubdirs -Source: Lib\tkinter\*.py; DestDir: {app}\Lib\tkinter; CopyMode: alwaysoverwrite; Components: tk; Flags: recursesubdirs - -Source: Lib\site-packages\README.txt; DestDir: {app}\Lib\site-packages; CopyMode: alwaysoverwrite; Components: main - -Source: Lib\site-packages\PyWin32.chm; DestDir: {app}\Lib\site-packages; CopyMode: alwaysoverwrite; Components: docs -Source: Lib\site-packages\win32\*.*; DestDir: {app}\Lib\site-packages\win32; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\site-packages\win32com\*.*; DestDir: {app}\Lib\site-packages\win32com; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\site-packages\win32comext\*.*; DestDir: {app}\Lib\site-packages\win32comext; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs - -Source: include\*.h; DestDir: {app}\include; CopyMode: alwaysoverwrite; Components: main - -Source: Tools\idle\*.*; DestDir: {app}\Tools\idle; CopyMode: alwaysoverwrite; Components: tk; Flags: recursesubdirs - -Source: Tools\pynche\*.*; DestDir: {app}\Tools\pynche; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs -Source: Tools\scripts\*.*; DestDir: {app}\Tools\Scripts; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs -Source: Tools\webchecker\*.*; DestDir: {app}\Tools\webchecker; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs -Source: Tools\versioncheck\*.*; DestDir: {app}\Tools\versioncheck; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs - -Source: Doc\*.*; DestDir: {app}\Doc; CopyMode: alwaysoverwrite; Flags: recursesubdirs; Components: docs - - -[Icons] -Name: {group}\Python (command line); Filename: {app}\python.exe; WorkingDir: {app}; Components: main -Name: {group}\Python Manuals; Filename: {app}\Doc\index.html; WorkingDir: {app}; Components: docs -Name: {group}\Win32 Extensions Help; Filename: {app}\Lib\site-packages\PyWin32.chm; WorkingDir: {app}\Lib\site-packages; Components: docs -Name: {group}\Module Docs; Filename: {app}\pythonw.exe; WorkingDir: {app}; Parameters: """{app}\Tools\Scripts\pydoc.pyw"""; Components: tools -Name: {group}\IDLE (Python GUI); Filename: {app}\pythonw.exe; WorkingDir: {app}; Parameters: """{app}\Tools\idle\idle.pyw"""; Components: tools - -[Registry] -; Register .py -Tasks: extensions; Root: HKCR; Subkey: .py; ValueType: string; ValueName: ; ValueData: Python File; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: .py; ValueType: string; ValueName: Content Type; ValueData: text/plain; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: Python File; ValueType: string; ValueName: ; ValueData: Python File; Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: Python File\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\Py.ico -Tasks: extensions; Root: HKCR; Subkey: Python File\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\python.exe"" ""%1"" %*" - -; Register .pyc -Tasks: extensions; Root: HKCR; Subkey: .pyc; ValueType: string; ValueName: ; ValueData: Python CompiledFile; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: Python CompiledFile; ValueType: string; ValueName: ; ValueData: Compiled Python File; Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: Python CompiledFile\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\pyc.ico -Tasks: extensions; Root: HKCR; Subkey: Python CompiledFile\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\python.exe"" ""%1"" %*" - -; Register .pyo -Tasks: extensions; Root: HKCR; Subkey: .pyo; ValueType: string; ValueName: ; ValueData: Python CompiledFile; Flags: uninsdeletevalue - -; Register .pyw -Tasks: extensions; Root: HKCR; Subkey: .pyw; ValueType: string; ValueName: ; ValueData: Python NoConFile; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: .pyw; ValueType: string; ValueName: Content Type; ValueData: text/plain; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: Python NoConFile; ValueType: string; ValueName: ; ValueData: Python File (no console); Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: Python NoConFile\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\Py.ico -Tasks: extensions; Root: HKCR; Subkey: Python NoConFile\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\pythonw.exe"" ""%1"" %*" - - -; Python Registry Keys -Root: HKLM; Subkey: SOFTWARE\Python; Flags: uninsdeletekeyifempty; Check: IsAdminLoggedOn -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\PythonPath; ValueData: "{app}\Lib;{app}\DLLs"; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\PythonPath\win32; ValueData: "{app}\lib\site-packages\win32;{app}\lib\site-packages\win32\lib"; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\PythonPath\win32com; ValueData: C:\Python\lib\site-packages; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Modules; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Modules\pythoncom; ValueData: {sys}\pythoncom22.dll; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Modules\pywintypes; ValueData: {sys}\PyWinTypes22.dll; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\InstallPath; ValueData: {app}; Flags: uninsdeletekeyifempty; ValueType: string -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\InstallPath\InstallGroup; ValueData: {group}; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Help; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Help\Main Python Documentation; ValueType: string; ValueData: {app}\Doc\index.html; Flags: uninsdeletekey; Components: docs -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Help\Python Win32 Documentation; ValueType: string; ValueData: {app}\lib\site-packages\PyWin32.chm; Flags: uninsdeletekey; Components: docs - -[_ISTool] -EnableISX=true - - -[Code] -Program Setup; - -Function IsAdminNotLoggedOn(): Boolean; -begin - Result := Not IsAdminLoggedOn(); -end; - -begin -end. - - - - -[UninstallDelete] -Name: {app}\Lib\compiler\*.pyc; Type: files -Name: {app}\Lib\compiler\*.pyo; Type: files -Name: {app}\Lib\compiler; Type: dirifempty -Name: {app}\Lib\distutils\command\*.pyc; Type: files -Name: {app}\Lib\distutils\command\*.pyo; Type: files -Name: {app}\Lib\distutils\command; Type: dirifempty -Name: {app}\Lib\distutils\*.pyc; Type: files -Name: {app}\Lib\distutils\*.pyo; Type: files -Name: {app}\Lib\distutils; Type: dirifempty -Name: {app}\Lib\email\test\*.pyc; Type: files -Name: {app}\Lib\email\test\*.pyo; Type: files -Name: {app}\Lib\email\test; Type: dirifempty -Name: {app}\Lib\email\*.pyc; Type: files -Name: {app}\Lib\email\*.pyo; Type: files -Name: {app}\Lib\email; Type: dirifempty -Name: {app}\Lib\encodings\*.pyc; Type: files -Name: {app}\Lib\encodings\*.pyo; Type: files -Name: {app}\Lib\encodings; Type: dirifempty -Name: {app}\Lib\hotshot\*.pyc; Type: files -Name: {app}\Lib\hotshot\*.pyo; Type: files -Name: {app}\Lib\hotshot; Type: dirifempty -Name: {app}\Lib\lib-old\*.pyc; Type: files -Name: {app}\Lib\lib-old\*.pyo; Type: files -Name: {app}\Lib\lib-old; Type: dirifempty -Name: {app}\Lib\tkinter\*.pyc; Type: files -Name: {app}\Lib\tkinter\*.pyo; Type: files -Name: {app}\Lib\tkinter; Type: dirifempty -Name: {app}\Lib\test\*.pyc; Type: files -Name: {app}\Lib\test\*.pyo; Type: files -Name: {app}\Lib\test; Type: dirifempty -Name: {app}\Lib\xml\dom\*.pyc; Type: files -Name: {app}\Lib\xml\dom\*.pyo; Type: files -Name: {app}\Lib\xml\dom; Type: dirifempty -Name: {app}\Lib\xml\parsers\*.pyc; Type: files -Name: {app}\Lib\xml\parsers\*.pyo; Type: files -Name: {app}\Lib\xml\parsers; Type: dirifempty -Name: {app}\Lib\xml\sax\*.pyc; Type: files -Name: {app}\Lib\xml\sax\*.pyo; Type: files -Name: {app}\Lib\xml\sax; Type: dirifempty -Name: {app}\Lib\xml\*.pyc; Type: files -Name: {app}\Lib\xml\*.pyo; Type: files -Name: {app}\Lib\xml; Type: dirifempty - -Name: {app}\Lib\site-packages\win32; Type: filesandordirs -Name: {app}\Lib\site-packages\win32com; Type: filesandordirs -Name: {app}\Lib\site-packages\win32comext; Type: filesandordirs -Name: {app}\Lib\site-packages\pythoncom.py*; Type: files -Name: {app}\Lib\site-packages; Type: dirifempty - -Name: {app}\Lib\*.pyc; Type: files -Name: {app}\Lib; Type: dirifempty - -Name: {app}\Tools\pynche\*.pyc; Type: files -Name: {app}\Tools\pynche\*.pyo; Type: files -Name: {app}\Tools\pynche; Type: dirifempty - -Name: {app}\Tools\idle\*.pyc; Type: files -Name: {app}\Tools\idle\*.pyo; Type: files -Name: {app}\Tools\idle; Type: dirifempty - -Name: {app}\Tools\scripts\*.pyc; Type: files -Name: {app}\Tools\scripts\*.pyo; Type: files -Name: {app}\Tools\scripts; Type: dirifempty - -Name: {app}\Tools\versioncheck\*.pyc; Type: files -Name: {app}\Tools\versioncheck\*.pyo; Type: files -Name: {app}\Tools\versioncheck; Type: dirifempty - -Name: {app}\Tools\webchecker\*.pyc; Type: files -Name: {app}\Tools\webchecker\*.pyo; Type: files -Name: {app}\Tools\webchecker; Type: dirifempty - -Name: {app}\Tools; Type: dirifempty - diff --git a/PC/VS7.1/python.vcproj b/PC/VS7.1/python.vcproj deleted file mode 100644 --- a/PC/VS7.1/python.vcproj +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/python20.wse b/PC/VS7.1/python20.wse deleted file mode 100644 --- a/PC/VS7.1/python20.wse +++ /dev/null @@ -1,3112 +0,0 @@ -Document Type: WSE -item: Global - Version=9.0 - Title=Python 2.4a1 - Flags=00010100 - Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - Japanese Font Name=MS Gothic - Japanese Font Size=10 - Start Gradient=0 255 0 - End Gradient=0 128 0 - Windows Flags=00000100000011010010010100001010 - Log Pathname=%MAINDIR%\INSTALL.LOG - Message Font=MS Sans Serif - Font Size=8 - Pages Modified=00010000011101000000000100000111 - Extra Pages=00000000000000000000000010110010 - Disk Filename=SETUP - Patch Flags=0000000000001001 - Patch Threshold=85 - Patch Memory=4000 - MIF PDF Version=1.0 - MIF SMS Version=2.0 - EXE Filename=Python-2.4a1.exe - Dialogs Version=8 - Version File=2.4a1 - Version Description=Python Programming Language - Version Copyright=?2001-2007 Python Software Foundation - Version Company=Python Software Foundation - Crystal Format=10111100101100000010001001001001 - Step View=&All - Variable Name1=_WISE_ - Variable Description1=WISE root directory - Variable Default1=C:\Programme\Wise Installation System - Variable Flags1=00001000 - Variable Name2=_TCLDIR_ - Variable Description2=The directory in which the Tcl/Tk installation - Variable Description2=lives. This must be a sibling of the Python - Variable Description2=directory. - Variable Default2=tcl84 - Variable Flags2=00001000 - Variable Name3=_DOC_ - Variable Description3=The unpacked HTML doc directory. - Variable Default3=..\html - Variable Flags3=00001001 - Variable Name4=_SYS_ - Variable Description4=System directory (where to find MSVCRT.DLL) - Variable Default4=C:\Windows\System - Variable Values4=C:\Windows\System - Variable Values4=C:\WINNT\System32 - Variable Values4=C:\Code\MSDLLs - Variable Values4=C:\Windows\System32 - Variable Flags4=00000010 - Variable Name5=_PYMAJOR_ - Variable Description5=Python major version number; the 2 in 2.3. - Variable Default5=2 - Variable Flags5=00001000 - Variable Name6=_PYMINOR_ - Variable Description6=Python minor version number; the 3 in 2.3 - Variable Default6=3 - Variable Flags6=00001000 - Variable Name7=_DOADMIN_ - Variable Description7=The initial value for %DOADMIN%. - Variable Description7=When 0, we never try to write under HKLM, - Variable Description7=and install the Python + MS runtime DLLs in - Variable Description7=the Python directory instead of the system dir. - Variable Default7=1 - Variable Values7=1 - Variable Values7=0 - Variable Flags7=00001010 - Variable Name8=_ALIASNAME_ - Variable Flags8=00001000 - Variable Name9=_ALIASPATH_ - Variable Flags9=00001000 - Variable Name10=_ALIASTYPE_ - Variable Flags10=00001000 -end -item: Set Variable - Variable=PYVER_STRING - Value=2.3 -end -item: Remark -end -item: Remark - Text=When the version number changes, set the compiler -end -item: Remark - Text=vrbls _PYMAJOR_ and _PYMINOR_. -end -item: Remark - Text=Nothing in the script below should need fiddling then. -end -item: Remark - Text=Other things that need fiddling: -end -item: Remark - Text= PYVER_STRING above. -end -item: Remark - Text= The "Title:" in the upper left corner of the GUI. -end -item: Remark - Text= Build Settings and Version Resource on step 6 (Finish) of the Installation Expert -end -item: Remark - Text= Be sure to select Steps->All or you may not see these! -end -item: Remark -end -item: Remark - Text=When the version of Tcl/Tk changes, the compiler vrbl -end -item: Remark - Text=_TCLDIR_ may also need to be changed. -end -item: Remark -end -item: Set Variable - Variable=APPTITLE - Value=Python %PYVER_STRING% -end -item: Remark - Text=PY_VERSION should be major.minor only; used to create the registry key; must match MS_DLL_ID in python_nt.rc -end -item: Set Variable - Variable=PY_VERSION - Value=%_PYMAJOR_%.%_PYMINOR_% -end -item: Remark - Text=GROUP is the Start menu group name; user can override. -end -item: Set Variable - Variable=GROUP - Value=Python %PY_VERSION% - Flags=10000000 -end -item: Remark - Text=MAINDIR is the app directory; user can override. -end -item: Set Variable - Variable=MAINDIR - Value=Python%_PYMAJOR_%%_PYMINOR_% -end -item: Remark -end -item: Set Variable - Variable=DOADMIN - Value=%_DOADMIN_% -end -item: Remark - Text=Give non-admin users a chance to abort. -end -item: Check Configuration - Flags=10011111 -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: Display Message - Title=Doing non-admin install - Text=The current login does not have Administrator Privileges on this machine. Python will install its registry information into the per-user area only for the current login, instead of into the per-machine area for every account on this machine. Some advanced uses of Python may not work as a result (for example, running a Python script as a service). - Text= - Text=If this is not what you want, please click Cancel to abort this installation, log on as an Administrator, and start the installation again. - Flags=00001000 -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=Note from Tim: the "stop" on the next line is actually "pause". -end -item: Open/Close INSTALL.LOG - Flags=00000001 -end -item: Remark - Text=If the destination system does not have a writable Windows\System directory, system files will be written to the Windows\ directory -end -item: Check if File/Dir Exists - Pathname=%SYS% - Flags=10000100 -end -item: Set Variable - Variable=SYS - Value=%WIN% -end -item: End Block -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=COMMON - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files\Common Files - Value Name=CommonFilesDir - Flags=00000100 -end -item: Get Registry Key Value - Variable=PROGRAM_FILES - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files - Value Name=ProgramFilesDir - Flags=00000100 -end -item: Set Variable - Variable=EXPLORER - Value=1 -end -item: End Block -end -item: Remark - Text=Note from Tim: The Wizard hardcod "C:" at the start of the replacement text for MAINDIR. -end -item: Remark - Text=That's not appropriate if the system drive doesn't happen to be C:. -end -item: Remark - Text=I removed the "C:", and that did the right thing for two people who tested it on non-C: machines, -end -item: Remark - Text=but it's unclear whether it will always do the right thing. -end -item: Set Variable - Variable=MAINDIR - Value=\%MAINDIR% - Flags=00001100 -end -item: Remark - Text=BACKUP is the variable that holds the path that all backup files will be copied to when overwritten -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP - Flags=10000000 -end -item: Remark - Text=DOBACKUP determines if a backup will be performed. The possible values are A (do backup) or B (do not do backup) -end -item: Set Variable - Variable=DOBACKUP - Value=A -end -item: Remark - Text=BRANDING determines if the installation will be branded with a name and company. By default, this is written to the INST directory (installation media). -end -item: Set Variable - Variable=BRANDING - Value=0 -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: Read INI Value - Variable=NAME - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Name -end -item: Read INI Value - Variable=COMPANY - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Company -end -item: If/While Statement - Variable=NAME -end -item: Set Variable - Variable=DOBRAND - Value=1 -end -item: Get System Information - Variable=NAME - Flags=00000110 -end -item: Get System Information - Variable=COMPANY - Flags=00000111 -end -item: End Block -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: Remark - Text=Set vrbls for the "Advanced Options" subdialog of Components. -end -item: Set Variable - Variable=SELECT_ADMIN - Value=A -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=SELECT_ADMIN - Value=B -end -item: End Block -end -item: Remark -end -item: Remark - Text=TASKS values: -end -item: Remark - Text=A: Register file extensions -end -item: Remark - Text=B: Create Start Menu shortcuts -end -item: Set Variable - Variable=TASKS - Value=AB -end -item: Remark -end -item: Remark - Text=COMPONENTS values: -end -item: Remark - Text=A: interpreter and libraries -end -item: Remark - Text=B: Tcl/Tk -end -item: Remark - Text=C: docs -end -item: Remark - Text=D: tools -end -item: Remark - Text=E: test suite -end -item: Set Variable - Variable=COMPONENTS - Value=ABCDE -end -item: Remark -end -item: Remark - Text=March thru the user GUI. -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Dialog=Select Destination Directory - Dialog=Backup Replaced Files - Dialog=Select Components - Dialog=Select Program Manager Group - Variable= - Variable= - Variable= - Variable=TASKS - Value= - Value= - Value= - Value=B - Compare=0 - Compare=0 - Compare=0 - Compare=3 - Flags=00000011 -end -item: If/While Statement - Variable=DISPLAY - Value=Start Installation -end -item: Set Variable - Variable=SUMMARY - Value=Install directory: %MAINDIR%%CRLF% -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing admin install.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing non-admin install.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Make backups, into %BACKUP%%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't make backups.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Components:%CRLF% - Flags=00000001 -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python interpreter and libraries%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tcl/Tk (Tkinter, IDLE, pydoc)%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python documentation%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tool and utility scripts%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python test suite%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Register file extensions.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't register file extensions.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Start Menu group: %GROUP%%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%No Start Menu shortcuts.%CRLF% - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Custom Dialog Set - Name=Select Destination Directory - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 11 323 33 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Destination Directory - Text French=S?lectionner le r?pertoire de destination - Text German=Zielverzeichnis w?hlen - Text Spanish=Seleccione el directorio de destino - Text Italian=Selezionare Directory di destinazione - end - item: Listbox - Rectangle=108 58 321 219 - Variable=MAINDIR - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000010000000101000001 - Flags=0000110000001010 - Text=%MAINDIR% - Text= - end - item: Static - Rectangle=108 40 313 58 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Please select a directory for the %APPTITLE% files. - end - end - item: Dialog - Title=Select Destination Directory - Title French=S?lectionner le r?pertoire de destination - Title German=Zielverzeichnis w?hlen - Title Spanish=Seleccione el directorio de destino - Title Italian=Selezionare Directory di destinazione - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 6 204 186 - Variable=MAINDIR - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%MAINDIR% - Text French=%MAINDIR% - Text German=%MAINDIR% - Text Spanish=%MAINDIR% - Text Italian=%MAINDIR% - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Spanish=Aceptar - Text Italian=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=MAINDIR - Value=%MAINDIR_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Spanish=Cancelar - Text Italian=Annulla - end - end -end -item: Custom Dialog Set - Name=Backup Replaced Files - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Fichiers de Sauvegarde Remplac?s - Title German=Sicherungskopie von ersetzten Dateien erstellen - Title Portuguese=Ficheiros substitu?dos de seguran?a - Title Spanish=Copias de seguridad de los archivos reemplazados - Title Italian=Backup file sostituiti - Title Danish=Sikkerhedskopiering af erstattede filer - Title Dutch=Vervangen bestanden kopi?ren - Title Norwegian=Sikkerhetskopiere erstattede filer - Title Swedish=S?kerhetskopiera utbytta filer - Width=350 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 251 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suivant> - Text German=&Weiter> - Text Portuguese=&Pr?ximo> - Text Spanish=&Siguiente > - Text Italian=&Avanti > - Text Danish=&N?ste> - Text Dutch=&Volgende> - Text Norwegian=&Neste> - Text Swedish=&N?sta > - end - item: Push Button - Rectangle=131 234 188 251 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=<&Retour - Text German=<&Zur?ck - Text Portuguese=<&Retornar - Text Spanish=<&Retroceder - Text Italian=< &Indietro - Text Danish=<&Tilbage - Text Dutch=<&Terug - Text Norwegian=<&Tilbake - Text Swedish=< &Tillbaka - end - item: Push Button - Rectangle=278 234 330 251 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Annuller - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - item: Static - Rectangle=11 221 329 223 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 46 320 98 - Create Flags=01010000000000000000000000000000 - Text=This installation program can create backup copies of all files replaced during the installation. These files will be used when the software is uninstalled and a rollback is requested. If backup copies are not created, you will only be able to uninstall the software and not roll the system back to a previous state. - Text= - Text=Do you want to create backups of replaced files? - Text French=Le programme d'installation peut cr?er des copies de sauvegarde de tous les fichiers remplac?s pendant l'installation. Ces fichiers sont utilis?s au cas o? le logiciel est d?sinstall? et que l'on proc?de ? la reprise du syst?me. Si les copies de sauvegarde ne sont pas cr??es, on ne pourra que d?sinstaller le logiciel sans reprendre le syst?me ? un ?tat pr?c?dent. Voulez-vous cr?er une sauvegarde des fichiers remplac?s ? - Text German=Dieses Installationsprogramm kann Sicherungskopien von allen w?hrend der Installation ersetzten Dateien erstellen. Diese Dateien werden zur R?ckg?ngigmachung der Installation und bei Anforderung eines Rollbacks verwendet. Ohne Sicherungskopien ist nur eine R?ckg?ngigmachung der Installation m?glich, nicht aber ein Rollback des Systems. Sicherungskopien der ersetzten Dateien erstellen? - Text Portuguese=Este programa de instala??o pode criar c?pias de seguran?a de todos os ficheiros substitu?dos durante a instala??o. Estes ficheiros ser?o utilizados quando o programa for desinstalado e for requisitada uma retomada. Se as c?pias de seguran?a n?o forem criadas, s? poder? desinstalar o programa e n?o pode retomar um estado anterior do sistema. Deseja criar c?pias de seguran?a dos ficheiros substitu?dos? - Text Spanish=Este programa de instalaci?n puede crear copias de seguridad de todos los archivos reemplazados durante la instalaci?n. Estos archivos se utilizar?n cuando se desinstale el software y se solicite volver al estado anterior. Si no se crean copias de seguridad, ?nicamente podr? desinstalar el software y no podr? devolver el sistema al estado anterior. ?Desea crear archivos de seguridad de los archivos reemplazados? - Text Italian=Questo programma di installazione pu? creare copie di backup di tutti i file sostituiti durante l?installazione. Questi file saranno usati quando il software sar? disinstallato e sar? richiesto un ritorno allo stato precedente. Se non crei le copie di backup, potrai solo disinstallare il software, ma non potrai riportare il sistema allo stato precedente. Vuoi creare i file di backup dei file sostituiti? - Text Danish=Dette installationsprogram kan oprette sikkerhedskopier af alle filer, som erstattes under installationen. Disse filer benyttes, n?r softwaren fjernes, og den tidligere systemkonfiguration genetableres. Hvis der ikke oprettes sikkerhedskopier, kan du kun fjerne den installerede software og ikke genetablere den tidligere systemkonfiguration. Vil du oprette sikkerhedskopier af filer, som erstattes? - Text Dutch=Dit installatieprogramma kan kopie?n maken van alle bestanden die tijdens de installatie worden vervangen. Deze worden dan gebruikt als de software-installatie ongedaan wordt gemaakt en u het systeem wilt laten terugkeren naar de oorspronkelijke staat. Als er geen back-up kopie?n worden gemaakt, kunt u de software enkel verwijderen maar het systeem niet in de oorspronkelijke staat terugbrengen. Wilt u een back-up maken van de vervangen bestanden? - Text Norwegian=Dette installasjonsprogrammet kan lage sikkerhetskopier av alle filer som blir erstattet under installasjonen. Disse filene vil tas i bruk n?r programvaren er avinstallert og det er behov for tilbakestilling. Hvis det ikke er laget sikkerhetskopier, kan du kun avinstallere programvaren og ikke stille systemet tilbake til tidligere status. ?nsker du ? lage sikkerhetskopier av de filene som blir erstattet n?? - Text Swedish=Installationsprogrammet kan skapa s?kerhetskopior av alla filer som byts ut under installationen. Dessa filer kan sedan anv?ndas n?r programvaran avinstalleras och du beg?r rollback. Om du d? inte har n?gra s?kerhetskopior kan du bara avinstallera programvaran, inte ?terskapa systemet i dess tidigare skick. Vill du g?ra s?kerhetskopior av de ersatta filerna? - end - item: Radio Button - Rectangle=141 106 265 136 - Variable=DOBACKUP - Create Flags=01010000000000010000000000001001 - Text=&Yes, make backups - Text=N&o, do not make backups - Text= - Text French=&Oui - Text French=N&on - Text French= - Text German=&Ja - Text German=N&ein - Text German= - Text Portuguese=&Sim - Text Portuguese=N?&o - Text Portuguese= - Text Spanish=&S? - Text Spanish=N&o - Text Spanish= - Text Italian=&S? - Text Italian=N&o - Text Italian= - Text Danish=&Ja - Text Danish=&Nej - Text Danish= - Text Dutch=&Ja - Text Dutch=N&ee - Text Dutch= - Text Norwegian=&Ja - Text Norwegian=&Nei - Text Norwegian= - Text Swedish=&Ja - Text Swedish=N&ej - Text Swedish= - end - item: Static - Control Name=BACK2 - Rectangle=108 173 320 208 - Action=1 - Create Flags=01010000000000000000000000000111 - Text=Backup File Destination Directory - Text French=R?pertoire de destination des fichiers de sauvegarde - Text German=Zielverzeichnis f?r die Sicherungsdatei - Text Portuguese=Direct?rio de destino de ficheiro de seguran?a - Text Spanish=Directorio de Destino de los Archivos de Seguridad - Text Italian=Directory di destinazione dei file di backup - Text Danish=Destinationsbibliotek til sikkerhedskopier - Text Dutch=Doeldirectory backup-bestand - Text Norwegian=M?lkatalog for sikkerhetskopier - Text Swedish=Katalog f?r s?kerhetskopierade filer - end - item: Push Button - Control Name=BACK3 - Rectangle=265 185 318 203 - Variable=BACKUP_SAVE - Value=%BACKUP% - Destination Dialog=1 - Action=2 - Create Flags=01010000000000010000000000000000 - Text=B&rowse... - Text French=P&arcourir - Text German=B&l?ttern... - Text Portuguese=P&rocurar - Text Spanish=V&isualizar... - Text Italian=Sfoglia... - Text Danish=&Gennemse... - Text Dutch=B&laderen... - Text Norwegian=Bla igjennom - Text Swedish=&Bl?ddra - end - item: Static - Control Name=BACK4 - Rectangle=129 188 254 200 - Destination Dialog=2 - Create Flags=01010000000000000000000000000000 - Text=%BACKUP% - Text French=%BACKUP% - Text German=%BACKUP% - Text Portuguese=%BACKUP% - Text Spanish=%BACKUP% - Text Italian=%BACKUP% - Text Danish=%BACKUP% - Text Dutch=%BACKUP% - Text Norwegian=%BACKUP% - Text Swedish=%BACKUP% - end - item: Static - Rectangle=108 11 323 36 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Backup Replaced Files - Text French=S?lectionner les composants - Text German=Komponenten ausw?hlen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: If/While Statement - Variable=DOBACKUP - Value=B - end - item: Set Control Attribute - Control Name=BACK3 - Operation=1 - end - item: Set Control Attribute - Control Name=BACK4 - Operation=1 - end - item: Else Statement - end - item: Set Control Attribute - Control Name=BACK3 - end - item: Set Control Attribute - Control Name=BACK4 - end - item: End Block - end - end - item: Dialog - Title=Select Destination Directory - Title French=Choisissez le r?pertoire de destination - Title German=Zielverzeichnis w?hlen - Title Portuguese=Seleccionar Direct?rio de Destino - Title Spanish=Seleccione el Directorio de Destino - Title Italian=Seleziona Directory di destinazione - Title Danish=V?lg Destinationsbibliotek - Title Dutch=Kies Doeldirectory - Title Norwegian=Velg m?lkatalog - Title Swedish=V?lj destinationskalatog - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 3 200 186 - Variable=BACKUP - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%BACKUP% - Text= - Text French=%BACKUP% - Text French= - Text German=%BACKUP% - Text German= - Text Portuguese=%BACKUP% - Text Portuguese= - Text Spanish=%BACKUP% - Text Spanish= - Text Italian=%BACKUP% - Text Italian= - Text Danish=%BACKUP% - Text Danish= - Text Dutch=%BACKUP% - Text Dutch= - Text Norwegian=%BACKUP% - Text Norwegian= - Text Swedish=%BACKUP% - Text Swedish= - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Portuguese=OK - Text Spanish=ACEPTAR - Text Italian=OK - Text Danish=OK - Text Dutch=OK - Text Norwegian=OK - Text Swedish=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=BACKUP - Value=%BACKUP_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Slet - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - end -end -item: Custom Dialog Set - Name=Select Components - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Checkbox - Rectangle=108 66 313 156 - Variable=COMPONENTS - Create Flags=01010000000000010000000000000011 - Flags=0000000000000110 - Text=Python interpreter and libraries - Text=Tcl/Tk (Tkinter, IDLE, pydoc) - Text=Python HTML docs - Text=Python utility scripts (Tools/) - Text=Python test suite (Lib/test/) - Text= - Text French=Python interpreter, library and IDLE - Text French=Python HTML docs - Text French=Python utility scripts (Tools/) - Text French=Python test suite (Lib/test/) - Text French= - Text German=Python interpreter, library and IDLE - Text German=Python HTML docs - Text German=Python utility scripts (Tools/) - Text German=Python test suite (Lib/test/) - Text German= - Text Spanish=Python interpreter, library and IDLE - Text Spanish=Python HTML docs - Text Spanish=Python utility scripts (Tools/) - Text Spanish=Python test suite (Lib/test/) - Text Spanish= - Text Italian=Python interpreter, library and IDLE - Text Italian=Python HTML docs - Text Italian=Python utility scripts (Tools/) - Text Italian=Python test suite (Lib/test/) - Text Italian= - end - item: Static - Rectangle=108 45 320 63 - Create Flags=01010000000000000000000000000000 - Text=Choose which components to install by checking the boxes below. - Text French=Choisissez les composants que vous voulez installer en cochant les cases ci-dessous. - Text German=W?hlen Sie die zu installierenden Komponenten, indem Sie in die entsprechenden K?stchen klicken. - Text Spanish=Elija los componentes que desee instalar marcando los cuadros de abajo. - Text Italian=Scegliere quali componenti installare selezionando le caselle sottostanti. - end - item: Push Button - Rectangle=188 203 269 220 - Destination Dialog=1 - Action=2 - Enabled Color=00000000000000000000000011111111 - Create Flags=01010000000000010000000000000000 - Text=Advanced Options ... - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 43 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Components - Text French=S?lectionner les composants - Text German=Komponenten ausw?hlen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: Static - Rectangle=251 180 311 193 - Variable=COMPONENTS - Value=MAINDIR - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=251 168 311 179 - Variable=COMPONENTS - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=123 168 234 181 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Required: - Text French=Espace disque requis : - Text German=Notwendiger Speicherplatz: - Text Spanish=Espacio requerido en el disco: - Text Italian=Spazio su disco necessario: - end - item: Static - Rectangle=123 180 234 193 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Remaining: - Text French=Espace disque disponible : - Text German=Verbleibender Speicherplatz: - Text Spanish=Espacio en disco disponible: - Text Italian=Spazio su disco disponibile: - end - item: Static - Rectangle=108 158 320 196 - Action=1 - Create Flags=01010000000000000000000000000111 - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=VERIFY - end - item: Remark - Text=If they're installing Tcl/Tk, Tools, or the test suite, doesn't make much sense unless they're installing Python too. - end - item: If/While Statement - Variable=COMPONENTS - Value=BDE - Flags=00001010 - end - item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000011 - end - item: Display Message - Title=Are you sure? - Text=Installing Tcl/Tk, Tools or the test suite doesn't make much sense unless you install the Python interpreter and libraries too. - Text= - Text=Click Yes if that's really what you want. - Flags=00101101 - end - item: Remark - Text=Nothing -- just proceed to the next dialog. - end - item: Else Statement - end - item: Remark - Text=Return to the dialog. - end - item: Set Variable - Variable=DLG_EVENT_TYPE - end - item: End Block - end - item: End Block - end - item: End Block - end - item: End Block - end - end - item: Dialog - Title=Advanced Options - Width=339 - Height=213 - Font Name=Helv - Font Size=8 - item: Radio Button - Control Name=ADMIN2 - Rectangle=11 46 90 76 - Variable=SELECT_ADMIN - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000001001 - Text=Admin install - Text=Non-Admin installl - Text= - end - item: Push Button - Rectangle=188 170 244 189 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Static - Rectangle=5 3 326 83 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Static - Control Name=ADMIN1 - Rectangle=11 11 321 45 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=By default, the install records settings in the per-machine area of the registry (HKLM), and installs the Python and C runtime DLLs to %SYS32%. Choose "Non-Admin install" if you would prefer settings made in the per-user registry (HKCU), and DLLs installed in %MAINDIR%. - end - item: Static - Rectangle=5 90 326 157 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Checkbox - Rectangle=11 121 243 151 - Variable=TASKS - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000000011 - Text=Register file extensions (.py, .pyw, .pyc, .pyo) - Text=Create Start Menu shortcuts - Text= - end - item: Static - Rectangle=11 103 320 121 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Choose tasks to perform by checking the boxes below. - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=INIT - end - item: If/While Statement - Variable=DOADMIN - Value=1 - end - item: Set Control Attribute - Control Name=ADMIN2 - end - item: Else Statement - end - item: Set Control Text - Control Name=ADMIN1 - Control Text=This section is available only if logged in to an account with Administrator privileges. - end - item: Set Control Attribute - Control Name=ADMIN2 - Operation=1 - end - item: End Block - end - item: End Block - end - end -end -item: Custom Dialog Set - Name=Select Program Manager Group - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Start Menu Group - Text French=S?lectionner le groupe du Gestionnaire de programme - Text German=Bestimmung der Programm-Managergruppe - Text Spanish=Seleccione grupo del Administrador de programas - Text Italian=Selezionare il gruppo ProgMan - end - item: Static - Rectangle=108 35 320 65 - Create Flags=01010000000000000000000000000000 - Text=Enter the name of the Start Menu program group to which to add the %APPTITLE% icons: - Text French=Entrez le nom du groupe du Gestionnaire de programme dans lequel vous souhaitez ajouter les ic?nes de %APPTITLE% : - Text German=Geben Sie den Namen der Programmgruppe ein, der das Symbol %APPTITLE% hinzugef?gt werden soll: - Text Spanish=Escriba el nombre del grupo del Administrador de programas en el que desea agregar los iconos de %APPTITLE%: - Text Italian=Inserire il nome del gruppo Program Manager per aggiungere le icone %APPTITLE% a: - end - item: Combobox - Rectangle=108 56 320 219 - Variable=GROUP - Create Flags=01010000001000010000001100000001 - Flags=0000000000000001 - Text=%GROUP% - Text= - Text French=%GROUP% - Text German=%GROUP% - Text Spanish=%GROUP% - Text Italian=%GROUP% - end - end -end -item: Custom Dialog Set - Name=Start Installation - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Ready to Install! - Text French=Pr?t ? installer ! - Text German=Installationsbereit! - Text Spanish=?Preparado para la instalaci?n! - Text Italian=Pronto per l'installazione! - end - item: Static - Rectangle=108 40 320 62 - Create Flags=01010000000000000000000000000000 - Text=Click the Next button to install %APPTITLE%, or the Back button to change choices: - Text French=Vous ?tes maintenant pr?t ? installer les fichiers %APPTITLE%. - Text French= - Text French=Cliquez sur le bouton Suite pour commencer l'installation ou sur le bouton Retour pour entrer les informations d'installation ? nouveau. - Text German=Sie k?nnen %APPTITLE% nun installieren. - Text German= - Text German=Klicken Sie auf "Weiter", um mit der Installation zu beginnen. Klicken Sie auf "Zur?ck", um die Installationsinformationen neu einzugeben. - Text Spanish=Ya est? listo para instalar %APPTITLE%. - Text Spanish= - Text Spanish=Presione el bot?n Siguiente para comenzar la instalaci?n o presione Atr?s para volver a ingresar la informaci?n para la instalaci?n. - Text Italian=Ora ? possibile installare %APPTITLE%. - Text Italian= - Text Italian=Premere il pulsante Avanti per avviare l'installazione o il pulsante Indietro per reinserire le informazioni di installazione. - end - item: Editbox - Rectangle=108 66 324 219 - Help Context=16711681 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000000001100011000100 - Text=%SUMMARY% - end - end -end -item: Remark -end -item: If/While Statement - Variable=DISPLAY - Value=Select Destination Directory -end -item: Remark - Text=User may have changed MAINDIR, so reset BACKUP to match. -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP -end -item: End Block -end -item: Remark -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=When the BACKUP feature is enabled, the BACKUPDIR is initialized -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=BACKUPDIR - Value=%BACKUP% -end -item: End Block -end -item: Remark - Text=The BRANDING information is written to the INI file on the installation media. -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit INI File - Pathname=%INST%\CUSTDATA.INI - Settings=[Registration] - Settings=NAME=%NAME% - Settings=COMPANY=%COMPANY% - Settings= -end -item: End Block -end -item: End Block -end -item: Remark - Text=Begin writing to the INSTALL.LOG -end -item: Open/Close INSTALL.LOG -end -item: Remark - Text=Check free disk space calculates free disk space as well as component sizes. -end -item: Remark - Text=It should be located before all Install File actions. -end -item: Check Disk Space - Component=COMPONENTS -end -item: Remark - Text=This include script allows uninstall support -end -item: Remark - Text=Note from Tim: this is our own Uninstal.wse, a copy of Wise's except -end -item: Remark - Text=it writes to HKCU (instead of HKLM) if the user doesn't have admin privs. -end -item: Include Script - Pathname=.\Uninstal.wse -end -item: Remark - Text=Note from Tim: these seeming no-ops actually convert to short filenames. -end -item: Set Variable - Variable=COMMON - Value=%COMMON% - Flags=00010100 -end -item: Set Variable - Variable=MAINDIR - Value=%MAINDIR% - Flags=00010100 -end -item: Remark - Text=This IF/THEN/ELSE reads the correct registry entries for shortcut/icon placement -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=STARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs\StartUp - Value Name=StartUp - Flags=00000010 -end -item: Get Registry Key Value - Variable=DESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Desktop - Value Name=Desktop - Flags=00000010 -end -item: Get Registry Key Value - Variable=STARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu - Value Name=Start Menu - Flags=00000010 -end -item: Get Registry Key Value - Variable=GROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs - Value Name=Programs - Flags=00000010 -end -item: Get Registry Key Value - Variable=CSTARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTUPDIR% - Value Name=Common Startup - Flags=00000100 -end -item: Get Registry Key Value - Variable=CDESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%DESKTOPDIR% - Value Name=Common Desktop - Flags=00000100 -end -item: Get Registry Key Value - Variable=CSTARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTMENUDIR% - Value Name=Common Start Menu - Flags=00000100 -end -item: Get Registry Key Value - Variable=CGROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%GROUPDIR% - Value Name=Common Programs - Flags=00000100 -end -item: Else Statement -end -item: Remark - Text=Note from Tim: the Wizard left this block empty! -end -item: Remark - Text=Perhaps it's only relevant on Windows 3.1. -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=B -end -item: Remark - Text=The user chose a non-admin install in "Advanced Options". -end -item: Remark - Text=This should come after the include of Uninstal.wse above, because -end -item: Remark - Text=writing uninstall info to HKCU is ineffective except under Win2K. -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=CGROUP_SAVE - Value=%GROUP% -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=GROUP - Value=%CGROUPDIR%\%GROUP% -end -item: Else Statement -end -item: Set Variable - Variable=GROUP - Value=%GROUPDIR%\%GROUP% -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Long section to install files. -end -item: Remark -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=DLLDEST - Value=%SYS32% -end -item: Else Statement -end -item: Set Variable - Variable=DLLDEST - Value=%MAINDIR% -end -item: End Block -end -item: Remark -end -item: Remark - Text=Install the license even if they deselect everything . -end -item: Install File - Source=..\license - Destination=%MAINDIR%\LICENSE.txt - Flags=0000000000000010 -end -item: Install File - Source=..\readme - Destination=%MAINDIR%\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\misc\news - Destination=%MAINDIR%\NEWS.txt - Flags=0000000000000010 -end -item: Remark - Text=Icons -- always install so that the uninstaller can use them for its own display. -end -item: Install File - Source=..\pc\pycon.ico - Destination=%MAINDIR%\pycon.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\pyc.ico - Destination=%MAINDIR%\pyc.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\py.ico - Destination=%MAINDIR%\py.ico - Flags=0000000010000010 -end -item: Remark -end -item: Remark - Text=These arrange to (recursively!) delete all .pyc and .pyo files at uninstall time. -end -item: Remark - Text=This "does the right thing": any directories left empty at the end are removed. -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyc -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyo -end -item: Remark -end -item: Remark - Text=A: interpreter and libraries -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Remark - Text=Executables -end -item: Install File - Source=.\python.exe - Destination=%MAINDIR%\python.exe - Flags=0000000000000010 -end -item: Install File - Source=.\pythonw.exe - Destination=%MAINDIR%\pythonw.exe - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Extension module DLLs (.pyd); keep in synch with libs directory next -end -item: Install File - Source=.\winreg.pyd - Destination=%MAINDIR%\DLLs\winreg.pyd - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.pyd - Destination=%MAINDIR%\DLLs\_csv.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.pyd - Destination=%MAINDIR%\DLLs\_sre.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.pyd - Destination=%MAINDIR%\DLLs\_ssl.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.pyd - Destination=%MAINDIR%\DLLs\_symtable.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.pyd - Destination=%MAINDIR%\DLLs\_testcapi.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.pyd - Destination=%MAINDIR%\DLLs\_tkinter.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.pyd - Destination=%MAINDIR%\DLLs\_socket.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.pyd - Destination=%MAINDIR%\DLLs\bz2.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.pyd - Destination=%MAINDIR%\DLLs\datetime.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.pyd - Destination=%MAINDIR%\DLLs\mmap.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\parser.pyd - Destination=%MAINDIR%\DLLs\parser.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.pyd - Destination=%MAINDIR%\DLLs\pyexpat.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\select.pyd - Destination=%MAINDIR%\DLLs\select.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.pyd - Destination=%MAINDIR%\DLLs\unicodedata.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.pyd - Destination=%MAINDIR%\DLLs\winsound.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.pyd - Destination=%MAINDIR%\DLLs\zlib.pyd - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Link libraries (.lib); keep in synch with DLLs above, except that the Python lib lives here. -end -item: Install File - Source=.\winreg.lib - Destination=%MAINDIR%\libs\winreg.lib - Description=Link library files - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.lib - Destination=%MAINDIR%\libs\_csv.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.lib - Destination=%MAINDIR%\libs\_sre.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.lib - Destination=%MAINDIR%\libs\_ssl.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.lib - Destination=%MAINDIR%\libs\_symtable.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.lib - Destination=%MAINDIR%\libs\_testcapi.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.lib - Destination=%MAINDIR%\libs\_tkinter.lib - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.lib - Destination=%MAINDIR%\libs\_socket.lib - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.lib - Destination=%MAINDIR%\libs\bz2.lib - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.lib - Destination=%MAINDIR%\libs\datetime.lib - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.lib - Destination=%MAINDIR%\libs\mmap.lib - Flags=0000000000000010 -end -item: Install File - Source=.\parser.lib - Destination=%MAINDIR%\libs\parser.lib - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.lib - Destination=%MAINDIR%\libs\pyexpat.lib - Flags=0000000000000010 -end -item: Install File - Source=.\select.lib - Destination=%MAINDIR%\libs\select.lib - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.lib - Destination=%MAINDIR%\libs\unicodedata.lib - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.lib - Destination=%MAINDIR%\libs\winsound.lib - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.lib - Destination=%MAINDIR%\libs\zlib.lib - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.lib - Destination=%MAINDIR%\libs\python%_PYMAJOR_%%_PYMINOR_%.lib - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Main Python DLL -end -item: Remark - Text=Tell Wise it's OK to delete the Python DLL at uninstall time, -end -item: Remark - Text=despite that we (may) write it into a system directory. -end -item: Add Text to INSTALL.LOG - Text=Non-System File: -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.dll - Destination=%DLLDEST%\python%_PYMAJOR_%%_PYMINOR_%.dll - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Libraries (Lib/) -end -item: Install File - Source=..\lib\*.py - Destination=%MAINDIR%\Lib - Description=Library Modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\compiler\*.py - Destination=%MAINDIR%\Lib\compiler - Description=Python compiler written in Python - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\distutils\*.py - Destination=%MAINDIR%\Lib\distutils - Description=Distribution utility modules - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\readme - Destination=%MAINDIR%\Lib\distutils\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\*.py - Destination=%MAINDIR%\Lib\distutils\command - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\wininst.exe - Destination=%MAINDIR%\Lib\distutils\command\wininst.exe - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\command_template - Destination=%MAINDIR%\Lib\distutils\command\command_template - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\email\*.py - Destination=%MAINDIR%\Lib\email - Description=Library email package - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\*.py - Destination=%MAINDIR%\Lib\email\test - Description=email tests - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.txt - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.gif - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.au - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\encodings\*.py - Destination=%MAINDIR%\Lib\encodings - Description=Unicode encoding tables - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\hotshot\*.py - Destination=%MAINDIR%\Lib\hotshot - Description=Fast Python profiler - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\lib-old\*.py - Destination=%MAINDIR%\Lib\lib-old - Description=Obsolete modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\tkinter\*.py - Destination=%MAINDIR%\Lib\tkinter - Description=Tkinter related library modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\logging\*.py - Destination=%MAINDIR%\Lib\logging - Description=Logging package - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\site-packages\readme - Destination=%MAINDIR%\Lib\site-packages\README.txt - Description=Site packages - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\xml\*.py - Destination=%MAINDIR%\Lib\xml - Description=XML support packages - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\dom\*.py - Destination=%MAINDIR%\Lib\xml\dom - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\parsers\*.py - Destination=%MAINDIR%\Lib\xml\parsers - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\sax\*.py - Destination=%MAINDIR%\Lib\xml\sax - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=C Include files -end -item: Install File - Source=..\include\*.h - Destination=%MAINDIR%\include - Description=Header files - Flags=0000000000000010 -end -item: Install File - Source=..\pc\pyconfig.h - Destination=%MAINDIR%\include\pyconfig.h - Description=Header files (pyconfig.h) - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Microsoft C runtime libraries -end -item: Install File - Source=%_SYS_%\MSVCIRT.DLL - Destination=%DLLDEST%\MSVCIRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: Install File - Source=%_SYS_%\MSVCRT.DLL - Destination=%DLLDEST%\MSVCRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: End Block -end -item: Remark -end -item: Remark - Text=B: Tcl/Tk (Tkinter, IDLE, pydoc) -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Remark - Text=Tcl/Tk -end -item: Install File - Source=..\..\%_tcldir_%\bin\*.dll - Destination=%MAINDIR%\DLLs - Description=Tcl/Tk binaries and libraries - Flags=0000000000000010 -end -item: Install File - Source=..\..\%_tcldir_%\lib\*.* - Destination=%MAINDIR%\tcl - Description=Tcl/Tk binaries and libraries - Flags=0000000100000010 -end -item: Remark -end -item: Remark - Text=IDLE -end -item: Install File - Source=..\Lib\idlelib\*.py - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.txt - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.def - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\Icons\* - Destination=%MAINDIR%\Lib\idlelib\Icons - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Tools\scripts\idle - Destination=%MAINDIR%\Lib\idlelib\idle.pyw - Description=IDLE bootstrap script - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Windows pydoc driver -end -item: Install File - Source=..\tools\scripts\*.pyw - Destination=%MAINDIR%\Tools\Scripts - Description=Windows pydoc driver - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=C: docs -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Install File - Source=%_DOC_%\*.* - Destination=%MAINDIR%\Doc - Description=Python Documentation (HTML) - Flags=0000000100000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=D: tools -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Install File - Source=..\tools\scripts\*.py - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\*.doc - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\readme - Destination=%MAINDIR%\Tools\Scripts\README.txt - Description=Utility Scripts - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\webchecker\*.py - Destination=%MAINDIR%\Tools\webchecker - Description=Web checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\webchecker\readme - Destination=%MAINDIR%\Tools\webchecker\README.txt - Description=Web checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\versioncheck\*.py - Destination=%MAINDIR%\Tools\versioncheck - Description=Version checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\versioncheck\readme - Destination=%MAINDIR%\Tools\versioncheck\README.txt - Description=Version checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\pynche\*.py - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\*.txt - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\x\*.txt - Destination=%MAINDIR%\Tools\pynche\X - Description=pynche color editor - X files - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\readme - Destination=%MAINDIR%\Tools\pynche\README.txt - Description=pynche color editor - README - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche - Destination=%MAINDIR%\Tools\pynche\pynche.py - Description=pynche color editor - main - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche.pyw - Destination=%MAINDIR%\Tools\pynche\pynche.pyw - Description=pynche color editor - noconsole main - Flags=0000000100000010 -end -item: Remark -end -item: Install File - Source=..\tools\i18n\*.py - Destination=%MAINDIR%\Tools\i18n - Description=Internationalization helpers - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=E: test suite -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Install File - Source=..\lib\test\audiotest.au - Destination=%MAINDIR%\Lib\test\audiotest.au - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.uue - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.py - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.xml - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.out - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.bz2 - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.tar - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.gz - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.txt - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\test\output\*.* - Destination=%MAINDIR%\Lib\test\output - Description=Python Test output files - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=DONE with file copying. -end -item: Remark - Text=The rest is registry and Start Menu fiddling. -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Remark - Text=Register file extensions. As usual, Admin privs get in the way, but with a twist: -end -item: Remark - Text=You don't need admin privs to write to HKEY_CLASSES_ROOT *except* under Win2K. -end -item: Remark - Text=On Win2K, a user without Admin privs has to register extensions under HKCU\Software\CLASSES instead. -end -item: Remark - Text=But while you can *do* that under other flavors of Windows too, it has no useful effect except in Win2K. -end -item: Set Variable - Variable=USE_HKCR - Value=1 -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=USE_HKCR - Value=0 -end -item: End Block -end -item: End Block -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Python.File - New Value=Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile - New Value=Python File (no console) -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile - New Value=Compiled Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=Python.File -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=Python.NoConFile -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyc - New Value=Python.CompiledFile -end -item: Edit Registry - Total Keys=1 - Key=.pyo - New Value=Python.CompiledFile -end -item: Else Statement -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File - New Value=Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile - New Value=Python File (no console) - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile - New Value=Compiled Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico - Root=1 -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=Python.File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=Python.NoConFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyc - New Value=Python.CompiledFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyo - New Value=Python.CompiledFile - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=If we're installing IDLE, also set an Edit context menu action to use IDLE, for .py and .pyw files. -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: End Block -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Register Python paths. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=130 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=129 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Registry fiddling for docs. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\index.html - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\index.html - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Set the app publisher and URL entries for Win2K add/remove. -end -item: Remark - Text=It doesn't hurt on other systems. -end -item: Remark - Text=As usual, write to HKLM or HKCU depending on Admin privs. -end -item: Remark - Text=CAUTION: If you set this info on the "Windows 2000" page (step 6) of the -end -item: Remark - Text=Installation Expert, it only shows up in the "If" block below. Keep in synch! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=Populate Start Menu group -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Remark - Text=Shortcut to installer no matter what. -end -item: Create Shortcut - Source=%MAINDIR%\unwise.exe - Destination=%GROUP%\Uninstall Python.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\python.exe - Destination=%GROUP%\Python (command line).lnk - Working Directory=%MAINDIR% - Icon Pathname=%MAINDIR%\pycon.ico - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\IDLE (Python GUI).lnk - Command Options="%MAINDIR%\Lib\idlelib\idle.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\Module Docs.lnk - Command Options="%MAINDIR%\Tools\Scripts\pydocgui.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\Doc\index.html - Destination=%GROUP%\Python Manuals.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=I don't think we need this, but have always done it. -end -item: Self-Register OCXs/DLLs - Description=Updating System Configuration, Please Wait... -end -item: Remark -end -remarked item: Remark - Text=Don't enable "Delete in-use files". Here's what happens: -end -remarked item: Remark - Text=Install Python; uninstall Python; install Python again. Reboot the machine. -end -remarked item: Remark - Text=Now UNWISE.EXE is missing. I think this is a Wise bug, but so it goes. -end -remarked item: Add Text to INSTALL.LOG - Text=Delete in-use files: On -end -item: Remark -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Flags=00000011 -end -item: Custom Dialog Set - Name=Finished - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Finish - Text French=&Fin - Text German=&Weiter - Text Spanish=&Terminar - Text Italian=&Fine - end - item: Push Button - Rectangle=264 234 320 253 - Variable=DISABLED - Value=! - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=108 10 323 48 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Installation Completed! - Text French=Installation termin?e ! - Text German=Die Installation ist abgeschlossen! - Text Spanish=?Instalaci?n terminada! - Text Italian=Installazione completata! - end - item: Static - Rectangle=108 44 320 82 - Create Flags=01010000000000000000000000000000 - Text=%APPTITLE% has been successfully installed. - Text= - Text=Press the Finish button to exit this installation. - Text French=%APPTITLE% est maintenant install?. - Text French= - Text French=Cliquez sur le bouton Fin pour quitter l'installation. - Text German=%APPTITLE% wurde erfolgreich installiert. - Text German= - Text German=Klicken Sie auf "Weiter", um die Installation zu beenden. - Text Spanish=%APPTITLE% se ha instalado con ?xito. - Text Spanish= - Text Spanish=Presione el bot?n Terminar para salir de esta instalaci?n. - Text Italian=L'installazione %APPTITLE% ? stata portata a termine con successo. - Text Italian= - Text Italian=Premere il pulsante Fine per uscire dall'installazione. - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=106 105 312 210 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Special Windows thanks to: - Text= - Text=Wise Solutions, for the use of InstallMaster 8.1. - Text= http://www.wisesolutions.com/ - Text= - Text= - Text=LettError, Erik van Blokland, for the Python for Windows graphic. - Text= http://www.letterror.com/ - Text= - Text= - Text=Mark Hammond, without whose years of freely shared Windows expertise, Python for Windows would still be Python for DOS. - end - item: Static - Rectangle=106 95 312 96 - Action=3 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000001001 - end - end -end -item: End Block -end -item: New Event - Name=Cancel -end -item: Remark - Text=This include script supports a rollback to preinstallation state if the user chooses to cancel before the installation is complete. -end -item: Include Script - Pathname=%_WISE_%\INCLUDE\rollback.wse -end diff --git a/PC/VS7.1/pythoncore.vcproj b/PC/VS7.1/pythoncore.vcproj deleted file mode 100644 --- a/PC/VS7.1/pythoncore.vcproj +++ /dev/null @@ -1,826 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/pythonw.vcproj b/PC/VS7.1/pythonw.vcproj deleted file mode 100644 --- a/PC/VS7.1/pythonw.vcproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/readme.txt b/PC/VS7.1/readme.txt deleted file mode 100644 --- a/PC/VS7.1/readme.txt +++ /dev/null @@ -1,337 +0,0 @@ -Building Python using VC++ 7.1 -------------------------------------- -This directory is used to build Python for Win32 platforms, e.g. Windows -95, 98 and NT. It requires Microsoft Visual C++ 7.1 -(a.k.a. Visual Studio .NET 2003). -(For other Windows platforms and compilers, see ../PC/readme.txt.) - -All you need to do is open the workspace "pcbuild.sln" in MSVC++, select -the Debug or Release setting (using "Solution Configuration" from -the "Standard" toolbar"), and build the projects. - -The proper order to build subprojects: - -1) pythoncore (this builds the main Python DLL and library files, - python34.{dll, lib} in Release mode) - NOTE: in previous releases, this subproject was - named after the release number, e.g. python20. - -2) python (this builds the main Python executable, - python.exe in Release mode) - -3) the other subprojects, as desired or needed (note: you probably don't - want to build most of the other subprojects, unless you're building an - entire Python distribution from scratch, or specifically making changes - to the subsystems they implement, or are running a Python core buildbot - test slave; see SUBPROJECTS below) - -When using the Debug setting, the output files have a _d added to -their name: python34_d.dll, python_d.exe, parser_d.pyd, and so on. - -SUBPROJECTS ------------ -These subprojects should build out of the box. Subprojects other than the -main ones (pythoncore, python, pythonw) generally build a DLL (renamed to -.pyd) from a specific module so that users don't have to load the code -supporting that module unless they import the module. - -pythoncore - .dll and .lib -python - .exe -pythonw - pythonw.exe, a variant of python.exe that doesn't pop up a DOS box -_socket - socketmodule.c -_testcapi - tests of the Python C API, run via Lib/test/test_capi.py, and - implemented by module Modules/_testcapimodule.c -pyexpat - Python wrapper for accelerated XML parsing, which incorporates stable - code from the Expat project: http://sourceforge.net/projects/expat/ -select - selectmodule.c -unicodedata - large tables of Unicode data -winsound - play sounds (typically .wav files) under Windows - -The following subprojects will generally NOT build out of the box. They -wrap code Python doesn't control, and you'll need to download the base -packages first and unpack them into siblings of PC's parent -directory; for example, if this directory is ....\dist\trunk\PC\VS7.1, -unpack into new subdirectories of dist\. - -_tkinter - Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. - - Get source - ---------- - In the dist directory, run - svn export http://svn.python.org/projects/external/tcl8.4.12 - svn export http://svn.python.org/projects/external/tk8.4.12 - svn export http://svn.python.org/projects/external/tix-8.4.0 - - Build Tcl first (done here w/ MSVC 7.1 on Windows XP) - --------------- - Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003 - -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt" - to get a shell window with the correct environment settings - cd dist\tcl8.4.12\win - nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - Optional: run tests, via - nmake -f makefile.vc test - - On WinXP Pro, wholly up to date as of 30-Aug-2004: - all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0 - Sourced 129 Test Files. - - Build Tk - -------- - cd dist\tk8.4.12\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - XXX Our installer copies a lot of stuff out of the Tcl/Tk install - XXX directory. Is all of that really needed for Python use of Tcl/Tk? - - Optional: run tests, via - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test - - On WinXP Pro, wholly up to date as of 30-Aug-2004: - all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13 - Sourced 91 Test Files. - Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test - - Built Tix - --------- - cd dist\tix-8.4.0\win - nmake -f python.mak - nmake -f python.mak install - -bz2 - Python wrapper for the libbz2 compression library. Homepage - http://sources.redhat.com/bzip2/ - Download the source from the python.org copy into the dist - directory: - - svn export http://svn.python.org/projects/external/bzip2-1.0.3 - - A custom pre-link step in the bz2 project settings should manage to - build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is - linked in VS7.1\. - However, the bz2 project is not smart enough to remove anything under - bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib - you need to clean up bzip2-1.0.3\ by hand. - - The build step shouldn't yield any warnings or errors, and should end - by displaying 6 blocks each terminated with - FC: no differences encountered - - All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python - project links in. - -_sqlite3 - Python wrapper for SQLite library. - - Get the source code through - - svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 - - To use the extension module in a Python build tree, copy sqlite3.dll into - the VS7.1 folder. - -_ssl - Python wrapper for the secure sockets library. - - Get the source code through - - svn export http://svn.python.org/projects/external/openssl-0.9.8a - - Alternatively, get the latest version from http://www.openssl.org. - You can (theoretically) use any version of OpenSSL you like - the - build process will automatically select the latest version. - - You must also install ActivePerl from - http://www.activestate.com/Products/ActivePerl/ - as this is used by the OpenSSL build process. Complain to them . - - The MSVC project simply invokes build_ssl.py to perform - the build. This Python script locates and builds your OpenSSL - installation, then invokes a simple makefile to build the final .pyd. - - build_ssl.py attempts to catch the most common errors (such as not - being able to find OpenSSL sources, or not being able to find a Perl - that works with OpenSSL) and give a reasonable error message. - If you have a problem that doesn't seem to be handled correctly - (eg, you know you have ActivePerl but we can't find it), please take - a peek at build_ssl.py and suggest patches. Note that build_ssl.py - should be able to be run directly from the command-line. - - build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do - this by hand. - -Building for Itanium --------------------- - -The project files support a ReleaseItanium configuration which creates -Win64/Itanium binaries. For this to work, you need to install the Platform -SDK, in particular the 64-bit support. This includes an Itanium compiler -(future releases of the SDK likely include an AMD64 compiler as well). -In addition, you need the Visual Studio plugin for external C compilers, -from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to -locate the proper target compiler, and convert compiler options -accordingly. The project files require atleast version 0.9. - -Building for AMD64 ------------------- - -The build process for the ReleaseAMD64 configuration is very similar -to the Itanium configuration; make sure you use the latest version of -vsextcomp. - -Building Python Using the free MS Toolkit Compiler --------------------------------------------------- - -The build process for Visual C++ can be used almost unchanged with the free MS -Toolkit Compiler. This provides a way of building Python using freely -available software. - -Note that Microsoft have withdrawn the free MS Toolkit Compiler, so this can -no longer be considered a supported option. The instructions are still -correct, but you need to already have a copy of the compiler in order to use -them. Microsoft now supply Visual C++ 2008 Express Edition for free, but this -is NOT compatible with Visual C++ 7.1 (it uses a different C runtime), and so -cannot be used to build a version of Python compatible with the standard -python.org build. If you are interested in using Visual C++ 2008 Express -Edition, however, you should look at the PCBuild directory. - -Requirements - - To build Python, the following tools are required: - - * The Visual C++ Toolkit Compiler - no longer available for download - see above - * A recent Platform SDK - from http://www.microsoft.com/downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a - * The .NET 1.1 SDK - from http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d - - [Does anyone have better URLs for the last 2 of these?] - - The toolkit compiler is needed as it is an optimising compiler (the - compiler supplied with the .NET SDK is a non-optimising version). The - platform SDK is needed to provide the Windows header files and libraries - (the Windows 2003 Server SP1 edition, typical install, is known to work - - other configurations or versions are probably fine as well). The .NET 1.1 - SDK is needed because it contains a version of msvcrt.dll which links to - the msvcr71.dll CRT. Note that the .NET 2.0 SDK is NOT acceptable, as it - references msvcr80.dll. - - All of the above items should be installed as normal. - - If you intend to build the openssl (needed for the _ssl extension) you - will need the C runtime sources installed as part of the platform SDK. - - In addition, you will need Nant, available from - http://nant.sourceforge.net. The 0.85 release candidate 3 version is known - to work. This is the latest released version at the time of writing. Later - "nightly build" versions are known NOT to work - it is not clear at - present whether future released versions will work. - -Setting up the environment - - Start a platform SDK "build environment window" from the start menu. The - "Windows XP 32-bit retail" version is known to work. - - Add the following directories to your PATH: - * The toolkit compiler directory - * The SDK "Win64" binaries directory - * The Nant directory - Add to your INCLUDE environment variable: - * The toolkit compiler INCLUDE directory - Add to your LIB environment variable: - * The toolkit compiler LIB directory - * The .NET SDK Visual Studio 2003 VC7\lib directory - - The following commands should set things up as you need them: - - rem Set these values according to where you installed the software - set TOOLKIT=C:\Program Files\Microsoft Visual C++ Toolkit 2003 - set SDK=C:\Program Files\Microsoft Platform SDK - set NET=C:\Program Files\Microsoft Visual Studio .NET 2003 - set NANT=C:\Utils\Nant - - set PATH=%TOOLKIT%\bin;%PATH%;%SDK%\Bin\win64;%NANT%\bin - set INCLUDE=%TOOLKIT%\include;%INCLUDE% - set LIB=%TOOLKIT%\lib;%NET%\VC7\lib;%LIB% - - The "win64" directory from the SDK is added to supply executables such as - "cvtres" and "lib", which are not available elsewhere. The versions in the - "win64" directory are 32-bit programs, so they are fine to use here. - - That's it. To build Python (the core only, no binary extensions which - depend on external libraries) you just need to issue the command - - nant -buildfile:python.build all - - from within the VS7.1 directory. - -Extension modules - - To build those extension modules which require external libraries - (_tkinter, bz2, _sqlite3, _ssl) you can follow the instructions - for the Visual Studio build above, with a few minor modifications. These - instructions have only been tested using the sources in the Python - subversion repository - building from original sources should work, but - has not been tested. - - For each extension module you wish to build, you should remove the - associated include line from the excludeprojects section of pc.build. - - The changes required are: - - _tkinter - The tix makefile (tix-8.4.0\win\makefile.vc) must be modified to - remove references to TOOLS32. The relevant lines should be changed to - read: - cc32 = cl.exe - link32 = link.exe - include32 = - The remainder of the build instructions will work as given. - - bz2 - No changes are needed - - _sqlite3 - No changes are needed. However, in order for the tests to succeed, a - copy of sqlite3.dll must be downloaded, and placed alongside - python.exe. - - _ssl - The documented build process works as written. However, it needs a - copy of the file setargv.obj, which is not supplied in the platform - SDK. However, the sources are available (in the crt source code). To - build setargv.obj, proceed as follows: - - Copy setargv.c, cruntime.h and internal.h from %SDK%\src\crt to a - temporary directory. - Compile using "cl /c /I. /MD /D_CRTBLD setargv.c" - Copy the resulting setargv.obj to somewhere on your LIB environment - (%SDK%\lib is a reasonable place). - - With setargv.obj in place, the standard build process should work - fine. - -YOUR OWN EXTENSION DLLs ------------------------ -If you want to create your own extension module DLL, there's an example -with easy-to-follow instructions in ../PC/example/; read the file -readme.txt there first. diff --git a/PC/VS7.1/rmpyc.py b/PC/VS7.1/rmpyc.py deleted file mode 100644 --- a/PC/VS7.1/rmpyc.py +++ /dev/null @@ -1,25 +0,0 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../Lib") -print npyc, ".pyc deleted,", npyo, ".pyo deleted" diff --git a/PC/VS7.1/rt.bat b/PC/VS7.1/rt.bat deleted file mode 100755 --- a/PC/VS7.1/rt.bat +++ /dev/null @@ -1,52 +0,0 @@ - at echo off -rem Run Tests. Run the regression test suite. -rem Usage: rt [-d] [-O] [-q] regrtest_args -rem -d Run Debug build (python_d.exe). Else release build. -rem -O Run python.exe or python_d.exe (see -d) with -O. -rem -q "quick" -- normally the tests are run twice, the first time -rem after deleting all the .py[co] files reachable from Lib/. -rem -q runs the tests just once, and without deleting .py[co] files. -rem All leading instances of these switches are shifted off, and -rem whatever remains is passed to regrtest.py. For example, -rem rt -O -d -x test_thread -rem runs -rem python_d -O ../../lib/test/regrtest.py -x test_thread -rem twice, and -rem rt -q -g test_binascii -rem runs -rem python_d ../../lib/test/regrtest.py -g test_binascii -rem to generate the expected-output file for binascii quickly. -rem -rem Confusing: if you want to pass a comma-separated list, like -rem -u network,largefile -rem then you have to quote it on the rt line, like -rem rt -u "network,largefile" - -setlocal - -set exe=python -set qmode= -set dashO= -PATH %PATH%;%~dp0..\..\..\tcltk\bin - -:CheckOpts -if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts -if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts -if "%1"=="-d" (set exe=python_d) & shift & goto CheckOpts - -set cmd=%exe% %dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 -if defined qmode goto Qmode - -echo Deleting .pyc/.pyo files ... -%exe% rmpyc.py - -echo on -%cmd% - at echo off - -echo About to run again without deleting .pyc/.pyo first: -pause - -:Qmode -echo on -%cmd% diff --git a/PC/VS7.1/select.vcproj b/PC/VS7.1/select.vcproj deleted file mode 100644 --- a/PC/VS7.1/select.vcproj +++ /dev/null @@ -1,258 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/unicodedata.vcproj b/PC/VS7.1/unicodedata.vcproj deleted file mode 100644 --- a/PC/VS7.1/unicodedata.vcproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/winsound.vcproj b/PC/VS7.1/winsound.vcproj deleted file mode 100644 --- a/PC/VS7.1/winsound.vcproj +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_ctypes.vcproj b/PC/VS8.0/_ctypes.vcproj deleted file mode 100644 --- a/PC/VS8.0/_ctypes.vcproj +++ /dev/null @@ -1,705 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_ctypes_test.vcproj b/PC/VS8.0/_ctypes_test.vcproj deleted file mode 100644 --- a/PC/VS8.0/_ctypes_test.vcproj +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_elementtree.vcproj b/PC/VS8.0/_elementtree.vcproj deleted file mode 100644 --- a/PC/VS8.0/_elementtree.vcproj +++ /dev/null @@ -1,613 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_hashlib.vcproj b/PC/VS8.0/_hashlib.vcproj deleted file mode 100644 --- a/PC/VS8.0/_hashlib.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_msi.vcproj b/PC/VS8.0/_msi.vcproj deleted file mode 100644 --- a/PC/VS8.0/_msi.vcproj +++ /dev/null @@ -1,529 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_multiprocessing.vcproj b/PC/VS8.0/_multiprocessing.vcproj deleted file mode 100644 --- a/PC/VS8.0/_multiprocessing.vcproj +++ /dev/null @@ -1,545 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_socket.vcproj b/PC/VS8.0/_socket.vcproj deleted file mode 100644 --- a/PC/VS8.0/_socket.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_sqlite3.vcproj b/PC/VS8.0/_sqlite3.vcproj deleted file mode 100644 --- a/PC/VS8.0/_sqlite3.vcproj +++ /dev/null @@ -1,613 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_ssl.vcproj b/PC/VS8.0/_ssl.vcproj deleted file mode 100644 --- a/PC/VS8.0/_ssl.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_testcapi.vcproj b/PC/VS8.0/_testcapi.vcproj deleted file mode 100644 --- a/PC/VS8.0/_testcapi.vcproj +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_tkinter.vcproj b/PC/VS8.0/_tkinter.vcproj deleted file mode 100644 --- a/PC/VS8.0/_tkinter.vcproj +++ /dev/null @@ -1,541 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/bdist_wininst.vcproj b/PC/VS8.0/bdist_wininst.vcproj deleted file mode 100644 --- a/PC/VS8.0/bdist_wininst.vcproj +++ /dev/null @@ -1,270 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/build.bat b/PC/VS8.0/build.bat deleted file mode 100644 --- a/PC/VS8.0/build.bat +++ /dev/null @@ -1,17 +0,0 @@ - at echo off -rem A batch program to build or rebuild a particular configuration. -rem just for convenience. - -setlocal -set platf=Win32 -set conf=Release -set build=/build - -:CheckOpts -if "%1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts -if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts -if "%1"=="-r" (set build=/rebuild) & shift & goto CheckOpts - -set cmd=devenv pcbuild.sln %build% "%conf%|%platf%" -echo %cmd% -%cmd% diff --git a/PC/VS8.0/build_env.bat b/PC/VS8.0/build_env.bat deleted file mode 100644 --- a/PC/VS8.0/build_env.bat +++ /dev/null @@ -1,1 +0,0 @@ -@%comspec% /k env.bat %* diff --git a/PC/VS8.0/build_pgo.bat b/PC/VS8.0/build_pgo.bat deleted file mode 100644 --- a/PC/VS8.0/build_pgo.bat +++ /dev/null @@ -1,41 +0,0 @@ - at echo off -rem A batch program to build PGO (Profile guided optimization) by first -rem building instrumented binaries, then running the testsuite, and -rem finally building the optimized code. -rem Note, after the first instrumented run, one can just keep on -rem building the PGUpdate configuration while developing. - -setlocal -set platf=Win32 - -rem use the performance testsuite. This is quick and simple -set job1=..\..\tools\pybench\pybench.py -n 1 -C 1 --with-gc -set path1=..\..\tools\pybench - -rem or the whole testsuite for more thorough testing -set job2=..\..\lib\test\regrtest.py -set path2=..\..\lib - -set job=%job1% -set clrpath=%path1% - -:CheckOpts -if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts -if "%1"=="-2" (set job=%job2%) & (set clrpath=%path2%) & shift & goto CheckOpts - -set PGI=%platf%-pgi -set PGO=%platf%-pgo - - at echo on -rem build the instrumented version -call build -p %platf% -c PGInstrument - -rem remove .pyc files, .pgc files and execute the job -%PGI%\python.exe rmpyc.py %clrpath% -del %PGI%\*.pgc -%PGI%\python.exe %job% - -rem finally build the optimized version -if exist %PGO% del /s /q %PGO% -call build -p %platf% -c PGUpdate - diff --git a/PC/VS8.0/build_ssl.bat b/PC/VS8.0/build_ssl.bat deleted file mode 100644 --- a/PC/VS8.0/build_ssl.bat +++ /dev/null @@ -1,12 +0,0 @@ - at echo off -if not defined HOST_PYTHON ( - if %1 EQU Debug ( - set HOST_PYTHON=python_d.exe - if not exist python34_d.dll exit 1 - ) ELSE ( - set HOST_PYTHON=python.exe - if not exist python34.dll exit 1 - ) -) -%HOST_PYTHON% build_ssl.py %1 %2 %3 - diff --git a/PC/VS8.0/build_ssl.py b/PC/VS8.0/build_ssl.py deleted file mode 100644 --- a/PC/VS8.0/build_ssl.py +++ /dev/null @@ -1,277 +0,0 @@ -# Script for building the _ssl and _hashlib modules for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for the actual _ssl.pyd and _hashlib.pyd DLLs. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PC/VS8.0 directory. -# -# it should configure and build SSL, then build the _ssl and _hashlib -# Python extensions without intervention. - -# Modified by Christian Heimes -# Now this script supports pre-generated makefiles and assembly files. -# Developers don't need an installation of Perl anymore to build Python. A svn -# checkout from our svn repository is enough. -# -# In Order to create the files in the case of an update you still need Perl. -# Run build_ssl in this order: -# python.exe build_ssl.py Release x64 -# python.exe build_ssl.py Release Win32 - -import os, sys, re, shutil - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen('"%s" -e "use Win32;"' % perl) - fh.read() - rc = fh.close() - if rc: - continue - return perl - print("Can not find a suitable PERL:") - if perls: - print(" the following perl interpreters were found:") - for p in perls: - print(" ", p) - print(" None of these versions appear suitable for building OpenSSL") - else: - print(" NO perl interpreters were found on this machine at all!") - print(" Please install ActivePerl and ensure it appears on your path") - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - # note: do not abspath s; the build will fail if any - # higher up directory name has spaces in it. - fnames = os.listdir(s) - except OSError: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print("Found an SSL directory at '%s'" % (best_name,)) - else: - print("Could not find an SSL directory in '%s'" % (sources,)) - sys.stdout.flush() - return best_name - -def create_makefile64(makefile, m32): - """Create and fix makefile for 64bit - - Replace 32 with 64bit directories - """ - if not os.path.isfile(m32): - return - with open(m32) as fin: - with open(makefile, 'w') as fout: - for line in fin: - line = line.replace("=tmp32", "=tmp64") - line = line.replace("=out32", "=out64") - line = line.replace("=inc32", "=inc64") - # force 64 bit machine - line = line.replace("MKLIB=lib", "MKLIB=lib /MACHINE:X64") - line = line.replace("LFLAGS=", "LFLAGS=/MACHINE:X64 ") - # don't link against the lib on 64bit systems - line = line.replace("bufferoverflowu.lib", "") - fout.write(line) - os.unlink(m32) - -def fix_makefile(makefile): - """Fix some stuff in all makefiles - """ - if not os.path.isfile(makefile): - return - with open(makefile) as fin: - lines = fin.readlines() - with open(makefile, 'w') as fout: - for line in lines: - if line.startswith("PERL="): - continue - if line.startswith("CP="): - line = "CP=copy\n" - if line.startswith("MKDIR="): - line = "MKDIR=mkdir\n" - if line.startswith("CFLAG="): - line = line.strip() - for algo in ("RC5", "MDC2", "IDEA"): - noalgo = " -DOPENSSL_NO_%s" % algo - if noalgo not in line: - line = line + noalgo - line = line + '\n' - fout.write(line) - -def run_configure(configure, do_script): - print("perl Configure "+configure+" no-idea no-mdc2") - os.system("perl Configure "+configure+" no-idea no-mdc2") - print(do_script) - os.system(do_script) - -def cmp(f1, f2): - bufsize = 1024 * 8 - with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True - -def copy(src, dst): - if os.path.isfile(dst) and cmp(src, dst): - return - shutil.copy(src, dst) - -def main(): - build_all = "-a" in sys.argv - if sys.argv[1] == "Release": - debug = False - elif sys.argv[1] == "Debug": - debug = True - else: - raise ValueError(str(sys.argv)) - - if sys.argv[2] == "Win32": - arch = "x86" - configure = "VC-WIN32" - do_script = "ms\\do_nasm" - makefile="ms\\nt.mak" - m32 = makefile - dirsuffix = "32" - elif sys.argv[2] == "x64": - arch="amd64" - configure = "VC-WIN64A" - do_script = "ms\\do_win64a" - makefile = "ms\\nt64.mak" - m32 = makefile.replace('64', '') - dirsuffix = "64" - #os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" - else: - raise ValueError(str(sys.argv)) - - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl: - print("Found a working perl at '%s'" % (perl,)) - else: - print("No Perl installation was found. Existing Makefiles are used.") - sys.stdout.flush() - # Look for SSL 3 levels up from PC/VS8.0 - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("..\\..\\..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # rebuild makefile when we do the role over from 32 to 64 build - if arch == "amd64" and os.path.isfile(m32) and not os.path.isfile(makefile): - os.unlink(m32) - - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - if perl is None: - print("Perl is required to build the makefiles!") - sys.exit(1) - - print("Creating the makefiles...") - sys.stdout.flush() - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.dirname(perl) + \ - os.pathsep + \ - os.environ["PATH"] - run_configure(configure, do_script) - if debug: - print("OpenSSL debug builds aren't supported.") - #if arch=="x86" and debug: - # # the do_masm script in openssl doesn't generate a debug - # # build makefile so we generate it here: - # os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile) - - if arch == "amd64": - create_makefile64(makefile, m32) - fix_makefile(makefile) - copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) - copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) - - # If the assembler files don't exist in tmpXX, copy them there - if perl is None and os.path.exists("asm"+dirsuffix): - if not os.path.exists("tmp"+dirsuffix): - os.mkdir("tmp"+dirsuffix) - for f in os.listdir("asm"+dirsuffix): - if not f.endswith(".asm"): continue - if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue - shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix) - - # Now run make. - if arch == "amd64": - rc = os.system("ml64 -c -Foms\\uptable.obj ms\\uptable.asm") - if rc: - print("ml64 assembler has failed.") - sys.exit(rc) - - copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h") - copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h") - - #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) - makeCommand = "nmake /nologo -f \"%s\"" % makefile - print("Executing ssl makefiles:", makeCommand) - sys.stdout.flush() - rc = os.system(makeCommand) - if rc: - print("Executing "+makefile+" failed") - print(rc) - sys.exit(rc) - finally: - os.chdir(old_cd) - sys.exit(rc) - -if __name__=='__main__': - main() diff --git a/PC/VS8.0/build_tkinter.py b/PC/VS8.0/build_tkinter.py deleted file mode 100644 --- a/PC/VS8.0/build_tkinter.py +++ /dev/null @@ -1,85 +0,0 @@ -"""Script to compile the dependencies of _tkinter - -Copyright (c) 2007 by Christian Heimes - -Licensed to PSF under a Contributor Agreement. -""" - -import os -import sys - -here = os.path.abspath(os.path.dirname(__file__)) -par = os.path.pardir - -if 1: - TCL = "tcl8.4.16" - TK = "tk8.4.16" - TIX = "tix-8.4.0" -else: - TCL = "tcl8.5b3" - TK = "tcl8.5b3" - TIX = "Tix8.4.2" - -ROOT = os.path.abspath(os.path.join(here, par, par, par)) -# Windows 2000 compatibility: WINVER 0x0500 -# http://msdn2.microsoft.com/en-us/library/aa383745.aspx -NMAKE = "nmake /nologo /f %s COMPILERFLAGS=-DWINVER=0x0500 %s %s" - -def nmake(makefile, command="", **kw): - defines = ' '.join(k+'='+v for k, v in kw.items()) - cmd = NMAKE % (makefile, defines, command) - print("\n\n"+cmd+"\n") - if os.system(cmd) != 0: - raise RuntimeError(cmd) - -def build(platform, clean): - if platform == "Win32": - dest = os.path.join(ROOT, "tcltk") - machine = "X86" - elif platform == "x64": - dest = os.path.join(ROOT, "tcltk64") - machine = "X64" - else: - raise ValueError(platform) - - # TCL - tcldir = os.path.join(ROOT, TCL) - if 1: - os.chdir(os.path.join(tcldir, "win")) - if clean: - nmake("makefile.vc", "clean") - nmake("makefile.vc") - nmake("makefile.vc", "install", INSTALLDIR=dest) - - # TK - if 1: - os.chdir(os.path.join(ROOT, TK, "win")) - if clean: - nmake("makefile.vc", "clean", TCLDIR=tcldir) - nmake("makefile.vc", TCLDIR=tcldir) - nmake("makefile.vc", "install", TCLDIR=tcldir, INSTALLDIR=dest) - - # TIX - if 1: - # python9.mak is available at http://svn.python.org - os.chdir(os.path.join(ROOT, TIX, "win")) - if clean: - nmake("python9.mak", "clean") - nmake("python9.mak", MACHINE=machine) - nmake("python9.mak", "install") - -def main(): - if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "x64"): - print("%s Win32|x64" % sys.argv[0]) - sys.exit(1) - - if "-c" in sys.argv: - clean = True - else: - clean = False - - build(sys.argv[1], clean) - - -if __name__ == '__main__': - main() diff --git a/PC/VS8.0/bz2.vcproj b/PC/VS8.0/bz2.vcproj deleted file mode 100644 --- a/PC/VS8.0/bz2.vcproj +++ /dev/null @@ -1,581 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/debug.vsprops b/PC/VS8.0/debug.vsprops deleted file mode 100644 --- a/PC/VS8.0/debug.vsprops +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/PC/VS8.0/env.bat b/PC/VS8.0/env.bat deleted file mode 100644 --- a/PC/VS8.0/env.bat +++ /dev/null @@ -1,5 +0,0 @@ - at echo off -set VS8=%ProgramFiles%\Microsoft Visual Studio 8 -echo Build environments: x86, ia64, amd64, x86_amd64, x86_ia64 -echo. -call "%VS8%\VC\vcvarsall.bat" %1 diff --git a/PC/VS8.0/field3.py b/PC/VS8.0/field3.py deleted file mode 100644 --- a/PC/VS8.0/field3.py +++ /dev/null @@ -1,35 +0,0 @@ -# An absurd workaround for the lack of arithmetic in MS's resource compiler. -# After building Python, run this, then paste the output into the appropriate -# part of PC\python_nt.rc. -# Example output: -# -# * For 2.3a0, -# * PY_MICRO_VERSION = 0 -# * PY_RELEASE_LEVEL = 'alpha' = 0xA -# * PY_RELEASE_SERIAL = 1 -# * -# * and 0*1000 + 10*10 + 1 = 101. -# */ -# #define FIELD3 101 - -import sys - -major, minor, micro, level, serial = sys.version_info -levelnum = {'alpha': 0xA, - 'beta': 0xB, - 'candidate': 0xC, - 'final': 0xF, - }[level] -string = sys.version.split()[0] # like '2.3a0' - -print(" * For %s," % string) -print(" * PY_MICRO_VERSION = %d" % micro) -print(" * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum))) -print(" * PY_RELEASE_SERIAL = %d" % serial) -print(" *") - -field3 = micro * 1000 + levelnum * 10 + serial - -print(" * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3)) -print(" */") -print("#define FIELD3", field3) diff --git a/PC/VS8.0/idle.bat b/PC/VS8.0/idle.bat deleted file mode 100644 --- a/PC/VS8.0/idle.bat +++ /dev/null @@ -1,15 +0,0 @@ - at echo off -rem start idle -rem Usage: idle [-d] -rem -d Run Debug build (python_d.exe). Else release build. - -setlocal -set exe=python -PATH %PATH%;..\..\..\tcltk\bin - -if "%1"=="-d" (set exe=python_d) & shift - -set cmd=%exe% ../../Lib/idlelib/idle.py %1 %2 %3 %4 %5 %6 %7 %8 %9 - -echo on -%cmd% diff --git a/PC/VS8.0/kill_python.c b/PC/VS8.0/kill_python.c deleted file mode 100644 --- a/PC/VS8.0/kill_python.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Helper program for killing lingering python[_d].exe processes before - * building, thus attempting to avoid build failures due to files being - * locked. - */ - -#include -#include -#include -#include - -#pragma comment(lib, "psapi") - -#ifdef _DEBUG -#define PYTHON_EXE (L"python_d.exe") -#define PYTHON_EXE_LEN (12) -#define KILL_PYTHON_EXE (L"kill_python_d.exe") -#define KILL_PYTHON_EXE_LEN (17) -#else -#define PYTHON_EXE (L"python.exe") -#define PYTHON_EXE_LEN (10) -#define KILL_PYTHON_EXE (L"kill_python.exe") -#define KILL_PYTHON_EXE_LEN (15) -#endif - -int -main(int argc, char **argv) -{ - HANDLE hp, hsp, hsm; /* process, snapshot processes, snapshot modules */ - DWORD dac, our_pid; - size_t len; - wchar_t path[MAX_PATH+1]; - - MODULEENTRY32W me; - PROCESSENTRY32W pe; - - me.dwSize = sizeof(MODULEENTRY32W); - pe.dwSize = sizeof(PROCESSENTRY32W); - - memset(path, 0, MAX_PATH+1); - - our_pid = GetCurrentProcessId(); - - hsm = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, our_pid); - if (hsm == INVALID_HANDLE_VALUE) { - printf("CreateToolhelp32Snapshot[1] failed: %d\n", GetLastError()); - return 1; - } - - if (!Module32FirstW(hsm, &me)) { - printf("Module32FirstW[1] failed: %d\n", GetLastError()); - CloseHandle(hsm); - return 1; - } - - /* - * Enumerate over the modules for the current process in order to find - * kill_process[_d].exe, then take a note of the directory it lives in. - */ - do { - if (_wcsnicmp(me.szModule, KILL_PYTHON_EXE, KILL_PYTHON_EXE_LEN)) - continue; - - len = wcsnlen_s(me.szExePath, MAX_PATH) - KILL_PYTHON_EXE_LEN; - wcsncpy_s(path, MAX_PATH+1, me.szExePath, len); - - break; - - } while (Module32NextW(hsm, &me)); - - CloseHandle(hsm); - - if (path == NULL) { - printf("failed to discern directory of running process\n"); - return 1; - } - - /* - * Take a snapshot of system processes. Enumerate over the snapshot, - * looking for python processes. When we find one, verify it lives - * in the same directory we live in. If it does, kill it. If we're - * unable to kill it, treat this as a fatal error and return 1. - * - * The rationale behind this is that we're called at the start of the - * build process on the basis that we'll take care of killing any - * running instances, such that the build won't encounter permission - * denied errors during linking. If we can't kill one of the processes, - * we can't provide this assurance, and the build shouldn't start. - */ - - hsp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (hsp == INVALID_HANDLE_VALUE) { - printf("CreateToolhelp32Snapshot[2] failed: %d\n", GetLastError()); - return 1; - } - - if (!Process32FirstW(hsp, &pe)) { - printf("Process32FirstW failed: %d\n", GetLastError()); - CloseHandle(hsp); - return 1; - } - - dac = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE; - do { - - /* - * XXX TODO: if we really wanted to be fancy, we could check the - * modules for all processes (not just the python[_d].exe ones) - * and see if any of our DLLs are loaded (i.e. python34[_d].dll), - * as that would also inhibit our ability to rebuild the solution. - * Not worth loosing sleep over though; for now, a simple check - * for just the python executable should be sufficient. - */ - - if (_wcsnicmp(pe.szExeFile, PYTHON_EXE, PYTHON_EXE_LEN)) - /* This isn't a python process. */ - continue; - - /* It's a python process, so figure out which directory it's in... */ - hsm = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pe.th32ProcessID); - if (hsm == INVALID_HANDLE_VALUE) - /* - * If our module snapshot fails (which will happen if we don't own - * the process), just ignore it and continue. (It seems different - * versions of Windows return different values for GetLastError() - * in this situation; it's easier to just ignore it and move on vs. - * stopping the build for what could be a false positive.) - */ - continue; - - if (!Module32FirstW(hsm, &me)) { - printf("Module32FirstW[2] failed: %d\n", GetLastError()); - CloseHandle(hsp); - CloseHandle(hsm); - return 1; - } - - do { - if (_wcsnicmp(me.szModule, PYTHON_EXE, PYTHON_EXE_LEN)) - /* Wrong module, we're looking for python[_d].exe... */ - continue; - - if (_wcsnicmp(path, me.szExePath, len)) - /* Process doesn't live in our directory. */ - break; - - /* Python process residing in the right directory, kill it! */ - hp = OpenProcess(dac, FALSE, pe.th32ProcessID); - if (!hp) { - printf("OpenProcess failed: %d\n", GetLastError()); - CloseHandle(hsp); - CloseHandle(hsm); - return 1; - } - - if (!TerminateProcess(hp, 1)) { - printf("TerminateProcess failed: %d\n", GetLastError()); - CloseHandle(hsp); - CloseHandle(hsm); - CloseHandle(hp); - return 1; - } - - CloseHandle(hp); - break; - - } while (Module32NextW(hsm, &me)); - - CloseHandle(hsm); - - } while (Process32NextW(hsp, &pe)); - - CloseHandle(hsp); - - return 0; -} - -/* vi: set ts=8 sw=4 sts=4 expandtab */ diff --git a/PC/VS8.0/kill_python.vcproj b/PC/VS8.0/kill_python.vcproj deleted file mode 100644 --- a/PC/VS8.0/kill_python.vcproj +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/make_buildinfo.c b/PC/VS8.0/make_buildinfo.c deleted file mode 100644 --- a/PC/VS8.0/make_buildinfo.c +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include - -#define CMD_SIZE 500 - -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PCBuild\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\..\\Modules\\getbuildinfo.c instead. - - Currently, subwcrev.exe is found from the registry entries - of TortoiseSVN. - - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. - - However, if a second argument is provided, this will be used - as a temporary directory where any getbuildinfo2.c and - getbuildinfo.o files are put. This is useful if multiple - configurations are being built in parallel, to avoid them - trampling each other's files. - -*/ - -int make_buildinfo2(const char *tmppath) -{ - struct _stat st; - HKEY hTortoise; - char command[CMD_SIZE+1]; - DWORD type, size; - if (_stat(".svn", &st) < 0) - return 0; - /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ - if (_stat("no_subwcrev", &st) == 0) - return 0; - if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && - RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) - /* Tortoise not installed */ - return 0; - command[0] = '"'; /* quote the path to the executable */ - size = sizeof(command) - 1; - if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || - type != REG_SZ) - /* Registry corrupted */ - return 0; - strcat_s(command, CMD_SIZE, "bin\\subwcrev.exe"); - if (_stat(command+1, &st) < 0) - /* subwcrev.exe not part of the release */ - return 0; - strcat_s(command, CMD_SIZE, "\" ..\\.. ..\\..\\Modules\\getbuildinfo.c "); - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo2.c"); - puts(command); fflush(stdout); - if (system(command) < 0) - return 0; - return 1; -} - -int main(int argc, char*argv[]) -{ - char command[CMD_SIZE] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - char tmppath[CMD_SIZE] = ""; - int do_unlink, result; - char *tmpdir = NULL; - if (argc <= 2 || argc > 3) { - fprintf(stderr, "make_buildinfo $(ConfigurationName) [tmpdir]\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat_s(command, CMD_SIZE, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat_s(command, CMD_SIZE, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat_s(command, CMD_SIZE, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat_s(command, CMD_SIZE, "-MD "); - strcat_s(command, CMD_SIZE, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } - if (argc > 2) { - tmpdir = argv[2]; - strcat_s(tmppath, _countof(tmppath), tmpdir); - strcat_s(tmppath, _countof(tmppath), "\\"); - } - - if ((do_unlink = make_buildinfo2(tmppath))) { - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo2.c -DSUBWCREV "); - } else - strcat_s(command, CMD_SIZE, "..\\..\\Modules\\getbuildinfo.c"); - strcat_s(command, CMD_SIZE, " -Fo"); - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo.o -I..\\..\\Include -I..\\..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) { - command[0] = '\0'; - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo2.c"); - _unlink(command); - } - if (result < 0) - return EXIT_FAILURE; - return 0; -} diff --git a/PC/VS8.0/make_buildinfo.vcproj b/PC/VS8.0/make_buildinfo.vcproj deleted file mode 100644 --- a/PC/VS8.0/make_buildinfo.vcproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/make_versioninfo.vcproj b/PC/VS8.0/make_versioninfo.vcproj deleted file mode 100644 --- a/PC/VS8.0/make_versioninfo.vcproj +++ /dev/null @@ -1,324 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pcbuild.sln b/PC/VS8.0/pcbuild.sln deleted file mode 100644 --- a/PC/VS8.0/pcbuild.sln +++ /dev/null @@ -1,555 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} = {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_versioninfo", "make_versioninfo.vcproj", "{F0E0541E-F17D-430B-97C4-93ADF0DD284E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" - ProjectSection(ProjectDependencies) = postProject - {F0E0541E-F17D-430B-97C4-93ADF0DD284E} = {F0E0541E-F17D-430B-97C4-93ADF0DD284E} - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buildinfo.vcproj", "{C73F0EC1-358B-4177-940F-0846AC8B04CD}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{553EC33E-9816-4996-A660-5D6186A0B0B3}" - ProjectSection(SolutionItems) = preProject - ..\..\Modules\getbuildinfo.c = ..\..\Modules\getbuildinfo.c - readme.txt = readme.txt - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winsound", "winsound.vcproj", "{28B5D777-DDF2-4B6B-B34F-31D938813856}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes", "_ctypes.vcproj", "{0E9791DB-593A-465F-98BC-681011311618}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "_ctypes_test.vcproj", "{9EC7190A-249F-4180-A900-548FDCF3055F}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_elementtree", "_elementtree.vcproj", "{17E1E049-C309-4D79-843F-AE483C264AEA}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_msi", "_msi.vcproj", "{31FFC478-7B4A-43E8-9954-8D03E2187E9C}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_socket", "_socket.vcproj", "{86937F53-C189-40EF-8CE8-8759D8E7D480}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{13CECB97-4119-4316-9D42-8534019A5A44}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {A1A295E5-463C-437F-81CA-1F32367685DA} = {A1A295E5-463C-437F-81CA-1F32367685DA} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ssl", "_ssl.vcproj", "{C6E20F84-3247-4AD6-B051-B073268F73BA}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - {86937F53-C189-40EF-8CE8-8759D8E7D480} = {86937F53-C189-40EF-8CE8-8759D8E7D480} - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} = {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testcapi", "_testcapi.vcproj", "{6901D91C-6E48-4BB7-9FEC-700C8131DF1D}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_tkinter", "_tkinter.vcproj", "{4946ECAC-2E69-4BF8-A90A-F5136F5094DF}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bz2", "bz2.vcproj", "{73FCD2BD-F133-46B7-8EC1-144CD82A59D5}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select", "select.vcproj", "{18CAE28C-B454-46C1-87A0-493D91D97F03}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicodedata", "unicodedata.vcproj", "{ECC7CEAC-A5E5-458E-BB9E-2413CC847881}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pyexpat", "pyexpat.vcproj", "{D06B6426-4762-44CC-8BAD-D79052507F2F}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bdist_wininst", "bdist_wininst.vcproj", "{EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} = {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}" - ProjectSection(ProjectDependencies) = postProject - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_multiprocessing", "_multiprocessing.vcproj", "{9E48B300-37D1-11DD-8C41-005056C00008}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl", "ssl.vcproj", "{E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kill_python", "kill_python.vcproj", "{6DE10744-E396-40A5-B4E2-1B69AA7C8D31}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - PGInstrument|Win32 = PGInstrument|Win32 - PGInstrument|x64 = PGInstrument|x64 - PGUpdate|Win32 = PGUpdate|Win32 - PGUpdate|x64 = PGUpdate|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.ActiveCfg = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.Build.0 = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.ActiveCfg = Debug|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.Build.0 = Debug|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.ActiveCfg = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.ActiveCfg = Release|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.Build.0 = Release|x64 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.ActiveCfg = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.Build.0 = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.ActiveCfg = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.Build.0 = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|x64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|x64.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|x64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|x64.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.ActiveCfg = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.Build.0 = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.ActiveCfg = Debug|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.Build.0 = Debug|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.ActiveCfg = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.ActiveCfg = Release|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.Build.0 = Release|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.ActiveCfg = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.Build.0 = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.ActiveCfg = Debug|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.Build.0 = Debug|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.ActiveCfg = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.ActiveCfg = Release|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.Build.0 = Release|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.ActiveCfg = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.Build.0 = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.ActiveCfg = Debug|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.Build.0 = Debug|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.ActiveCfg = Release|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.Build.0 = Release|x64 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|x64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|x64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.Build.0 = Release|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|Win32.ActiveCfg = Debug|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|Win32.Build.0 = Debug|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|x64.ActiveCfg = Debug|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|x64.Build.0 = Debug|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|Win32.ActiveCfg = Release|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|Win32.Build.0 = Release|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|x64.ActiveCfg = Release|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|x64.Build.0 = Release|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|Win32.ActiveCfg = Debug|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|Win32.Build.0 = Debug|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|x64.ActiveCfg = Debug|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|x64.Build.0 = Debug|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Release|Win32.ActiveCfg = Release|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Release|Win32.Build.0 = Release|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Release|x64.ActiveCfg = Release|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Release|x64.Build.0 = Release|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|Win32.ActiveCfg = Debug|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|Win32.Build.0 = Debug|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|x64.ActiveCfg = Debug|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|x64.Build.0 = Debug|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|Win32.ActiveCfg = Release|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|Win32.Build.0 = Release|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|x64.ActiveCfg = Release|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|x64.Build.0 = Release|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|Win32.ActiveCfg = Debug|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|Win32.Build.0 = Debug|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|x64.ActiveCfg = Debug|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|x64.Build.0 = Debug|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|Win32.ActiveCfg = Release|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|Win32.Build.0 = Release|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|x64.ActiveCfg = Release|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|x64.Build.0 = Release|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|Win32.ActiveCfg = Debug|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|Win32.Build.0 = Debug|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|x64.ActiveCfg = Debug|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|x64.Build.0 = Debug|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|Win32.ActiveCfg = Release|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|Win32.Build.0 = Release|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|x64.ActiveCfg = Release|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|x64.Build.0 = Release|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|Win32.ActiveCfg = Debug|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|Win32.Build.0 = Debug|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|x64.ActiveCfg = Debug|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|x64.Build.0 = Debug|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|Win32.ActiveCfg = Release|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|Win32.Build.0 = Release|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|x64.ActiveCfg = Release|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|x64.Build.0 = Release|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|Win32.ActiveCfg = Debug|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|Win32.Build.0 = Debug|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|x64.ActiveCfg = Debug|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|x64.Build.0 = Debug|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|Win32.ActiveCfg = Release|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|Win32.Build.0 = Release|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|x64.ActiveCfg = Release|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|x64.Build.0 = Release|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|Win32.ActiveCfg = Debug|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|Win32.Build.0 = Debug|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|x64.ActiveCfg = Debug|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|x64.Build.0 = Debug|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|Win32.ActiveCfg = Release|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|Win32.Build.0 = Release|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|x64.ActiveCfg = Release|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|x64.Build.0 = Release|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|Win32.ActiveCfg = Debug|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|Win32.Build.0 = Debug|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|x64.ActiveCfg = Debug|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|x64.Build.0 = Debug|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|Win32.ActiveCfg = Release|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|Win32.Build.0 = Release|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|x64.ActiveCfg = Release|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|x64.Build.0 = Release|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|Win32.Build.0 = Debug|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|x64.ActiveCfg = Debug|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|x64.Build.0 = Debug|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|Win32.ActiveCfg = Release|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|Win32.Build.0 = Release|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|x64.ActiveCfg = Release|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|x64.Build.0 = Release|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|Win32.ActiveCfg = Debug|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|Win32.Build.0 = Debug|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|x64.ActiveCfg = Debug|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|x64.Build.0 = Debug|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|Win32.ActiveCfg = Release|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|Win32.Build.0 = Release|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|x64.ActiveCfg = Release|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|x64.Build.0 = Release|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|Win32.ActiveCfg = Debug|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|Win32.Build.0 = Debug|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|x64.ActiveCfg = Debug|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|x64.Build.0 = Debug|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|Win32.ActiveCfg = Release|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|Win32.Build.0 = Release|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|x64.ActiveCfg = Release|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|x64.Build.0 = Release|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|Win32.ActiveCfg = Debug|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|Win32.Build.0 = Debug|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|x64.ActiveCfg = Debug|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|x64.Build.0 = Debug|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|Win32.ActiveCfg = Release|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|Win32.Build.0 = Release|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|x64.ActiveCfg = Release|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|x64.Build.0 = Release|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|Win32.ActiveCfg = Debug|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|Win32.Build.0 = Debug|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|x64.ActiveCfg = Debug|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|x64.Build.0 = Debug|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|Win32.ActiveCfg = Release|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|Win32.Build.0 = Release|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|x64.ActiveCfg = Release|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|x64.Build.0 = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Debug|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Debug|x64.ActiveCfg = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGInstrument|x64.ActiveCfg = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGUpdate|x64.ActiveCfg = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Release|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Release|x64.ActiveCfg = Release|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|Win32.ActiveCfg = Debug|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|Win32.Build.0 = Debug|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|x64.ActiveCfg = Debug|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|x64.Build.0 = Debug|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|Win32.ActiveCfg = Release|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|Win32.Build.0 = Release|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|x64.ActiveCfg = Release|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|x64.Build.0 = Release|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|Win32.ActiveCfg = Debug|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|Win32.Build.0 = Debug|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|x64.ActiveCfg = Debug|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|x64.Build.0 = Debug|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|Win32.ActiveCfg = Release|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|Win32.Build.0 = Release|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|x64.ActiveCfg = Release|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|x64.Build.0 = Release|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|Win32.ActiveCfg = Debug|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|Win32.Build.0 = Debug|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|x64.ActiveCfg = Debug|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|x64.Build.0 = Debug|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|Win32.ActiveCfg = Release|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|Win32.Build.0 = Release|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|x64.ActiveCfg = Release|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|x64.Build.0 = Release|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|Win32.ActiveCfg = Debug|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|Win32.Build.0 = Debug|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|x64.ActiveCfg = Debug|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|x64.Build.0 = Debug|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|Win32.ActiveCfg = Release|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|Win32.Build.0 = Release|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|x64.ActiveCfg = Release|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|x64.Build.0 = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|Win32.Build.0 = Debug|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|x64.ActiveCfg = Debug|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|x64.Build.0 = Debug|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|Win32.Build.0 = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|x64.ActiveCfg = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|x64.Build.0 = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|Win32.Build.0 = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|x64.ActiveCfg = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|x64.Build.0 = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|Win32.ActiveCfg = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|Win32.Build.0 = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.ActiveCfg = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/PC/VS8.0/pginstrument.vsprops b/PC/VS8.0/pginstrument.vsprops deleted file mode 100644 --- a/PC/VS8.0/pginstrument.vsprops +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - diff --git a/PC/VS8.0/pgupdate.vsprops b/PC/VS8.0/pgupdate.vsprops deleted file mode 100644 --- a/PC/VS8.0/pgupdate.vsprops +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/PC/VS8.0/pyd.vsprops b/PC/VS8.0/pyd.vsprops deleted file mode 100644 --- a/PC/VS8.0/pyd.vsprops +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - diff --git a/PC/VS8.0/pyd_d.vsprops b/PC/VS8.0/pyd_d.vsprops deleted file mode 100644 --- a/PC/VS8.0/pyd_d.vsprops +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - diff --git a/PC/VS8.0/pyexpat.vcproj b/PC/VS8.0/pyexpat.vcproj deleted file mode 100644 --- a/PC/VS8.0/pyexpat.vcproj +++ /dev/null @@ -1,553 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pyproject.vsprops b/PC/VS8.0/pyproject.vsprops deleted file mode 100644 --- a/PC/VS8.0/pyproject.vsprops +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/python.vcproj b/PC/VS8.0/python.vcproj deleted file mode 100644 --- a/PC/VS8.0/python.vcproj +++ /dev/null @@ -1,637 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pythoncore.vcproj b/PC/VS8.0/pythoncore.vcproj deleted file mode 100644 --- a/PC/VS8.0/pythoncore.vcproj +++ /dev/null @@ -1,1921 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pythonw.vcproj b/PC/VS8.0/pythonw.vcproj deleted file mode 100644 --- a/PC/VS8.0/pythonw.vcproj +++ /dev/null @@ -1,618 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/release.vsprops b/PC/VS8.0/release.vsprops deleted file mode 100644 --- a/PC/VS8.0/release.vsprops +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/PC/VS8.0/rmpyc.py b/PC/VS8.0/rmpyc.py deleted file mode 100644 --- a/PC/VS8.0/rmpyc.py +++ /dev/null @@ -1,25 +0,0 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../../Lib") -print(npyc, ".pyc deleted,", npyo, ".pyo deleted") diff --git a/PC/VS8.0/rt.bat b/PC/VS8.0/rt.bat deleted file mode 100644 --- a/PC/VS8.0/rt.bat +++ /dev/null @@ -1,52 +0,0 @@ - at echo off -rem Run Tests. Run the regression test suite. -rem Usage: rt [-d] [-O] [-q] regrtest_args -rem -d Run Debug build (python_d.exe). Else release build. -rem -O Run python.exe or python_d.exe (see -d) with -O. -rem -q "quick" -- normally the tests are run twice, the first time -rem after deleting all the .py[co] files reachable from Lib/. -rem -q runs the tests just once, and without deleting .py[co] files. -rem All leading instances of these switches are shifted off, and -rem whatever remains is passed to regrtest.py. For example, -rem rt -O -d -x test_thread -rem runs -rem python_d -O ../lib/test/regrtest.py -x test_thread -rem twice, and -rem rt -q -g test_binascii -rem runs -rem python_d ../lib/test/regrtest.py -g test_binascii -rem to generate the expected-output file for binascii quickly. -rem -rem Confusing: if you want to pass a comma-separated list, like -rem -u network,largefile -rem then you have to quote it on the rt line, like -rem rt -u "network,largefile" - -setlocal - -set exe=python -set qmode= -set dashO= -PATH %PATH%;%~dp0..\..\..\tcltk\bin - -:CheckOpts -if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts -if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts -if "%1"=="-d" (set exe=python_d) & shift & goto CheckOpts - -set cmd=%exe% %dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 -if defined qmode goto Qmode - -echo Deleting .pyc/.pyo files ... -%exe% rmpyc.py - -echo on -%cmd% - at echo off - -echo About to run again without deleting .pyc/.pyo first: -pause - -:Qmode -echo on -%cmd% diff --git a/PC/VS8.0/select.vcproj b/PC/VS8.0/select.vcproj deleted file mode 100644 --- a/PC/VS8.0/select.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/sqlite3.vcproj b/PC/VS8.0/sqlite3.vcproj deleted file mode 100644 --- a/PC/VS8.0/sqlite3.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/sqlite3.vsprops b/PC/VS8.0/sqlite3.vsprops deleted file mode 100644 --- a/PC/VS8.0/sqlite3.vsprops +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/PC/VS8.0/ssl.vcproj b/PC/VS8.0/ssl.vcproj deleted file mode 100644 --- a/PC/VS8.0/ssl.vcproj +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/unicodedata.vcproj b/PC/VS8.0/unicodedata.vcproj deleted file mode 100644 --- a/PC/VS8.0/unicodedata.vcproj +++ /dev/null @@ -1,533 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/winsound.vcproj b/PC/VS8.0/winsound.vcproj deleted file mode 100644 --- a/PC/VS8.0/winsound.vcproj +++ /dev/null @@ -1,523 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/x64.vsprops b/PC/VS8.0/x64.vsprops deleted file mode 100644 --- a/PC/VS8.0/x64.vsprops +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 01:23:37 2013 From: python-checkins at python.org (victor.stinner) Date: Sat, 26 Jan 2013 01:23:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_specify_behaviour_?= =?utf-8?q?of_old_Linux_kernels_with_SOCK=5FCLOEXEC?= Message-ID: <3YtHrn18rhzSPZ@mail.python.org> http://hg.python.org/peps/rev/3a0c10d6409a changeset: 4692:3a0c10d6409a user: Victor Stinner date: Sat Jan 26 01:22:05 2013 +0100 summary: PEP 433: specify behaviour of old Linux kernels with SOCK_CLOEXEC files: pep-0433.txt | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -647,8 +647,9 @@ we have to check that the flag is supported by calling ``fcntl()``. If it does not work, we have to set the flag using ``fcntl()``. -XXX what is the behaviour on Linux older than 2.6.27 -XXX with SOCK_CLOEXEC? XXX +On Linux older than 2.6.27, if the ``SOCK_CLOEXEC`` flag is set in the +socket type, ``socket()`` or ``socketpair()`` fail and ``errno`` is set +to ``EINVAL``. New functions: @@ -657,7 +658,7 @@ * ``accept4()``: available on Linux 2.6.28+ (and glibc 2.10) If ``accept4()`` is called on Linux older than 2.6.28, ``accept4()`` -returns ``-1`` (fail) and errno is set to ``ENOSYS``. +returns ``-1`` (fail) and ``errno`` is set to ``ENOSYS``. Links -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Sat Jan 26 06:03:14 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 26 Jan 2013 06:03:14 +0100 Subject: [Python-checkins] Daily reference leaks (01bbac9369e8): sum=0 Message-ID: results for 01bbac9369e8 on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogU1uCRF', '-x'] From python-checkins at python.org Sat Jan 26 10:56:34 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 10:56:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Optimize_the_t?= =?utf-8?q?est_for_issue_=2313454=2E?= Message-ID: <3YtXYt3WVLzRCZ@mail.python.org> http://hg.python.org/cpython/rev/4ee8d38398d4 changeset: 81744:4ee8d38398d4 branch: 2.7 parent: 81737:5970c90dd8d1 user: Serhiy Storchaka date: Sat Jan 26 11:51:42 2013 +0200 summary: Optimize the test for issue #13454. Now it requires almost 4x less memory and is almost 2x faster. files: Lib/test/test_itertools.py | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -908,10 +908,8 @@ # Issue 13454: Crash when deleting backward iterator from tee() def test_tee_del_backward(self): - forward, backward = tee(xrange(20000000)) - for i in forward: - pass - + forward, backward = tee(repeat(None, 20000000)) + any(forward) # exhaust the iterator del backward def test_StopIteration(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 10:56:35 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 10:56:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Optimize_the_t?= =?utf-8?q?est_for_issue_=2313454=2E?= Message-ID: <3YtXYv6MmmzSMj@mail.python.org> http://hg.python.org/cpython/rev/d391b2849a51 changeset: 81745:d391b2849a51 branch: 3.2 parent: 81738:22594c5060eb user: Serhiy Storchaka date: Sat Jan 26 11:52:06 2013 +0200 summary: Optimize the test for issue #13454. Now it requires almost 4x less memory and is almost 2x faster. files: Lib/test/test_itertools.py | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -932,10 +932,8 @@ # Issue 13454: Crash when deleting backward iterator from tee() def test_tee_del_backward(self): - forward, backward = tee(range(20000000)) - for i in forward: - pass - + forward, backward = tee(repeat(None, 20000000)) + any(forward) # exhaust the iterator del backward def test_StopIteration(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 10:56:37 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 10:56:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Optimize_the_test_for_issue_=2313454=2E?= Message-ID: <3YtXYx29cxzSSB@mail.python.org> http://hg.python.org/cpython/rev/2258b4d89c9f changeset: 81746:2258b4d89c9f branch: 3.3 parent: 81741:dcbc16afd6bc parent: 81745:d391b2849a51 user: Serhiy Storchaka date: Sat Jan 26 11:53:17 2013 +0200 summary: Optimize the test for issue #13454. Now it requires almost 4x less memory and is almost 2x faster. files: Lib/test/test_itertools.py | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1269,10 +1269,8 @@ # Issue 13454: Crash when deleting backward iterator from tee() def test_tee_del_backward(self): - forward, backward = tee(range(20000000)) - for i in forward: - pass - + forward, backward = tee(repeat(None, 20000000)) + any(forward) # exhaust the iterator del backward def test_StopIteration(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 10:56:38 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 10:56:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Optimize_the_test_for_issue_=2313454=2E?= Message-ID: <3YtXYy4mqpzSSk@mail.python.org> http://hg.python.org/cpython/rev/1f57fb5e1e8e changeset: 81747:1f57fb5e1e8e parent: 81743:01bbac9369e8 parent: 81746:2258b4d89c9f user: Serhiy Storchaka date: Sat Jan 26 11:54:27 2013 +0200 summary: Optimize the test for issue #13454. Now it requires almost 4x less memory and is almost 2x faster. files: Lib/test/test_itertools.py | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1269,10 +1269,8 @@ # Issue 13454: Crash when deleting backward iterator from tee() def test_tee_del_backward(self): - forward, backward = tee(range(20000000)) - for i in forward: - pass - + forward, backward = tee(repeat(None, 20000000)) + any(forward) # exhaust the iterator del backward def test_StopIteration(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 11:21:51 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 11:21:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzEwMTU2?= =?utf-8?q?=3A_In_the_interpreter=27s_initialization_phase=2C_unicode_glob?= =?utf-8?q?als?= Message-ID: <3YtY733mfkzSRn@mail.python.org> http://hg.python.org/cpython/rev/7c8ad0d02664 changeset: 81748:7c8ad0d02664 branch: 2.7 parent: 81744:4ee8d38398d4 user: Serhiy Storchaka date: Sat Jan 26 12:13:40 2013 +0200 summary: Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. files: Misc/NEWS | 3 + Objects/unicodeobject.c | 85 +++++++++++++--------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,9 @@ Core and Builtins ----------------- +- Issue #10156: In the interpreter's initialization phase, unicode globals + are now initialized dynamically as needed. + - Issue #16975: Fix error handling bug in the escape-decode decoder. - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -82,8 +82,9 @@ /* --- Globals ------------------------------------------------------------ - The globals are initialized by the _PyUnicode_Init() API and should - not be used before calling that API. +NOTE: In the interpreter's initialization phase, some globals are currently + initialized dynamically as needed. In the process Unicode objects may + be created before the Unicode type is ready. */ @@ -93,15 +94,27 @@ #endif /* Free list for Unicode objects */ -static PyUnicodeObject *free_list; -static int numfree; +static PyUnicodeObject *free_list = NULL; +static int numfree = 0; /* The empty Unicode object is shared to improve performance. */ -static PyUnicodeObject *unicode_empty; +static PyUnicodeObject *unicode_empty = NULL; + +#define _Py_RETURN_UNICODE_EMPTY() \ + do { \ + if (unicode_empty != NULL) \ + Py_INCREF(unicode_empty); \ + else { \ + unicode_empty = _PyUnicode_New(0); \ + if (unicode_empty != NULL) \ + Py_INCREF(unicode_empty); \ + } \ + return (PyObject *)unicode_empty; \ + } while (0) /* Single character Unicode strings in the Latin-1 range are being shared as well. */ -static PyUnicodeObject *unicode_latin1[256]; +static PyUnicodeObject *unicode_latin1[256] = {NULL}; /* Default encoding to use and assume when NULL is passed as encoding parameter; it is initialized by _PyUnicode_Init(). @@ -110,7 +123,7 @@ PyUnicode_GetDefaultEncoding() APIs to access this global. */ -static char unicode_default_encoding[100]; +static char unicode_default_encoding[100 + 1] = "ascii"; /* Fast detection of the most frequent whitespace characters */ const unsigned char _Py_ascii_whitespace[] = { @@ -204,7 +217,7 @@ #define BLOOM_MASK unsigned long -static BLOOM_MASK bloom_linebreak; +static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0; #define BLOOM_ADD(mask, ch) ((mask |= (1UL << ((ch) & (BLOOM_WIDTH - 1))))) #define BLOOM(mask, ch) ((mask & (1UL << ((ch) & (BLOOM_WIDTH - 1))))) @@ -448,10 +461,8 @@ if (u != NULL) { /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return (PyObject *)unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Single character Unicode objects in the Latin-1 range are shared when using this constructor */ @@ -497,10 +508,8 @@ if (u != NULL) { /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return (PyObject *)unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Single characters are shared when using this constructor. Restrict to ASCII, since the input must be UTF-8. */ @@ -1162,13 +1171,10 @@ } /* Convert to Unicode */ - if (len == 0) { - Py_INCREF(unicode_empty); - v = (PyObject *)unicode_empty; - } - else - v = PyUnicode_Decode(s, len, encoding, errors); - + if (len == 0) + _Py_RETURN_UNICODE_EMPTY(); + + v = PyUnicode_Decode(s, len, encoding, errors); return v; onError: @@ -1381,7 +1387,7 @@ Py_DECREF(v); strncpy(unicode_default_encoding, encoding, - sizeof(unicode_default_encoding)); + sizeof(unicode_default_encoding) - 1); return 0; onError: @@ -8850,8 +8856,6 @@ void _PyUnicode_Init(void) { - int i; - /* XXX - move this array to unicodectype.c ? */ Py_UNICODE linebreak[] = { 0x000A, /* LINE FEED */ @@ -8865,15 +8869,12 @@ }; /* Init the implementation */ - free_list = NULL; - numfree = 0; - unicode_empty = _PyUnicode_New(0); - if (!unicode_empty) - return; - - strcpy(unicode_default_encoding, "ascii"); - for (i = 0; i < 256; i++) - unicode_latin1[i] = NULL; + if (!unicode_empty) { + unicode_empty = _PyUnicode_New(0); + if (!unicode_empty) + return; + } + if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); @@ -8918,15 +8919,11 @@ { int i; - Py_XDECREF(unicode_empty); - unicode_empty = NULL; - - for (i = 0; i < 256; i++) { - if (unicode_latin1[i]) { - Py_DECREF(unicode_latin1[i]); - unicode_latin1[i] = NULL; - } - } + Py_CLEAR(unicode_empty); + + for (i = 0; i < 256; i++) + Py_CLEAR(unicode_latin1[i]); + (void)PyUnicode_ClearFreeList(); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 11:21:53 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 11:21:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEwMTU2?= =?utf-8?q?=3A_In_the_interpreter=27s_initialization_phase=2C_unicode_glob?= =?utf-8?q?als?= Message-ID: <3YtY75119RzSSl@mail.python.org> http://hg.python.org/cpython/rev/f7eda8165e6f changeset: 81749:f7eda8165e6f branch: 3.2 parent: 81745:d391b2849a51 user: Serhiy Storchaka date: Sat Jan 26 12:14:02 2013 +0200 summary: Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. files: Misc/NEWS | 3 + Objects/unicodeobject.c | 105 +++++++++++++-------------- 2 files changed, 52 insertions(+), 56 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #10156: In the interpreter's initialization phase, unicode globals + are now initialized dynamically as needed. + - Issue #16975: Fix error handling bug in the escape-decode bytes decoder. - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -80,8 +80,9 @@ /* --- Globals ------------------------------------------------------------ - The globals are initialized by the _PyUnicode_Init() API and should - not be used before calling that API. +NOTE: In the interpreter's initialization phase, some globals are currently + initialized dynamically as needed. In the process Unicode objects may + be created before the Unicode type is ready. */ @@ -98,18 +99,30 @@ Another way to look at this is that to say that the actual reference count of a string is: s->ob_refcnt + (s->state ? 2 : 0) */ -static PyObject *interned; +static PyObject *interned = NULL; /* Free list for Unicode objects */ -static PyUnicodeObject *free_list; -static int numfree; +static PyUnicodeObject *free_list = NULL; +static int numfree = 0; /* The empty Unicode object is shared to improve performance. */ -static PyUnicodeObject *unicode_empty; +static PyUnicodeObject *unicode_empty = NULL; + +#define _Py_RETURN_UNICODE_EMPTY() \ + do { \ + if (unicode_empty != NULL) \ + Py_INCREF(unicode_empty); \ + else { \ + unicode_empty = _PyUnicode_New(0); \ + if (unicode_empty != NULL) \ + Py_INCREF(unicode_empty); \ + } \ + return (PyObject *)unicode_empty; \ + } while (0) /* Single character Unicode strings in the Latin-1 range are being shared as well. */ -static PyUnicodeObject *unicode_latin1[256]; +static PyUnicodeObject *unicode_latin1[256] = {NULL}; /* Fast detection of the most frequent whitespace characters */ const unsigned char _Py_ascii_whitespace[] = { @@ -214,7 +227,7 @@ #define BLOOM_MASK unsigned long -static BLOOM_MASK bloom_linebreak; +static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0; #define BLOOM_ADD(mask, ch) ((mask |= (1UL << ((ch) & (BLOOM_WIDTH - 1))))) #define BLOOM(mask, ch) ((mask & (1UL << ((ch) & (BLOOM_WIDTH - 1))))) @@ -479,10 +492,8 @@ if (u != NULL) { /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return (PyObject *)unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Single character Unicode objects in the Latin-1 range are shared when using this constructor */ @@ -528,10 +539,8 @@ if (u != NULL) { /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return (PyObject *)unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Single characters are shared when using this constructor. Restrict to ASCII, since the input must be UTF-8. */ @@ -1393,15 +1402,11 @@ /* Decoding bytes objects is the most common case and should be fast */ if (PyBytes_Check(obj)) { - if (PyBytes_GET_SIZE(obj) == 0) { - Py_INCREF(unicode_empty); - v = (PyObject *) unicode_empty; - } - else { - v = PyUnicode_Decode( - PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), - encoding, errors); - } + if (PyBytes_GET_SIZE(obj) == 0) + _Py_RETURN_UNICODE_EMPTY(); + v = PyUnicode_Decode( + PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), + encoding, errors); return v; } @@ -1421,12 +1426,11 @@ } if (buffer.len == 0) { - Py_INCREF(unicode_empty); - v = (PyObject *) unicode_empty; - } - else - v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); - + PyBuffer_Release(&buffer); + _Py_RETURN_UNICODE_EMPTY(); + } + + v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); PyBuffer_Release(&buffer); return v; } @@ -8323,10 +8327,8 @@ Py_ssize_t nchars; size_t nbytes; - if (len < 1) { - Py_INCREF(unicode_empty); - return (PyObject *)unicode_empty; - } + if (len < 1) + _Py_RETURN_UNICODE_EMPTY(); if (len == 1 && PyUnicode_CheckExact(str)) { /* no repeat, return original string */ @@ -10056,8 +10058,6 @@ void _PyUnicode_Init(void) { - int i; - /* XXX - move this array to unicodectype.c ? */ Py_UNICODE linebreak[] = { 0x000A, /* LINE FEED */ @@ -10071,14 +10071,12 @@ }; /* Init the implementation */ - free_list = NULL; - numfree = 0; - unicode_empty = _PyUnicode_New(0); - if (!unicode_empty) - return; - - for (i = 0; i < 256; i++) - unicode_latin1[i] = NULL; + if (!unicode_empty) { + unicode_empty = _PyUnicode_New(0); + if (!unicode_empty) + return; + } + if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); @@ -10123,15 +10121,11 @@ { int i; - Py_XDECREF(unicode_empty); - unicode_empty = NULL; - - for (i = 0; i < 256; i++) { - if (unicode_latin1[i]) { - Py_DECREF(unicode_latin1[i]); - unicode_latin1[i] = NULL; - } - } + Py_CLEAR(unicode_empty); + + for (i = 0; i < 256; i++) + Py_CLEAR(unicode_latin1[i]); + (void)PyUnicode_ClearFreeList(); } @@ -10250,8 +10244,7 @@ "mortal/immortal\n", mortal_size, immortal_size); Py_DECREF(keys); PyDict_Clear(interned); - Py_DECREF(interned); - interned = NULL; + Py_CLEAR(interned); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 11:21:54 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 11:21:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2310156=3A_In_the_interpreter=27s_initialization_phase?= =?utf-8?q?=2C_unicode_globals?= Message-ID: <3YtY765DHyzSSw@mail.python.org> http://hg.python.org/cpython/rev/01d4dd412581 changeset: 81750:01d4dd412581 branch: 3.3 parent: 81746:2258b4d89c9f parent: 81749:f7eda8165e6f user: Serhiy Storchaka date: Sat Jan 26 12:16:36 2013 +0200 summary: Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. files: Misc/NEWS | 3 + Objects/unicodeobject.c | 171 ++++++++++++--------------- 2 files changed, 80 insertions(+), 94 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #10156: In the interpreter's initialization phase, unicode globals + are now initialized dynamically as needed. + - Issue #16980: Fix processing of escaped non-ascii bytes in the unicode-escape-decode decoder. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -57,8 +57,9 @@ /* --- Globals ------------------------------------------------------------ - The globals are initialized by the _PyUnicode_Init() API and should - not be used before calling that API. +NOTE: In the interpreter's initialization phase, some globals are currently + initialized dynamically as needed. In the process Unicode objects may + be created before the Unicode type is ready. */ @@ -179,17 +180,36 @@ Another way to look at this is that to say that the actual reference count of a string is: s->ob_refcnt + (s->state ? 2 : 0) */ -static PyObject *interned; +static PyObject *interned = NULL; /* The empty Unicode object is shared to improve performance. */ -static PyObject *unicode_empty; +static PyObject *unicode_empty = NULL; + +#define _Py_INCREF_UNICODE_EMPTY() \ + do { \ + if (unicode_empty != NULL) \ + Py_INCREF(unicode_empty); \ + else { \ + unicode_empty = PyUnicode_New(0, 0); \ + if (unicode_empty != NULL) { \ + Py_INCREF(unicode_empty); \ + assert(_PyUnicode_CheckConsistency(unicode_empty, 1)); \ + } \ + } \ + } while (0) + +#define _Py_RETURN_UNICODE_EMPTY() \ + do { \ + _Py_INCREF_UNICODE_EMPTY(); \ + return unicode_empty; \ + } while (0) /* List of static strings. */ -static _Py_Identifier *static_strings; +static _Py_Identifier *static_strings = NULL; /* Single character Unicode strings in the Latin-1 range are being shared as well. */ -static PyObject *unicode_latin1[256]; +static PyObject *unicode_latin1[256] = {NULL}; /* Fast detection of the most frequent whitespace characters */ const unsigned char _Py_ascii_whitespace[] = { @@ -416,9 +436,8 @@ len = _PyUnicode_WSTR_LENGTH(unicode); if (len == 0) { - Py_INCREF(unicode_empty); Py_DECREF(unicode); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } if (len == 1) { @@ -450,8 +469,8 @@ length = PyUnicode_GET_LENGTH(unicode); if (length == 0) { if (unicode != unicode_empty) { - Py_INCREF(unicode_empty); Py_DECREF(unicode); + _Py_RETURN_UNICODE_EMPTY(); } return unicode_empty; } @@ -528,7 +547,7 @@ #define BLOOM_MASK unsigned long -static BLOOM_MASK bloom_linebreak; +static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0; #define BLOOM_ADD(mask, ch) ((mask |= (1UL << ((ch) & (BLOOM_WIDTH - 1))))) #define BLOOM(mask, ch) ((mask & (1UL << ((ch) & (BLOOM_WIDTH - 1))))) @@ -1582,9 +1601,11 @@ return 0; if (length == 0) { + _Py_INCREF_UNICODE_EMPTY(); + if (!unicode_empty) + return -1; Py_DECREF(*p_unicode); *p_unicode = unicode_empty; - Py_INCREF(*p_unicode); return 0; } @@ -1731,10 +1752,8 @@ some optimizations which share commonly used objects. */ /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Single character Unicode objects in the Latin-1 range are shared when using this constructor */ @@ -1893,10 +1912,8 @@ PyObject *res; unsigned char max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) return get_latin1_char(u[0]); @@ -1916,10 +1933,8 @@ PyObject *res; Py_UCS2 max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) { Py_UCS4 ch = u[0]; @@ -1954,10 +1969,8 @@ PyObject *res; Py_UCS4 max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) { Py_UCS4 ch = u[0]; @@ -2249,10 +2262,8 @@ PyUnicode_FromWideChar(register const wchar_t *w, Py_ssize_t size) { if (w == NULL) { - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); PyErr_BadInternalCall(); return NULL; } @@ -3007,15 +3018,11 @@ /* Decoding bytes objects is the most common case and should be fast */ if (PyBytes_Check(obj)) { - if (PyBytes_GET_SIZE(obj) == 0) { - Py_INCREF(unicode_empty); - v = unicode_empty; - } - else { - v = PyUnicode_Decode( - PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), - encoding, errors); - } + if (PyBytes_GET_SIZE(obj) == 0) + _Py_RETURN_UNICODE_EMPTY(); + v = PyUnicode_Decode( + PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), + encoding, errors); return v; } @@ -3035,12 +3042,11 @@ } if (buffer.len == 0) { - Py_INCREF(unicode_empty); - v = unicode_empty; - } - else - v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); - + PyBuffer_Release(&buffer); + _Py_RETURN_UNICODE_EMPTY(); + } + + v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); PyBuffer_Release(&buffer); return v; } @@ -4720,8 +4726,7 @@ if (size == 0) { if (consumed) *consumed = 0; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } /* ASCII is equivalent to the first 128 ordinals in Unicode. */ @@ -5232,8 +5237,7 @@ if (q == e) { if (consumed) *consumed = size; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } #ifdef BYTEORDER_IS_LITTLE_ENDIAN @@ -6558,10 +6562,8 @@ PyObject *errorHandler = NULL; PyObject *exc = NULL; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* ASCII is equivalent to the first 128 ordinals in Unicode. */ if (size == 1 && (unsigned char)s[0] < 128) @@ -6940,8 +6942,7 @@ if (chunk_size == 0 && done) { if (v != NULL) break; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } @@ -9503,9 +9504,7 @@ /* If empty sequence, return u"". */ if (seqlen == 0) { Py_DECREF(fseq); - Py_INCREF(unicode_empty); - res = unicode_empty; - return res; + _Py_RETURN_UNICODE_EMPTY(); } /* If singleton sequence with an exact Unicode, return that. */ @@ -10205,7 +10204,9 @@ } new_size = slen + n * (len2 - len1); if (new_size == 0) { - Py_INCREF(unicode_empty); + _Py_INCREF_UNICODE_EMPTY(); + if (!unicode_empty) + goto error; u = unicode_empty; goto done; } @@ -11672,10 +11673,8 @@ PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; } - if (start >= length || end < start) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (start >= length || end < start) + _Py_RETURN_UNICODE_EMPTY(); length = end - start; if (PyUnicode_IS_ASCII(self)) { @@ -11802,10 +11801,8 @@ PyObject *u; Py_ssize_t nchars, n; - if (len < 1) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (len < 1) + _Py_RETURN_UNICODE_EMPTY(); /* no repeat, return original string */ if (len == 1) @@ -12924,8 +12921,7 @@ { if (writer->pos == 0) { Py_XDECREF(writer->buffer); - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } if (writer->readonly) { assert(PyUnicode_GET_LENGTH(writer->buffer) == writer->pos); @@ -13143,8 +13139,7 @@ } if (slicelength <= 0) { - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } else if (start == 0 && step == 1 && slicelength == PyUnicode_GET_LENGTH(self)) { return unicode_result_unchanged(self); @@ -13974,10 +13969,8 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:str", kwlist, &x, &encoding, &errors)) return NULL; - if (x == NULL) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (x == NULL) + _Py_RETURN_UNICODE_EMPTY(); if (encoding == NULL && errors == NULL) return PyObject_Str(x); else @@ -14146,8 +14139,6 @@ int _PyUnicode_Init(void) { - int i; - /* XXX - move this array to unicodectype.c ? */ Py_UCS2 linebreak[] = { 0x000A, /* LINE FEED */ @@ -14161,13 +14152,11 @@ }; /* Init the implementation */ - unicode_empty = PyUnicode_New(0, 0); + _Py_INCREF_UNICODE_EMPTY(); if (!unicode_empty) Py_FatalError("Can't create empty string"); - assert(_PyUnicode_CheckConsistency(unicode_empty, 1)); - - for (i = 0; i < 256; i++) - unicode_latin1[i] = NULL; + Py_DECREF(unicode_empty); + if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); @@ -14207,15 +14196,10 @@ { int i; - Py_XDECREF(unicode_empty); - unicode_empty = NULL; - - for (i = 0; i < 256; i++) { - if (unicode_latin1[i]) { - Py_DECREF(unicode_latin1[i]); - unicode_latin1[i] = NULL; - } - } + Py_CLEAR(unicode_empty); + + for (i = 0; i < 256; i++) + Py_CLEAR(unicode_latin1[i]); _PyUnicode_ClearStaticStrings(); (void)PyUnicode_ClearFreeList(); } @@ -14344,8 +14328,7 @@ "mortal/immortal\n", mortal_size, immortal_size); Py_DECREF(keys); PyDict_Clear(interned); - Py_DECREF(interned); - interned = NULL; + Py_CLEAR(interned); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 11:21:56 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 26 Jan 2013 11:21:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2310156=3A_In_the_interpreter=27s_initialization_?= =?utf-8?q?phase=2C_unicode_globals?= Message-ID: <3YtY782gx4zST5@mail.python.org> http://hg.python.org/cpython/rev/cb12d642eed2 changeset: 81751:cb12d642eed2 parent: 81747:1f57fb5e1e8e parent: 81750:01d4dd412581 user: Serhiy Storchaka date: Sat Jan 26 12:18:17 2013 +0200 summary: Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. files: Misc/NEWS | 3 + Objects/unicodeobject.c | 201 ++++++++++++--------------- 2 files changed, 90 insertions(+), 114 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #10156: In the interpreter's initialization phase, unicode globals + are now initialized dynamically as needed. + - Issue #16980: Fix processing of escaped non-ascii bytes in the unicode-escape-decode decoder. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -49,8 +49,9 @@ /* --- Globals ------------------------------------------------------------ - The globals are initialized by the _PyUnicode_Init() API and should - not be used before calling that API. +NOTE: In the interpreter's initialization phase, some globals are currently + initialized dynamically as needed. In the process Unicode objects may + be created before the Unicode type is ready. */ @@ -171,17 +172,36 @@ Another way to look at this is that to say that the actual reference count of a string is: s->ob_refcnt + (s->state ? 2 : 0) */ -static PyObject *interned; +static PyObject *interned = NULL; /* The empty Unicode object is shared to improve performance. */ -static PyObject *unicode_empty; +static PyObject *unicode_empty = NULL; + +#define _Py_INCREF_UNICODE_EMPTY() \ + do { \ + if (unicode_empty != NULL) \ + Py_INCREF(unicode_empty); \ + else { \ + unicode_empty = PyUnicode_New(0, 0); \ + if (unicode_empty != NULL) { \ + Py_INCREF(unicode_empty); \ + assert(_PyUnicode_CheckConsistency(unicode_empty, 1)); \ + } \ + } \ + } while (0) + +#define _Py_RETURN_UNICODE_EMPTY() \ + do { \ + _Py_INCREF_UNICODE_EMPTY(); \ + return unicode_empty; \ + } while (0) /* List of static strings. */ -static _Py_Identifier *static_strings; +static _Py_Identifier *static_strings = NULL; /* Single character Unicode strings in the Latin-1 range are being shared as well. */ -static PyObject *unicode_latin1[256]; +static PyObject *unicode_latin1[256] = {NULL}; /* Fast detection of the most frequent whitespace characters */ const unsigned char _Py_ascii_whitespace[] = { @@ -406,9 +426,8 @@ len = _PyUnicode_WSTR_LENGTH(unicode); if (len == 0) { - Py_INCREF(unicode_empty); Py_DECREF(unicode); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } if (len == 1) { @@ -442,8 +461,8 @@ length = PyUnicode_GET_LENGTH(unicode); if (length == 0) { if (unicode != unicode_empty) { - Py_INCREF(unicode_empty); Py_DECREF(unicode); + _Py_RETURN_UNICODE_EMPTY(); } return unicode_empty; } @@ -520,7 +539,7 @@ #define BLOOM_MASK unsigned long -static BLOOM_MASK bloom_linebreak; +static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0; #define BLOOM_ADD(mask, ch) ((mask |= (1UL << ((ch) & (BLOOM_WIDTH - 1))))) #define BLOOM(mask, ch) ((mask & (1UL << ((ch) & (BLOOM_WIDTH - 1))))) @@ -1602,9 +1621,11 @@ return 0; if (length == 0) { + _Py_INCREF_UNICODE_EMPTY(); + if (!unicode_empty) + return -1; Py_DECREF(*p_unicode); *p_unicode = unicode_empty; - Py_INCREF(*p_unicode); return 0; } @@ -1727,10 +1748,8 @@ some optimizations which share commonly used objects. */ /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Single character Unicode objects in the Latin-1 range are shared when using this constructor */ @@ -1889,10 +1908,8 @@ PyObject *res; unsigned char max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) return get_latin1_char(u[0]); @@ -1912,10 +1929,8 @@ PyObject *res; Py_UCS2 max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) { Py_UCS4 ch = u[0]; @@ -1950,10 +1965,8 @@ PyObject *res; Py_UCS4 max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) { Py_UCS4 ch = u[0]; @@ -2245,10 +2258,8 @@ PyUnicode_FromWideChar(register const wchar_t *w, Py_ssize_t size) { if (w == NULL) { - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); PyErr_BadInternalCall(); return NULL; } @@ -2825,15 +2836,11 @@ /* Decoding bytes objects is the most common case and should be fast */ if (PyBytes_Check(obj)) { - if (PyBytes_GET_SIZE(obj) == 0) { - Py_INCREF(unicode_empty); - v = unicode_empty; - } - else { - v = PyUnicode_Decode( - PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), - encoding, errors); - } + if (PyBytes_GET_SIZE(obj) == 0) + _Py_RETURN_UNICODE_EMPTY(); + v = PyUnicode_Decode( + PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), + encoding, errors); return v; } @@ -2853,12 +2860,11 @@ } if (buffer.len == 0) { - Py_INCREF(unicode_empty); - v = unicode_empty; - } - else - v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); - + PyBuffer_Release(&buffer); + _Py_RETURN_UNICODE_EMPTY(); + } + + v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); PyBuffer_Release(&buffer); return v; } @@ -4201,8 +4207,7 @@ if (size == 0) { if (consumed) *consumed = 0; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } /* Start off assuming it's all ASCII. Widen later as necessary. */ @@ -4609,8 +4614,7 @@ if (size == 0) { if (consumed) *consumed = 0; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } /* ASCII is equivalent to the first 128 ordinals in Unicode. */ @@ -4868,8 +4872,7 @@ if (q == e) { if (consumed) *consumed = size; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } #ifdef WORDS_BIGENDIAN @@ -5108,8 +5111,7 @@ if (q == e) { if (consumed) *consumed = size; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } #if PY_LITTLE_ENDIAN @@ -5386,10 +5388,8 @@ Py_ssize_t len; len = length_of_escaped_ascii_string(s, size); - if (len == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (len == 0) + _Py_RETURN_UNICODE_EMPTY(); /* After length_of_escaped_ascii_string() there are two alternatives, either the string is pure ASCII with named escapes like \n, etc. @@ -5781,10 +5781,8 @@ PyObject *errorHandler = NULL; PyObject *exc = NULL; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Escaped strings will always be longer than the resulting Unicode string, so we start with size here and then reduce the @@ -5988,10 +5986,8 @@ 1)) return NULL; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* XXX overflow detection missing */ _PyUnicodeWriter_Init(&writer, 0); @@ -6439,10 +6435,8 @@ PyObject *errorHandler = NULL; PyObject *exc = NULL; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* ASCII is equivalent to the first 128 ordinals in Unicode. */ if (size == 1 && (unsigned char)s[0] < 128) @@ -6820,8 +6814,7 @@ if (chunk_size == 0 && done) { if (v != NULL) break; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } @@ -7298,10 +7291,8 @@ if (mapping == NULL) return PyUnicode_DecodeLatin1(s, size, errors); - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); _PyUnicodeWriter_Init(&writer, 0); if (_PyUnicodeWriter_Prepare(&writer, size, 127) == -1) goto onError; @@ -9354,9 +9345,7 @@ /* If empty sequence, return u"". */ if (seqlen == 0) { Py_DECREF(fseq); - Py_INCREF(unicode_empty); - res = unicode_empty; - return res; + _Py_RETURN_UNICODE_EMPTY(); } /* If singleton sequence with an exact Unicode, return that. */ @@ -10056,7 +10045,9 @@ } new_size = slen + n * (len2 - len1); if (new_size == 0) { - Py_INCREF(unicode_empty); + _Py_INCREF_UNICODE_EMPTY(); + if (!unicode_empty) + goto error; u = unicode_empty; goto done; } @@ -11559,10 +11550,8 @@ PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; } - if (start >= length || end < start) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (start >= length || end < start) + _Py_RETURN_UNICODE_EMPTY(); length = end - start; if (PyUnicode_IS_ASCII(self)) { @@ -11689,10 +11678,8 @@ PyObject *u; Py_ssize_t nchars, n; - if (len < 1) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (len < 1) + _Py_RETURN_UNICODE_EMPTY(); /* no repeat, return original string */ if (len == 1) @@ -12832,8 +12819,7 @@ { if (writer->pos == 0) { Py_XDECREF(writer->buffer); - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } if (writer->readonly) { assert(PyUnicode_GET_LENGTH(writer->buffer) == writer->pos); @@ -13051,8 +13037,7 @@ } if (slicelength <= 0) { - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } else if (start == 0 && step == 1 && slicelength == PyUnicode_GET_LENGTH(self)) { return unicode_result_unchanged(self); @@ -14056,10 +14041,8 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:str", kwlist, &x, &encoding, &errors)) return NULL; - if (x == NULL) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (x == NULL) + _Py_RETURN_UNICODE_EMPTY(); if (encoding == NULL && errors == NULL) return PyObject_Str(x); else @@ -14228,8 +14211,6 @@ int _PyUnicode_Init(void) { - int i; - /* XXX - move this array to unicodectype.c ? */ Py_UCS2 linebreak[] = { 0x000A, /* LINE FEED */ @@ -14243,13 +14224,11 @@ }; /* Init the implementation */ - unicode_empty = PyUnicode_New(0, 0); + _Py_INCREF_UNICODE_EMPTY(); if (!unicode_empty) Py_FatalError("Can't create empty string"); - assert(_PyUnicode_CheckConsistency(unicode_empty, 1)); - - for (i = 0; i < 256; i++) - unicode_latin1[i] = NULL; + Py_DECREF(unicode_empty); + if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); @@ -14289,15 +14268,10 @@ { int i; - Py_XDECREF(unicode_empty); - unicode_empty = NULL; - - for (i = 0; i < 256; i++) { - if (unicode_latin1[i]) { - Py_DECREF(unicode_latin1[i]); - unicode_latin1[i] = NULL; - } - } + Py_CLEAR(unicode_empty); + + for (i = 0; i < 256; i++) + Py_CLEAR(unicode_latin1[i]); _PyUnicode_ClearStaticStrings(); (void)PyUnicode_ClearFreeList(); } @@ -14426,8 +14400,7 @@ "mortal/immortal\n", mortal_size, immortal_size); Py_DECREF(keys); PyDict_Clear(interned); - Py_DECREF(interned); - interned = NULL; + Py_CLEAR(interned); } -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 11:39:49 2013 From: python-checkins at python.org (matthias.klose) Date: Sat, 26 Jan 2013 11:39:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_-_Issue_=2316235=3A_Implem?= =?utf-8?q?ent_python-config_as_a_shell_script=2E?= Message-ID: <3YtYWn4xd0zSSp@mail.python.org> http://hg.python.org/cpython/rev/c0370730b364 changeset: 81752:c0370730b364 user: doko at python.org date: Sat Jan 26 11:39:31 2013 +0100 summary: - Issue #16235: Implement python-config as a shell script. files: Makefile.pre.in | 11 +- Misc/NEWS | 2 + Misc/python-config.sh.in | 106 +++++++++++++++++++++++++++ configure | 11 ++- configure.ac | 9 ++- 5 files changed, 133 insertions(+), 6 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -438,7 +438,7 @@ # Default target all: build_all -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed python-config # Compile a binary with gcc profile guided optimization. profile-opt: @@ -1132,10 +1132,12 @@ fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen -python-config: $(srcdir)/Misc/python-config.in +python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh # Substitution happens here, as the completely-expanded BINDIR # is not available in configure - sed -e "s, at EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config + sed -e "s, at EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py + # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} + sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config # Install the include files INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) @@ -1193,8 +1195,8 @@ $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh + $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config - rm python-config @if [ -s Modules/python.exp -a \ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ echo; echo "Installing support files for building shared extension modules on AIX:"; \ @@ -1381,6 +1383,7 @@ config.cache config.log pyconfig.h Modules/config.c -rm -rf build platform -rm -rf $(PYTHONFRAMEWORKDIR) + -rm -f python-config.py python-config # Make things extra clean, before making a distribution: # remove all generated files, even Makefile[.pre] diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -763,6 +763,8 @@ Build ----- +- Issue #16235: Implement python-config as a shell script. + - Issue #16769: Remove outdated Visual Studio projects. - Issue #17031: Fix running regen in cross builds. diff --git a/Misc/python-config.sh.in b/Misc/python-config.sh.in new file mode 100644 --- /dev/null +++ b/Misc/python-config.sh.in @@ -0,0 +1,106 @@ +#!/bin/sh + +exit_with_usage () +{ + echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir" + exit $1 +} + +if [ "$1" = "" ] ; then + exit_with_usage 1 +fi + +# Returns the actual prefix where this script was installed to. +installed_prefix () +{ + RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) + if which readlink >/dev/null 2>&1 ; then + RESULT=$(readlink -f "$RESULT") + fi + echo $RESULT +} + +prefix_build="@prefix@" +prefix_real=$(installed_prefix "$0") + +# Use sed to fix paths from their built to locations to their installed to locations. +prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#") +exec_prefix_build="@exec_prefix@" +exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") +includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#") +libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") +CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") +VERSION="@VERSION@" +LIBM="@LIBM@" +LIBC="@LIBC@" +SYSLIBS="$LIBM $LIBC" +ABIFLAGS="@ABIFLAGS@" +LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}${ABIFLAGS}" +BASECFLAGS="@BASECFLAGS@" +LDLIBRARY="@LDLIBRARY@" +LINKFORSHARED="@LINKFORSHARED@" +OPT="@OPT@" +PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" +LDVERSION="@LDVERSION@" +LIBDEST=${prefix}/lib/python${VERSION} +LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#") +SO="@SO@" +PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" +INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" +PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" + +# Scan for --help or unknown argument. +for ARG in $* +do + case $ARG in + --help) + exit_with_usage 0 + ;; + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) + ;; + *) + exit_with_usage 1 + ;; + esac +done + +for ARG in "$@" +do + case "$ARG" in + --prefix) + echo "$prefix" + ;; + --exec-prefix) + echo "$exec_prefix" + ;; + --includes) + echo "$INCDIR $PLATINCDIR" + ;; + --cflags) + echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" + ;; + --libs) + echo "$LIBS" + ;; + --ldflags) + LINKFORSHAREDUSED= + if [ -z "$PYTHONFRAMEWORK" ] ; then + LINKFORSHAREDUSED=$LINKFORSHARED + fi + LIBPLUSED= + if [ "$PY_ENABLE_SHARED" = "0" ] ; then + LIBPLUSED="-L$LIBPL" + fi + echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" + ;; + --extension-suffix) + echo "$SO" + ;; + --abiflags) + echo "$ABIFLAGS" + ;; + --configdir) + echo "$LIBPL" + ;; +esac +done diff --git a/configure b/configure --- a/configure +++ b/configure @@ -625,6 +625,8 @@ ac_subst_vars='LTLIBOBJS SRCDIRS THREADHEADERS +LIBPL +PY_ENABLE_SHARED SOABI LIBC LIBM @@ -5573,6 +5575,7 @@ # Other platforms follow if test $enable_shared = "yes"; then + PY_ENABLE_SHARED=1 $as_echo "#define Py_ENABLE_SHARED 1" >>confdefs.h @@ -5630,6 +5633,7 @@ esac else # shared is disabled + PY_ENABLE_SHARED=0 case $ac_sys_system in CYGWIN*) BLDLIBRARY='$(LIBRARY)' @@ -13689,6 +13693,10 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDVERSION" >&5 $as_echo "$LDVERSION" >&6; } + +LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}" + + # SO is the extension of shared libraries `(including the dot!) # -- usually .so, .sl on HP-UX, .dll on Cygwin { $as_echo "$as_me:${as_lineno-$LINENO}: checking SO" >&5 @@ -15136,7 +15144,7 @@ fi # generate output files -ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc" +ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh" ac_config_files="$ac_config_files Modules/ld_so_aix" @@ -15840,6 +15848,7 @@ "Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;; "Modules/Setup.config") CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;; "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; + "Misc/python-config.sh") CONFIG_FILES="$CONFIG_FILES Misc/python-config.sh" ;; "Modules/ld_so_aix") CONFIG_FILES="$CONFIG_FILES Modules/ld_so_aix" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -917,6 +917,7 @@ # Other platforms follow if test $enable_shared = "yes"; then + PY_ENABLE_SHARED=1 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) case $ac_sys_system in CYGWIN*) @@ -972,6 +973,7 @@ esac else # shared is disabled + PY_ENABLE_SHARED=0 case $ac_sys_system in CYGWIN*) BLDLIBRARY='$(LIBRARY)' @@ -3929,6 +3931,11 @@ LDVERSION='$(VERSION)$(ABIFLAGS)' AC_MSG_RESULT($LDVERSION) +dnl define LIBPL after ABIFLAGS and LDVERSION is defined. +AC_SUBST(PY_ENABLE_SHARED) +LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}" +AC_SUBST(LIBPL) + # SO is the extension of shared libraries `(including the dot!) # -- usually .so, .sl on HP-UX, .dll on Cygwin AC_MSG_CHECKING(SO) @@ -4641,7 +4648,7 @@ fi # generate output files -AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) +AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) AC_OUTPUT -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 12:09:47 2013 From: python-checkins at python.org (matthias.klose) Date: Sat, 26 Jan 2013 12:09:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_-_Follow-up_fo?= =?utf-8?q?r_issue_=2315484=3A_In_PYTHON=5FFOR=5FBUILD=2C_use_=24=28PLATDI?= =?utf-8?q?R=29_instead?= Message-ID: <3YtZBM2BJKzSRM@mail.python.org> http://hg.python.org/cpython/rev/f0cde9b6830a changeset: 81753:f0cde9b6830a branch: 3.3 parent: 81750:01d4dd412581 user: doko at python.org date: Sat Jan 26 12:08:25 2013 +0100 summary: - Follow-up for issue #15484: In PYTHON_FOR_BUILD, use $(PLATDIR) instead of plat-$(MACHDEP). files: configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2944,7 +2944,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 $as_echo "$interp" >&6; } - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp fi elif test "$cross_compiling" = maybe; then as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,7 @@ AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) fi AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp fi elif test "$cross_compiling" = maybe; then AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 12:09:48 2013 From: python-checkins at python.org (matthias.klose) Date: Sat, 26 Jan 2013 12:09:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_-_Follow-up_for_issue_=2315484=3A_In_PYTHON=5FFOR=5FBUIL?= =?utf-8?q?D=2C_use_=24=28PLATDIR=29_instead?= Message-ID: <3YtZBN56m8zST7@mail.python.org> http://hg.python.org/cpython/rev/938a045cfe7d changeset: 81754:938a045cfe7d parent: 81752:c0370730b364 parent: 81753:f0cde9b6830a user: doko at python.org date: Sat Jan 26 12:09:31 2013 +0100 summary: - Follow-up for issue #15484: In PYTHON_FOR_BUILD, use $(PLATDIR) instead of plat-$(MACHDEP). files: configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2946,7 +2946,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 $as_echo "$interp" >&6; } - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp fi elif test "$cross_compiling" = maybe; then as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,7 @@ AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) fi AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp fi elif test "$cross_compiling" = maybe; then AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 13:32:47 2013 From: python-checkins at python.org (stefan.krah) Date: Sat, 26 Jan 2013 13:32:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogQWRhcHQgdGVzdF9i?= =?utf-8?q?ytes_for_a_build_--without-doc-strings=2E?= Message-ID: <3Ytc275kkszSSC@mail.python.org> http://hg.python.org/cpython/rev/5c7f92bfe785 changeset: 81755:5c7f92bfe785 branch: 3.3 parent: 81753:f0cde9b6830a user: Stefan Krah date: Sat Jan 26 13:06:36 2013 +0100 summary: Adapt test_bytes for a build --without-doc-strings. files: Lib/test/support.py | 4 ++++ Lib/test/test_bytes.py | 1 + 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -590,6 +590,10 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') +requires_docstrings = unittest.skipUnless( + sysconfig.get_config_var('WITH_DOC_STRINGS'), + "test requires docstrings") + is_jython = sys.platform.startswith('java') # Filename used for testing diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -1158,6 +1158,7 @@ self.assertEqual(bytes(b"abc") < b"ab", False) self.assertEqual(bytes(b"abc") <= b"ab", False) + @test.support.requires_docstrings def test_doc(self): self.assertIsNotNone(bytearray.__doc__) self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 13:32:49 2013 From: python-checkins at python.org (stefan.krah) Date: Sat, 26 Jan 2013 13:32:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3Ytc291L9nzSSv@mail.python.org> http://hg.python.org/cpython/rev/2c2cd9e833f3 changeset: 81756:2c2cd9e833f3 parent: 81754:938a045cfe7d parent: 81755:5c7f92bfe785 user: Stefan Krah date: Sat Jan 26 13:07:36 2013 +0100 summary: Merge 3.3. files: Lib/test/support.py | 4 ++++ Lib/test/test_bytes.py | 1 + 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -597,6 +597,10 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') +requires_docstrings = unittest.skipUnless( + sysconfig.get_config_var('WITH_DOC_STRINGS'), + "test requires docstrings") + is_jython = sys.platform.startswith('java') # Filename used for testing diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -1172,6 +1172,7 @@ self.assertEqual(bytes(b"abc") < b"ab", False) self.assertEqual(bytes(b"abc") <= b"ab", False) + @test.support.requires_docstrings def test_doc(self): self.assertIsNotNone(bytearray.__doc__) self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 13:32:50 2013 From: python-checkins at python.org (stefan.krah) Date: Sat, 26 Jan 2013 13:32:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Adapt_test_for?= =?utf-8?q?_build_--without-doc-strings=2E?= Message-ID: <3Ytc2B40mdzSSl@mail.python.org> http://hg.python.org/cpython/rev/523f309cf558 changeset: 81757:523f309cf558 branch: 2.7 parent: 81748:7c8ad0d02664 user: Stefan Krah date: Sat Jan 26 13:31:44 2013 +0100 summary: Adapt test for build --without-doc-strings. files: Lib/test/test_bytes.py | 1 + Lib/test/test_support.py | 5 +++++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -925,6 +925,7 @@ self.assertEqual(bytes(b"abc") < b"ab", False) self.assertEqual(bytes(b"abc") <= b"ab", False) + @test.test_support.requires_docstrings def test_doc(self): self.assertIsNotNone(bytearray.__doc__) self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__) diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -20,6 +20,7 @@ import time import struct import _testcapi +import sysconfig try: import thread except ImportError: @@ -1111,6 +1112,10 @@ else: return unittest.skip("resource {0!r} is not enabled".format(resource)) +requires_docstrings = unittest.skipUnless( + sysconfig.get_config_var('WITH_DOC_STRINGS'), + "test requires docstrings") + def cpython_only(test): """ Decorator for tests only applicable on CPython. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 13:58:48 2013 From: python-checkins at python.org (stefan.krah) Date: Sat, 26 Jan 2013 13:58:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogRml4IHRlc3RfcHlk?= =?utf-8?q?oc_for_build_--without-doc-strings=2E?= Message-ID: <3Ytcc84Y7WzSSj@mail.python.org> http://hg.python.org/cpython/rev/9a98ab22ab95 changeset: 81758:9a98ab22ab95 branch: 3.3 parent: 81755:5c7f92bfe785 user: Stefan Krah date: Sat Jan 26 13:57:15 2013 +0100 summary: Fix test_pydoc for build --without-doc-strings. files: Lib/test/test_pydoc.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -256,6 +256,7 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_html_doc(self): result, doc_loc = get_pydoc_html(pydoc_mod) mod_file = inspect.getabsfile(pydoc_mod) @@ -273,6 +274,7 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) expected_text = expected_text_pattern % \ @@ -327,6 +329,7 @@ 'Docstrings are omitted with -O2 and above') @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_help_output_redirect(self): # issue 940286, if output is set in Helper, then all output from # Helper.help should be redirected @@ -496,6 +499,7 @@ self.assertRaises(TypeError, f, 'A', '') self.assertRaises(TypeError, f, 'B', 'foobar') + @test.support.requires_docstrings def test_url_requests(self): # Test for the correct title in the html pages returned. # This tests the different parts of the URL handler without -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 13:58:50 2013 From: python-checkins at python.org (stefan.krah) Date: Sat, 26 Jan 2013 13:58:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy4zLg==?= Message-ID: <3YtccB0SLZzST0@mail.python.org> http://hg.python.org/cpython/rev/0cd5d215179a changeset: 81759:0cd5d215179a parent: 81756:2c2cd9e833f3 parent: 81758:9a98ab22ab95 user: Stefan Krah date: Sat Jan 26 13:58:00 2013 +0100 summary: Merge 3.3. files: Lib/test/test_pydoc.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -256,6 +256,7 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_html_doc(self): result, doc_loc = get_pydoc_html(pydoc_mod) mod_file = inspect.getabsfile(pydoc_mod) @@ -273,6 +274,7 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) expected_text = expected_text_pattern % \ @@ -327,6 +329,7 @@ 'Docstrings are omitted with -O2 and above') @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_help_output_redirect(self): # issue 940286, if output is set in Helper, then all output from # Helper.help should be redirected @@ -496,6 +499,7 @@ self.assertRaises(TypeError, f, 'A', '') self.assertRaises(TypeError, f, 'B', 'foobar') + @test.support.requires_docstrings def test_url_requests(self): # Test for the correct title in the html pages returned. # This tests the different parts of the URL handler without -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 14:50:05 2013 From: python-checkins at python.org (brett.cannon) Date: Sat, 26 Jan 2013 14:50:05 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Skip_a_test_unless_the_net?= =?utf-8?q?work_resource_is_available=2E?= Message-ID: <3YtdlK3KjDzSTg@mail.python.org> http://hg.python.org/cpython/rev/7aebb882a0c8 changeset: 81760:7aebb882a0c8 parent: 81742:d8c2ce63f5a4 user: Brett Cannon date: Fri Jan 25 22:27:21 2013 -0500 summary: Skip a test unless the network resource is available. files: Lib/test/test_urllib2.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1445,6 +1445,8 @@ self.opener_has_handler(o, MyHTTPHandler) self.opener_has_handler(o, MyOtherHTTPHandler) + @unittest.skipUnless(support.is_resource_enabled('network'), + 'test requires network access') def test_issue16464(self): opener = urllib.request.build_opener() request = urllib.request.Request("http://www.python.org/~jeremy/") -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 14:50:07 2013 From: python-checkins at python.org (brett.cannon) Date: Sat, 26 Jan 2013 14:50:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Port_py=5Fcompile_over_to_?= =?utf-8?q?importlib?= Message-ID: <3YtdlM0cDHzSTx@mail.python.org> http://hg.python.org/cpython/rev/d4eb02b6aac9 changeset: 81761:d4eb02b6aac9 user: Brett Cannon date: Sat Jan 26 08:48:36 2013 -0500 summary: Port py_compile over to importlib files: Lib/importlib/_bootstrap.py | 21 +- Lib/py_compile.py | 56 +- Misc/NEWS | 2 + Python/importlib.h | 8700 +++++++++++----------- 4 files changed, 4396 insertions(+), 4383 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -689,6 +689,15 @@ raise ImportError("Non-code object in {!r}".format(bytecode_path), name=name, path=bytecode_path) +def _code_to_bytecode(code, mtime=0, source_size=0): + """Compile a code object into bytecode for writing out to a byte-compiled + file.""" + data = bytearray(_MAGIC_BYTES) + data.extend(_w_long(mtime)) + data.extend(_w_long(source_size)) + data.extend(marshal.dumps(code)) + return data + # Loaders ##################################################################### @@ -951,13 +960,13 @@ raise ImportError("Failed to decode source file", name=fullname) from exc - def source_to_code(self, data, path): + def source_to_code(self, data, path, *, _optimize=-1): """Return the code object compiled from source. The 'data' argument can be any object type that compile() supports. """ return _call_with_frames_removed(compile, data, path, 'exec', - dont_inherit=True) + dont_inherit=True, optimize=_optimize) def get_code(self, fullname): """Concrete implementation of InspectLoader.get_code. @@ -1000,11 +1009,9 @@ code_object = self.source_to_code(source_bytes, source_path) _verbose_message('code object from {}', source_path) if (not sys.dont_write_bytecode and bytecode_path is not None and - source_mtime is not None): - data = bytearray(_MAGIC_BYTES) - data.extend(_w_long(source_mtime)) - data.extend(_w_long(len(source_bytes))) - data.extend(marshal.dumps(code_object)) + source_mtime is not None): + data = _code_to_bytecode(code_object, source_mtime, + len(source_bytes)) try: self._cache_bytecode(source_path, bytecode_path, data) _verbose_message('wrote {!r}', bytecode_path) diff --git a/Lib/py_compile.py b/Lib/py_compile.py --- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -3,17 +3,13 @@ This module has intimate knowledge of the format of .pyc files. """ -import builtins -import errno import imp -import marshal +import importlib._bootstrap +import importlib.machinery import os import sys -import tokenize import traceback -MAGIC = imp.get_magic() - __all__ = ["compile", "main", "PyCompileError"] @@ -65,13 +61,6 @@ return self.msg -def wr_long(f, x): - """Internal; write a 32-bit int to a file in little-endian order.""" - f.write(bytes([x & 0xff, - (x >> 8) & 0xff, - (x >> 16) & 0xff, - (x >> 24) & 0xff])) - def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1): """Byte-compile one Python source file to Python bytecode. @@ -108,17 +97,16 @@ byte-compile all installed files (or all files in selected directories). """ - with tokenize.open(file) as f: - try: - st = os.fstat(f.fileno()) - except AttributeError: - st = os.stat(file) - timestamp = int(st.st_mtime) - size = st.st_size & 0xFFFFFFFF - codestring = f.read() + if cfile is None: + if optimize >= 0: + cfile = imp.cache_from_source(file, debug_override=not optimize) + else: + cfile = imp.cache_from_source(file) + loader = importlib.machinery.SourceFileLoader('', file) + source_bytes = loader.get_data(file) try: - codeobject = builtins.compile(codestring, dfile or file, 'exec', - optimize=optimize) + code = loader.source_to_code(source_bytes, dfile or file, + _optimize=optimize) except Exception as err: py_exc = PyCompileError(err.__class__, err, dfile or file) if doraise: @@ -126,26 +114,16 @@ else: sys.stderr.write(py_exc.msg + '\n') return - if cfile is None: - if optimize >= 0: - cfile = imp.cache_from_source(file, debug_override=not optimize) - else: - cfile = imp.cache_from_source(file) try: dirname = os.path.dirname(cfile) if dirname: os.makedirs(dirname) - except OSError as error: - if error.errno != errno.EEXIST: - raise - with open(cfile, 'wb') as fc: - fc.write(b'\0\0\0\0') - wr_long(fc, timestamp) - wr_long(fc, size) - marshal.dump(codeobject, fc) - fc.flush() - fc.seek(0, 0) - fc.write(MAGIC) + except FileExistsError: + pass + source_stats = loader.path_stats(file) + bytecode = importlib._bootstrap._code_to_bytecode(code, + source_stats['mtime'], len(source_bytes)) + loader._cache_bytecode(file, cfile, bytecode) return cfile def main(args=None): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -223,6 +223,8 @@ Library ------- +Have py_compile use importlib as much as possible to avoid code duplication. + - Issue #180022: Have site.addpackage() consider already known paths even when none are explicitly passed in. Bug report and fix by Kirill. diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 14:50:12 2013 From: python-checkins at python.org (brett.cannon) Date: Sat, 26 Jan 2013 14:50:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_merge?= Message-ID: <3YtdlS0r9qzSTl@mail.python.org> http://hg.python.org/cpython/rev/3a74ce3dfbf8 changeset: 81762:3a74ce3dfbf8 parent: 81761:d4eb02b6aac9 parent: 81759:0cd5d215179a user: Brett Cannon date: Sat Jan 26 08:49:53 2013 -0500 summary: merge files: Lib/test/support.py | 4 + Lib/test/test_bytes.py | 1 + Lib/test/test_itertools.py | 6 +- Lib/test/test_pydoc.py | 4 + Makefile.pre.in | 11 +- Misc/NEWS | 7 + Misc/python-config.sh.in | 106 + Objects/unicodeobject.c | 201 +- PC/VC6/_ctypes.dsp | 131 - PC/VC6/_ctypes_test.dsp | 99 - PC/VC6/_elementtree.dsp | 111 - PC/VC6/_msi.dsp | 99 - PC/VC6/_multiprocessing.dsp | 107 - PC/VC6/_socket.dsp | 99 - PC/VC6/_sqlite3.dsp | 131 - PC/VC6/_ssl.dsp | 89 - PC/VC6/_ssl.mak | 22 - PC/VC6/_testcapi.dsp | 99 - PC/VC6/_tkinter.dsp | 103 - PC/VC6/build_ssl.py | 228 - PC/VC6/build_tkinter.py | 81 - PC/VC6/bz2.dsp | 99 - PC/VC6/make_versioninfo.dsp | 108 - PC/VC6/pcbuild.dsw | 293 - PC/VC6/pyexpat.dsp | 111 - PC/VC6/python.dsp | 100 - PC/VC6/pythoncore.dsp | 780 ---- PC/VC6/pythonw.dsp | 101 - PC/VC6/readme.txt | 192 - PC/VC6/rmpyc.py | 25 - PC/VC6/rt.bat | 41 - PC/VC6/select.dsp | 99 - PC/VC6/tcl852.patch | 11 - PC/VC6/unicodedata.dsp | 99 - PC/VC6/winsound.dsp | 99 - PC/VS7.1/Uninstal.wse | 514 -- PC/VS7.1/_ctypes.vcproj | 311 - PC/VS7.1/_ctypes_test.vcproj | 242 - PC/VS7.1/_elementtree.vcproj | 264 - PC/VS7.1/_msi.vcproj | 252 - PC/VS7.1/_socket.vcproj | 254 - PC/VS7.1/_sqlite3.vcproj | 283 - PC/VS7.1/_ssl.mak | 38 - PC/VS7.1/_ssl.vcproj | 84 - PC/VS7.1/_testcapi.vcproj | 247 - PC/VS7.1/_tkinter.vcproj | 261 - PC/VS7.1/amd64_ml64.bat | 17 - PC/VS7.1/build_ssl.bat | 12 - PC/VS7.1/build_ssl.py | 181 - PC/VS7.1/bz2.vcproj | 271 - PC/VS7.1/db.build | 10 - PC/VS7.1/field3.py | 35 - PC/VS7.1/installer.bmp | Bin PC/VS7.1/make_buildinfo.c | 92 - PC/VS7.1/make_buildinfo.vcproj | 122 - PC/VS7.1/make_versioninfo.vcproj | 142 - PC/VS7.1/pcbuild.sln | 271 - PC/VS7.1/pyexpat.vcproj | 263 - PC/VS7.1/python.build | 20 - PC/VS7.1/python.iss | 340 - PC/VS7.1/python.vcproj | 274 - PC/VS7.1/python20.wse | 3112 ------------------ PC/VS7.1/pythoncore.vcproj | 826 ---- PC/VS7.1/pythonw.vcproj | 261 - PC/VS7.1/readme.txt | 337 - PC/VS7.1/rmpyc.py | 25 - PC/VS7.1/rt.bat | 52 - PC/VS7.1/select.vcproj | 258 - PC/VS7.1/unicodedata.vcproj | 247 - PC/VS7.1/winsound.vcproj | 251 - PC/VS8.0/_ctypes.vcproj | 705 ---- PC/VS8.0/_ctypes_test.vcproj | 521 --- PC/VS8.0/_elementtree.vcproj | 613 --- PC/VS8.0/_hashlib.vcproj | 537 --- PC/VS8.0/_msi.vcproj | 529 --- PC/VS8.0/_multiprocessing.vcproj | 545 --- PC/VS8.0/_socket.vcproj | 537 --- PC/VS8.0/_sqlite3.vcproj | 613 --- PC/VS8.0/_ssl.vcproj | 537 --- PC/VS8.0/_testcapi.vcproj | 521 --- PC/VS8.0/_tkinter.vcproj | 541 --- PC/VS8.0/bdist_wininst.vcproj | 270 - PC/VS8.0/build.bat | 17 - PC/VS8.0/build_env.bat | 1 - PC/VS8.0/build_pgo.bat | 41 - PC/VS8.0/build_ssl.bat | 12 - PC/VS8.0/build_ssl.py | 277 - PC/VS8.0/build_tkinter.py | 85 - PC/VS8.0/bz2.vcproj | 581 --- PC/VS8.0/debug.vsprops | 15 - PC/VS8.0/env.bat | 5 - PC/VS8.0/field3.py | 35 - PC/VS8.0/idle.bat | 15 - PC/VS8.0/kill_python.c | 178 - PC/VS8.0/kill_python.vcproj | 279 - PC/VS8.0/make_buildinfo.c | 116 - PC/VS8.0/make_buildinfo.vcproj | 101 - PC/VS8.0/make_versioninfo.vcproj | 324 - PC/VS8.0/pcbuild.sln | 555 --- PC/VS8.0/pginstrument.vsprops | 34 - PC/VS8.0/pgupdate.vsprops | 14 - PC/VS8.0/pyd.vsprops | 28 - PC/VS8.0/pyd_d.vsprops | 36 - PC/VS8.0/pyexpat.vcproj | 553 --- PC/VS8.0/pyproject.vsprops | 87 - PC/VS8.0/python.vcproj | 637 --- PC/VS8.0/pythoncore.vcproj | 1921 ----------- PC/VS8.0/pythonw.vcproj | 618 --- PC/VS8.0/release.vsprops | 15 - PC/VS8.0/rmpyc.py | 25 - PC/VS8.0/rt.bat | 52 - PC/VS8.0/select.vcproj | 537 --- PC/VS8.0/sqlite3.vcproj | 537 --- PC/VS8.0/sqlite3.vsprops | 14 - PC/VS8.0/ssl.vcproj | 189 - PC/VS8.0/unicodedata.vcproj | 533 --- PC/VS8.0/winsound.vcproj | 523 --- PC/VS8.0/x64.vsprops | 22 - configure | 13 +- configure.ac | 11 +- 120 files changed, 238 insertions(+), 29333 deletions(-) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -597,6 +597,10 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') +requires_docstrings = unittest.skipUnless( + sysconfig.get_config_var('WITH_DOC_STRINGS'), + "test requires docstrings") + is_jython = sys.platform.startswith('java') # Filename used for testing diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -1172,6 +1172,7 @@ self.assertEqual(bytes(b"abc") < b"ab", False) self.assertEqual(bytes(b"abc") <= b"ab", False) + @test.support.requires_docstrings def test_doc(self): self.assertIsNotNone(bytearray.__doc__) self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1269,10 +1269,8 @@ # Issue 13454: Crash when deleting backward iterator from tee() def test_tee_del_backward(self): - forward, backward = tee(range(20000000)) - for i in forward: - pass - + forward, backward = tee(repeat(None, 20000000)) + any(forward) # exhaust the iterator del backward def test_StopIteration(self): diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -256,6 +256,7 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_html_doc(self): result, doc_loc = get_pydoc_html(pydoc_mod) mod_file = inspect.getabsfile(pydoc_mod) @@ -273,6 +274,7 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) expected_text = expected_text_pattern % \ @@ -327,6 +329,7 @@ 'Docstrings are omitted with -O2 and above') @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') + @test.support.requires_docstrings def test_help_output_redirect(self): # issue 940286, if output is set in Helper, then all output from # Helper.help should be redirected @@ -496,6 +499,7 @@ self.assertRaises(TypeError, f, 'A', '') self.assertRaises(TypeError, f, 'B', 'foobar') + @test.support.requires_docstrings def test_url_requests(self): # Test for the correct title in the html pages returned. # This tests the different parts of the URL handler without diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -438,7 +438,7 @@ # Default target all: build_all -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed python-config # Compile a binary with gcc profile guided optimization. profile-opt: @@ -1132,10 +1132,12 @@ fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen -python-config: $(srcdir)/Misc/python-config.in +python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh # Substitution happens here, as the completely-expanded BINDIR # is not available in configure - sed -e "s, at EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config + sed -e "s, at EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py + # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} + sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config # Install the include files INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) @@ -1193,8 +1195,8 @@ $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh + $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config - rm python-config @if [ -s Modules/python.exp -a \ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ echo; echo "Installing support files for building shared extension modules on AIX:"; \ @@ -1381,6 +1383,7 @@ config.cache config.log pyconfig.h Modules/config.c -rm -rf build platform -rm -rf $(PYTHONFRAMEWORKDIR) + -rm -f python-config.py python-config # Make things extra clean, before making a distribution: # remove all generated files, even Makefile[.pre] diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #10156: In the interpreter's initialization phase, unicode globals + are now initialized dynamically as needed. + - Issue #16980: Fix processing of escaped non-ascii bytes in the unicode-escape-decode decoder. @@ -762,6 +765,10 @@ Build ----- +- Issue #16235: Implement python-config as a shell script. + +- Issue #16769: Remove outdated Visual Studio projects. + - Issue #17031: Fix running regen in cross builds. - Issue #3754: fix typo in pthread AC_CACHE_VAL. diff --git a/Misc/python-config.sh.in b/Misc/python-config.sh.in new file mode 100644 --- /dev/null +++ b/Misc/python-config.sh.in @@ -0,0 +1,106 @@ +#!/bin/sh + +exit_with_usage () +{ + echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir" + exit $1 +} + +if [ "$1" = "" ] ; then + exit_with_usage 1 +fi + +# Returns the actual prefix where this script was installed to. +installed_prefix () +{ + RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) + if which readlink >/dev/null 2>&1 ; then + RESULT=$(readlink -f "$RESULT") + fi + echo $RESULT +} + +prefix_build="@prefix@" +prefix_real=$(installed_prefix "$0") + +# Use sed to fix paths from their built to locations to their installed to locations. +prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#") +exec_prefix_build="@exec_prefix@" +exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") +includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#") +libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") +CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") +VERSION="@VERSION@" +LIBM="@LIBM@" +LIBC="@LIBC@" +SYSLIBS="$LIBM $LIBC" +ABIFLAGS="@ABIFLAGS@" +LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}${ABIFLAGS}" +BASECFLAGS="@BASECFLAGS@" +LDLIBRARY="@LDLIBRARY@" +LINKFORSHARED="@LINKFORSHARED@" +OPT="@OPT@" +PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" +LDVERSION="@LDVERSION@" +LIBDEST=${prefix}/lib/python${VERSION} +LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#") +SO="@SO@" +PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" +INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" +PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" + +# Scan for --help or unknown argument. +for ARG in $* +do + case $ARG in + --help) + exit_with_usage 0 + ;; + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) + ;; + *) + exit_with_usage 1 + ;; + esac +done + +for ARG in "$@" +do + case "$ARG" in + --prefix) + echo "$prefix" + ;; + --exec-prefix) + echo "$exec_prefix" + ;; + --includes) + echo "$INCDIR $PLATINCDIR" + ;; + --cflags) + echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" + ;; + --libs) + echo "$LIBS" + ;; + --ldflags) + LINKFORSHAREDUSED= + if [ -z "$PYTHONFRAMEWORK" ] ; then + LINKFORSHAREDUSED=$LINKFORSHARED + fi + LIBPLUSED= + if [ "$PY_ENABLE_SHARED" = "0" ] ; then + LIBPLUSED="-L$LIBPL" + fi + echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" + ;; + --extension-suffix) + echo "$SO" + ;; + --abiflags) + echo "$ABIFLAGS" + ;; + --configdir) + echo "$LIBPL" + ;; +esac +done diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -49,8 +49,9 @@ /* --- Globals ------------------------------------------------------------ - The globals are initialized by the _PyUnicode_Init() API and should - not be used before calling that API. +NOTE: In the interpreter's initialization phase, some globals are currently + initialized dynamically as needed. In the process Unicode objects may + be created before the Unicode type is ready. */ @@ -171,17 +172,36 @@ Another way to look at this is that to say that the actual reference count of a string is: s->ob_refcnt + (s->state ? 2 : 0) */ -static PyObject *interned; +static PyObject *interned = NULL; /* The empty Unicode object is shared to improve performance. */ -static PyObject *unicode_empty; +static PyObject *unicode_empty = NULL; + +#define _Py_INCREF_UNICODE_EMPTY() \ + do { \ + if (unicode_empty != NULL) \ + Py_INCREF(unicode_empty); \ + else { \ + unicode_empty = PyUnicode_New(0, 0); \ + if (unicode_empty != NULL) { \ + Py_INCREF(unicode_empty); \ + assert(_PyUnicode_CheckConsistency(unicode_empty, 1)); \ + } \ + } \ + } while (0) + +#define _Py_RETURN_UNICODE_EMPTY() \ + do { \ + _Py_INCREF_UNICODE_EMPTY(); \ + return unicode_empty; \ + } while (0) /* List of static strings. */ -static _Py_Identifier *static_strings; +static _Py_Identifier *static_strings = NULL; /* Single character Unicode strings in the Latin-1 range are being shared as well. */ -static PyObject *unicode_latin1[256]; +static PyObject *unicode_latin1[256] = {NULL}; /* Fast detection of the most frequent whitespace characters */ const unsigned char _Py_ascii_whitespace[] = { @@ -406,9 +426,8 @@ len = _PyUnicode_WSTR_LENGTH(unicode); if (len == 0) { - Py_INCREF(unicode_empty); Py_DECREF(unicode); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } if (len == 1) { @@ -442,8 +461,8 @@ length = PyUnicode_GET_LENGTH(unicode); if (length == 0) { if (unicode != unicode_empty) { - Py_INCREF(unicode_empty); Py_DECREF(unicode); + _Py_RETURN_UNICODE_EMPTY(); } return unicode_empty; } @@ -520,7 +539,7 @@ #define BLOOM_MASK unsigned long -static BLOOM_MASK bloom_linebreak; +static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0; #define BLOOM_ADD(mask, ch) ((mask |= (1UL << ((ch) & (BLOOM_WIDTH - 1))))) #define BLOOM(mask, ch) ((mask & (1UL << ((ch) & (BLOOM_WIDTH - 1))))) @@ -1602,9 +1621,11 @@ return 0; if (length == 0) { + _Py_INCREF_UNICODE_EMPTY(); + if (!unicode_empty) + return -1; Py_DECREF(*p_unicode); *p_unicode = unicode_empty; - Py_INCREF(*p_unicode); return 0; } @@ -1727,10 +1748,8 @@ some optimizations which share commonly used objects. */ /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Single character Unicode objects in the Latin-1 range are shared when using this constructor */ @@ -1889,10 +1908,8 @@ PyObject *res; unsigned char max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) return get_latin1_char(u[0]); @@ -1912,10 +1929,8 @@ PyObject *res; Py_UCS2 max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) { Py_UCS4 ch = u[0]; @@ -1950,10 +1965,8 @@ PyObject *res; Py_UCS4 max_char; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); if (size == 1) { Py_UCS4 ch = u[0]; @@ -2245,10 +2258,8 @@ PyUnicode_FromWideChar(register const wchar_t *w, Py_ssize_t size) { if (w == NULL) { - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); PyErr_BadInternalCall(); return NULL; } @@ -2825,15 +2836,11 @@ /* Decoding bytes objects is the most common case and should be fast */ if (PyBytes_Check(obj)) { - if (PyBytes_GET_SIZE(obj) == 0) { - Py_INCREF(unicode_empty); - v = unicode_empty; - } - else { - v = PyUnicode_Decode( - PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), - encoding, errors); - } + if (PyBytes_GET_SIZE(obj) == 0) + _Py_RETURN_UNICODE_EMPTY(); + v = PyUnicode_Decode( + PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj), + encoding, errors); return v; } @@ -2853,12 +2860,11 @@ } if (buffer.len == 0) { - Py_INCREF(unicode_empty); - v = unicode_empty; - } - else - v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); - + PyBuffer_Release(&buffer); + _Py_RETURN_UNICODE_EMPTY(); + } + + v = PyUnicode_Decode((char*) buffer.buf, buffer.len, encoding, errors); PyBuffer_Release(&buffer); return v; } @@ -4201,8 +4207,7 @@ if (size == 0) { if (consumed) *consumed = 0; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } /* Start off assuming it's all ASCII. Widen later as necessary. */ @@ -4609,8 +4614,7 @@ if (size == 0) { if (consumed) *consumed = 0; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } /* ASCII is equivalent to the first 128 ordinals in Unicode. */ @@ -4868,8 +4872,7 @@ if (q == e) { if (consumed) *consumed = size; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } #ifdef WORDS_BIGENDIAN @@ -5108,8 +5111,7 @@ if (q == e) { if (consumed) *consumed = size; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } #if PY_LITTLE_ENDIAN @@ -5386,10 +5388,8 @@ Py_ssize_t len; len = length_of_escaped_ascii_string(s, size); - if (len == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (len == 0) + _Py_RETURN_UNICODE_EMPTY(); /* After length_of_escaped_ascii_string() there are two alternatives, either the string is pure ASCII with named escapes like \n, etc. @@ -5781,10 +5781,8 @@ PyObject *errorHandler = NULL; PyObject *exc = NULL; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* Escaped strings will always be longer than the resulting Unicode string, so we start with size here and then reduce the @@ -5988,10 +5986,8 @@ 1)) return NULL; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* XXX overflow detection missing */ _PyUnicodeWriter_Init(&writer, 0); @@ -6439,10 +6435,8 @@ PyObject *errorHandler = NULL; PyObject *exc = NULL; - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); /* ASCII is equivalent to the first 128 ordinals in Unicode. */ if (size == 1 && (unsigned char)s[0] < 128) @@ -6820,8 +6814,7 @@ if (chunk_size == 0 && done) { if (v != NULL) break; - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } @@ -7298,10 +7291,8 @@ if (mapping == NULL) return PyUnicode_DecodeLatin1(s, size, errors); - if (size == 0) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (size == 0) + _Py_RETURN_UNICODE_EMPTY(); _PyUnicodeWriter_Init(&writer, 0); if (_PyUnicodeWriter_Prepare(&writer, size, 127) == -1) goto onError; @@ -9354,9 +9345,7 @@ /* If empty sequence, return u"". */ if (seqlen == 0) { Py_DECREF(fseq); - Py_INCREF(unicode_empty); - res = unicode_empty; - return res; + _Py_RETURN_UNICODE_EMPTY(); } /* If singleton sequence with an exact Unicode, return that. */ @@ -10056,7 +10045,9 @@ } new_size = slen + n * (len2 - len1); if (new_size == 0) { - Py_INCREF(unicode_empty); + _Py_INCREF_UNICODE_EMPTY(); + if (!unicode_empty) + goto error; u = unicode_empty; goto done; } @@ -11559,10 +11550,8 @@ PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; } - if (start >= length || end < start) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (start >= length || end < start) + _Py_RETURN_UNICODE_EMPTY(); length = end - start; if (PyUnicode_IS_ASCII(self)) { @@ -11689,10 +11678,8 @@ PyObject *u; Py_ssize_t nchars, n; - if (len < 1) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (len < 1) + _Py_RETURN_UNICODE_EMPTY(); /* no repeat, return original string */ if (len == 1) @@ -12832,8 +12819,7 @@ { if (writer->pos == 0) { Py_XDECREF(writer->buffer); - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } if (writer->readonly) { assert(PyUnicode_GET_LENGTH(writer->buffer) == writer->pos); @@ -13051,8 +13037,7 @@ } if (slicelength <= 0) { - Py_INCREF(unicode_empty); - return unicode_empty; + _Py_RETURN_UNICODE_EMPTY(); } else if (start == 0 && step == 1 && slicelength == PyUnicode_GET_LENGTH(self)) { return unicode_result_unchanged(self); @@ -14056,10 +14041,8 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:str", kwlist, &x, &encoding, &errors)) return NULL; - if (x == NULL) { - Py_INCREF(unicode_empty); - return unicode_empty; - } + if (x == NULL) + _Py_RETURN_UNICODE_EMPTY(); if (encoding == NULL && errors == NULL) return PyObject_Str(x); else @@ -14228,8 +14211,6 @@ int _PyUnicode_Init(void) { - int i; - /* XXX - move this array to unicodectype.c ? */ Py_UCS2 linebreak[] = { 0x000A, /* LINE FEED */ @@ -14243,13 +14224,11 @@ }; /* Init the implementation */ - unicode_empty = PyUnicode_New(0, 0); + _Py_INCREF_UNICODE_EMPTY(); if (!unicode_empty) Py_FatalError("Can't create empty string"); - assert(_PyUnicode_CheckConsistency(unicode_empty, 1)); - - for (i = 0; i < 256; i++) - unicode_latin1[i] = NULL; + Py_DECREF(unicode_empty); + if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); @@ -14289,15 +14268,10 @@ { int i; - Py_XDECREF(unicode_empty); - unicode_empty = NULL; - - for (i = 0; i < 256; i++) { - if (unicode_latin1[i]) { - Py_DECREF(unicode_latin1[i]); - unicode_latin1[i] = NULL; - } - } + Py_CLEAR(unicode_empty); + + for (i = 0; i < 256; i++) + Py_CLEAR(unicode_latin1[i]); _PyUnicode_ClearStaticStrings(); (void)PyUnicode_ClearFreeList(); } @@ -14426,8 +14400,7 @@ "mortal/immortal\n", mortal_size, immortal_size); Py_DECREF(keys); PyDict_Clear(interned); - Py_DECREF(interned); - interned = NULL; + Py_CLEAR(interned); } diff --git a/PC/VC6/_ctypes.dsp b/PC/VC6/_ctypes.dsp deleted file mode 100644 --- a/PC/VC6/_ctypes.dsp +++ /dev/null @@ -1,131 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_ctypes" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_ctypes - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_ctypes.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_ctypes.mak" CFG="_ctypes - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_ctypes - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_ctypes - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_ctypes" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_ctypes - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_ctypes" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_ctypes - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_ctypes" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_ctypes - Win32 Release" -# Name "_ctypes - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\_ctypes.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\callbacks.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\callproc.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\cfield.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\libffi_msvc\ffi.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\malloc_closure.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\libffi_msvc\prep_cif.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\stgdict.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\libffi_msvc\win32.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_ctypes_test.dsp b/PC/VC6/_ctypes_test.dsp deleted file mode 100644 --- a/PC/VC6/_ctypes_test.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_ctypes_test" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_ctypes_test - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_ctypes_test.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_ctypes_test.mak" CFG="_ctypes_test - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_ctypes_test - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_ctypes_test - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_ctypes_test" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_ctypes_test - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_ctypes_test" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes_test.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_ctypes_test - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_ctypes_test" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"./_ctypes_test_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_ctypes_test - Win32 Release" -# Name "_ctypes_test - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_ctypes\_ctypes_test.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_elementtree.dsp b/PC/VC6/_elementtree.dsp deleted file mode 100644 --- a/PC/VC6/_elementtree.dsp +++ /dev/null @@ -1,111 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_elementtree" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_elementtree - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_elementtree.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_elementtree.mak" CFG="_elementtree - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_elementtree - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_elementtree - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_elementtree" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_elementtree - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_elementtree" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d100000" /subsystem:windows /dll /debug /machine:I386 /out:"./_elementtree.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_elementtree - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_elementtree" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d100000" /subsystem:windows /dll /debug /machine:I386 /out:"./_elementtree_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_elementtree - Win32 Release" -# Name "_elementtree - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_elementtree.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlparse.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlrole.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmltok.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_msi.dsp b/PC/VC6/_msi.dsp deleted file mode 100644 --- a/PC/VC6/_msi.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_msi" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_msi - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_msi.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_msi.mak" CFG="_msi - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_msi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_msi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_msi" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_msi - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_msi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_msi.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_msi - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_msi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fci.lib msi.lib rpcrt4.lib /nologo /base:"0x1d1a0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_msi_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_msi - Win32 Release" -# Name "_msi - Win32 Debug" -# Begin Source File - -SOURCE=..\..\PC\_msi.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_multiprocessing.dsp b/PC/VC6/_multiprocessing.dsp deleted file mode 100644 --- a/PC/VC6/_multiprocessing.dsp +++ /dev/null @@ -1,107 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_multiprocessing" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_multiprocessing - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_multiprocessing.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_multiprocessing.mak" CFG="_multiprocessing - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_multiprocessing - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_multiprocessing - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_multiprocessing" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_multiprocessing - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_multiprocessing" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_multiprocessing.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_multiprocessing - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_multiprocessing" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1d0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_multiprocessing_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_multiprocessing - Win32 Release" -# Name "_multiprocessing - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_multiprocessing\multiprocessing.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_multiprocessing\semaphore.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_multiprocessing\win32_functions.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_socket.dsp b/PC/VC6/_socket.dsp deleted file mode 100644 --- a/PC/VC6/_socket.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_socket" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_socket - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_socket.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_socket.mak" CFG="_socket - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_socket - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_socket - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_socket" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_socket - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_socket" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_socket.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_socket - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_socket" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_socket_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_socket - Win32 Release" -# Name "_socket - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\socketmodule.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_sqlite3.dsp b/PC/VC6/_sqlite3.dsp deleted file mode 100644 --- a/PC/VC6/_sqlite3.dsp +++ /dev/null @@ -1,131 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_sqlite3" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_sqlite3 - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_sqlite3.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_sqlite3.mak" CFG="_sqlite3 - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_sqlite3 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_sqlite3 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_sqlite3" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_sqlite3 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_sqlite3" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\sqlite-source-3.3.4\sqlite3.lib /nologo /base:"0x1e180000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sqlite3.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_sqlite3 - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_sqlite3" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\sqlite-source-3.3.4\sqlite3.lib /nologo /base:"0x1e180000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sqlite3_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_sqlite3 - Win32 Release" -# Name "_sqlite3 - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\cache.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\connection.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\cursor.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\microprotocols.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\prepare_protocol.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\row.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\statement.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sqlite\util.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_ssl.dsp b/PC/VC6/_ssl.dsp deleted file mode 100644 --- a/PC/VC6/_ssl.dsp +++ /dev/null @@ -1,89 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_ssl" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) External Target" 0x0106 - -CFG=_ssl - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_ssl.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_ssl.mak" CFG="_ssl - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_ssl - Win32 Release" (based on "Win32 (x86) External Target") -!MESSAGE "_ssl - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "_ssl - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "_ssl.exe" -# PROP BASE Bsc_Name "_ssl.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_ssl" -# PROP Cmd_Line "python build_ssl.py" -# PROP Rebuild_Opt "-a" -# PROP Target_File "_ssl.pyd" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "x86-temp-debug\_ssl" -# PROP BASE Intermediate_Dir "x86-temp-debug\_ssl" -# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "_ssl_d.pyd" -# PROP BASE Bsc_Name "_ssl_d.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_ssl" -# PROP Cmd_Line "python_d -u build_ssl.py -d" -# PROP Rebuild_Opt "-a" -# PROP Target_File "_ssl_d.pyd" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ENDIF - -# Begin Target - -# Name "_ssl - Win32 Release" -# Name "_ssl - Win32 Debug" - -!IF "$(CFG)" == "_ssl - Win32 Release" - -!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" - -!ENDIF - -# Begin Source File - -SOURCE=..\..\Modules\_ssl.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_ssl.mak b/PC/VC6/_ssl.mak deleted file mode 100644 --- a/PC/VC6/_ssl.mak +++ /dev/null @@ -1,22 +0,0 @@ - -!IFDEF DEBUG -MODULE=_ssl_d.pyd -TEMP_DIR=x86-temp-debug/_ssl -CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32 -LFLAGS=/nodefaultlib:"msvcrt" -!ELSE -MODULE=_ssl.pyd -TEMP_DIR=x86-temp-release/_ssl -CFLAGS=/Ox /MD /LD /DWIN32 -LFLAGS= -!ENDIF - -INCLUDES=-I ../../Include -I .. -I $(SSL_DIR)/inc32 -SSL_LIB_DIR=$(SSL_DIR)/out32 -LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib - -SOURCE=../../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib - -$(MODULE): $(SOURCE) ../*.h ../../Include/*.h - @if not exist "$(TEMP_DIR)/." mkdir "$(TEMP_DIR)" - cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS) $(LFLAGS) diff --git a/PC/VC6/_testcapi.dsp b/PC/VC6/_testcapi.dsp deleted file mode 100644 --- a/PC/VC6/_testcapi.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_testcapi" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_testcapi - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_testcapi.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_testcapi.mak" CFG="_testcapi - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_testcapi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_testcapi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_testcapi" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_testcapi - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_testcapi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /machine:I386 /out:"./_testcapi.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_testcapi - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_testcapi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /debug /machine:I386 /out:"./_testcapi_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_testcapi - Win32 Release" -# Name "_testcapi - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_testcapimodule.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/_tkinter.dsp b/PC/VC6/_tkinter.dsp deleted file mode 100644 --- a/PC/VC6/_tkinter.dsp +++ /dev/null @@ -1,103 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_tkinter" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_tkinter - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_tkinter.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_tkinter.mak" CFG="_tkinter - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_tkinter - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_tkinter - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "_tkinter" -# PROP Scc_LocalPath "..\..\.." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_tkinter - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_tkinter" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\..\tcltk\lib\tk85g.lib ..\..\..\tcltk\lib\tcl85g.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_tkinter - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_tkinter" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\..\tcltk\lib\tk85.lib ..\..\..\tcltk\lib\tcl85.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter.pyd" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_tkinter - Win32 Release" -# Name "_tkinter - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_tkinter.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\tkappinit.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/build_ssl.py b/PC/VC6/build_ssl.py deleted file mode 100644 --- a/PC/VC6/build_ssl.py +++ /dev/null @@ -1,228 +0,0 @@ -# Script for building the _ssl module for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for _ssl.pyd itself. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PC/VC6 directory. -# -# it should configure and build SSL, then build the ssl Python extension -# without intervention. - -# Modified by Christian Heimes -# Now this script supports pre-generated makefiles and assembly files. -# Developers don't need an installation of Perl anymore to build Python. A svn -# checkout from our svn repository is enough. - -import os, sys, re, shutil - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen('"%s" -e "use Win32;"' % perl) - fh.read() - rc = fh.close() - if rc: - continue - return perl - print("Can not find a suitable PERL:") - if perls: - print(" the following perl interpreters were found:") - for p in perls: - print(" ", p) - print(" None of these versions appear suitable for building OpenSSL") - else: - print(" NO perl interpreters were found on this machine at all!") - print(" Please install ActivePerl and ensure it appears on your path") - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - # note: do not abspath s; the build will fail if any - # higher up directory name has spaces in it. - fnames = os.listdir(s) - except OSError: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print("Found an SSL directory at '%s'" % (best_name,)) - else: - print("Could not find an SSL directory in '%s'" % (sources,)) - sys.stdout.flush() - return best_name - -def fix_makefile(makefile): - """Fix some stuff in all makefiles - """ - if not os.path.isfile(makefile): - return - with open(makefile) as fin: - lines = fin.readlines() - with open(makefile, 'w') as fout: - for line in lines: - if line.startswith("PERL="): - continue - if line.startswith("CP="): - line = "CP=copy\n" - if line.startswith("MKDIR="): - line = "MKDIR=mkdir\n" - if line.startswith("CFLAG="): - line = line.strip() - for algo in ("RC5", "MDC2", "IDEA"): - noalgo = " -DOPENSSL_NO_%s" % algo - if noalgo not in line: - line = line + noalgo - line = line + '\n' - fout.write(line) - -def run_configure(configure, do_script): - print("perl Configure "+configure) - os.system("perl Configure "+configure) - print(do_script) - os.system(do_script) - -def cmp(f1, f2): - bufsize = 1024 * 8 - with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True - -def copy(src, dst): - if os.path.isfile(dst) and cmp(src, dst): - return - shutil.copy(src, dst) - -def main(): - debug = "-d" in sys.argv - build_all = "-a" in sys.argv - if 1: # Win32 - arch = "x86" - configure = "VC-WIN32" - do_script = "ms\\do_nasm" - makefile="ms\\nt.mak" - m32 = makefile - dirsuffix = "32" - configure += " no-idea no-rc5 no-mdc2" - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl: - print("Found a working perl at '%s'" % (perl,)) - else: - print("No Perl installation was found. Existing Makefiles are used.") - sys.stdout.flush() - # Look for SSL 3 levels up from PC/VC6 - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("..\\..\\..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - if perl is None: - print("Perl is required to build the makefiles!") - sys.exit(1) - - print("Creating the makefiles...") - sys.stdout.flush() - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.dirname(perl) + \ - os.pathsep + \ - os.environ["PATH"] - run_configure(configure, do_script) - if debug: - print("OpenSSL debug builds aren't supported.") - #if arch=="x86" and debug: - # # the do_masm script in openssl doesn't generate a debug - # # build makefile so we generate it here: - # os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile) - - fix_makefile(makefile) - copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) - copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) - - # If the assembler files don't exist in tmpXX, copy them there - if perl is None and os.path.exists("asm"+dirsuffix): - if not os.path.exists("tmp"+dirsuffix): - os.mkdir("tmp"+dirsuffix) - for f in os.listdir("asm"+dirsuffix): - if not f.endswith(".asm"): continue - if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue - shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix) - - # Now run make. - copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h") - copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h") - - #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) - makeCommand = "nmake /nologo -f \"%s\"" % makefile - print("Executing ssl makefiles:", makeCommand) - sys.stdout.flush() - rc = os.system(makeCommand) - if rc: - print("Executing "+makefile+" failed") - print(rc) - sys.exit(rc) - finally: - os.chdir(old_cd) - # And finally, we can build the _ssl module itself for Python. - defs = "SSL_DIR=%s" % (ssl_dir,) - if debug: - defs = defs + " " + "DEBUG=1" - rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) - sys.exit(rc) - -if __name__=='__main__': - main() diff --git a/PC/VC6/build_tkinter.py b/PC/VC6/build_tkinter.py deleted file mode 100644 --- a/PC/VC6/build_tkinter.py +++ /dev/null @@ -1,81 +0,0 @@ -import os -import sys -import subprocess - -TCL_MAJOR = 8 -TCL_MINOR = 5 -TCL_PATCH = 2 - -TIX_MAJOR = 8 -TIX_MINOR = 4 -TIX_PATCH = 3 - -def abspath(name): - par = os.path.pardir - return os.path.abspath(os.path.join(__file__, par, par, par, par, name)) - -TCL_DIR = abspath("tcl%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH)) -TK_DIR = abspath("tk%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH)) -TIX_DIR = abspath("tix%d.%d.%d" % (TIX_MAJOR, TIX_MINOR, TIX_PATCH)) -OUT_DIR = abspath("tcltk") - -def have_args(*a): - return any(s in sys.argv[1:] for s in a) - -def enter(dir): - os.chdir(os.path.join(dir, "win")) - -def main(): - debug = have_args("-d", "--debug") - clean = have_args("clean") - install = have_args("install") - tcl = have_args("tcl") - tk = have_args("tk") - tix = have_args("tix") - if not(tcl) and not(tk) and not(tix): - tcl = tk = tix = True - - def nmake(makefile, *a): - args = ["nmake", "/nologo", "/f", makefile, "DEBUG=%d" % debug] - args.extend(a) - subprocess.check_call(args) - - if tcl: - enter(TCL_DIR) - def nmake_tcl(*a): - nmake("makefile.vc", *a) - if clean: - nmake_tcl("clean") - elif install: - nmake_tcl("install", "INSTALLDIR=" + OUT_DIR) - else: - nmake_tcl() - - if tk: - enter(TK_DIR) - def nmake_tk(*a): - nmake("makefile.vc", "TCLDIR=" + TCL_DIR, *a) - if clean: - nmake_tk("clean") - elif install: - nmake_tk("install", "INSTALLDIR=" + OUT_DIR) - else: - nmake_tk() - - if tix: - enter(TIX_DIR) - def nmake_tix(*a): - nmake("python.mak", - "TCL_MAJOR=%d" % TCL_MAJOR, - "TCL_MINOR=%d" % TCL_MINOR, - "TCL_PATCH=%d" % TCL_PATCH, - "MACHINE=IX86", *a) - if clean: - nmake_tix("clean") - elif install: - nmake_tix("install", "INSTALL_DIR=" + OUT_DIR) - else: - nmake_tix() - -if __name__ == '__main__': - main() diff --git a/PC/VC6/bz2.dsp b/PC/VC6/bz2.dsp deleted file mode 100644 --- a/PC/VC6/bz2.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="bz2" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=bz2 - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "bz2.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "bz2.mak" CFG="bz2 - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "bz2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "bz2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "bz2" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "bz2 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\bz2" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" -# SUBTRACT LINK32 /pdb:none /nodefaultlib - -!ELSEIF "$(CFG)" == "bz2 - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\bz2" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "bz2 - Win32 Release" -# Name "bz2 - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\bz2module.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/make_versioninfo.dsp b/PC/VC6/make_versioninfo.dsp deleted file mode 100644 --- a/PC/VC6/make_versioninfo.dsp +++ /dev/null @@ -1,108 +0,0 @@ -# Microsoft Developer Studio Project File - Name="make_versioninfo" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=make_versioninfo - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "make_versioninfo.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "make_versioninfo.mak" CFG="make_versioninfo - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "make_versioninfo - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "make_versioninfo - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "make_versioninfo" -# PROP Scc_LocalPath ".." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "make_versioninfo - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\make_versioninfo" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none -# Begin Custom Build -InputPath=.\make_versioninfo.exe -SOURCE="$(InputPath)" - -"..\pythonnt_rc.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - .\make_versioninfo.exe >..\pythonnt_rc.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "make_versioninfo - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\make_versioninfo" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\..\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 /out:"./make_versioninfo_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none -# Begin Custom Build -InputPath=.\make_versioninfo_d.exe -SOURCE="$(InputPath)" - -"..\pythonnt_rc_d.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - .\make_versioninfo_d.exe >..\pythonnt_rc_d.h - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "make_versioninfo - Win32 Release" -# Name "make_versioninfo - Win32 Debug" -# Begin Source File - -SOURCE=..\make_versioninfo.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/pcbuild.dsw b/PC/VC6/pcbuild.dsw deleted file mode 100644 --- a/PC/VC6/pcbuild.dsw +++ /dev/null @@ -1,293 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "_ctypes"=".\_ctypes.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_ctypes_test"=".\_ctypes_test.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "_elementtree"=".\_elementtree.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "_msi"=".\_msi.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_multiprocessing"=".\_multiprocessing.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_socket"=".\_socket.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_sqlite3"=".\_sqlite3.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "_ssl"=".\_ssl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency - Begin Project Dependency - Project_Dep_Name python - End Project Dependency - Begin Project Dependency - End Project Dependency -}}} - -############################################################################### - -Project: "_testcapi"=".\_testcapi.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_tkinter"=".\_tkinter.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "bz2"=".\bz2.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "make_versioninfo"=".\make_versioninfo.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "pyexpat"=".\pyexpat.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "python"=".\python.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "pythoncore"=".\pythoncore.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name make_versioninfo - End Project Dependency -}}} - -############################################################################### - -Project: "pythonw"=".\pythonw.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "select"=".\select.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "unicodedata"=".\unicodedata.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################## - -Project: "winsound"=".\winsound.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - - diff --git a/PC/VC6/pyexpat.dsp b/PC/VC6/pyexpat.dsp deleted file mode 100644 --- a/PC/VC6/pyexpat.dsp +++ /dev/null @@ -1,111 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pyexpat" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pyexpat - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pyexpat.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pyexpat.mak" CFG="pyexpat - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pyexpat - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pyexpat - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "pyexpat" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pyexpat - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pyexpat" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D100000" /subsystem:windows /dll /debug /machine:I386 /out:"./pyexpat.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pyexpat - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pyexpat" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "HAVE_EXPAT_H" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D100000" /subsystem:windows /dll /debug /machine:I386 /out:"./pyexpat_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pyexpat - Win32 Release" -# Name "pyexpat - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\pyexpat.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlparse.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmlrole.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\expat\xmltok.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/python.dsp b/PC/VC6/python.dsp deleted file mode 100644 --- a/PC/VC6/python.dsp +++ /dev/null @@ -1,100 +0,0 @@ -# Microsoft Developer Studio Project File - Name="python" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=python - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "python.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "python.mak" CFG="python - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "python - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "python - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "python" -# PROP Scc_LocalPath ".." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "python - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\python" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "python - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\python" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "....\\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /stack:0x200000 /subsystem:console /debug /machine:I386 /out:"./python_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "python - Win32 Release" -# Name "python - Win32 Debug" -# Begin Source File - -SOURCE=..\pycon.ico -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\python.c -# End Source File -# Begin Source File - -SOURCE=..\python_exe.rc -# End Source File -# End Target -# End Project diff --git a/PC/VC6/pythoncore.dsp b/PC/VC6/pythoncore.dsp deleted file mode 100644 --- a/PC/VC6/pythoncore.dsp +++ /dev/null @@ -1,780 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pythoncore" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pythoncore - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pythoncore.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pythoncore.mak" CFG="pythoncore - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pythoncore - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pythoncore - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "pythoncore" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pythoncore - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pythoncore" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_DL_EXPORT" /YX /FD /Zm200 /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\..\Include" /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python34.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pythoncore" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "USE_DL_EXPORT" /D "WIN32" /D "_WINDOWS" /YX /FD /Zm200 /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\..\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python34_d.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pythoncore - Win32 Release" -# Name "pythoncore - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\_bisectmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_cn.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_hk.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_iso2022.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_jp.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_kr.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\_codecs_tw.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_codecsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_collectionsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_csv.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_datetimemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_functoolsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_heapqmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\_iomodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_json.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_localemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_lsprof.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_math.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_pickle.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_randommodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_sre.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_struct.c -# End Source File -# Begin Source File - -SOURCE=..\..\PC\_subprocess.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_threadmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_time.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\_warnings.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_weakref.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\abstract.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\accu.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\acceler.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\adler32.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\arraymodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\asdl.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\ast.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\atexitmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\audioop.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\binascii.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\bitset.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\bltinmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\boolobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\bufferedio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\bytearrayobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\bytes_methods.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\bytesio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\bytesobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\capsule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\cellobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\ceval.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\classobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cmathmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\codecs.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\codeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\compile.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\complexobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\compress.c -# End Source File -# Begin Source File - -SOURCE=..\config.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\crc32.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\dynamic_annotations.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\deflate.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\descrobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\dictobject.c -# End Source File -# Begin Source File - -SOURCE=..\dl_nt.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\dtoa.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\dynload_win.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\enumobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\errnomodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\errors.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\exceptions.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\fileio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\fileobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\fileutils.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\firstsets.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\floatobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\formatter_unicode.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\frameobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\frozen.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\funcobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\future.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\gcmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\genobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getargs.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\getbuildinfo.c -# ADD CPP /D BUILD=46 -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getcompiler.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getcopyright.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getopt.c -# End Source File -# Begin Source File - -SOURCE=..\getpathp.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getplatform.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\getversion.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\graminit.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\grammar.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\grammar1.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\gzio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\import.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\importdl.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\infback.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\inffast.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\inflate.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\inftrees.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\iobase.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\iterobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\itertoolsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\listnode.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\listobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\longobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\main.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\marshal.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\mathmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\md5module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\memoryobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\metagrammar.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\methodobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\mmapmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\modsupport.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\moduleobject.c -# End Source File -# Begin Source File - -SOURCE=..\msvcrtmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\cjkcodecs\multibytecodec.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\myreadline.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\mysnprintf.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\mystrtoul.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\node.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\object.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\obmalloc.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\operator.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\parser.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\parsermodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\parsetok.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\peephole.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\posixmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pyarena.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pyctype.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pyfpe.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pymath.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pystate.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pystrcmp.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pystrtod.c -# End Source File -# Begin Source File - -SOURCE="..\..\Python\Python-ast.c" -# End Source File -# Begin Source File - -SOURCE=..\python_nt.rc -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pythonrun.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\pytime.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\random.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\rangeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\rotatingtree.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\setobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\sha1module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\sha256module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\sha512module.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\signalmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\sliceobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\stringio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\structmember.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\structseq.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\symtable.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\symtablemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\sysmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\_io\textio.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\thread.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\timemodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Parser\tokenizer.c -# End Source File -# Begin Source File - -SOURCE=..\..\Python\traceback.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\trees.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\tupleobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\typeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\uncompr.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\unicodectype.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\unicodeobject.c -# End Source File -# Begin Source File - -SOURCE=..\..\Objects\weakrefobject.c -# End Source File -# Begin Source File - -SOURCE=..\winreg.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\xxsubtype.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zipimport.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlibmodule.c -# End Source File -# Begin Source File - -SOURCE=..\..\Modules\zlib\zutil.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/pythonw.dsp b/PC/VC6/pythonw.dsp deleted file mode 100644 --- a/PC/VC6/pythonw.dsp +++ /dev/null @@ -1,101 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pythonw" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=pythonw - Win32 Alpha Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pythonw.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pythonw.mak" CFG="pythonw - Win32 Alpha Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pythonw - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "pythonw - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "pythonw" -# PROP Scc_LocalPath "..\pc" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pythonw - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pythonw" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d000000" /subsystem:windows /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pythonw - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pythonw" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d000000" /subsystem:windows /debug /machine:I386 /out:"./pythonw_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pythonw - Win32 Release" -# Name "pythonw - Win32 Debug" -# Begin Source File - -SOURCE=..\python_exe.rc -# End Source File -# Begin Source File - -SOURCE=..\WinMain.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/readme.txt b/PC/VC6/readme.txt deleted file mode 100644 --- a/PC/VC6/readme.txt +++ /dev/null @@ -1,192 +0,0 @@ -Building Python using VC++ 6.0 or 5.0 -------------------------------------- -This directory is used to build Python for Win32 platforms, e.g. Windows -2000 and XP. It requires Microsoft Visual C++ 6.x or 5.x and Platform -SDK February 2003 Edition (Core SDK). -(For other Windows platforms and compilers, see ../readme.txt.) - -All you need to do is open the workspace "pcbuild.dsw" in MSVC++, select -the Debug or Release setting (using Build -> Set Active Configuration...), -and build the projects. - -The proper order to build subprojects: - -1) pythoncore (this builds the main Python DLL and library files, - python34.{dll, lib} in Release mode) - -2) python (this builds the main Python executable, - python.exe in Release mode) - -3) the other subprojects, as desired or needed (note: you probably don't - want to build most of the other subprojects, unless you're building an - entire Python distribution from scratch, or specifically making changes - to the subsystems they implement; see SUBPROJECTS below) - -When using the Debug setting, the output files have a _d added to -their name: python34_d.dll, python_d.exe, pyexpat_d.pyd, and so on. - -SUBPROJECTS ------------ -These subprojects should build out of the box. Subprojects other than the -main ones (pythoncore, python, pythonw) generally build a DLL (renamed to -.pyd) from a specific module so that users don't have to load the code -supporting that module unless they import the module. - -pythoncore - .dll and .lib -python - .exe -pythonw - pythonw.exe, a variant of python.exe that doesn't pop up a DOS box -_msi - _msi.c. You need to install Windows Installer SDK to build this module. -_socket - socketmodule.c -_testcapi - tests of the Python C API, run via Lib/test/test_capi.py, and - implemented by module Modules/_testcapimodule.c -pyexpat - Python wrapper for accelerated XML parsing, which incorporates stable - code from the Expat project: http://sourceforge.net/projects/expat/ -select - selectmodule.c -unicodedata - large tables of Unicode data -winsound - play sounds (typically .wav files) under Windows - -The following subprojects will generally NOT build out of the box. They -wrap code Python doesn't control, and you'll need to download the base -packages first and unpack them into siblings of PCbuilds's parent -directory; for example, if your PCbuild is .......\dist\src\PCbuild\, -unpack into new subdirectories of dist\. - -_tkinter - Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.5.2. - - Get source - ---------- - In the dist directory, run - svn export http://svn.python.org/projects/external/tcl-8.5.2.1 tcl8.5.2 - svn export http://svn.python.org/projects/external/tk-8.5.2.0 tk8.5.2 - svn export http://svn.python.org/projects/external/tix-8.4.3.1 tix8.4.3 - - Debug Build - ----------- - To build debug version, add DEBUG=1 to all nmake call bellow. - - Build Tcl first (done here w/ MSVC 6 on Win2K) - --------------- - If your environment doesn't have struct _stat64, you need to apply - tcl852.patch in this directory to dist\tcl8.5.2\generic\tcl.h. - - cd dist\tcl8.5.2\win - run vcvars32.bat - nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - Optional: run tests, via - nmake -f makefile.vc test - - all.tcl: Total 24242 Passed 23358 Skipped 877 Failed 7 - Sourced 137 Test Files. - Files with failing tests: exec.test http.test io.test main.test string.test stri - ngObj.test - - Build Tk - -------- - cd dist\tk8.5.2\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.5.2 - nmake -f makefile.vc TCLDIR=..\..\tcl8.5.2 INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - XXX I have no idea whether "nmake -f makefile.vc test" passed or - XXX failed. It popped up tons of little windows, and did lots of - XXX stuff, and nothing blew up. - - Build Tix - --------- - cd dist\tix8.4.3\win - nmake -f python.mak TCL_MAJOR=8 TCL_MINOR=5 TCL_PATCH=2 MACHINE=IX86 DEBUG=0 - nmake -f python.mak TCL_MAJOR=8 TCL_MINOR=5 TCL_PATCH=2 MACHINE=IX86 DEBUG=0 INSTALL_DIR=..\..\tcltk install - -bz2 - Python wrapper for the libbz2 compression library. Homepage - http://www.bzip.org/ - Download the source from the python.org copy into the dist - directory: - - svn export http://svn.python.org/projects/external/bzip2-1.0.6 - - And requires building bz2 first. - - cd dist\bzip2-1.0.6 - nmake -f makefile.msc - - All of this managed to build bzip2-1.0.6\libbz2.lib, which the Python - project links in. - - -_sqlite3 - Python wrapper for SQLite library. - - Get the source code through - - svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 - - To use the extension module in a Python build tree, copy sqlite3.dll into - the PC/VC6 folder. - - -_ssl - Python wrapper for the secure sockets library. - - Get the latest source code for OpenSSL from - http://www.openssl.org - - You (probably) don't want the "engine" code. For example, don't get - openssl-engine-0.9.6g.tar.gz - - Unpack into the "dist" directory, retaining the folder name from - the archive - for example, the latest stable OpenSSL will install as - dist/openssl-1.0.1c - - You need to use version 1.0.1c of OpenSSL. - - You can install the NASM assembler from - http://www.nasm.us/ - for x86 builds. Put nasmw.exe anywhere in your PATH. - Note: recent releases of nasm only have nasm.exe. Just rename it to - nasmw.exe. - - You can also install ActivePerl from - http://www.activestate.com/activeperl/ - if you like to use the official sources instead of the files from - python's subversion repository. The svn version contains pre-build - makefiles and assembly files. - - The MSVC project simply invokes PC/VC6/build_ssl.py to perform - the build. This Python script locates and builds your OpenSSL - installation, then invokes a simple makefile to build the final .pyd. - - build_ssl.py attempts to catch the most common errors (such as not - being able to find OpenSSL sources, or not being able to find a Perl - that works with OpenSSL) and give a reasonable error message. - If you have a problem that doesn't seem to be handled correctly - (eg, you know you have ActivePerl but we can't find it), please take - a peek at build_ssl.py and suggest patches. Note that build_ssl.py - should be able to be run directly from the command-line. - - build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do - this by hand. - - -YOUR OWN EXTENSION DLLs ------------------------ -If you want to create your own extension module DLL, there's an example -with easy-to-follow instructions in ../PC/example/; read the file -readme.txt there first. diff --git a/PC/VC6/rmpyc.py b/PC/VC6/rmpyc.py deleted file mode 100644 --- a/PC/VC6/rmpyc.py +++ /dev/null @@ -1,25 +0,0 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../../Lib") -print npyc, ".pyc deleted,", npyo, ".pyo deleted" diff --git a/PC/VC6/rt.bat b/PC/VC6/rt.bat deleted file mode 100755 --- a/PC/VC6/rt.bat +++ /dev/null @@ -1,41 +0,0 @@ - at rem Run Tests. Run the regression test suite. - at rem Usage: rt [-d] [-O] [-q] regrtest_args - at rem -d Run Debug build (python_d.exe). Else release build. - at rem -O Run python.exe or python_d.exe (see -d) with -O. - at rem -q "quick" -- normally the tests are run twice, the first time - at rem after deleting all the .py[co] files reachable from Lib/. - at rem -q runs the tests just once, and without deleting .py[co] files. - at rem All leading instances of these switches are shifted off, and - at rem whatever remains is passed to regrtest.py. For example, - at rem rt -O -d -x test_thread - at rem runs - at rem python_d -O ../../lib/test/regrtest.py -x test_thread - at rem twice, and - at rem rt -q -g test_binascii - at rem runs - at rem python_d ../../lib/test/regrtest.py -g test_binascii - at rem to generate the expected-output file for binascii quickly. - at set _exe=python - at set _qmode=no - at set _dashO= - at goto CheckOpts -:Again - at shift -:CheckOpts - at if "%1"=="-O" set _dashO=-O - at if "%1"=="-O" goto Again - at if "%1"=="-q" set _qmode=yes - at if "%1"=="-q" goto Again - at if "%1"=="-d" set _exe=python_d - at if "%1"=="-d" goto Again - at if "%_qmode%"=="yes" goto Qmode - at echo Deleting .pyc/.pyo files ... -@%_exe% rmpyc.py -%_exe% %_dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 - at echo About to run again without deleting .pyc/.pyo first: - at pause -:Qmode -%_exe% %_dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 - at set _exe= - at set _qmode= - at set _dashO= diff --git a/PC/VC6/select.dsp b/PC/VC6/select.dsp deleted file mode 100644 --- a/PC/VC6/select.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="select" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=select - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "select.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "select.mak" CFG="select - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "select - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "select - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "select" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "select - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\select" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./select.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "select - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\select" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt" /out:"./select_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "select - Win32 Release" -# Name "select - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\selectmodule.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/tcl852.patch b/PC/VC6/tcl852.patch deleted file mode 100644 --- a/PC/VC6/tcl852.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- tcl8.5.2\generic\tcl.h Fri Jun 13 03:35:39 2008 -+++ tcl8.5.2\generic\tcl.h Sun Jan 4 16:52:30 2009 -@@ -367,7 +367,7 @@ - typedef struct stati64 Tcl_StatBuf; - # define TCL_LL_MODIFIER "L" - # else /* __BORLANDC__ */ --# if _MSC_VER < 1400 && !defined(_M_IX86) -+# if _MSC_VER < 1400 /*&& !defined(_M_IX86)*/ - typedef struct _stati64 Tcl_StatBuf; - # else - typedef struct _stat64 Tcl_StatBuf; diff --git a/PC/VC6/unicodedata.dsp b/PC/VC6/unicodedata.dsp deleted file mode 100644 --- a/PC/VC6/unicodedata.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="unicodedata" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=unicodedata - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "unicodedata.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "unicodedata.mak" CFG="unicodedata - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "unicodedata - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "unicodedata - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "unicodedata" -# PROP Scc_LocalPath ".." -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "unicodedata - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\unicodedata" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D120000" /dll /machine:I386 /out:"./unicodedata.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "unicodedata - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\unicodedata" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D120000" /dll /debug /machine:I386 /out:"./unicodedata_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "unicodedata - Win32 Release" -# Name "unicodedata - Win32 Debug" -# Begin Source File - -SOURCE=..\..\Modules\unicodedata.c -# End Source File -# End Target -# End Project diff --git a/PC/VC6/winsound.dsp b/PC/VC6/winsound.dsp deleted file mode 100644 --- a/PC/VC6/winsound.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="winsound" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=winsound - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "winsound.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "winsound.mak" CFG="winsound - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "winsound - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "winsound - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "winsound" -# PROP Scc_LocalPath "..\pc" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "winsound - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\winsound" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib winmm.lib user32.lib /nologo /base:"0x1D160000" /dll /machine:I386 /out:"./winsound.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "winsound - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\winsound" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib winmm.lib /nologo /base:"0x1D160000" /dll /debug /machine:I386 /out:"./winsound_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "winsound - Win32 Release" -# Name "winsound - Win32 Debug" -# Begin Source File - -SOURCE=..\winsound.c -# End Source File -# End Target -# End Project diff --git a/PC/VS7.1/Uninstal.wse b/PC/VS7.1/Uninstal.wse deleted file mode 100644 --- a/PC/VS7.1/Uninstal.wse +++ /dev/null @@ -1,514 +0,0 @@ -Document Type: WSE -item: Global - Version=8.14 - Flags=00000100 - Split=1420 - Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - Copy Default=1 - Japanese Font Name=MS Gothic - Japanese Font Size=10 - Start Gradient=0 0 255 - End Gradient=0 0 0 - Windows Flags=00000000000000000000101000001000 - Message Font=MS Sans Serif - Font Size=8 - Disk Label=GLBS - Disk Filename=INSTALL - Patch Flags=0000000000000001 - Patch Threshold=200 - Patch Memory=4096 - Per-User Version ID=1 - Crystal Format=10111100101100000010001001001001 - Step View=&Properties -end -item: Remark - Text=Note from Tim: This is a verbatim copy of Wise's Uninstal.wse, altered at the end to write -end -item: Remark - Text=uninstall info under HKCU instead of HKLM if our DOADMIN var is false. -end -item: Remark -end -item: Remark - Text= Install Support for uninstalling the application. -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%_LOGFILE_PATH_% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH%\UNWISE.EXE -end -item: Compiler Variable If - Variable=_EXE_OS_TYPE_ - Value=WIN32 -end -item: Install File - Source=%_WISE_%\UNWISE32.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable Else -end -item: Install File - Source=%_WISE_%\UNWISE.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install Support for multiple languages -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_PATH% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_LANG%\UNWISE.INI -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=C - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_C_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=D - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_D_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=E - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DEU - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_E_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DEU - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=F - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.PTG - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_F_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.PTG - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=G - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_G_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=H - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_H_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=I - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ITA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_I_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ITA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=J - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DAN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_J_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DAN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=K - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FIN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_K_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FIN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=L - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ISL - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_L_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ISL - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=M - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NLD - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_M_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NLD - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=N - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NOR - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_N_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NOR - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=O - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.SVE - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_O_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.SVE - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=P - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.JPN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_P_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.JPN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install the add/remove or uninstall icon -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH% - Flags=00010100 -end -item: Set Variable - Variable=INST_LOG_PATH - Value=%_LOGFILE_PATH_% - Flags=00010100 -end -item: Check Configuration - Flags=10111011 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Remark - Text=Write uninstall info under HKLM. This if/else/end block added by Tim. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=2 -end -item: Else Statement -end -item: Remark - Text=The same, but write under HKCU instead. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=1 -end -item: End Block -end -item: Else Statement -end -item: Add ProgMan Icon - Group=%GROUP% - Icon Name=Uninstall %APPTITLE% - Command Line=%UNINSTALL_PATH% %INST_LOG_PATH% -end -item: End Block -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit Registry - Total Keys=2 - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%COMPANY% - Value Name=RegCompany - Root=2 - end - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%NAME% - Value Name=RegOwner - Root=2 - end -end -item: End Block -end -item: End Block -end diff --git a/PC/VS7.1/_ctypes.vcproj b/PC/VS7.1/_ctypes.vcproj deleted file mode 100644 --- a/PC/VS7.1/_ctypes.vcproj +++ /dev/null @@ -1,311 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_ctypes_test.vcproj b/PC/VS7.1/_ctypes_test.vcproj deleted file mode 100644 --- a/PC/VS7.1/_ctypes_test.vcproj +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_elementtree.vcproj b/PC/VS7.1/_elementtree.vcproj deleted file mode 100644 --- a/PC/VS7.1/_elementtree.vcproj +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_msi.vcproj b/PC/VS7.1/_msi.vcproj deleted file mode 100644 --- a/PC/VS7.1/_msi.vcproj +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_socket.vcproj b/PC/VS7.1/_socket.vcproj deleted file mode 100644 --- a/PC/VS7.1/_socket.vcproj +++ /dev/null @@ -1,254 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_sqlite3.vcproj b/PC/VS7.1/_sqlite3.vcproj deleted file mode 100644 --- a/PC/VS7.1/_sqlite3.vcproj +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_ssl.mak b/PC/VS7.1/_ssl.mak deleted file mode 100644 --- a/PC/VS7.1/_ssl.mak +++ /dev/null @@ -1,38 +0,0 @@ -EXTRA_LIBS= - -!IFDEF DEBUG -SUFFIX=_d.pyd -TEMP=x86-temp-debug/ -CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32 -SSL_LIB_DIR=$(SSL_DIR)/out32.dbg -!ELSE -SUFFIX=.pyd -TEMP=x86-temp-release/ -CFLAGS=/Ox /MD /LD /DWIN32 -SSL_LIB_DIR=$(SSL_DIR)/out32 -!ENDIF - -INCLUDES=-I ../../Include -I ../../PC -I $(SSL_DIR)/inc32 - -SSL_LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /LIBPATH:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib -SSL_SOURCE=../../Modules/_ssl.c - -HASH_LIBS=gdi32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib -HASH_SOURCE=../../Modules/_hashopenssl.c - -all: _ssl$(SUFFIX) _hashlib$(SUFFIX) - -# Split compile/link into two steps to better support VSExtComp -_ssl$(SUFFIX): $(SSL_SOURCE) $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib ../../PC/*.h ../../Include/*.h - @if not exist "$(TEMP)/_ssl/." mkdir "$(TEMP)/_ssl" - cl /nologo /c $(SSL_SOURCE) $(CFLAGS) /Fo$(TEMP)\_ssl\$*.obj $(INCLUDES) - link /nologo @<< - /dll /out:_ssl$(SUFFIX) $(TEMP)\_ssl\$*.obj $(SSL_LIBS) $(EXTRA_LIBS) -<< - -_hashlib$(SUFFIX): $(HASH_SOURCE) $(SSL_LIB_DIR)/libeay32.lib ../../PC/*.h ../../Include/*.h - @if not exist "$(TEMP)/_hashlib/." mkdir "$(TEMP)/_hashlib" - cl /nologo /c $(HASH_SOURCE) $(CFLAGS) $(EXTRA_CFLAGS) /Fo$(TEMP)\_hashlib\$*.obj $(INCLUDES) - link /nologo @<< - /dll /out:_hashlib$(SUFFIX) $(HASH_LIBS) $(EXTRA_LIBS) $(TEMP)\_hashlib\$*.obj -<< diff --git a/PC/VS7.1/_ssl.vcproj b/PC/VS7.1/_ssl.vcproj deleted file mode 100644 --- a/PC/VS7.1/_ssl.vcproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_testcapi.vcproj b/PC/VS7.1/_testcapi.vcproj deleted file mode 100644 --- a/PC/VS7.1/_testcapi.vcproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/_tkinter.vcproj b/PC/VS7.1/_tkinter.vcproj deleted file mode 100644 --- a/PC/VS7.1/_tkinter.vcproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/amd64_ml64.bat b/PC/VS7.1/amd64_ml64.bat deleted file mode 100644 --- a/PC/VS7.1/amd64_ml64.bat +++ /dev/null @@ -1,17 +0,0 @@ - at echo off -rem Try to find the AMD64 assembler and call it with the supplied arguments. - -set MLEXE=Microsoft Platform SDK\Bin\Win64\x86\AMD64\ml64.EXE - -rem For the environment variables see also -rem http://msdn.microsoft.com/library/en-us/win64/win64/wow64_implementation_details.asp - -if exist "%ProgramFiles%\%MLEXE%" ( - set ML64="%ProgramFiles%\%MLEXE%" -) else if exist "%ProgramW6432%\%MLEXE%" ( - set ML64="%ProgramW6432%\%MLEXE%" -) else ( - set ML64=ml64.exe -) - -%ML64% %* diff --git a/PC/VS7.1/build_ssl.bat b/PC/VS7.1/build_ssl.bat deleted file mode 100644 --- a/PC/VS7.1/build_ssl.bat +++ /dev/null @@ -1,12 +0,0 @@ -if "%1" == "ReleaseAMD64" call "%MSSdk%\SetEnv" /XP64 /RETAIL - - at echo off -if not defined HOST_PYTHON ( - if %1 EQU Debug ( - set HOST_PYTHON=python_d.exe - ) ELSE ( - set HOST_PYTHON=python.exe - ) -) -%HOST_PYTHON% build_ssl.py %1 %2 - diff --git a/PC/VS7.1/build_ssl.py b/PC/VS7.1/build_ssl.py deleted file mode 100644 --- a/PC/VS7.1/build_ssl.py +++ /dev/null @@ -1,181 +0,0 @@ -# Script for building the _ssl and _hashlib modules for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for the actual _ssl.pyd and _hashlib.pyd DLLs. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PCBuild directory. -# -# it should configure and build SSL, then build the _ssl and _hashlib -# Python extensions without intervention. - -import os, sys, re - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen(perl + ' -e "use Win32;"') - fh.read() - rc = fh.close() - if rc: - continue - return perl - print "Can not find a suitable PERL:" - if perls: - print " the following perl interpreters were found:" - for p in perls: - print " ", p - print " None of these versions appear suitable for building OpenSSL" - else: - print " NO perl interpreters were found on this machine at all!" - print " Please install ActivePerl and ensure it appears on your path" - print "The Python SSL module was not built" - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - # note: do not abspath s; the build will fail if any - # higher up directory name has spaces in it. - fnames = os.listdir(s) - except OSError: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print "Found an SSL directory at '%s'" % (best_name,) - else: - print "Could not find an SSL directory in '%s'" % (sources,) - sys.stdout.flush() - return best_name - -def run_configure(configure, do_script): - os.system("perl Configure "+configure) - os.system(do_script) - -def main(): - build_all = "-a" in sys.argv - if sys.argv[1] == "Release": - arch = "x86" - debug = False - configure = "VC-WIN32" - do_script = "ms\\do_masm" - makefile = "ms\\nt.mak" - elif sys.argv[1] == "Debug": - arch = "x86" - debug = True - configure = "VC-WIN32" - do_script = "ms\\do_masm" - makefile="ms\\d32.mak" - elif sys.argv[1] == "ReleaseItanium": - arch = "ia64" - debug = False - configure = "VC-WIN64I" - do_script = "ms\\do_win64i" - makefile = "ms\\nt.mak" - os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" - elif sys.argv[1] == "ReleaseAMD64": - arch="amd64" - debug=False - configure = "VC-WIN64A" - do_script = "ms\\do_win64a" - makefile = "ms\\nt.mak" - os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl is None: - sys.exit(1) - - print "Found a working perl at '%s'" % (perl,) - sys.stdout.flush() - # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("..\\..\\..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - print "Creating the makefiles..." - sys.stdout.flush() - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.dirname(perl) + \ - os.pathsep + \ - os.environ["PATH"] - run_configure(configure, do_script) - if arch=="x86" and debug: - # the do_masm script in openssl doesn't generate a debug - # build makefile so we generate it here: - os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile) - - # Now run make. - makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) - print "Executing ssl makefiles:", makeCommand - sys.stdout.flush() - rc = os.system(makeCommand) - if rc: - print "Executing "+makefile+" failed" - print rc - sys.exit(rc) - finally: - os.chdir(old_cd) - # And finally, we can build the _ssl module itself for Python. - defs = "SSL_DIR=\"%s\"" % (ssl_dir,) - if debug: - defs = defs + " " + "DEBUG=1" - if arch in ('amd64', 'ia64'): - defs = defs + " EXTRA_CFLAGS=/GS- EXTRA_LIBS=bufferoverflowU.lib" - makeCommand = 'nmake /nologo -f _ssl.mak ' + defs + " " + make_flags - print "Executing:", makeCommand - sys.stdout.flush() - rc = os.system(makeCommand) - sys.exit(rc) - -if __name__=='__main__': - main() diff --git a/PC/VS7.1/bz2.vcproj b/PC/VS7.1/bz2.vcproj deleted file mode 100644 --- a/PC/VS7.1/bz2.vcproj +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/db.build b/PC/VS7.1/db.build deleted file mode 100644 --- a/PC/VS7.1/db.build +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/PC/VS7.1/field3.py b/PC/VS7.1/field3.py deleted file mode 100644 --- a/PC/VS7.1/field3.py +++ /dev/null @@ -1,35 +0,0 @@ -# An absurd workaround for the lack of arithmetic in MS's resource compiler. -# After building Python, run this, then paste the output into the appropriate -# part of PC\python_nt.rc. -# Example output: -# -# * For 2.3a0, -# * PY_MICRO_VERSION = 0 -# * PY_RELEASE_LEVEL = 'alpha' = 0xA -# * PY_RELEASE_SERIAL = 1 -# * -# * and 0*1000 + 10*10 + 1 = 101. -# */ -# #define FIELD3 101 - -import sys - -major, minor, micro, level, serial = sys.version_info -levelnum = {'alpha': 0xA, - 'beta': 0xB, - 'candidate': 0xC, - 'final': 0xF, - }[level] -string = sys.version.split()[0] # like '2.3a0' - -print " * For %s," % string -print " * PY_MICRO_VERSION = %d" % micro -print " * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)) -print " * PY_RELEASE_SERIAL = %d" % serial -print " *" - -field3 = micro * 1000 + levelnum * 10 + serial - -print " * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3) -print " */" -print "#define FIELD3", field3 diff --git a/PC/VS7.1/installer.bmp b/PC/VS7.1/installer.bmp deleted file mode 100644 Binary file PC/VS7.1/installer.bmp has changed diff --git a/PC/VS7.1/make_buildinfo.c b/PC/VS7.1/make_buildinfo.c deleted file mode 100644 --- a/PC/VS7.1/make_buildinfo.c +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -#include -#include - -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PC\VS7.1\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\..\\Modules\\getbuildinfo.c instead. - - Currently, subwcrev.exe is found from the registry entries - of TortoiseSVN. - - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. - -*/ - -int make_buildinfo2() -{ - struct _stat st; - HKEY hTortoise; - char command[500]; - DWORD type, size; - if (_stat(".svn", &st) < 0) - return 0; - /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ - if (_stat("no_subwcrev", &st) == 0) - return 0; - if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && - RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) - /* Tortoise not installed */ - return 0; - command[0] = '"'; /* quote the path to the executable */ - size = sizeof(command) - 1; - if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || - type != REG_SZ) - /* Registry corrupted */ - return 0; - strcat(command, "bin\\subwcrev.exe"); - if (_stat(command+1, &st) < 0) - /* subwcrev.exe not part of the release */ - return 0; - strcat(command, "\" ..\\.. ..\\..\\Modules\\getbuildinfo.c getbuildinfo2.c"); - puts(command); fflush(stdout); - if (system(command) < 0) - return 0; - return 1; -} - -int main(int argc, char*argv[]) -{ - char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - int do_unlink, result; - if (argc != 2) { - fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat(command, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat(command, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat(command, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat(command, "-MD "); - strcat(command, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } - - if ((do_unlink = make_buildinfo2())) - strcat(command, "getbuildinfo2.c -DSUBWCREV "); - else - strcat(command, "..\\..\\Modules\\getbuildinfo.c"); - strcat(command, " -Fogetbuildinfo.o -I..\\..\\Include -I..\\..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) - unlink("getbuildinfo2.c"); - if (result < 0) - return EXIT_FAILURE; - return 0; -} diff --git a/PC/VS7.1/make_buildinfo.vcproj b/PC/VS7.1/make_buildinfo.vcproj deleted file mode 100644 --- a/PC/VS7.1/make_buildinfo.vcproj +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/make_versioninfo.vcproj b/PC/VS7.1/make_versioninfo.vcproj deleted file mode 100644 --- a/PC/VS7.1/make_versioninfo.vcproj +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/pcbuild.sln b/PC/VS7.1/pcbuild.sln deleted file mode 100644 --- a/PC/VS7.1/pcbuild.sln +++ /dev/null @@ -1,271 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_socket", "_socket.vcproj", "{324F66C2-44D0-4D50-B979-F9DAE7FD36DB}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ssl", "_ssl.vcproj", "{8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} = {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testcapi", "_testcapi.vcproj", "{59CBF474-9E06-4C50-9142-C44A118BB447}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_tkinter", "_tkinter.vcproj", "{5B51DFF7-5DC0-41F8-8791-A4AB7114A151}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bz2", "bz2.vcproj", "{AC557788-6354-43F7-BE05-C9C8C59A344A}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_versioninfo", "make_versioninfo.vcproj", "{F0E0541E-F17D-430B-97C4-93ADF0DD284E}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pyexpat", "pyexpat.vcproj", "{7E551393-3C43-47F8-9F3F-5BC368A6C487}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" - ProjectSection(ProjectDependencies) = postProject - {F0E0541E-F17D-430B-97C4-93ADF0DD284E} = {F0E0541E-F17D-430B-97C4-93ADF0DD284E} - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select", "select.vcproj", "{97239A56-DBC0-41D2-BC14-C87D9B97D63B}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicodedata", "unicodedata.vcproj", "{FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winsound", "winsound.vcproj", "{51F35FAE-FB92-4B2C-9187-1542C065AD77}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_elementtree", "_elementtree.vcproj", "{1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buildinfo.vcproj", "{C73F0EC1-358B-4177-940F-0846AC8B04CD}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_msi", "_msi.vcproj", "{2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes", "_ctypes.vcproj", "{F22F40F4-D318-40DC-96B3-88DC81CE0894}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "_ctypes_test.vcproj", "{8CF334D9-4F82-42EB-97AF-83592C5AFD2F}" - ProjectSection(ProjectDependencies) = postProject - {F22F40F4-D318-40DC-96B3-88DC81CE0894} = {F22F40F4-D318-40DC-96B3-88DC81CE0894} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{2FF0A312-22F9-4C34-B070-842916DE27A9}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - ReleaseAMD64 = ReleaseAMD64 - ReleaseItanium = ReleaseItanium - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Debug.ActiveCfg = Debug|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Debug.Build.0 = Debug|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Release.ActiveCfg = Release|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.Release.Build.0 = Release|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {324F66C2-44D0-4D50-B979-F9DAE7FD36DB}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Debug.ActiveCfg = Debug|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Debug.Build.0 = Debug|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Release.ActiveCfg = Release|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.Release.Build.0 = Release|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {8E85BA54-8A47-4C8B-B72E-8E17579CC6D7}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Debug.ActiveCfg = Debug|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Debug.Build.0 = Debug|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Release.ActiveCfg = Release|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.Release.Build.0 = Release|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {59CBF474-9E06-4C50-9142-C44A118BB447}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Debug.ActiveCfg = Debug|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Debug.Build.0 = Debug|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Release.ActiveCfg = Release|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.Release.Build.0 = Release|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {5B51DFF7-5DC0-41F8-8791-A4AB7114A151}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Debug.ActiveCfg = Debug|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Debug.Build.0 = Debug|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Release.ActiveCfg = Release|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.Release.Build.0 = Release|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {AC557788-6354-43F7-BE05-C9C8C59A344A}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug.ActiveCfg = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug.Build.0 = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium.Build.0 = Release|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Debug.ActiveCfg = Debug|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Debug.Build.0 = Debug|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Release.ActiveCfg = Release|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.Release.Build.0 = Release|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {7E551393-3C43-47F8-9F3F-5BC368A6C487}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug.ActiveCfg = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug.Build.0 = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release.ActiveCfg = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug.ActiveCfg = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug.Build.0 = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release.ActiveCfg = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug.ActiveCfg = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug.Build.0 = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release.ActiveCfg = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug.ActiveCfg = Debug|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug.Build.0 = Debug|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release.ActiveCfg = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release.Build.0 = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug.ActiveCfg = Debug|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug.Build.0 = Debug|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release.ActiveCfg = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release.Build.0 = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug.ActiveCfg = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug.Build.0 = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseAMD64.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium.ActiveCfg = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug.ActiveCfg = Debug|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug.Build.0 = Debug|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release.ActiveCfg = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release.Build.0 = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug.ActiveCfg = Debug|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug.Build.0 = Debug|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release.ActiveCfg = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release.Build.0 = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug.ActiveCfg = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug.Build.0 = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug.ActiveCfg = Debug|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug.Build.0 = Debug|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release.ActiveCfg = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug.ActiveCfg = Debug|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug.Build.0 = Debug|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release.ActiveCfg = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release.Build.0 = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug.ActiveCfg = Debug|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug.Build.0 = Debug|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release.ActiveCfg = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release.Build.0 = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug.ActiveCfg = Debug|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug.Build.0 = Debug|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release.ActiveCfg = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release.Build.0 = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64.ActiveCfg = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64.Build.0 = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium.Build.0 = ReleaseItanium|Win32 - EndGlobalSection - GlobalSection(SolutionItems) = postSolution - ..\Modules\getbuildinfo.c = ..\Modules\getbuildinfo.c - readme.txt = readme.txt - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/PC/VS7.1/pyexpat.vcproj b/PC/VS7.1/pyexpat.vcproj deleted file mode 100644 --- a/PC/VS7.1/pyexpat.vcproj +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/python.build b/PC/VS7.1/python.build deleted file mode 100644 --- a/PC/VS7.1/python.build +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/python.iss b/PC/VS7.1/python.iss deleted file mode 100644 --- a/PC/VS7.1/python.iss +++ /dev/null @@ -1,340 +0,0 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -; This is the whole ball of wax for an Inno installer for Python. -; To use, download Inno Setup from http://www.jrsoftware.org/isdl.htm/, -; install it, and double-click on this file. That launches the Inno -; script compiler. The GUI is extemely simple, and has only one button -; you may not recognize instantly: click it. You're done. It builds -; the installer into PCBuild/Python-2.2a1.exe. Size and speed of the -; installer are competitive with the Wise installer; Inno uninstall -; seems much quicker than Wise (but also feebler, and the uninstall -; log is in some un(human)readable binary format). -; -; What's Done -; ----------- -; All the usual Windows Python files are installed by this now. -; All the usual Windows Python Start menu entries are created and -; work fine. -; .py, .pyw, .pyc and .pyo extensions are registered. -; PROBLEM: Inno uninstall does not restore their previous registry -; associations (if any). Wise did. This will make life -; difficult for alpha (etc) testers. -; The Python install is fully functional for "typical" uses. -; -; What's Not Done -; --------------- -; None of "Mark Hammond's" registry entries are written. -; No installation of files is done into the system dir: -; The MS DLLs aren't handled at all by this yet. -; Python22.dll is unpacked into the main Python dir. -; -; Inno can't do different things on NT/2000 depending on whether the user -; has Admin privileges, so I don't know how to "solve" either of those, -; short of building two installers (one *requiring* Admin privs, the -; other not doing anything that needs Admin privs). -; -; Inno has no concept of variables, so lots of lines in this file need -; to be fiddled by hand across releases. Simplest way out: stick this -; file in a giant triple-quoted r-string (note that backslashes are -; required all over the place here -- forward slashes DON'T WORK in -; Inno), and use %(yadda)s string interpolation to do substitutions; i.e., -; write a very simple Python program to *produce* this script. - -[Setup] -AppName=Python and combined Win32 Extensions -AppVerName=Python 2.2.2 and combined Win32 Extensions 150 -AppId=Python 2.2.2.150 -AppVersion=2.2.2.150 -AppCopyright=Python is Copyright ? 2001 Python Software Foundation. Win32 Extensions are Copyright ? 1996-2001 Greg Stein and Mark Hammond. - -; Default install dir; value of {app} later (unless user overrides). -; {sd} = system root drive, probably "C:". -DefaultDirName={sd}\Python22 -;DefaultDirName={pf}\Python - -; Start menu folder name; value of {group} later (unless user overrides). -DefaultGroupName=Python 2.2 - -; Point SourceDir to one above PCBuild = src. -; means this script can run unchanged from anyone's CVS tree, no matter -; what they called the top-level directories. -SourceDir=. -OutputDir=.. -OutputBaseFilename=Python-2.2.2-Win32-150-Setup - -AppPublisher=PythonLabs at Digital Creations -AppPublisherURL=http://www.python.org -AppSupportURL=http://www.python.org -AppUpdatesURL=http://www.python.org - -AlwaysCreateUninstallIcon=true -ChangesAssociations=true -UninstallLogMode=new -AllowNoIcons=true -AdminPrivilegesRequired=true -UninstallDisplayIcon={app}\pyc.ico -WizardDebug=false - -; The fewer screens the better; leave these commented. - -Compression=bzip -InfoBeforeFile=LICENSE.txt -;InfoBeforeFile=Misc\NEWS - -; uncomment the following line if you want your installation to run on NT 3.51 too. -; MinVersion=4,3.51 - -[Types] -Name: normal; Description: Select desired components; Flags: iscustom - -[Components] -Name: main; Description: Python and Win32 Extensions; Types: normal -Name: docs; Description: Python documentation (HTML); Types: normal -Name: tk; Description: TCL/TK, tkinter, and Idle; Types: normal -Name: tools; Description: Python utility scripts (Tools\); Types: normal -Name: test; Description: Python test suite (Lib\test\); Types: normal - -[Tasks] -Name: extensions; Description: Register file associations (.py, .pyw, .pyc, .pyo); Components: main; Check: IsAdminLoggedOn - -[Files] -; Caution: Using forward slashes instead screws up in amazing ways. -; Unknown: By the time Components (and other attrs) are added to these lines, they're -; going to get awfully long. But don't see a way to continue logical lines across -; physical lines. - -Source: LICENSE.txt; DestDir: {app}; CopyMode: alwaysoverwrite -Source: README.txt; DestDir: {app}; CopyMode: alwaysoverwrite -Source: News.txt; DestDir: {app}; CopyMode: alwaysoverwrite -Source: *.ico; DestDir: {app}; CopyMode: alwaysoverwrite; Components: main - -Source: python.exe; DestDir: {app}; CopyMode: alwaysoverwrite; Components: main -Source: pythonw.exe; DestDir: {app}; CopyMode: alwaysoverwrite; Components: main - - -Source: DLLs\tcl83.dll; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: tk -Source: DLLs\tk83.dll; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: tk -Source: tcl\*.*; DestDir: {app}\tcl; CopyMode: alwaysoverwrite; Components: tk; Flags: recursesubdirs - -Source: sysdir\python22.dll; DestDir: {sys}; CopyMode: alwaysskipifsameorolder; Components: main; Flags: sharedfile restartreplace -Source: sysdir\PyWinTypes22.dll; DestDir: {sys}; CopyMode: alwaysskipifsameorolder; Components: main; Flags: restartreplace sharedfile -Source: sysdir\pythoncom22.dll; DestDir: {sys}; CopyMode: alwaysskipifsameorolder; Components: main; Flags: restartreplace sharedfile - -Source: DLLs\_socket.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_socket.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_sre.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_sre.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_symtable.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_symtable.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_testcapi.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\_testcapi.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\_tkinter.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: tk -Source: libs\_tkinter.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: tk - -Source: DLLs\mmap.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\mmap.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\parser.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\parser.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\pyexpat.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\pyexpat.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\select.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\select.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\unicodedata.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\unicodedata.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\winreg.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\winreg.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\winsound.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\winsound.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\zlib.pyd; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main -Source: libs\zlib.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: libs\python22.lib; DestDir: {app}\libs; CopyMode: alwaysoverwrite; Components: main - -Source: DLLs\expat.dll; DestDir: {app}\DLLs; CopyMode: alwaysoverwrite; Components: main - - - -Source: Lib\*.py; DestDir: {app}\Lib; CopyMode: alwaysoverwrite; Components: main -Source: Lib\compiler\*.*; DestDir: {app}\Lib\compiler; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\distutils\*.*; DestDir: {app}\Lib\distutils; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\email\*.*; DestDir: {app}\Lib\email; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\encodings\*.*; DestDir: {app}\Lib\encodings; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\hotshot\*.*; DestDir: {app}\Lib\hotshot; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\lib-old\*.*; DestDir: {app}\Lib\lib-old; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\xml\*.*; DestDir: {app}\Lib\xml; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\hotshot\*.*; DestDir: {app}\Lib\hotshot; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\test\*.*; DestDir: {app}\Lib\test; CopyMode: alwaysoverwrite; Components: test; Flags: recursesubdirs -Source: Lib\tkinter\*.py; DestDir: {app}\Lib\tkinter; CopyMode: alwaysoverwrite; Components: tk; Flags: recursesubdirs - -Source: Lib\site-packages\README.txt; DestDir: {app}\Lib\site-packages; CopyMode: alwaysoverwrite; Components: main - -Source: Lib\site-packages\PyWin32.chm; DestDir: {app}\Lib\site-packages; CopyMode: alwaysoverwrite; Components: docs -Source: Lib\site-packages\win32\*.*; DestDir: {app}\Lib\site-packages\win32; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\site-packages\win32com\*.*; DestDir: {app}\Lib\site-packages\win32com; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs -Source: Lib\site-packages\win32comext\*.*; DestDir: {app}\Lib\site-packages\win32comext; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs - -Source: include\*.h; DestDir: {app}\include; CopyMode: alwaysoverwrite; Components: main - -Source: Tools\idle\*.*; DestDir: {app}\Tools\idle; CopyMode: alwaysoverwrite; Components: tk; Flags: recursesubdirs - -Source: Tools\pynche\*.*; DestDir: {app}\Tools\pynche; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs -Source: Tools\scripts\*.*; DestDir: {app}\Tools\Scripts; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs -Source: Tools\webchecker\*.*; DestDir: {app}\Tools\webchecker; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs -Source: Tools\versioncheck\*.*; DestDir: {app}\Tools\versioncheck; CopyMode: alwaysoverwrite; Components: tools; Flags: recursesubdirs - -Source: Doc\*.*; DestDir: {app}\Doc; CopyMode: alwaysoverwrite; Flags: recursesubdirs; Components: docs - - -[Icons] -Name: {group}\Python (command line); Filename: {app}\python.exe; WorkingDir: {app}; Components: main -Name: {group}\Python Manuals; Filename: {app}\Doc\index.html; WorkingDir: {app}; Components: docs -Name: {group}\Win32 Extensions Help; Filename: {app}\Lib\site-packages\PyWin32.chm; WorkingDir: {app}\Lib\site-packages; Components: docs -Name: {group}\Module Docs; Filename: {app}\pythonw.exe; WorkingDir: {app}; Parameters: """{app}\Tools\Scripts\pydoc.pyw"""; Components: tools -Name: {group}\IDLE (Python GUI); Filename: {app}\pythonw.exe; WorkingDir: {app}; Parameters: """{app}\Tools\idle\idle.pyw"""; Components: tools - -[Registry] -; Register .py -Tasks: extensions; Root: HKCR; Subkey: .py; ValueType: string; ValueName: ; ValueData: Python File; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: .py; ValueType: string; ValueName: Content Type; ValueData: text/plain; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: Python File; ValueType: string; ValueName: ; ValueData: Python File; Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: Python File\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\Py.ico -Tasks: extensions; Root: HKCR; Subkey: Python File\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\python.exe"" ""%1"" %*" - -; Register .pyc -Tasks: extensions; Root: HKCR; Subkey: .pyc; ValueType: string; ValueName: ; ValueData: Python CompiledFile; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: Python CompiledFile; ValueType: string; ValueName: ; ValueData: Compiled Python File; Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: Python CompiledFile\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\pyc.ico -Tasks: extensions; Root: HKCR; Subkey: Python CompiledFile\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\python.exe"" ""%1"" %*" - -; Register .pyo -Tasks: extensions; Root: HKCR; Subkey: .pyo; ValueType: string; ValueName: ; ValueData: Python CompiledFile; Flags: uninsdeletevalue - -; Register .pyw -Tasks: extensions; Root: HKCR; Subkey: .pyw; ValueType: string; ValueName: ; ValueData: Python NoConFile; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: .pyw; ValueType: string; ValueName: Content Type; ValueData: text/plain; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: Python NoConFile; ValueType: string; ValueName: ; ValueData: Python File (no console); Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: Python NoConFile\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\Py.ico -Tasks: extensions; Root: HKCR; Subkey: Python NoConFile\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\pythonw.exe"" ""%1"" %*" - - -; Python Registry Keys -Root: HKLM; Subkey: SOFTWARE\Python; Flags: uninsdeletekeyifempty; Check: IsAdminLoggedOn -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\PythonPath; ValueData: "{app}\Lib;{app}\DLLs"; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\PythonPath\win32; ValueData: "{app}\lib\site-packages\win32;{app}\lib\site-packages\win32\lib"; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\PythonPath\win32com; ValueData: C:\Python\lib\site-packages; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Modules; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Modules\pythoncom; ValueData: {sys}\pythoncom22.dll; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Modules\pywintypes; ValueData: {sys}\PyWinTypes22.dll; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\InstallPath; ValueData: {app}; Flags: uninsdeletekeyifempty; ValueType: string -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\InstallPath\InstallGroup; ValueData: {group}; Flags: uninsdeletekey -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Help; Flags: uninsdeletekeyifempty -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Help\Main Python Documentation; ValueType: string; ValueData: {app}\Doc\index.html; Flags: uninsdeletekey; Components: docs -Root: HKLM; Subkey: SOFTWARE\Python\PythonCore\2.2\Help\Python Win32 Documentation; ValueType: string; ValueData: {app}\lib\site-packages\PyWin32.chm; Flags: uninsdeletekey; Components: docs - -[_ISTool] -EnableISX=true - - -[Code] -Program Setup; - -Function IsAdminNotLoggedOn(): Boolean; -begin - Result := Not IsAdminLoggedOn(); -end; - -begin -end. - - - - -[UninstallDelete] -Name: {app}\Lib\compiler\*.pyc; Type: files -Name: {app}\Lib\compiler\*.pyo; Type: files -Name: {app}\Lib\compiler; Type: dirifempty -Name: {app}\Lib\distutils\command\*.pyc; Type: files -Name: {app}\Lib\distutils\command\*.pyo; Type: files -Name: {app}\Lib\distutils\command; Type: dirifempty -Name: {app}\Lib\distutils\*.pyc; Type: files -Name: {app}\Lib\distutils\*.pyo; Type: files -Name: {app}\Lib\distutils; Type: dirifempty -Name: {app}\Lib\email\test\*.pyc; Type: files -Name: {app}\Lib\email\test\*.pyo; Type: files -Name: {app}\Lib\email\test; Type: dirifempty -Name: {app}\Lib\email\*.pyc; Type: files -Name: {app}\Lib\email\*.pyo; Type: files -Name: {app}\Lib\email; Type: dirifempty -Name: {app}\Lib\encodings\*.pyc; Type: files -Name: {app}\Lib\encodings\*.pyo; Type: files -Name: {app}\Lib\encodings; Type: dirifempty -Name: {app}\Lib\hotshot\*.pyc; Type: files -Name: {app}\Lib\hotshot\*.pyo; Type: files -Name: {app}\Lib\hotshot; Type: dirifempty -Name: {app}\Lib\lib-old\*.pyc; Type: files -Name: {app}\Lib\lib-old\*.pyo; Type: files -Name: {app}\Lib\lib-old; Type: dirifempty -Name: {app}\Lib\tkinter\*.pyc; Type: files -Name: {app}\Lib\tkinter\*.pyo; Type: files -Name: {app}\Lib\tkinter; Type: dirifempty -Name: {app}\Lib\test\*.pyc; Type: files -Name: {app}\Lib\test\*.pyo; Type: files -Name: {app}\Lib\test; Type: dirifempty -Name: {app}\Lib\xml\dom\*.pyc; Type: files -Name: {app}\Lib\xml\dom\*.pyo; Type: files -Name: {app}\Lib\xml\dom; Type: dirifempty -Name: {app}\Lib\xml\parsers\*.pyc; Type: files -Name: {app}\Lib\xml\parsers\*.pyo; Type: files -Name: {app}\Lib\xml\parsers; Type: dirifempty -Name: {app}\Lib\xml\sax\*.pyc; Type: files -Name: {app}\Lib\xml\sax\*.pyo; Type: files -Name: {app}\Lib\xml\sax; Type: dirifempty -Name: {app}\Lib\xml\*.pyc; Type: files -Name: {app}\Lib\xml\*.pyo; Type: files -Name: {app}\Lib\xml; Type: dirifempty - -Name: {app}\Lib\site-packages\win32; Type: filesandordirs -Name: {app}\Lib\site-packages\win32com; Type: filesandordirs -Name: {app}\Lib\site-packages\win32comext; Type: filesandordirs -Name: {app}\Lib\site-packages\pythoncom.py*; Type: files -Name: {app}\Lib\site-packages; Type: dirifempty - -Name: {app}\Lib\*.pyc; Type: files -Name: {app}\Lib; Type: dirifempty - -Name: {app}\Tools\pynche\*.pyc; Type: files -Name: {app}\Tools\pynche\*.pyo; Type: files -Name: {app}\Tools\pynche; Type: dirifempty - -Name: {app}\Tools\idle\*.pyc; Type: files -Name: {app}\Tools\idle\*.pyo; Type: files -Name: {app}\Tools\idle; Type: dirifempty - -Name: {app}\Tools\scripts\*.pyc; Type: files -Name: {app}\Tools\scripts\*.pyo; Type: files -Name: {app}\Tools\scripts; Type: dirifempty - -Name: {app}\Tools\versioncheck\*.pyc; Type: files -Name: {app}\Tools\versioncheck\*.pyo; Type: files -Name: {app}\Tools\versioncheck; Type: dirifempty - -Name: {app}\Tools\webchecker\*.pyc; Type: files -Name: {app}\Tools\webchecker\*.pyo; Type: files -Name: {app}\Tools\webchecker; Type: dirifempty - -Name: {app}\Tools; Type: dirifempty - diff --git a/PC/VS7.1/python.vcproj b/PC/VS7.1/python.vcproj deleted file mode 100644 --- a/PC/VS7.1/python.vcproj +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/python20.wse b/PC/VS7.1/python20.wse deleted file mode 100644 --- a/PC/VS7.1/python20.wse +++ /dev/null @@ -1,3112 +0,0 @@ -Document Type: WSE -item: Global - Version=9.0 - Title=Python 2.4a1 - Flags=00010100 - Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - Japanese Font Name=MS Gothic - Japanese Font Size=10 - Start Gradient=0 255 0 - End Gradient=0 128 0 - Windows Flags=00000100000011010010010100001010 - Log Pathname=%MAINDIR%\INSTALL.LOG - Message Font=MS Sans Serif - Font Size=8 - Pages Modified=00010000011101000000000100000111 - Extra Pages=00000000000000000000000010110010 - Disk Filename=SETUP - Patch Flags=0000000000001001 - Patch Threshold=85 - Patch Memory=4000 - MIF PDF Version=1.0 - MIF SMS Version=2.0 - EXE Filename=Python-2.4a1.exe - Dialogs Version=8 - Version File=2.4a1 - Version Description=Python Programming Language - Version Copyright=?2001-2007 Python Software Foundation - Version Company=Python Software Foundation - Crystal Format=10111100101100000010001001001001 - Step View=&All - Variable Name1=_WISE_ - Variable Description1=WISE root directory - Variable Default1=C:\Programme\Wise Installation System - Variable Flags1=00001000 - Variable Name2=_TCLDIR_ - Variable Description2=The directory in which the Tcl/Tk installation - Variable Description2=lives. This must be a sibling of the Python - Variable Description2=directory. - Variable Default2=tcl84 - Variable Flags2=00001000 - Variable Name3=_DOC_ - Variable Description3=The unpacked HTML doc directory. - Variable Default3=..\html - Variable Flags3=00001001 - Variable Name4=_SYS_ - Variable Description4=System directory (where to find MSVCRT.DLL) - Variable Default4=C:\Windows\System - Variable Values4=C:\Windows\System - Variable Values4=C:\WINNT\System32 - Variable Values4=C:\Code\MSDLLs - Variable Values4=C:\Windows\System32 - Variable Flags4=00000010 - Variable Name5=_PYMAJOR_ - Variable Description5=Python major version number; the 2 in 2.3. - Variable Default5=2 - Variable Flags5=00001000 - Variable Name6=_PYMINOR_ - Variable Description6=Python minor version number; the 3 in 2.3 - Variable Default6=3 - Variable Flags6=00001000 - Variable Name7=_DOADMIN_ - Variable Description7=The initial value for %DOADMIN%. - Variable Description7=When 0, we never try to write under HKLM, - Variable Description7=and install the Python + MS runtime DLLs in - Variable Description7=the Python directory instead of the system dir. - Variable Default7=1 - Variable Values7=1 - Variable Values7=0 - Variable Flags7=00001010 - Variable Name8=_ALIASNAME_ - Variable Flags8=00001000 - Variable Name9=_ALIASPATH_ - Variable Flags9=00001000 - Variable Name10=_ALIASTYPE_ - Variable Flags10=00001000 -end -item: Set Variable - Variable=PYVER_STRING - Value=2.3 -end -item: Remark -end -item: Remark - Text=When the version number changes, set the compiler -end -item: Remark - Text=vrbls _PYMAJOR_ and _PYMINOR_. -end -item: Remark - Text=Nothing in the script below should need fiddling then. -end -item: Remark - Text=Other things that need fiddling: -end -item: Remark - Text= PYVER_STRING above. -end -item: Remark - Text= The "Title:" in the upper left corner of the GUI. -end -item: Remark - Text= Build Settings and Version Resource on step 6 (Finish) of the Installation Expert -end -item: Remark - Text= Be sure to select Steps->All or you may not see these! -end -item: Remark -end -item: Remark - Text=When the version of Tcl/Tk changes, the compiler vrbl -end -item: Remark - Text=_TCLDIR_ may also need to be changed. -end -item: Remark -end -item: Set Variable - Variable=APPTITLE - Value=Python %PYVER_STRING% -end -item: Remark - Text=PY_VERSION should be major.minor only; used to create the registry key; must match MS_DLL_ID in python_nt.rc -end -item: Set Variable - Variable=PY_VERSION - Value=%_PYMAJOR_%.%_PYMINOR_% -end -item: Remark - Text=GROUP is the Start menu group name; user can override. -end -item: Set Variable - Variable=GROUP - Value=Python %PY_VERSION% - Flags=10000000 -end -item: Remark - Text=MAINDIR is the app directory; user can override. -end -item: Set Variable - Variable=MAINDIR - Value=Python%_PYMAJOR_%%_PYMINOR_% -end -item: Remark -end -item: Set Variable - Variable=DOADMIN - Value=%_DOADMIN_% -end -item: Remark - Text=Give non-admin users a chance to abort. -end -item: Check Configuration - Flags=10011111 -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: Display Message - Title=Doing non-admin install - Text=The current login does not have Administrator Privileges on this machine. Python will install its registry information into the per-user area only for the current login, instead of into the per-machine area for every account on this machine. Some advanced uses of Python may not work as a result (for example, running a Python script as a service). - Text= - Text=If this is not what you want, please click Cancel to abort this installation, log on as an Administrator, and start the installation again. - Flags=00001000 -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=Note from Tim: the "stop" on the next line is actually "pause". -end -item: Open/Close INSTALL.LOG - Flags=00000001 -end -item: Remark - Text=If the destination system does not have a writable Windows\System directory, system files will be written to the Windows\ directory -end -item: Check if File/Dir Exists - Pathname=%SYS% - Flags=10000100 -end -item: Set Variable - Variable=SYS - Value=%WIN% -end -item: End Block -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=COMMON - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files\Common Files - Value Name=CommonFilesDir - Flags=00000100 -end -item: Get Registry Key Value - Variable=PROGRAM_FILES - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files - Value Name=ProgramFilesDir - Flags=00000100 -end -item: Set Variable - Variable=EXPLORER - Value=1 -end -item: End Block -end -item: Remark - Text=Note from Tim: The Wizard hardcod "C:" at the start of the replacement text for MAINDIR. -end -item: Remark - Text=That's not appropriate if the system drive doesn't happen to be C:. -end -item: Remark - Text=I removed the "C:", and that did the right thing for two people who tested it on non-C: machines, -end -item: Remark - Text=but it's unclear whether it will always do the right thing. -end -item: Set Variable - Variable=MAINDIR - Value=\%MAINDIR% - Flags=00001100 -end -item: Remark - Text=BACKUP is the variable that holds the path that all backup files will be copied to when overwritten -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP - Flags=10000000 -end -item: Remark - Text=DOBACKUP determines if a backup will be performed. The possible values are A (do backup) or B (do not do backup) -end -item: Set Variable - Variable=DOBACKUP - Value=A -end -item: Remark - Text=BRANDING determines if the installation will be branded with a name and company. By default, this is written to the INST directory (installation media). -end -item: Set Variable - Variable=BRANDING - Value=0 -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: Read INI Value - Variable=NAME - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Name -end -item: Read INI Value - Variable=COMPANY - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Company -end -item: If/While Statement - Variable=NAME -end -item: Set Variable - Variable=DOBRAND - Value=1 -end -item: Get System Information - Variable=NAME - Flags=00000110 -end -item: Get System Information - Variable=COMPANY - Flags=00000111 -end -item: End Block -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: Remark - Text=Set vrbls for the "Advanced Options" subdialog of Components. -end -item: Set Variable - Variable=SELECT_ADMIN - Value=A -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=SELECT_ADMIN - Value=B -end -item: End Block -end -item: Remark -end -item: Remark - Text=TASKS values: -end -item: Remark - Text=A: Register file extensions -end -item: Remark - Text=B: Create Start Menu shortcuts -end -item: Set Variable - Variable=TASKS - Value=AB -end -item: Remark -end -item: Remark - Text=COMPONENTS values: -end -item: Remark - Text=A: interpreter and libraries -end -item: Remark - Text=B: Tcl/Tk -end -item: Remark - Text=C: docs -end -item: Remark - Text=D: tools -end -item: Remark - Text=E: test suite -end -item: Set Variable - Variable=COMPONENTS - Value=ABCDE -end -item: Remark -end -item: Remark - Text=March thru the user GUI. -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Dialog=Select Destination Directory - Dialog=Backup Replaced Files - Dialog=Select Components - Dialog=Select Program Manager Group - Variable= - Variable= - Variable= - Variable=TASKS - Value= - Value= - Value= - Value=B - Compare=0 - Compare=0 - Compare=0 - Compare=3 - Flags=00000011 -end -item: If/While Statement - Variable=DISPLAY - Value=Start Installation -end -item: Set Variable - Variable=SUMMARY - Value=Install directory: %MAINDIR%%CRLF% -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing admin install.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing non-admin install.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Make backups, into %BACKUP%%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't make backups.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Components:%CRLF% - Flags=00000001 -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python interpreter and libraries%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tcl/Tk (Tkinter, IDLE, pydoc)%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python documentation%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tool and utility scripts%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python test suite%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Register file extensions.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't register file extensions.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Start Menu group: %GROUP%%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%No Start Menu shortcuts.%CRLF% - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Custom Dialog Set - Name=Select Destination Directory - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 11 323 33 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Destination Directory - Text French=S?lectionner le r?pertoire de destination - Text German=Zielverzeichnis w?hlen - Text Spanish=Seleccione el directorio de destino - Text Italian=Selezionare Directory di destinazione - end - item: Listbox - Rectangle=108 58 321 219 - Variable=MAINDIR - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000010000000101000001 - Flags=0000110000001010 - Text=%MAINDIR% - Text= - end - item: Static - Rectangle=108 40 313 58 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Please select a directory for the %APPTITLE% files. - end - end - item: Dialog - Title=Select Destination Directory - Title French=S?lectionner le r?pertoire de destination - Title German=Zielverzeichnis w?hlen - Title Spanish=Seleccione el directorio de destino - Title Italian=Selezionare Directory di destinazione - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 6 204 186 - Variable=MAINDIR - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%MAINDIR% - Text French=%MAINDIR% - Text German=%MAINDIR% - Text Spanish=%MAINDIR% - Text Italian=%MAINDIR% - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Spanish=Aceptar - Text Italian=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=MAINDIR - Value=%MAINDIR_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Spanish=Cancelar - Text Italian=Annulla - end - end -end -item: Custom Dialog Set - Name=Backup Replaced Files - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Fichiers de Sauvegarde Remplac?s - Title German=Sicherungskopie von ersetzten Dateien erstellen - Title Portuguese=Ficheiros substitu?dos de seguran?a - Title Spanish=Copias de seguridad de los archivos reemplazados - Title Italian=Backup file sostituiti - Title Danish=Sikkerhedskopiering af erstattede filer - Title Dutch=Vervangen bestanden kopi?ren - Title Norwegian=Sikkerhetskopiere erstattede filer - Title Swedish=S?kerhetskopiera utbytta filer - Width=350 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 251 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suivant> - Text German=&Weiter> - Text Portuguese=&Pr?ximo> - Text Spanish=&Siguiente > - Text Italian=&Avanti > - Text Danish=&N?ste> - Text Dutch=&Volgende> - Text Norwegian=&Neste> - Text Swedish=&N?sta > - end - item: Push Button - Rectangle=131 234 188 251 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=<&Retour - Text German=<&Zur?ck - Text Portuguese=<&Retornar - Text Spanish=<&Retroceder - Text Italian=< &Indietro - Text Danish=<&Tilbage - Text Dutch=<&Terug - Text Norwegian=<&Tilbake - Text Swedish=< &Tillbaka - end - item: Push Button - Rectangle=278 234 330 251 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Annuller - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - item: Static - Rectangle=11 221 329 223 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 46 320 98 - Create Flags=01010000000000000000000000000000 - Text=This installation program can create backup copies of all files replaced during the installation. These files will be used when the software is uninstalled and a rollback is requested. If backup copies are not created, you will only be able to uninstall the software and not roll the system back to a previous state. - Text= - Text=Do you want to create backups of replaced files? - Text French=Le programme d'installation peut cr?er des copies de sauvegarde de tous les fichiers remplac?s pendant l'installation. Ces fichiers sont utilis?s au cas o? le logiciel est d?sinstall? et que l'on proc?de ? la reprise du syst?me. Si les copies de sauvegarde ne sont pas cr??es, on ne pourra que d?sinstaller le logiciel sans reprendre le syst?me ? un ?tat pr?c?dent. Voulez-vous cr?er une sauvegarde des fichiers remplac?s ? - Text German=Dieses Installationsprogramm kann Sicherungskopien von allen w?hrend der Installation ersetzten Dateien erstellen. Diese Dateien werden zur R?ckg?ngigmachung der Installation und bei Anforderung eines Rollbacks verwendet. Ohne Sicherungskopien ist nur eine R?ckg?ngigmachung der Installation m?glich, nicht aber ein Rollback des Systems. Sicherungskopien der ersetzten Dateien erstellen? - Text Portuguese=Este programa de instala??o pode criar c?pias de seguran?a de todos os ficheiros substitu?dos durante a instala??o. Estes ficheiros ser?o utilizados quando o programa for desinstalado e for requisitada uma retomada. Se as c?pias de seguran?a n?o forem criadas, s? poder? desinstalar o programa e n?o pode retomar um estado anterior do sistema. Deseja criar c?pias de seguran?a dos ficheiros substitu?dos? - Text Spanish=Este programa de instalaci?n puede crear copias de seguridad de todos los archivos reemplazados durante la instalaci?n. Estos archivos se utilizar?n cuando se desinstale el software y se solicite volver al estado anterior. Si no se crean copias de seguridad, ?nicamente podr? desinstalar el software y no podr? devolver el sistema al estado anterior. ?Desea crear archivos de seguridad de los archivos reemplazados? - Text Italian=Questo programma di installazione pu? creare copie di backup di tutti i file sostituiti durante l?installazione. Questi file saranno usati quando il software sar? disinstallato e sar? richiesto un ritorno allo stato precedente. Se non crei le copie di backup, potrai solo disinstallare il software, ma non potrai riportare il sistema allo stato precedente. Vuoi creare i file di backup dei file sostituiti? - Text Danish=Dette installationsprogram kan oprette sikkerhedskopier af alle filer, som erstattes under installationen. Disse filer benyttes, n?r softwaren fjernes, og den tidligere systemkonfiguration genetableres. Hvis der ikke oprettes sikkerhedskopier, kan du kun fjerne den installerede software og ikke genetablere den tidligere systemkonfiguration. Vil du oprette sikkerhedskopier af filer, som erstattes? - Text Dutch=Dit installatieprogramma kan kopie?n maken van alle bestanden die tijdens de installatie worden vervangen. Deze worden dan gebruikt als de software-installatie ongedaan wordt gemaakt en u het systeem wilt laten terugkeren naar de oorspronkelijke staat. Als er geen back-up kopie?n worden gemaakt, kunt u de software enkel verwijderen maar het systeem niet in de oorspronkelijke staat terugbrengen. Wilt u een back-up maken van de vervangen bestanden? - Text Norwegian=Dette installasjonsprogrammet kan lage sikkerhetskopier av alle filer som blir erstattet under installasjonen. Disse filene vil tas i bruk n?r programvaren er avinstallert og det er behov for tilbakestilling. Hvis det ikke er laget sikkerhetskopier, kan du kun avinstallere programvaren og ikke stille systemet tilbake til tidligere status. ?nsker du ? lage sikkerhetskopier av de filene som blir erstattet n?? - Text Swedish=Installationsprogrammet kan skapa s?kerhetskopior av alla filer som byts ut under installationen. Dessa filer kan sedan anv?ndas n?r programvaran avinstalleras och du beg?r rollback. Om du d? inte har n?gra s?kerhetskopior kan du bara avinstallera programvaran, inte ?terskapa systemet i dess tidigare skick. Vill du g?ra s?kerhetskopior av de ersatta filerna? - end - item: Radio Button - Rectangle=141 106 265 136 - Variable=DOBACKUP - Create Flags=01010000000000010000000000001001 - Text=&Yes, make backups - Text=N&o, do not make backups - Text= - Text French=&Oui - Text French=N&on - Text French= - Text German=&Ja - Text German=N&ein - Text German= - Text Portuguese=&Sim - Text Portuguese=N?&o - Text Portuguese= - Text Spanish=&S? - Text Spanish=N&o - Text Spanish= - Text Italian=&S? - Text Italian=N&o - Text Italian= - Text Danish=&Ja - Text Danish=&Nej - Text Danish= - Text Dutch=&Ja - Text Dutch=N&ee - Text Dutch= - Text Norwegian=&Ja - Text Norwegian=&Nei - Text Norwegian= - Text Swedish=&Ja - Text Swedish=N&ej - Text Swedish= - end - item: Static - Control Name=BACK2 - Rectangle=108 173 320 208 - Action=1 - Create Flags=01010000000000000000000000000111 - Text=Backup File Destination Directory - Text French=R?pertoire de destination des fichiers de sauvegarde - Text German=Zielverzeichnis f?r die Sicherungsdatei - Text Portuguese=Direct?rio de destino de ficheiro de seguran?a - Text Spanish=Directorio de Destino de los Archivos de Seguridad - Text Italian=Directory di destinazione dei file di backup - Text Danish=Destinationsbibliotek til sikkerhedskopier - Text Dutch=Doeldirectory backup-bestand - Text Norwegian=M?lkatalog for sikkerhetskopier - Text Swedish=Katalog f?r s?kerhetskopierade filer - end - item: Push Button - Control Name=BACK3 - Rectangle=265 185 318 203 - Variable=BACKUP_SAVE - Value=%BACKUP% - Destination Dialog=1 - Action=2 - Create Flags=01010000000000010000000000000000 - Text=B&rowse... - Text French=P&arcourir - Text German=B&l?ttern... - Text Portuguese=P&rocurar - Text Spanish=V&isualizar... - Text Italian=Sfoglia... - Text Danish=&Gennemse... - Text Dutch=B&laderen... - Text Norwegian=Bla igjennom - Text Swedish=&Bl?ddra - end - item: Static - Control Name=BACK4 - Rectangle=129 188 254 200 - Destination Dialog=2 - Create Flags=01010000000000000000000000000000 - Text=%BACKUP% - Text French=%BACKUP% - Text German=%BACKUP% - Text Portuguese=%BACKUP% - Text Spanish=%BACKUP% - Text Italian=%BACKUP% - Text Danish=%BACKUP% - Text Dutch=%BACKUP% - Text Norwegian=%BACKUP% - Text Swedish=%BACKUP% - end - item: Static - Rectangle=108 11 323 36 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Backup Replaced Files - Text French=S?lectionner les composants - Text German=Komponenten ausw?hlen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: If/While Statement - Variable=DOBACKUP - Value=B - end - item: Set Control Attribute - Control Name=BACK3 - Operation=1 - end - item: Set Control Attribute - Control Name=BACK4 - Operation=1 - end - item: Else Statement - end - item: Set Control Attribute - Control Name=BACK3 - end - item: Set Control Attribute - Control Name=BACK4 - end - item: End Block - end - end - item: Dialog - Title=Select Destination Directory - Title French=Choisissez le r?pertoire de destination - Title German=Zielverzeichnis w?hlen - Title Portuguese=Seleccionar Direct?rio de Destino - Title Spanish=Seleccione el Directorio de Destino - Title Italian=Seleziona Directory di destinazione - Title Danish=V?lg Destinationsbibliotek - Title Dutch=Kies Doeldirectory - Title Norwegian=Velg m?lkatalog - Title Swedish=V?lj destinationskalatog - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 3 200 186 - Variable=BACKUP - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%BACKUP% - Text= - Text French=%BACKUP% - Text French= - Text German=%BACKUP% - Text German= - Text Portuguese=%BACKUP% - Text Portuguese= - Text Spanish=%BACKUP% - Text Spanish= - Text Italian=%BACKUP% - Text Italian= - Text Danish=%BACKUP% - Text Danish= - Text Dutch=%BACKUP% - Text Dutch= - Text Norwegian=%BACKUP% - Text Norwegian= - Text Swedish=%BACKUP% - Text Swedish= - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Portuguese=OK - Text Spanish=ACEPTAR - Text Italian=OK - Text Danish=OK - Text Dutch=OK - Text Norwegian=OK - Text Swedish=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=BACKUP - Value=%BACKUP_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Slet - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - end -end -item: Custom Dialog Set - Name=Select Components - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Checkbox - Rectangle=108 66 313 156 - Variable=COMPONENTS - Create Flags=01010000000000010000000000000011 - Flags=0000000000000110 - Text=Python interpreter and libraries - Text=Tcl/Tk (Tkinter, IDLE, pydoc) - Text=Python HTML docs - Text=Python utility scripts (Tools/) - Text=Python test suite (Lib/test/) - Text= - Text French=Python interpreter, library and IDLE - Text French=Python HTML docs - Text French=Python utility scripts (Tools/) - Text French=Python test suite (Lib/test/) - Text French= - Text German=Python interpreter, library and IDLE - Text German=Python HTML docs - Text German=Python utility scripts (Tools/) - Text German=Python test suite (Lib/test/) - Text German= - Text Spanish=Python interpreter, library and IDLE - Text Spanish=Python HTML docs - Text Spanish=Python utility scripts (Tools/) - Text Spanish=Python test suite (Lib/test/) - Text Spanish= - Text Italian=Python interpreter, library and IDLE - Text Italian=Python HTML docs - Text Italian=Python utility scripts (Tools/) - Text Italian=Python test suite (Lib/test/) - Text Italian= - end - item: Static - Rectangle=108 45 320 63 - Create Flags=01010000000000000000000000000000 - Text=Choose which components to install by checking the boxes below. - Text French=Choisissez les composants que vous voulez installer en cochant les cases ci-dessous. - Text German=W?hlen Sie die zu installierenden Komponenten, indem Sie in die entsprechenden K?stchen klicken. - Text Spanish=Elija los componentes que desee instalar marcando los cuadros de abajo. - Text Italian=Scegliere quali componenti installare selezionando le caselle sottostanti. - end - item: Push Button - Rectangle=188 203 269 220 - Destination Dialog=1 - Action=2 - Enabled Color=00000000000000000000000011111111 - Create Flags=01010000000000010000000000000000 - Text=Advanced Options ... - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 43 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Components - Text French=S?lectionner les composants - Text German=Komponenten ausw?hlen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: Static - Rectangle=251 180 311 193 - Variable=COMPONENTS - Value=MAINDIR - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=251 168 311 179 - Variable=COMPONENTS - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=123 168 234 181 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Required: - Text French=Espace disque requis : - Text German=Notwendiger Speicherplatz: - Text Spanish=Espacio requerido en el disco: - Text Italian=Spazio su disco necessario: - end - item: Static - Rectangle=123 180 234 193 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Remaining: - Text French=Espace disque disponible : - Text German=Verbleibender Speicherplatz: - Text Spanish=Espacio en disco disponible: - Text Italian=Spazio su disco disponibile: - end - item: Static - Rectangle=108 158 320 196 - Action=1 - Create Flags=01010000000000000000000000000111 - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=VERIFY - end - item: Remark - Text=If they're installing Tcl/Tk, Tools, or the test suite, doesn't make much sense unless they're installing Python too. - end - item: If/While Statement - Variable=COMPONENTS - Value=BDE - Flags=00001010 - end - item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000011 - end - item: Display Message - Title=Are you sure? - Text=Installing Tcl/Tk, Tools or the test suite doesn't make much sense unless you install the Python interpreter and libraries too. - Text= - Text=Click Yes if that's really what you want. - Flags=00101101 - end - item: Remark - Text=Nothing -- just proceed to the next dialog. - end - item: Else Statement - end - item: Remark - Text=Return to the dialog. - end - item: Set Variable - Variable=DLG_EVENT_TYPE - end - item: End Block - end - item: End Block - end - item: End Block - end - item: End Block - end - end - item: Dialog - Title=Advanced Options - Width=339 - Height=213 - Font Name=Helv - Font Size=8 - item: Radio Button - Control Name=ADMIN2 - Rectangle=11 46 90 76 - Variable=SELECT_ADMIN - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000001001 - Text=Admin install - Text=Non-Admin installl - Text= - end - item: Push Button - Rectangle=188 170 244 189 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Static - Rectangle=5 3 326 83 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Static - Control Name=ADMIN1 - Rectangle=11 11 321 45 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=By default, the install records settings in the per-machine area of the registry (HKLM), and installs the Python and C runtime DLLs to %SYS32%. Choose "Non-Admin install" if you would prefer settings made in the per-user registry (HKCU), and DLLs installed in %MAINDIR%. - end - item: Static - Rectangle=5 90 326 157 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Checkbox - Rectangle=11 121 243 151 - Variable=TASKS - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000000011 - Text=Register file extensions (.py, .pyw, .pyc, .pyo) - Text=Create Start Menu shortcuts - Text= - end - item: Static - Rectangle=11 103 320 121 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Choose tasks to perform by checking the boxes below. - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=INIT - end - item: If/While Statement - Variable=DOADMIN - Value=1 - end - item: Set Control Attribute - Control Name=ADMIN2 - end - item: Else Statement - end - item: Set Control Text - Control Name=ADMIN1 - Control Text=This section is available only if logged in to an account with Administrator privileges. - end - item: Set Control Attribute - Control Name=ADMIN2 - Operation=1 - end - item: End Block - end - item: End Block - end - end -end -item: Custom Dialog Set - Name=Select Program Manager Group - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Start Menu Group - Text French=S?lectionner le groupe du Gestionnaire de programme - Text German=Bestimmung der Programm-Managergruppe - Text Spanish=Seleccione grupo del Administrador de programas - Text Italian=Selezionare il gruppo ProgMan - end - item: Static - Rectangle=108 35 320 65 - Create Flags=01010000000000000000000000000000 - Text=Enter the name of the Start Menu program group to which to add the %APPTITLE% icons: - Text French=Entrez le nom du groupe du Gestionnaire de programme dans lequel vous souhaitez ajouter les ic?nes de %APPTITLE% : - Text German=Geben Sie den Namen der Programmgruppe ein, der das Symbol %APPTITLE% hinzugef?gt werden soll: - Text Spanish=Escriba el nombre del grupo del Administrador de programas en el que desea agregar los iconos de %APPTITLE%: - Text Italian=Inserire il nome del gruppo Program Manager per aggiungere le icone %APPTITLE% a: - end - item: Combobox - Rectangle=108 56 320 219 - Variable=GROUP - Create Flags=01010000001000010000001100000001 - Flags=0000000000000001 - Text=%GROUP% - Text= - Text French=%GROUP% - Text German=%GROUP% - Text Spanish=%GROUP% - Text Italian=%GROUP% - end - end -end -item: Custom Dialog Set - Name=Start Installation - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Ready to Install! - Text French=Pr?t ? installer ! - Text German=Installationsbereit! - Text Spanish=?Preparado para la instalaci?n! - Text Italian=Pronto per l'installazione! - end - item: Static - Rectangle=108 40 320 62 - Create Flags=01010000000000000000000000000000 - Text=Click the Next button to install %APPTITLE%, or the Back button to change choices: - Text French=Vous ?tes maintenant pr?t ? installer les fichiers %APPTITLE%. - Text French= - Text French=Cliquez sur le bouton Suite pour commencer l'installation ou sur le bouton Retour pour entrer les informations d'installation ? nouveau. - Text German=Sie k?nnen %APPTITLE% nun installieren. - Text German= - Text German=Klicken Sie auf "Weiter", um mit der Installation zu beginnen. Klicken Sie auf "Zur?ck", um die Installationsinformationen neu einzugeben. - Text Spanish=Ya est? listo para instalar %APPTITLE%. - Text Spanish= - Text Spanish=Presione el bot?n Siguiente para comenzar la instalaci?n o presione Atr?s para volver a ingresar la informaci?n para la instalaci?n. - Text Italian=Ora ? possibile installare %APPTITLE%. - Text Italian= - Text Italian=Premere il pulsante Avanti per avviare l'installazione o il pulsante Indietro per reinserire le informazioni di installazione. - end - item: Editbox - Rectangle=108 66 324 219 - Help Context=16711681 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000000001100011000100 - Text=%SUMMARY% - end - end -end -item: Remark -end -item: If/While Statement - Variable=DISPLAY - Value=Select Destination Directory -end -item: Remark - Text=User may have changed MAINDIR, so reset BACKUP to match. -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP -end -item: End Block -end -item: Remark -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=When the BACKUP feature is enabled, the BACKUPDIR is initialized -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=BACKUPDIR - Value=%BACKUP% -end -item: End Block -end -item: Remark - Text=The BRANDING information is written to the INI file on the installation media. -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit INI File - Pathname=%INST%\CUSTDATA.INI - Settings=[Registration] - Settings=NAME=%NAME% - Settings=COMPANY=%COMPANY% - Settings= -end -item: End Block -end -item: End Block -end -item: Remark - Text=Begin writing to the INSTALL.LOG -end -item: Open/Close INSTALL.LOG -end -item: Remark - Text=Check free disk space calculates free disk space as well as component sizes. -end -item: Remark - Text=It should be located before all Install File actions. -end -item: Check Disk Space - Component=COMPONENTS -end -item: Remark - Text=This include script allows uninstall support -end -item: Remark - Text=Note from Tim: this is our own Uninstal.wse, a copy of Wise's except -end -item: Remark - Text=it writes to HKCU (instead of HKLM) if the user doesn't have admin privs. -end -item: Include Script - Pathname=.\Uninstal.wse -end -item: Remark - Text=Note from Tim: these seeming no-ops actually convert to short filenames. -end -item: Set Variable - Variable=COMMON - Value=%COMMON% - Flags=00010100 -end -item: Set Variable - Variable=MAINDIR - Value=%MAINDIR% - Flags=00010100 -end -item: Remark - Text=This IF/THEN/ELSE reads the correct registry entries for shortcut/icon placement -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=STARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs\StartUp - Value Name=StartUp - Flags=00000010 -end -item: Get Registry Key Value - Variable=DESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Desktop - Value Name=Desktop - Flags=00000010 -end -item: Get Registry Key Value - Variable=STARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu - Value Name=Start Menu - Flags=00000010 -end -item: Get Registry Key Value - Variable=GROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs - Value Name=Programs - Flags=00000010 -end -item: Get Registry Key Value - Variable=CSTARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTUPDIR% - Value Name=Common Startup - Flags=00000100 -end -item: Get Registry Key Value - Variable=CDESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%DESKTOPDIR% - Value Name=Common Desktop - Flags=00000100 -end -item: Get Registry Key Value - Variable=CSTARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTMENUDIR% - Value Name=Common Start Menu - Flags=00000100 -end -item: Get Registry Key Value - Variable=CGROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%GROUPDIR% - Value Name=Common Programs - Flags=00000100 -end -item: Else Statement -end -item: Remark - Text=Note from Tim: the Wizard left this block empty! -end -item: Remark - Text=Perhaps it's only relevant on Windows 3.1. -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=B -end -item: Remark - Text=The user chose a non-admin install in "Advanced Options". -end -item: Remark - Text=This should come after the include of Uninstal.wse above, because -end -item: Remark - Text=writing uninstall info to HKCU is ineffective except under Win2K. -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=CGROUP_SAVE - Value=%GROUP% -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=GROUP - Value=%CGROUPDIR%\%GROUP% -end -item: Else Statement -end -item: Set Variable - Variable=GROUP - Value=%GROUPDIR%\%GROUP% -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Long section to install files. -end -item: Remark -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=DLLDEST - Value=%SYS32% -end -item: Else Statement -end -item: Set Variable - Variable=DLLDEST - Value=%MAINDIR% -end -item: End Block -end -item: Remark -end -item: Remark - Text=Install the license even if they deselect everything . -end -item: Install File - Source=..\license - Destination=%MAINDIR%\LICENSE.txt - Flags=0000000000000010 -end -item: Install File - Source=..\readme - Destination=%MAINDIR%\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\misc\news - Destination=%MAINDIR%\NEWS.txt - Flags=0000000000000010 -end -item: Remark - Text=Icons -- always install so that the uninstaller can use them for its own display. -end -item: Install File - Source=..\pc\pycon.ico - Destination=%MAINDIR%\pycon.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\pyc.ico - Destination=%MAINDIR%\pyc.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\py.ico - Destination=%MAINDIR%\py.ico - Flags=0000000010000010 -end -item: Remark -end -item: Remark - Text=These arrange to (recursively!) delete all .pyc and .pyo files at uninstall time. -end -item: Remark - Text=This "does the right thing": any directories left empty at the end are removed. -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyc -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyo -end -item: Remark -end -item: Remark - Text=A: interpreter and libraries -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Remark - Text=Executables -end -item: Install File - Source=.\python.exe - Destination=%MAINDIR%\python.exe - Flags=0000000000000010 -end -item: Install File - Source=.\pythonw.exe - Destination=%MAINDIR%\pythonw.exe - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Extension module DLLs (.pyd); keep in synch with libs directory next -end -item: Install File - Source=.\winreg.pyd - Destination=%MAINDIR%\DLLs\winreg.pyd - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.pyd - Destination=%MAINDIR%\DLLs\_csv.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.pyd - Destination=%MAINDIR%\DLLs\_sre.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.pyd - Destination=%MAINDIR%\DLLs\_ssl.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.pyd - Destination=%MAINDIR%\DLLs\_symtable.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.pyd - Destination=%MAINDIR%\DLLs\_testcapi.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.pyd - Destination=%MAINDIR%\DLLs\_tkinter.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.pyd - Destination=%MAINDIR%\DLLs\_socket.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.pyd - Destination=%MAINDIR%\DLLs\bz2.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.pyd - Destination=%MAINDIR%\DLLs\datetime.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.pyd - Destination=%MAINDIR%\DLLs\mmap.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\parser.pyd - Destination=%MAINDIR%\DLLs\parser.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.pyd - Destination=%MAINDIR%\DLLs\pyexpat.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\select.pyd - Destination=%MAINDIR%\DLLs\select.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.pyd - Destination=%MAINDIR%\DLLs\unicodedata.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.pyd - Destination=%MAINDIR%\DLLs\winsound.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.pyd - Destination=%MAINDIR%\DLLs\zlib.pyd - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Link libraries (.lib); keep in synch with DLLs above, except that the Python lib lives here. -end -item: Install File - Source=.\winreg.lib - Destination=%MAINDIR%\libs\winreg.lib - Description=Link library files - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.lib - Destination=%MAINDIR%\libs\_csv.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.lib - Destination=%MAINDIR%\libs\_sre.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.lib - Destination=%MAINDIR%\libs\_ssl.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.lib - Destination=%MAINDIR%\libs\_symtable.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.lib - Destination=%MAINDIR%\libs\_testcapi.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.lib - Destination=%MAINDIR%\libs\_tkinter.lib - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.lib - Destination=%MAINDIR%\libs\_socket.lib - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.lib - Destination=%MAINDIR%\libs\bz2.lib - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.lib - Destination=%MAINDIR%\libs\datetime.lib - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.lib - Destination=%MAINDIR%\libs\mmap.lib - Flags=0000000000000010 -end -item: Install File - Source=.\parser.lib - Destination=%MAINDIR%\libs\parser.lib - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.lib - Destination=%MAINDIR%\libs\pyexpat.lib - Flags=0000000000000010 -end -item: Install File - Source=.\select.lib - Destination=%MAINDIR%\libs\select.lib - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.lib - Destination=%MAINDIR%\libs\unicodedata.lib - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.lib - Destination=%MAINDIR%\libs\winsound.lib - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.lib - Destination=%MAINDIR%\libs\zlib.lib - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.lib - Destination=%MAINDIR%\libs\python%_PYMAJOR_%%_PYMINOR_%.lib - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Main Python DLL -end -item: Remark - Text=Tell Wise it's OK to delete the Python DLL at uninstall time, -end -item: Remark - Text=despite that we (may) write it into a system directory. -end -item: Add Text to INSTALL.LOG - Text=Non-System File: -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.dll - Destination=%DLLDEST%\python%_PYMAJOR_%%_PYMINOR_%.dll - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Libraries (Lib/) -end -item: Install File - Source=..\lib\*.py - Destination=%MAINDIR%\Lib - Description=Library Modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\compiler\*.py - Destination=%MAINDIR%\Lib\compiler - Description=Python compiler written in Python - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\distutils\*.py - Destination=%MAINDIR%\Lib\distutils - Description=Distribution utility modules - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\readme - Destination=%MAINDIR%\Lib\distutils\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\*.py - Destination=%MAINDIR%\Lib\distutils\command - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\wininst.exe - Destination=%MAINDIR%\Lib\distutils\command\wininst.exe - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\command_template - Destination=%MAINDIR%\Lib\distutils\command\command_template - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\email\*.py - Destination=%MAINDIR%\Lib\email - Description=Library email package - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\*.py - Destination=%MAINDIR%\Lib\email\test - Description=email tests - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.txt - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.gif - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.au - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\encodings\*.py - Destination=%MAINDIR%\Lib\encodings - Description=Unicode encoding tables - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\hotshot\*.py - Destination=%MAINDIR%\Lib\hotshot - Description=Fast Python profiler - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\lib-old\*.py - Destination=%MAINDIR%\Lib\lib-old - Description=Obsolete modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\tkinter\*.py - Destination=%MAINDIR%\Lib\tkinter - Description=Tkinter related library modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\logging\*.py - Destination=%MAINDIR%\Lib\logging - Description=Logging package - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\site-packages\readme - Destination=%MAINDIR%\Lib\site-packages\README.txt - Description=Site packages - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\xml\*.py - Destination=%MAINDIR%\Lib\xml - Description=XML support packages - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\dom\*.py - Destination=%MAINDIR%\Lib\xml\dom - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\parsers\*.py - Destination=%MAINDIR%\Lib\xml\parsers - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\sax\*.py - Destination=%MAINDIR%\Lib\xml\sax - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=C Include files -end -item: Install File - Source=..\include\*.h - Destination=%MAINDIR%\include - Description=Header files - Flags=0000000000000010 -end -item: Install File - Source=..\pc\pyconfig.h - Destination=%MAINDIR%\include\pyconfig.h - Description=Header files (pyconfig.h) - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Microsoft C runtime libraries -end -item: Install File - Source=%_SYS_%\MSVCIRT.DLL - Destination=%DLLDEST%\MSVCIRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: Install File - Source=%_SYS_%\MSVCRT.DLL - Destination=%DLLDEST%\MSVCRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: End Block -end -item: Remark -end -item: Remark - Text=B: Tcl/Tk (Tkinter, IDLE, pydoc) -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Remark - Text=Tcl/Tk -end -item: Install File - Source=..\..\%_tcldir_%\bin\*.dll - Destination=%MAINDIR%\DLLs - Description=Tcl/Tk binaries and libraries - Flags=0000000000000010 -end -item: Install File - Source=..\..\%_tcldir_%\lib\*.* - Destination=%MAINDIR%\tcl - Description=Tcl/Tk binaries and libraries - Flags=0000000100000010 -end -item: Remark -end -item: Remark - Text=IDLE -end -item: Install File - Source=..\Lib\idlelib\*.py - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.txt - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.def - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\Icons\* - Destination=%MAINDIR%\Lib\idlelib\Icons - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Tools\scripts\idle - Destination=%MAINDIR%\Lib\idlelib\idle.pyw - Description=IDLE bootstrap script - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Windows pydoc driver -end -item: Install File - Source=..\tools\scripts\*.pyw - Destination=%MAINDIR%\Tools\Scripts - Description=Windows pydoc driver - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=C: docs -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Install File - Source=%_DOC_%\*.* - Destination=%MAINDIR%\Doc - Description=Python Documentation (HTML) - Flags=0000000100000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=D: tools -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Install File - Source=..\tools\scripts\*.py - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\*.doc - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\readme - Destination=%MAINDIR%\Tools\Scripts\README.txt - Description=Utility Scripts - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\webchecker\*.py - Destination=%MAINDIR%\Tools\webchecker - Description=Web checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\webchecker\readme - Destination=%MAINDIR%\Tools\webchecker\README.txt - Description=Web checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\versioncheck\*.py - Destination=%MAINDIR%\Tools\versioncheck - Description=Version checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\versioncheck\readme - Destination=%MAINDIR%\Tools\versioncheck\README.txt - Description=Version checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\pynche\*.py - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\*.txt - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\x\*.txt - Destination=%MAINDIR%\Tools\pynche\X - Description=pynche color editor - X files - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\readme - Destination=%MAINDIR%\Tools\pynche\README.txt - Description=pynche color editor - README - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche - Destination=%MAINDIR%\Tools\pynche\pynche.py - Description=pynche color editor - main - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche.pyw - Destination=%MAINDIR%\Tools\pynche\pynche.pyw - Description=pynche color editor - noconsole main - Flags=0000000100000010 -end -item: Remark -end -item: Install File - Source=..\tools\i18n\*.py - Destination=%MAINDIR%\Tools\i18n - Description=Internationalization helpers - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=E: test suite -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Install File - Source=..\lib\test\audiotest.au - Destination=%MAINDIR%\Lib\test\audiotest.au - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.uue - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.py - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.xml - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.out - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.bz2 - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.tar - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.gz - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.txt - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\test\output\*.* - Destination=%MAINDIR%\Lib\test\output - Description=Python Test output files - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=DONE with file copying. -end -item: Remark - Text=The rest is registry and Start Menu fiddling. -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Remark - Text=Register file extensions. As usual, Admin privs get in the way, but with a twist: -end -item: Remark - Text=You don't need admin privs to write to HKEY_CLASSES_ROOT *except* under Win2K. -end -item: Remark - Text=On Win2K, a user without Admin privs has to register extensions under HKCU\Software\CLASSES instead. -end -item: Remark - Text=But while you can *do* that under other flavors of Windows too, it has no useful effect except in Win2K. -end -item: Set Variable - Variable=USE_HKCR - Value=1 -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=USE_HKCR - Value=0 -end -item: End Block -end -item: End Block -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Python.File - New Value=Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile - New Value=Python File (no console) -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile - New Value=Compiled Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=Python.File -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=Python.NoConFile -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyc - New Value=Python.CompiledFile -end -item: Edit Registry - Total Keys=1 - Key=.pyo - New Value=Python.CompiledFile -end -item: Else Statement -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File - New Value=Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile - New Value=Python File (no console) - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile - New Value=Compiled Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico - Root=1 -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=Python.File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=Python.NoConFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyc - New Value=Python.CompiledFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyo - New Value=Python.CompiledFile - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=If we're installing IDLE, also set an Edit context menu action to use IDLE, for .py and .pyw files. -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: End Block -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Register Python paths. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=130 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=129 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Registry fiddling for docs. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\index.html - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\index.html - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Set the app publisher and URL entries for Win2K add/remove. -end -item: Remark - Text=It doesn't hurt on other systems. -end -item: Remark - Text=As usual, write to HKLM or HKCU depending on Admin privs. -end -item: Remark - Text=CAUTION: If you set this info on the "Windows 2000" page (step 6) of the -end -item: Remark - Text=Installation Expert, it only shows up in the "If" block below. Keep in synch! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=Populate Start Menu group -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Remark - Text=Shortcut to installer no matter what. -end -item: Create Shortcut - Source=%MAINDIR%\unwise.exe - Destination=%GROUP%\Uninstall Python.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\python.exe - Destination=%GROUP%\Python (command line).lnk - Working Directory=%MAINDIR% - Icon Pathname=%MAINDIR%\pycon.ico - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\IDLE (Python GUI).lnk - Command Options="%MAINDIR%\Lib\idlelib\idle.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\Module Docs.lnk - Command Options="%MAINDIR%\Tools\Scripts\pydocgui.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\Doc\index.html - Destination=%GROUP%\Python Manuals.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=I don't think we need this, but have always done it. -end -item: Self-Register OCXs/DLLs - Description=Updating System Configuration, Please Wait... -end -item: Remark -end -remarked item: Remark - Text=Don't enable "Delete in-use files". Here's what happens: -end -remarked item: Remark - Text=Install Python; uninstall Python; install Python again. Reboot the machine. -end -remarked item: Remark - Text=Now UNWISE.EXE is missing. I think this is a Wise bug, but so it goes. -end -remarked item: Add Text to INSTALL.LOG - Text=Delete in-use files: On -end -item: Remark -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Flags=00000011 -end -item: Custom Dialog Set - Name=Finished - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Finish - Text French=&Fin - Text German=&Weiter - Text Spanish=&Terminar - Text Italian=&Fine - end - item: Push Button - Rectangle=264 234 320 253 - Variable=DISABLED - Value=! - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=108 10 323 48 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Installation Completed! - Text French=Installation termin?e ! - Text German=Die Installation ist abgeschlossen! - Text Spanish=?Instalaci?n terminada! - Text Italian=Installazione completata! - end - item: Static - Rectangle=108 44 320 82 - Create Flags=01010000000000000000000000000000 - Text=%APPTITLE% has been successfully installed. - Text= - Text=Press the Finish button to exit this installation. - Text French=%APPTITLE% est maintenant install?. - Text French= - Text French=Cliquez sur le bouton Fin pour quitter l'installation. - Text German=%APPTITLE% wurde erfolgreich installiert. - Text German= - Text German=Klicken Sie auf "Weiter", um die Installation zu beenden. - Text Spanish=%APPTITLE% se ha instalado con ?xito. - Text Spanish= - Text Spanish=Presione el bot?n Terminar para salir de esta instalaci?n. - Text Italian=L'installazione %APPTITLE% ? stata portata a termine con successo. - Text Italian= - Text Italian=Premere il pulsante Fine per uscire dall'installazione. - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=106 105 312 210 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Special Windows thanks to: - Text= - Text=Wise Solutions, for the use of InstallMaster 8.1. - Text= http://www.wisesolutions.com/ - Text= - Text= - Text=LettError, Erik van Blokland, for the Python for Windows graphic. - Text= http://www.letterror.com/ - Text= - Text= - Text=Mark Hammond, without whose years of freely shared Windows expertise, Python for Windows would still be Python for DOS. - end - item: Static - Rectangle=106 95 312 96 - Action=3 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000001001 - end - end -end -item: End Block -end -item: New Event - Name=Cancel -end -item: Remark - Text=This include script supports a rollback to preinstallation state if the user chooses to cancel before the installation is complete. -end -item: Include Script - Pathname=%_WISE_%\INCLUDE\rollback.wse -end diff --git a/PC/VS7.1/pythoncore.vcproj b/PC/VS7.1/pythoncore.vcproj deleted file mode 100644 --- a/PC/VS7.1/pythoncore.vcproj +++ /dev/null @@ -1,826 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/pythonw.vcproj b/PC/VS7.1/pythonw.vcproj deleted file mode 100644 --- a/PC/VS7.1/pythonw.vcproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/readme.txt b/PC/VS7.1/readme.txt deleted file mode 100644 --- a/PC/VS7.1/readme.txt +++ /dev/null @@ -1,337 +0,0 @@ -Building Python using VC++ 7.1 -------------------------------------- -This directory is used to build Python for Win32 platforms, e.g. Windows -95, 98 and NT. It requires Microsoft Visual C++ 7.1 -(a.k.a. Visual Studio .NET 2003). -(For other Windows platforms and compilers, see ../PC/readme.txt.) - -All you need to do is open the workspace "pcbuild.sln" in MSVC++, select -the Debug or Release setting (using "Solution Configuration" from -the "Standard" toolbar"), and build the projects. - -The proper order to build subprojects: - -1) pythoncore (this builds the main Python DLL and library files, - python34.{dll, lib} in Release mode) - NOTE: in previous releases, this subproject was - named after the release number, e.g. python20. - -2) python (this builds the main Python executable, - python.exe in Release mode) - -3) the other subprojects, as desired or needed (note: you probably don't - want to build most of the other subprojects, unless you're building an - entire Python distribution from scratch, or specifically making changes - to the subsystems they implement, or are running a Python core buildbot - test slave; see SUBPROJECTS below) - -When using the Debug setting, the output files have a _d added to -their name: python34_d.dll, python_d.exe, parser_d.pyd, and so on. - -SUBPROJECTS ------------ -These subprojects should build out of the box. Subprojects other than the -main ones (pythoncore, python, pythonw) generally build a DLL (renamed to -.pyd) from a specific module so that users don't have to load the code -supporting that module unless they import the module. - -pythoncore - .dll and .lib -python - .exe -pythonw - pythonw.exe, a variant of python.exe that doesn't pop up a DOS box -_socket - socketmodule.c -_testcapi - tests of the Python C API, run via Lib/test/test_capi.py, and - implemented by module Modules/_testcapimodule.c -pyexpat - Python wrapper for accelerated XML parsing, which incorporates stable - code from the Expat project: http://sourceforge.net/projects/expat/ -select - selectmodule.c -unicodedata - large tables of Unicode data -winsound - play sounds (typically .wav files) under Windows - -The following subprojects will generally NOT build out of the box. They -wrap code Python doesn't control, and you'll need to download the base -packages first and unpack them into siblings of PC's parent -directory; for example, if this directory is ....\dist\trunk\PC\VS7.1, -unpack into new subdirectories of dist\. - -_tkinter - Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. - - Get source - ---------- - In the dist directory, run - svn export http://svn.python.org/projects/external/tcl8.4.12 - svn export http://svn.python.org/projects/external/tk8.4.12 - svn export http://svn.python.org/projects/external/tix-8.4.0 - - Build Tcl first (done here w/ MSVC 7.1 on Windows XP) - --------------- - Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003 - -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt" - to get a shell window with the correct environment settings - cd dist\tcl8.4.12\win - nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - Optional: run tests, via - nmake -f makefile.vc test - - On WinXP Pro, wholly up to date as of 30-Aug-2004: - all.tcl: Total 10678 Passed 9969 Skipped 709 Failed 0 - Sourced 129 Test Files. - - Build Tk - -------- - cd dist\tk8.4.12\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install - - XXX Should we compile with OPTS=threads? - - XXX Our installer copies a lot of stuff out of the Tcl/Tk install - XXX directory. Is all of that really needed for Python use of Tcl/Tk? - - Optional: run tests, via - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test - - On WinXP Pro, wholly up to date as of 30-Aug-2004: - all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13 - Sourced 91 Test Files. - Files with failing tests: canvImg.test scrollbar.test textWind.test winWm.test - - Built Tix - --------- - cd dist\tix-8.4.0\win - nmake -f python.mak - nmake -f python.mak install - -bz2 - Python wrapper for the libbz2 compression library. Homepage - http://sources.redhat.com/bzip2/ - Download the source from the python.org copy into the dist - directory: - - svn export http://svn.python.org/projects/external/bzip2-1.0.3 - - A custom pre-link step in the bz2 project settings should manage to - build bzip2-1.0.3\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is - linked in VS7.1\. - However, the bz2 project is not smart enough to remove anything under - bzip2-1.0.3\ when you do a clean, so if you want to rebuild bzip2.lib - you need to clean up bzip2-1.0.3\ by hand. - - The build step shouldn't yield any warnings or errors, and should end - by displaying 6 blocks each terminated with - FC: no differences encountered - - All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python - project links in. - -_sqlite3 - Python wrapper for SQLite library. - - Get the source code through - - svn export http://svn.python.org/projects/external/sqlite-source-3.3.4 - - To use the extension module in a Python build tree, copy sqlite3.dll into - the VS7.1 folder. - -_ssl - Python wrapper for the secure sockets library. - - Get the source code through - - svn export http://svn.python.org/projects/external/openssl-0.9.8a - - Alternatively, get the latest version from http://www.openssl.org. - You can (theoretically) use any version of OpenSSL you like - the - build process will automatically select the latest version. - - You must also install ActivePerl from - http://www.activestate.com/Products/ActivePerl/ - as this is used by the OpenSSL build process. Complain to them . - - The MSVC project simply invokes build_ssl.py to perform - the build. This Python script locates and builds your OpenSSL - installation, then invokes a simple makefile to build the final .pyd. - - build_ssl.py attempts to catch the most common errors (such as not - being able to find OpenSSL sources, or not being able to find a Perl - that works with OpenSSL) and give a reasonable error message. - If you have a problem that doesn't seem to be handled correctly - (eg, you know you have ActivePerl but we can't find it), please take - a peek at build_ssl.py and suggest patches. Note that build_ssl.py - should be able to be run directly from the command-line. - - build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do - this by hand. - -Building for Itanium --------------------- - -The project files support a ReleaseItanium configuration which creates -Win64/Itanium binaries. For this to work, you need to install the Platform -SDK, in particular the 64-bit support. This includes an Itanium compiler -(future releases of the SDK likely include an AMD64 compiler as well). -In addition, you need the Visual Studio plugin for external C compilers, -from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to -locate the proper target compiler, and convert compiler options -accordingly. The project files require atleast version 0.9. - -Building for AMD64 ------------------- - -The build process for the ReleaseAMD64 configuration is very similar -to the Itanium configuration; make sure you use the latest version of -vsextcomp. - -Building Python Using the free MS Toolkit Compiler --------------------------------------------------- - -The build process for Visual C++ can be used almost unchanged with the free MS -Toolkit Compiler. This provides a way of building Python using freely -available software. - -Note that Microsoft have withdrawn the free MS Toolkit Compiler, so this can -no longer be considered a supported option. The instructions are still -correct, but you need to already have a copy of the compiler in order to use -them. Microsoft now supply Visual C++ 2008 Express Edition for free, but this -is NOT compatible with Visual C++ 7.1 (it uses a different C runtime), and so -cannot be used to build a version of Python compatible with the standard -python.org build. If you are interested in using Visual C++ 2008 Express -Edition, however, you should look at the PCBuild directory. - -Requirements - - To build Python, the following tools are required: - - * The Visual C++ Toolkit Compiler - no longer available for download - see above - * A recent Platform SDK - from http://www.microsoft.com/downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a - * The .NET 1.1 SDK - from http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d - - [Does anyone have better URLs for the last 2 of these?] - - The toolkit compiler is needed as it is an optimising compiler (the - compiler supplied with the .NET SDK is a non-optimising version). The - platform SDK is needed to provide the Windows header files and libraries - (the Windows 2003 Server SP1 edition, typical install, is known to work - - other configurations or versions are probably fine as well). The .NET 1.1 - SDK is needed because it contains a version of msvcrt.dll which links to - the msvcr71.dll CRT. Note that the .NET 2.0 SDK is NOT acceptable, as it - references msvcr80.dll. - - All of the above items should be installed as normal. - - If you intend to build the openssl (needed for the _ssl extension) you - will need the C runtime sources installed as part of the platform SDK. - - In addition, you will need Nant, available from - http://nant.sourceforge.net. The 0.85 release candidate 3 version is known - to work. This is the latest released version at the time of writing. Later - "nightly build" versions are known NOT to work - it is not clear at - present whether future released versions will work. - -Setting up the environment - - Start a platform SDK "build environment window" from the start menu. The - "Windows XP 32-bit retail" version is known to work. - - Add the following directories to your PATH: - * The toolkit compiler directory - * The SDK "Win64" binaries directory - * The Nant directory - Add to your INCLUDE environment variable: - * The toolkit compiler INCLUDE directory - Add to your LIB environment variable: - * The toolkit compiler LIB directory - * The .NET SDK Visual Studio 2003 VC7\lib directory - - The following commands should set things up as you need them: - - rem Set these values according to where you installed the software - set TOOLKIT=C:\Program Files\Microsoft Visual C++ Toolkit 2003 - set SDK=C:\Program Files\Microsoft Platform SDK - set NET=C:\Program Files\Microsoft Visual Studio .NET 2003 - set NANT=C:\Utils\Nant - - set PATH=%TOOLKIT%\bin;%PATH%;%SDK%\Bin\win64;%NANT%\bin - set INCLUDE=%TOOLKIT%\include;%INCLUDE% - set LIB=%TOOLKIT%\lib;%NET%\VC7\lib;%LIB% - - The "win64" directory from the SDK is added to supply executables such as - "cvtres" and "lib", which are not available elsewhere. The versions in the - "win64" directory are 32-bit programs, so they are fine to use here. - - That's it. To build Python (the core only, no binary extensions which - depend on external libraries) you just need to issue the command - - nant -buildfile:python.build all - - from within the VS7.1 directory. - -Extension modules - - To build those extension modules which require external libraries - (_tkinter, bz2, _sqlite3, _ssl) you can follow the instructions - for the Visual Studio build above, with a few minor modifications. These - instructions have only been tested using the sources in the Python - subversion repository - building from original sources should work, but - has not been tested. - - For each extension module you wish to build, you should remove the - associated include line from the excludeprojects section of pc.build. - - The changes required are: - - _tkinter - The tix makefile (tix-8.4.0\win\makefile.vc) must be modified to - remove references to TOOLS32. The relevant lines should be changed to - read: - cc32 = cl.exe - link32 = link.exe - include32 = - The remainder of the build instructions will work as given. - - bz2 - No changes are needed - - _sqlite3 - No changes are needed. However, in order for the tests to succeed, a - copy of sqlite3.dll must be downloaded, and placed alongside - python.exe. - - _ssl - The documented build process works as written. However, it needs a - copy of the file setargv.obj, which is not supplied in the platform - SDK. However, the sources are available (in the crt source code). To - build setargv.obj, proceed as follows: - - Copy setargv.c, cruntime.h and internal.h from %SDK%\src\crt to a - temporary directory. - Compile using "cl /c /I. /MD /D_CRTBLD setargv.c" - Copy the resulting setargv.obj to somewhere on your LIB environment - (%SDK%\lib is a reasonable place). - - With setargv.obj in place, the standard build process should work - fine. - -YOUR OWN EXTENSION DLLs ------------------------ -If you want to create your own extension module DLL, there's an example -with easy-to-follow instructions in ../PC/example/; read the file -readme.txt there first. diff --git a/PC/VS7.1/rmpyc.py b/PC/VS7.1/rmpyc.py deleted file mode 100644 --- a/PC/VS7.1/rmpyc.py +++ /dev/null @@ -1,25 +0,0 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../Lib") -print npyc, ".pyc deleted,", npyo, ".pyo deleted" diff --git a/PC/VS7.1/rt.bat b/PC/VS7.1/rt.bat deleted file mode 100755 --- a/PC/VS7.1/rt.bat +++ /dev/null @@ -1,52 +0,0 @@ - at echo off -rem Run Tests. Run the regression test suite. -rem Usage: rt [-d] [-O] [-q] regrtest_args -rem -d Run Debug build (python_d.exe). Else release build. -rem -O Run python.exe or python_d.exe (see -d) with -O. -rem -q "quick" -- normally the tests are run twice, the first time -rem after deleting all the .py[co] files reachable from Lib/. -rem -q runs the tests just once, and without deleting .py[co] files. -rem All leading instances of these switches are shifted off, and -rem whatever remains is passed to regrtest.py. For example, -rem rt -O -d -x test_thread -rem runs -rem python_d -O ../../lib/test/regrtest.py -x test_thread -rem twice, and -rem rt -q -g test_binascii -rem runs -rem python_d ../../lib/test/regrtest.py -g test_binascii -rem to generate the expected-output file for binascii quickly. -rem -rem Confusing: if you want to pass a comma-separated list, like -rem -u network,largefile -rem then you have to quote it on the rt line, like -rem rt -u "network,largefile" - -setlocal - -set exe=python -set qmode= -set dashO= -PATH %PATH%;%~dp0..\..\..\tcltk\bin - -:CheckOpts -if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts -if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts -if "%1"=="-d" (set exe=python_d) & shift & goto CheckOpts - -set cmd=%exe% %dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 -if defined qmode goto Qmode - -echo Deleting .pyc/.pyo files ... -%exe% rmpyc.py - -echo on -%cmd% - at echo off - -echo About to run again without deleting .pyc/.pyo first: -pause - -:Qmode -echo on -%cmd% diff --git a/PC/VS7.1/select.vcproj b/PC/VS7.1/select.vcproj deleted file mode 100644 --- a/PC/VS7.1/select.vcproj +++ /dev/null @@ -1,258 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/unicodedata.vcproj b/PC/VS7.1/unicodedata.vcproj deleted file mode 100644 --- a/PC/VS7.1/unicodedata.vcproj +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS7.1/winsound.vcproj b/PC/VS7.1/winsound.vcproj deleted file mode 100644 --- a/PC/VS7.1/winsound.vcproj +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_ctypes.vcproj b/PC/VS8.0/_ctypes.vcproj deleted file mode 100644 --- a/PC/VS8.0/_ctypes.vcproj +++ /dev/null @@ -1,705 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_ctypes_test.vcproj b/PC/VS8.0/_ctypes_test.vcproj deleted file mode 100644 --- a/PC/VS8.0/_ctypes_test.vcproj +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_elementtree.vcproj b/PC/VS8.0/_elementtree.vcproj deleted file mode 100644 --- a/PC/VS8.0/_elementtree.vcproj +++ /dev/null @@ -1,613 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_hashlib.vcproj b/PC/VS8.0/_hashlib.vcproj deleted file mode 100644 --- a/PC/VS8.0/_hashlib.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_msi.vcproj b/PC/VS8.0/_msi.vcproj deleted file mode 100644 --- a/PC/VS8.0/_msi.vcproj +++ /dev/null @@ -1,529 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_multiprocessing.vcproj b/PC/VS8.0/_multiprocessing.vcproj deleted file mode 100644 --- a/PC/VS8.0/_multiprocessing.vcproj +++ /dev/null @@ -1,545 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_socket.vcproj b/PC/VS8.0/_socket.vcproj deleted file mode 100644 --- a/PC/VS8.0/_socket.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_sqlite3.vcproj b/PC/VS8.0/_sqlite3.vcproj deleted file mode 100644 --- a/PC/VS8.0/_sqlite3.vcproj +++ /dev/null @@ -1,613 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_ssl.vcproj b/PC/VS8.0/_ssl.vcproj deleted file mode 100644 --- a/PC/VS8.0/_ssl.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_testcapi.vcproj b/PC/VS8.0/_testcapi.vcproj deleted file mode 100644 --- a/PC/VS8.0/_testcapi.vcproj +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/_tkinter.vcproj b/PC/VS8.0/_tkinter.vcproj deleted file mode 100644 --- a/PC/VS8.0/_tkinter.vcproj +++ /dev/null @@ -1,541 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/bdist_wininst.vcproj b/PC/VS8.0/bdist_wininst.vcproj deleted file mode 100644 --- a/PC/VS8.0/bdist_wininst.vcproj +++ /dev/null @@ -1,270 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/build.bat b/PC/VS8.0/build.bat deleted file mode 100644 --- a/PC/VS8.0/build.bat +++ /dev/null @@ -1,17 +0,0 @@ - at echo off -rem A batch program to build or rebuild a particular configuration. -rem just for convenience. - -setlocal -set platf=Win32 -set conf=Release -set build=/build - -:CheckOpts -if "%1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts -if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts -if "%1"=="-r" (set build=/rebuild) & shift & goto CheckOpts - -set cmd=devenv pcbuild.sln %build% "%conf%|%platf%" -echo %cmd% -%cmd% diff --git a/PC/VS8.0/build_env.bat b/PC/VS8.0/build_env.bat deleted file mode 100644 --- a/PC/VS8.0/build_env.bat +++ /dev/null @@ -1,1 +0,0 @@ -@%comspec% /k env.bat %* diff --git a/PC/VS8.0/build_pgo.bat b/PC/VS8.0/build_pgo.bat deleted file mode 100644 --- a/PC/VS8.0/build_pgo.bat +++ /dev/null @@ -1,41 +0,0 @@ - at echo off -rem A batch program to build PGO (Profile guided optimization) by first -rem building instrumented binaries, then running the testsuite, and -rem finally building the optimized code. -rem Note, after the first instrumented run, one can just keep on -rem building the PGUpdate configuration while developing. - -setlocal -set platf=Win32 - -rem use the performance testsuite. This is quick and simple -set job1=..\..\tools\pybench\pybench.py -n 1 -C 1 --with-gc -set path1=..\..\tools\pybench - -rem or the whole testsuite for more thorough testing -set job2=..\..\lib\test\regrtest.py -set path2=..\..\lib - -set job=%job1% -set clrpath=%path1% - -:CheckOpts -if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts -if "%1"=="-2" (set job=%job2%) & (set clrpath=%path2%) & shift & goto CheckOpts - -set PGI=%platf%-pgi -set PGO=%platf%-pgo - - at echo on -rem build the instrumented version -call build -p %platf% -c PGInstrument - -rem remove .pyc files, .pgc files and execute the job -%PGI%\python.exe rmpyc.py %clrpath% -del %PGI%\*.pgc -%PGI%\python.exe %job% - -rem finally build the optimized version -if exist %PGO% del /s /q %PGO% -call build -p %platf% -c PGUpdate - diff --git a/PC/VS8.0/build_ssl.bat b/PC/VS8.0/build_ssl.bat deleted file mode 100644 --- a/PC/VS8.0/build_ssl.bat +++ /dev/null @@ -1,12 +0,0 @@ - at echo off -if not defined HOST_PYTHON ( - if %1 EQU Debug ( - set HOST_PYTHON=python_d.exe - if not exist python34_d.dll exit 1 - ) ELSE ( - set HOST_PYTHON=python.exe - if not exist python34.dll exit 1 - ) -) -%HOST_PYTHON% build_ssl.py %1 %2 %3 - diff --git a/PC/VS8.0/build_ssl.py b/PC/VS8.0/build_ssl.py deleted file mode 100644 --- a/PC/VS8.0/build_ssl.py +++ /dev/null @@ -1,277 +0,0 @@ -# Script for building the _ssl and _hashlib modules for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for the actual _ssl.pyd and _hashlib.pyd DLLs. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PC/VS8.0 directory. -# -# it should configure and build SSL, then build the _ssl and _hashlib -# Python extensions without intervention. - -# Modified by Christian Heimes -# Now this script supports pre-generated makefiles and assembly files. -# Developers don't need an installation of Perl anymore to build Python. A svn -# checkout from our svn repository is enough. -# -# In Order to create the files in the case of an update you still need Perl. -# Run build_ssl in this order: -# python.exe build_ssl.py Release x64 -# python.exe build_ssl.py Release Win32 - -import os, sys, re, shutil - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen('"%s" -e "use Win32;"' % perl) - fh.read() - rc = fh.close() - if rc: - continue - return perl - print("Can not find a suitable PERL:") - if perls: - print(" the following perl interpreters were found:") - for p in perls: - print(" ", p) - print(" None of these versions appear suitable for building OpenSSL") - else: - print(" NO perl interpreters were found on this machine at all!") - print(" Please install ActivePerl and ensure it appears on your path") - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - # note: do not abspath s; the build will fail if any - # higher up directory name has spaces in it. - fnames = os.listdir(s) - except OSError: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print("Found an SSL directory at '%s'" % (best_name,)) - else: - print("Could not find an SSL directory in '%s'" % (sources,)) - sys.stdout.flush() - return best_name - -def create_makefile64(makefile, m32): - """Create and fix makefile for 64bit - - Replace 32 with 64bit directories - """ - if not os.path.isfile(m32): - return - with open(m32) as fin: - with open(makefile, 'w') as fout: - for line in fin: - line = line.replace("=tmp32", "=tmp64") - line = line.replace("=out32", "=out64") - line = line.replace("=inc32", "=inc64") - # force 64 bit machine - line = line.replace("MKLIB=lib", "MKLIB=lib /MACHINE:X64") - line = line.replace("LFLAGS=", "LFLAGS=/MACHINE:X64 ") - # don't link against the lib on 64bit systems - line = line.replace("bufferoverflowu.lib", "") - fout.write(line) - os.unlink(m32) - -def fix_makefile(makefile): - """Fix some stuff in all makefiles - """ - if not os.path.isfile(makefile): - return - with open(makefile) as fin: - lines = fin.readlines() - with open(makefile, 'w') as fout: - for line in lines: - if line.startswith("PERL="): - continue - if line.startswith("CP="): - line = "CP=copy\n" - if line.startswith("MKDIR="): - line = "MKDIR=mkdir\n" - if line.startswith("CFLAG="): - line = line.strip() - for algo in ("RC5", "MDC2", "IDEA"): - noalgo = " -DOPENSSL_NO_%s" % algo - if noalgo not in line: - line = line + noalgo - line = line + '\n' - fout.write(line) - -def run_configure(configure, do_script): - print("perl Configure "+configure+" no-idea no-mdc2") - os.system("perl Configure "+configure+" no-idea no-mdc2") - print(do_script) - os.system(do_script) - -def cmp(f1, f2): - bufsize = 1024 * 8 - with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True - -def copy(src, dst): - if os.path.isfile(dst) and cmp(src, dst): - return - shutil.copy(src, dst) - -def main(): - build_all = "-a" in sys.argv - if sys.argv[1] == "Release": - debug = False - elif sys.argv[1] == "Debug": - debug = True - else: - raise ValueError(str(sys.argv)) - - if sys.argv[2] == "Win32": - arch = "x86" - configure = "VC-WIN32" - do_script = "ms\\do_nasm" - makefile="ms\\nt.mak" - m32 = makefile - dirsuffix = "32" - elif sys.argv[2] == "x64": - arch="amd64" - configure = "VC-WIN64A" - do_script = "ms\\do_win64a" - makefile = "ms\\nt64.mak" - m32 = makefile.replace('64', '') - dirsuffix = "64" - #os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" - else: - raise ValueError(str(sys.argv)) - - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl: - print("Found a working perl at '%s'" % (perl,)) - else: - print("No Perl installation was found. Existing Makefiles are used.") - sys.stdout.flush() - # Look for SSL 3 levels up from PC/VS8.0 - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("..\\..\\..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # rebuild makefile when we do the role over from 32 to 64 build - if arch == "amd64" and os.path.isfile(m32) and not os.path.isfile(makefile): - os.unlink(m32) - - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - if perl is None: - print("Perl is required to build the makefiles!") - sys.exit(1) - - print("Creating the makefiles...") - sys.stdout.flush() - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.dirname(perl) + \ - os.pathsep + \ - os.environ["PATH"] - run_configure(configure, do_script) - if debug: - print("OpenSSL debug builds aren't supported.") - #if arch=="x86" and debug: - # # the do_masm script in openssl doesn't generate a debug - # # build makefile so we generate it here: - # os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile) - - if arch == "amd64": - create_makefile64(makefile, m32) - fix_makefile(makefile) - copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) - copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) - - # If the assembler files don't exist in tmpXX, copy them there - if perl is None and os.path.exists("asm"+dirsuffix): - if not os.path.exists("tmp"+dirsuffix): - os.mkdir("tmp"+dirsuffix) - for f in os.listdir("asm"+dirsuffix): - if not f.endswith(".asm"): continue - if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue - shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix) - - # Now run make. - if arch == "amd64": - rc = os.system("ml64 -c -Foms\\uptable.obj ms\\uptable.asm") - if rc: - print("ml64 assembler has failed.") - sys.exit(rc) - - copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h") - copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h") - - #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) - makeCommand = "nmake /nologo -f \"%s\"" % makefile - print("Executing ssl makefiles:", makeCommand) - sys.stdout.flush() - rc = os.system(makeCommand) - if rc: - print("Executing "+makefile+" failed") - print(rc) - sys.exit(rc) - finally: - os.chdir(old_cd) - sys.exit(rc) - -if __name__=='__main__': - main() diff --git a/PC/VS8.0/build_tkinter.py b/PC/VS8.0/build_tkinter.py deleted file mode 100644 --- a/PC/VS8.0/build_tkinter.py +++ /dev/null @@ -1,85 +0,0 @@ -"""Script to compile the dependencies of _tkinter - -Copyright (c) 2007 by Christian Heimes - -Licensed to PSF under a Contributor Agreement. -""" - -import os -import sys - -here = os.path.abspath(os.path.dirname(__file__)) -par = os.path.pardir - -if 1: - TCL = "tcl8.4.16" - TK = "tk8.4.16" - TIX = "tix-8.4.0" -else: - TCL = "tcl8.5b3" - TK = "tcl8.5b3" - TIX = "Tix8.4.2" - -ROOT = os.path.abspath(os.path.join(here, par, par, par)) -# Windows 2000 compatibility: WINVER 0x0500 -# http://msdn2.microsoft.com/en-us/library/aa383745.aspx -NMAKE = "nmake /nologo /f %s COMPILERFLAGS=-DWINVER=0x0500 %s %s" - -def nmake(makefile, command="", **kw): - defines = ' '.join(k+'='+v for k, v in kw.items()) - cmd = NMAKE % (makefile, defines, command) - print("\n\n"+cmd+"\n") - if os.system(cmd) != 0: - raise RuntimeError(cmd) - -def build(platform, clean): - if platform == "Win32": - dest = os.path.join(ROOT, "tcltk") - machine = "X86" - elif platform == "x64": - dest = os.path.join(ROOT, "tcltk64") - machine = "X64" - else: - raise ValueError(platform) - - # TCL - tcldir = os.path.join(ROOT, TCL) - if 1: - os.chdir(os.path.join(tcldir, "win")) - if clean: - nmake("makefile.vc", "clean") - nmake("makefile.vc") - nmake("makefile.vc", "install", INSTALLDIR=dest) - - # TK - if 1: - os.chdir(os.path.join(ROOT, TK, "win")) - if clean: - nmake("makefile.vc", "clean", TCLDIR=tcldir) - nmake("makefile.vc", TCLDIR=tcldir) - nmake("makefile.vc", "install", TCLDIR=tcldir, INSTALLDIR=dest) - - # TIX - if 1: - # python9.mak is available at http://svn.python.org - os.chdir(os.path.join(ROOT, TIX, "win")) - if clean: - nmake("python9.mak", "clean") - nmake("python9.mak", MACHINE=machine) - nmake("python9.mak", "install") - -def main(): - if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "x64"): - print("%s Win32|x64" % sys.argv[0]) - sys.exit(1) - - if "-c" in sys.argv: - clean = True - else: - clean = False - - build(sys.argv[1], clean) - - -if __name__ == '__main__': - main() diff --git a/PC/VS8.0/bz2.vcproj b/PC/VS8.0/bz2.vcproj deleted file mode 100644 --- a/PC/VS8.0/bz2.vcproj +++ /dev/null @@ -1,581 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/debug.vsprops b/PC/VS8.0/debug.vsprops deleted file mode 100644 --- a/PC/VS8.0/debug.vsprops +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/PC/VS8.0/env.bat b/PC/VS8.0/env.bat deleted file mode 100644 --- a/PC/VS8.0/env.bat +++ /dev/null @@ -1,5 +0,0 @@ - at echo off -set VS8=%ProgramFiles%\Microsoft Visual Studio 8 -echo Build environments: x86, ia64, amd64, x86_amd64, x86_ia64 -echo. -call "%VS8%\VC\vcvarsall.bat" %1 diff --git a/PC/VS8.0/field3.py b/PC/VS8.0/field3.py deleted file mode 100644 --- a/PC/VS8.0/field3.py +++ /dev/null @@ -1,35 +0,0 @@ -# An absurd workaround for the lack of arithmetic in MS's resource compiler. -# After building Python, run this, then paste the output into the appropriate -# part of PC\python_nt.rc. -# Example output: -# -# * For 2.3a0, -# * PY_MICRO_VERSION = 0 -# * PY_RELEASE_LEVEL = 'alpha' = 0xA -# * PY_RELEASE_SERIAL = 1 -# * -# * and 0*1000 + 10*10 + 1 = 101. -# */ -# #define FIELD3 101 - -import sys - -major, minor, micro, level, serial = sys.version_info -levelnum = {'alpha': 0xA, - 'beta': 0xB, - 'candidate': 0xC, - 'final': 0xF, - }[level] -string = sys.version.split()[0] # like '2.3a0' - -print(" * For %s," % string) -print(" * PY_MICRO_VERSION = %d" % micro) -print(" * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum))) -print(" * PY_RELEASE_SERIAL = %d" % serial) -print(" *") - -field3 = micro * 1000 + levelnum * 10 + serial - -print(" * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3)) -print(" */") -print("#define FIELD3", field3) diff --git a/PC/VS8.0/idle.bat b/PC/VS8.0/idle.bat deleted file mode 100644 --- a/PC/VS8.0/idle.bat +++ /dev/null @@ -1,15 +0,0 @@ - at echo off -rem start idle -rem Usage: idle [-d] -rem -d Run Debug build (python_d.exe). Else release build. - -setlocal -set exe=python -PATH %PATH%;..\..\..\tcltk\bin - -if "%1"=="-d" (set exe=python_d) & shift - -set cmd=%exe% ../../Lib/idlelib/idle.py %1 %2 %3 %4 %5 %6 %7 %8 %9 - -echo on -%cmd% diff --git a/PC/VS8.0/kill_python.c b/PC/VS8.0/kill_python.c deleted file mode 100644 --- a/PC/VS8.0/kill_python.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Helper program for killing lingering python[_d].exe processes before - * building, thus attempting to avoid build failures due to files being - * locked. - */ - -#include -#include -#include -#include - -#pragma comment(lib, "psapi") - -#ifdef _DEBUG -#define PYTHON_EXE (L"python_d.exe") -#define PYTHON_EXE_LEN (12) -#define KILL_PYTHON_EXE (L"kill_python_d.exe") -#define KILL_PYTHON_EXE_LEN (17) -#else -#define PYTHON_EXE (L"python.exe") -#define PYTHON_EXE_LEN (10) -#define KILL_PYTHON_EXE (L"kill_python.exe") -#define KILL_PYTHON_EXE_LEN (15) -#endif - -int -main(int argc, char **argv) -{ - HANDLE hp, hsp, hsm; /* process, snapshot processes, snapshot modules */ - DWORD dac, our_pid; - size_t len; - wchar_t path[MAX_PATH+1]; - - MODULEENTRY32W me; - PROCESSENTRY32W pe; - - me.dwSize = sizeof(MODULEENTRY32W); - pe.dwSize = sizeof(PROCESSENTRY32W); - - memset(path, 0, MAX_PATH+1); - - our_pid = GetCurrentProcessId(); - - hsm = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, our_pid); - if (hsm == INVALID_HANDLE_VALUE) { - printf("CreateToolhelp32Snapshot[1] failed: %d\n", GetLastError()); - return 1; - } - - if (!Module32FirstW(hsm, &me)) { - printf("Module32FirstW[1] failed: %d\n", GetLastError()); - CloseHandle(hsm); - return 1; - } - - /* - * Enumerate over the modules for the current process in order to find - * kill_process[_d].exe, then take a note of the directory it lives in. - */ - do { - if (_wcsnicmp(me.szModule, KILL_PYTHON_EXE, KILL_PYTHON_EXE_LEN)) - continue; - - len = wcsnlen_s(me.szExePath, MAX_PATH) - KILL_PYTHON_EXE_LEN; - wcsncpy_s(path, MAX_PATH+1, me.szExePath, len); - - break; - - } while (Module32NextW(hsm, &me)); - - CloseHandle(hsm); - - if (path == NULL) { - printf("failed to discern directory of running process\n"); - return 1; - } - - /* - * Take a snapshot of system processes. Enumerate over the snapshot, - * looking for python processes. When we find one, verify it lives - * in the same directory we live in. If it does, kill it. If we're - * unable to kill it, treat this as a fatal error and return 1. - * - * The rationale behind this is that we're called at the start of the - * build process on the basis that we'll take care of killing any - * running instances, such that the build won't encounter permission - * denied errors during linking. If we can't kill one of the processes, - * we can't provide this assurance, and the build shouldn't start. - */ - - hsp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (hsp == INVALID_HANDLE_VALUE) { - printf("CreateToolhelp32Snapshot[2] failed: %d\n", GetLastError()); - return 1; - } - - if (!Process32FirstW(hsp, &pe)) { - printf("Process32FirstW failed: %d\n", GetLastError()); - CloseHandle(hsp); - return 1; - } - - dac = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE; - do { - - /* - * XXX TODO: if we really wanted to be fancy, we could check the - * modules for all processes (not just the python[_d].exe ones) - * and see if any of our DLLs are loaded (i.e. python34[_d].dll), - * as that would also inhibit our ability to rebuild the solution. - * Not worth loosing sleep over though; for now, a simple check - * for just the python executable should be sufficient. - */ - - if (_wcsnicmp(pe.szExeFile, PYTHON_EXE, PYTHON_EXE_LEN)) - /* This isn't a python process. */ - continue; - - /* It's a python process, so figure out which directory it's in... */ - hsm = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pe.th32ProcessID); - if (hsm == INVALID_HANDLE_VALUE) - /* - * If our module snapshot fails (which will happen if we don't own - * the process), just ignore it and continue. (It seems different - * versions of Windows return different values for GetLastError() - * in this situation; it's easier to just ignore it and move on vs. - * stopping the build for what could be a false positive.) - */ - continue; - - if (!Module32FirstW(hsm, &me)) { - printf("Module32FirstW[2] failed: %d\n", GetLastError()); - CloseHandle(hsp); - CloseHandle(hsm); - return 1; - } - - do { - if (_wcsnicmp(me.szModule, PYTHON_EXE, PYTHON_EXE_LEN)) - /* Wrong module, we're looking for python[_d].exe... */ - continue; - - if (_wcsnicmp(path, me.szExePath, len)) - /* Process doesn't live in our directory. */ - break; - - /* Python process residing in the right directory, kill it! */ - hp = OpenProcess(dac, FALSE, pe.th32ProcessID); - if (!hp) { - printf("OpenProcess failed: %d\n", GetLastError()); - CloseHandle(hsp); - CloseHandle(hsm); - return 1; - } - - if (!TerminateProcess(hp, 1)) { - printf("TerminateProcess failed: %d\n", GetLastError()); - CloseHandle(hsp); - CloseHandle(hsm); - CloseHandle(hp); - return 1; - } - - CloseHandle(hp); - break; - - } while (Module32NextW(hsm, &me)); - - CloseHandle(hsm); - - } while (Process32NextW(hsp, &pe)); - - CloseHandle(hsp); - - return 0; -} - -/* vi: set ts=8 sw=4 sts=4 expandtab */ diff --git a/PC/VS8.0/kill_python.vcproj b/PC/VS8.0/kill_python.vcproj deleted file mode 100644 --- a/PC/VS8.0/kill_python.vcproj +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/make_buildinfo.c b/PC/VS8.0/make_buildinfo.c deleted file mode 100644 --- a/PC/VS8.0/make_buildinfo.c +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include - -#define CMD_SIZE 500 - -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PCBuild\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\..\\Modules\\getbuildinfo.c instead. - - Currently, subwcrev.exe is found from the registry entries - of TortoiseSVN. - - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. - - However, if a second argument is provided, this will be used - as a temporary directory where any getbuildinfo2.c and - getbuildinfo.o files are put. This is useful if multiple - configurations are being built in parallel, to avoid them - trampling each other's files. - -*/ - -int make_buildinfo2(const char *tmppath) -{ - struct _stat st; - HKEY hTortoise; - char command[CMD_SIZE+1]; - DWORD type, size; - if (_stat(".svn", &st) < 0) - return 0; - /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ - if (_stat("no_subwcrev", &st) == 0) - return 0; - if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && - RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) - /* Tortoise not installed */ - return 0; - command[0] = '"'; /* quote the path to the executable */ - size = sizeof(command) - 1; - if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || - type != REG_SZ) - /* Registry corrupted */ - return 0; - strcat_s(command, CMD_SIZE, "bin\\subwcrev.exe"); - if (_stat(command+1, &st) < 0) - /* subwcrev.exe not part of the release */ - return 0; - strcat_s(command, CMD_SIZE, "\" ..\\.. ..\\..\\Modules\\getbuildinfo.c "); - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo2.c"); - puts(command); fflush(stdout); - if (system(command) < 0) - return 0; - return 1; -} - -int main(int argc, char*argv[]) -{ - char command[CMD_SIZE] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - char tmppath[CMD_SIZE] = ""; - int do_unlink, result; - char *tmpdir = NULL; - if (argc <= 2 || argc > 3) { - fprintf(stderr, "make_buildinfo $(ConfigurationName) [tmpdir]\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat_s(command, CMD_SIZE, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat_s(command, CMD_SIZE, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat_s(command, CMD_SIZE, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat_s(command, CMD_SIZE, "-MD "); - strcat_s(command, CMD_SIZE, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } - if (argc > 2) { - tmpdir = argv[2]; - strcat_s(tmppath, _countof(tmppath), tmpdir); - strcat_s(tmppath, _countof(tmppath), "\\"); - } - - if ((do_unlink = make_buildinfo2(tmppath))) { - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo2.c -DSUBWCREV "); - } else - strcat_s(command, CMD_SIZE, "..\\..\\Modules\\getbuildinfo.c"); - strcat_s(command, CMD_SIZE, " -Fo"); - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo.o -I..\\..\\Include -I..\\..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) { - command[0] = '\0'; - strcat_s(command, CMD_SIZE, tmppath); - strcat_s(command, CMD_SIZE, "getbuildinfo2.c"); - _unlink(command); - } - if (result < 0) - return EXIT_FAILURE; - return 0; -} diff --git a/PC/VS8.0/make_buildinfo.vcproj b/PC/VS8.0/make_buildinfo.vcproj deleted file mode 100644 --- a/PC/VS8.0/make_buildinfo.vcproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/make_versioninfo.vcproj b/PC/VS8.0/make_versioninfo.vcproj deleted file mode 100644 --- a/PC/VS8.0/make_versioninfo.vcproj +++ /dev/null @@ -1,324 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pcbuild.sln b/PC/VS8.0/pcbuild.sln deleted file mode 100644 --- a/PC/VS8.0/pcbuild.sln +++ /dev/null @@ -1,555 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} = {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_versioninfo", "make_versioninfo.vcproj", "{F0E0541E-F17D-430B-97C4-93ADF0DD284E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" - ProjectSection(ProjectDependencies) = postProject - {F0E0541E-F17D-430B-97C4-93ADF0DD284E} = {F0E0541E-F17D-430B-97C4-93ADF0DD284E} - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_buildinfo", "make_buildinfo.vcproj", "{C73F0EC1-358B-4177-940F-0846AC8B04CD}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{553EC33E-9816-4996-A660-5D6186A0B0B3}" - ProjectSection(SolutionItems) = preProject - ..\..\Modules\getbuildinfo.c = ..\..\Modules\getbuildinfo.c - readme.txt = readme.txt - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winsound", "winsound.vcproj", "{28B5D777-DDF2-4B6B-B34F-31D938813856}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes", "_ctypes.vcproj", "{0E9791DB-593A-465F-98BC-681011311618}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes_test", "_ctypes_test.vcproj", "{9EC7190A-249F-4180-A900-548FDCF3055F}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_elementtree", "_elementtree.vcproj", "{17E1E049-C309-4D79-843F-AE483C264AEA}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_msi", "_msi.vcproj", "{31FFC478-7B4A-43E8-9954-8D03E2187E9C}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_socket", "_socket.vcproj", "{86937F53-C189-40EF-8CE8-8759D8E7D480}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{13CECB97-4119-4316-9D42-8534019A5A44}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {A1A295E5-463C-437F-81CA-1F32367685DA} = {A1A295E5-463C-437F-81CA-1F32367685DA} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ssl", "_ssl.vcproj", "{C6E20F84-3247-4AD6-B051-B073268F73BA}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - {86937F53-C189-40EF-8CE8-8759D8E7D480} = {86937F53-C189-40EF-8CE8-8759D8E7D480} - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} = {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testcapi", "_testcapi.vcproj", "{6901D91C-6E48-4BB7-9FEC-700C8131DF1D}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_tkinter", "_tkinter.vcproj", "{4946ECAC-2E69-4BF8-A90A-F5136F5094DF}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bz2", "bz2.vcproj", "{73FCD2BD-F133-46B7-8EC1-144CD82A59D5}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select", "select.vcproj", "{18CAE28C-B454-46C1-87A0-493D91D97F03}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicodedata", "unicodedata.vcproj", "{ECC7CEAC-A5E5-458E-BB9E-2413CC847881}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pyexpat", "pyexpat.vcproj", "{D06B6426-4762-44CC-8BAD-D79052507F2F}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bdist_wininst", "bdist_wininst.vcproj", "{EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} = {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}" - ProjectSection(ProjectDependencies) = postProject - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_multiprocessing", "_multiprocessing.vcproj", "{9E48B300-37D1-11DD-8C41-005056C00008}" - ProjectSection(ProjectDependencies) = postProject - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl", "ssl.vcproj", "{E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}" - ProjectSection(ProjectDependencies) = postProject - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kill_python", "kill_python.vcproj", "{6DE10744-E396-40A5-B4E2-1B69AA7C8D31}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - PGInstrument|Win32 = PGInstrument|Win32 - PGInstrument|x64 = PGInstrument|x64 - PGUpdate|Win32 = PGUpdate|Win32 - PGUpdate|x64 = PGUpdate|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.ActiveCfg = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.Build.0 = Debug|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.ActiveCfg = Debug|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.Build.0 = Debug|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.ActiveCfg = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.ActiveCfg = Release|x64 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.Build.0 = Release|x64 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.ActiveCfg = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.Build.0 = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.ActiveCfg = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.Build.0 = Debug|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|x64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGInstrument|x64.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|x64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGUpdate|x64.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.ActiveCfg = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.Build.0 = Debug|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.ActiveCfg = Debug|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.Build.0 = Debug|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.ActiveCfg = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.ActiveCfg = Release|x64 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.Build.0 = Release|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.ActiveCfg = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.Build.0 = Debug|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.ActiveCfg = Debug|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.Build.0 = Debug|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.ActiveCfg = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.ActiveCfg = Release|x64 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.Build.0 = Release|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.ActiveCfg = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.Build.0 = Debug|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.ActiveCfg = Debug|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.Build.0 = Debug|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.ActiveCfg = Release|x64 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.Build.0 = Release|x64 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGInstrument|x64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGUpdate|x64.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.Build.0 = Release|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|Win32.ActiveCfg = Debug|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|Win32.Build.0 = Debug|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|x64.ActiveCfg = Debug|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Debug|x64.Build.0 = Debug|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|Win32.ActiveCfg = Release|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|Win32.Build.0 = Release|Win32 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|x64.ActiveCfg = Release|x64 - {28B5D777-DDF2-4B6B-B34F-31D938813856}.Release|x64.Build.0 = Release|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|Win32.ActiveCfg = Debug|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|Win32.Build.0 = Debug|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|x64.ActiveCfg = Debug|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Debug|x64.Build.0 = Debug|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {0E9791DB-593A-465F-98BC-681011311618}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Release|Win32.ActiveCfg = Release|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Release|Win32.Build.0 = Release|Win32 - {0E9791DB-593A-465F-98BC-681011311618}.Release|x64.ActiveCfg = Release|x64 - {0E9791DB-593A-465F-98BC-681011311618}.Release|x64.Build.0 = Release|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|Win32.ActiveCfg = Debug|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|Win32.Build.0 = Debug|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|x64.ActiveCfg = Debug|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Debug|x64.Build.0 = Debug|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|Win32.ActiveCfg = Release|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|Win32.Build.0 = Release|Win32 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|x64.ActiveCfg = Release|x64 - {9EC7190A-249F-4180-A900-548FDCF3055F}.Release|x64.Build.0 = Release|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|Win32.ActiveCfg = Debug|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|Win32.Build.0 = Debug|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|x64.ActiveCfg = Debug|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Debug|x64.Build.0 = Debug|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|Win32.ActiveCfg = Release|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|Win32.Build.0 = Release|Win32 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|x64.ActiveCfg = Release|x64 - {17E1E049-C309-4D79-843F-AE483C264AEA}.Release|x64.Build.0 = Release|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|Win32.ActiveCfg = Debug|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|Win32.Build.0 = Debug|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|x64.ActiveCfg = Debug|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Debug|x64.Build.0 = Debug|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|Win32.ActiveCfg = Release|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|Win32.Build.0 = Release|Win32 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|x64.ActiveCfg = Release|x64 - {31FFC478-7B4A-43E8-9954-8D03E2187E9C}.Release|x64.Build.0 = Release|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|Win32.ActiveCfg = Debug|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|Win32.Build.0 = Debug|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|x64.ActiveCfg = Debug|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Debug|x64.Build.0 = Debug|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|Win32.ActiveCfg = Release|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|Win32.Build.0 = Release|Win32 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|x64.ActiveCfg = Release|x64 - {86937F53-C189-40EF-8CE8-8759D8E7D480}.Release|x64.Build.0 = Release|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|Win32.ActiveCfg = Debug|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|Win32.Build.0 = Debug|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|x64.ActiveCfg = Debug|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Debug|x64.Build.0 = Debug|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|Win32.ActiveCfg = Release|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|Win32.Build.0 = Release|Win32 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|x64.ActiveCfg = Release|x64 - {13CECB97-4119-4316-9D42-8534019A5A44}.Release|x64.Build.0 = Release|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|Win32.ActiveCfg = Debug|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|Win32.Build.0 = Debug|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|x64.ActiveCfg = Debug|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Debug|x64.Build.0 = Debug|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|Win32.ActiveCfg = Release|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|Win32.Build.0 = Release|Win32 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|x64.ActiveCfg = Release|x64 - {C6E20F84-3247-4AD6-B051-B073268F73BA}.Release|x64.Build.0 = Release|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|Win32.ActiveCfg = Debug|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|Win32.Build.0 = Debug|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|x64.ActiveCfg = Debug|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Debug|x64.Build.0 = Debug|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|Win32.ActiveCfg = Release|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|Win32.Build.0 = Release|Win32 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|x64.ActiveCfg = Release|x64 - {6901D91C-6E48-4BB7-9FEC-700C8131DF1D}.Release|x64.Build.0 = Release|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|Win32.Build.0 = Debug|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|x64.ActiveCfg = Debug|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Debug|x64.Build.0 = Debug|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|Win32.ActiveCfg = Release|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|Win32.Build.0 = Release|Win32 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|x64.ActiveCfg = Release|x64 - {4946ECAC-2E69-4BF8-A90A-F5136F5094DF}.Release|x64.Build.0 = Release|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|Win32.ActiveCfg = Debug|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|Win32.Build.0 = Debug|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|x64.ActiveCfg = Debug|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Debug|x64.Build.0 = Debug|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|Win32.ActiveCfg = Release|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|Win32.Build.0 = Release|Win32 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|x64.ActiveCfg = Release|x64 - {73FCD2BD-F133-46B7-8EC1-144CD82A59D5}.Release|x64.Build.0 = Release|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|Win32.ActiveCfg = Debug|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|Win32.Build.0 = Debug|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|x64.ActiveCfg = Debug|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Debug|x64.Build.0 = Debug|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|Win32.ActiveCfg = Release|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|Win32.Build.0 = Release|Win32 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|x64.ActiveCfg = Release|x64 - {18CAE28C-B454-46C1-87A0-493D91D97F03}.Release|x64.Build.0 = Release|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|Win32.ActiveCfg = Debug|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|Win32.Build.0 = Debug|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|x64.ActiveCfg = Debug|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Debug|x64.Build.0 = Debug|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|Win32.ActiveCfg = Release|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|Win32.Build.0 = Release|Win32 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|x64.ActiveCfg = Release|x64 - {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}.Release|x64.Build.0 = Release|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|Win32.ActiveCfg = Debug|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|Win32.Build.0 = Debug|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|x64.ActiveCfg = Debug|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Debug|x64.Build.0 = Debug|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|Win32.ActiveCfg = Release|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|Win32.Build.0 = Release|Win32 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|x64.ActiveCfg = Release|x64 - {D06B6426-4762-44CC-8BAD-D79052507F2F}.Release|x64.Build.0 = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Debug|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Debug|x64.ActiveCfg = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGInstrument|x64.ActiveCfg = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.PGUpdate|x64.ActiveCfg = Release|x64 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Release|Win32.ActiveCfg = Release|Win32 - {EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}.Release|x64.ActiveCfg = Release|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|Win32.ActiveCfg = Debug|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|Win32.Build.0 = Debug|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|x64.ActiveCfg = Debug|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Debug|x64.Build.0 = Debug|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|Win32.ActiveCfg = Release|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|Win32.Build.0 = Release|Win32 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|x64.ActiveCfg = Release|x64 - {447F05A8-F581-4CAC-A466-5AC7936E207E}.Release|x64.Build.0 = Release|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|Win32.ActiveCfg = Debug|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|Win32.Build.0 = Debug|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|x64.ActiveCfg = Debug|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Debug|x64.Build.0 = Debug|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|Win32.ActiveCfg = Release|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|Win32.Build.0 = Release|Win32 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|x64.ActiveCfg = Release|x64 - {A1A295E5-463C-437F-81CA-1F32367685DA}.Release|x64.Build.0 = Release|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|Win32.ActiveCfg = Debug|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|Win32.Build.0 = Debug|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|x64.ActiveCfg = Debug|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Debug|x64.Build.0 = Debug|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|Win32.ActiveCfg = Release|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|Win32.Build.0 = Release|Win32 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|x64.ActiveCfg = Release|x64 - {9E48B300-37D1-11DD-8C41-005056C00008}.Release|x64.Build.0 = Release|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|Win32.ActiveCfg = Debug|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|Win32.Build.0 = Debug|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|x64.ActiveCfg = Debug|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Debug|x64.Build.0 = Debug|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|Win32.ActiveCfg = Release|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|Win32.Build.0 = Release|Win32 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|x64.ActiveCfg = Release|x64 - {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}.Release|x64.Build.0 = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|Win32.Build.0 = Debug|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|x64.ActiveCfg = Debug|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Debug|x64.Build.0 = Debug|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|Win32.Build.0 = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|x64.ActiveCfg = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGInstrument|x64.Build.0 = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|Win32.Build.0 = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|x64.ActiveCfg = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.PGUpdate|x64.Build.0 = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|Win32.ActiveCfg = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|Win32.Build.0 = Release|Win32 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.ActiveCfg = Release|x64 - {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/PC/VS8.0/pginstrument.vsprops b/PC/VS8.0/pginstrument.vsprops deleted file mode 100644 --- a/PC/VS8.0/pginstrument.vsprops +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - diff --git a/PC/VS8.0/pgupdate.vsprops b/PC/VS8.0/pgupdate.vsprops deleted file mode 100644 --- a/PC/VS8.0/pgupdate.vsprops +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/PC/VS8.0/pyd.vsprops b/PC/VS8.0/pyd.vsprops deleted file mode 100644 --- a/PC/VS8.0/pyd.vsprops +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - diff --git a/PC/VS8.0/pyd_d.vsprops b/PC/VS8.0/pyd_d.vsprops deleted file mode 100644 --- a/PC/VS8.0/pyd_d.vsprops +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - diff --git a/PC/VS8.0/pyexpat.vcproj b/PC/VS8.0/pyexpat.vcproj deleted file mode 100644 --- a/PC/VS8.0/pyexpat.vcproj +++ /dev/null @@ -1,553 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pyproject.vsprops b/PC/VS8.0/pyproject.vsprops deleted file mode 100644 --- a/PC/VS8.0/pyproject.vsprops +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/python.vcproj b/PC/VS8.0/python.vcproj deleted file mode 100644 --- a/PC/VS8.0/python.vcproj +++ /dev/null @@ -1,637 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pythoncore.vcproj b/PC/VS8.0/pythoncore.vcproj deleted file mode 100644 --- a/PC/VS8.0/pythoncore.vcproj +++ /dev/null @@ -1,1921 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/pythonw.vcproj b/PC/VS8.0/pythonw.vcproj deleted file mode 100644 --- a/PC/VS8.0/pythonw.vcproj +++ /dev/null @@ -1,618 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/release.vsprops b/PC/VS8.0/release.vsprops deleted file mode 100644 --- a/PC/VS8.0/release.vsprops +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/PC/VS8.0/rmpyc.py b/PC/VS8.0/rmpyc.py deleted file mode 100644 --- a/PC/VS8.0/rmpyc.py +++ /dev/null @@ -1,25 +0,0 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../../Lib") -print(npyc, ".pyc deleted,", npyo, ".pyo deleted") diff --git a/PC/VS8.0/rt.bat b/PC/VS8.0/rt.bat deleted file mode 100644 --- a/PC/VS8.0/rt.bat +++ /dev/null @@ -1,52 +0,0 @@ - at echo off -rem Run Tests. Run the regression test suite. -rem Usage: rt [-d] [-O] [-q] regrtest_args -rem -d Run Debug build (python_d.exe). Else release build. -rem -O Run python.exe or python_d.exe (see -d) with -O. -rem -q "quick" -- normally the tests are run twice, the first time -rem after deleting all the .py[co] files reachable from Lib/. -rem -q runs the tests just once, and without deleting .py[co] files. -rem All leading instances of these switches are shifted off, and -rem whatever remains is passed to regrtest.py. For example, -rem rt -O -d -x test_thread -rem runs -rem python_d -O ../lib/test/regrtest.py -x test_thread -rem twice, and -rem rt -q -g test_binascii -rem runs -rem python_d ../lib/test/regrtest.py -g test_binascii -rem to generate the expected-output file for binascii quickly. -rem -rem Confusing: if you want to pass a comma-separated list, like -rem -u network,largefile -rem then you have to quote it on the rt line, like -rem rt -u "network,largefile" - -setlocal - -set exe=python -set qmode= -set dashO= -PATH %PATH%;%~dp0..\..\..\tcltk\bin - -:CheckOpts -if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts -if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts -if "%1"=="-d" (set exe=python_d) & shift & goto CheckOpts - -set cmd=%exe% %dashO% -E ../../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 -if defined qmode goto Qmode - -echo Deleting .pyc/.pyo files ... -%exe% rmpyc.py - -echo on -%cmd% - at echo off - -echo About to run again without deleting .pyc/.pyo first: -pause - -:Qmode -echo on -%cmd% diff --git a/PC/VS8.0/select.vcproj b/PC/VS8.0/select.vcproj deleted file mode 100644 --- a/PC/VS8.0/select.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/sqlite3.vcproj b/PC/VS8.0/sqlite3.vcproj deleted file mode 100644 --- a/PC/VS8.0/sqlite3.vcproj +++ /dev/null @@ -1,537 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/sqlite3.vsprops b/PC/VS8.0/sqlite3.vsprops deleted file mode 100644 --- a/PC/VS8.0/sqlite3.vsprops +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/PC/VS8.0/ssl.vcproj b/PC/VS8.0/ssl.vcproj deleted file mode 100644 --- a/PC/VS8.0/ssl.vcproj +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/unicodedata.vcproj b/PC/VS8.0/unicodedata.vcproj deleted file mode 100644 --- a/PC/VS8.0/unicodedata.vcproj +++ /dev/null @@ -1,533 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/winsound.vcproj b/PC/VS8.0/winsound.vcproj deleted file mode 100644 --- a/PC/VS8.0/winsound.vcproj +++ /dev/null @@ -1,523 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PC/VS8.0/x64.vsprops b/PC/VS8.0/x64.vsprops deleted file mode 100644 --- a/PC/VS8.0/x64.vsprops +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/configure b/configure --- a/configure +++ b/configure @@ -625,6 +625,8 @@ ac_subst_vars='LTLIBOBJS SRCDIRS THREADHEADERS +LIBPL +PY_ENABLE_SHARED SOABI LIBC LIBM @@ -2944,7 +2946,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 $as_echo "$interp" >&6; } - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp fi elif test "$cross_compiling" = maybe; then as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 @@ -5573,6 +5575,7 @@ # Other platforms follow if test $enable_shared = "yes"; then + PY_ENABLE_SHARED=1 $as_echo "#define Py_ENABLE_SHARED 1" >>confdefs.h @@ -5630,6 +5633,7 @@ esac else # shared is disabled + PY_ENABLE_SHARED=0 case $ac_sys_system in CYGWIN*) BLDLIBRARY='$(LIBRARY)' @@ -13689,6 +13693,10 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDVERSION" >&5 $as_echo "$LDVERSION" >&6; } + +LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}" + + # SO is the extension of shared libraries `(including the dot!) # -- usually .so, .sl on HP-UX, .dll on Cygwin { $as_echo "$as_me:${as_lineno-$LINENO}: checking SO" >&5 @@ -15136,7 +15144,7 @@ fi # generate output files -ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc" +ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh" ac_config_files="$ac_config_files Modules/ld_so_aix" @@ -15840,6 +15848,7 @@ "Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;; "Modules/Setup.config") CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;; "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; + "Misc/python-config.sh") CONFIG_FILES="$CONFIG_FILES Misc/python-config.sh" ;; "Modules/ld_so_aix") CONFIG_FILES="$CONFIG_FILES Modules/ld_so_aix" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,7 @@ AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) fi AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp fi elif test "$cross_compiling" = maybe; then AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) @@ -917,6 +917,7 @@ # Other platforms follow if test $enable_shared = "yes"; then + PY_ENABLE_SHARED=1 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) case $ac_sys_system in CYGWIN*) @@ -972,6 +973,7 @@ esac else # shared is disabled + PY_ENABLE_SHARED=0 case $ac_sys_system in CYGWIN*) BLDLIBRARY='$(LIBRARY)' @@ -3929,6 +3931,11 @@ LDVERSION='$(VERSION)$(ABIFLAGS)' AC_MSG_RESULT($LDVERSION) +dnl define LIBPL after ABIFLAGS and LDVERSION is defined. +AC_SUBST(PY_ENABLE_SHARED) +LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}" +AC_SUBST(LIBPL) + # SO is the extension of shared libraries `(including the dot!) # -- usually .so, .sl on HP-UX, .dll on Cygwin AC_MSG_CHECKING(SO) @@ -4641,7 +4648,7 @@ fi # generate output files -AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) +AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) AC_OUTPUT -- Repository URL: http://hg.python.org/cpython From ezio.melotti at gmail.com Sat Jan 26 18:25:18 2013 From: ezio.melotti at gmail.com (Ezio Melotti) Date: Sat, 26 Jan 2013 19:25:18 +0200 Subject: [Python-checkins] cpython: Touch up exception messaging In-Reply-To: <3Yt8RJ6v3nzSLv@mail.python.org> References: <3Yt8RJ6v3nzSLv@mail.python.org> Message-ID: Hi, I'm not sure these changes are an improvement. On Fri, Jan 25, 2013 at 8:49 PM, brett.cannon wrote: > http://hg.python.org/cpython/rev/792810303239 > changeset: 81735:792810303239 > user: Brett Cannon > date: Fri Jan 25 13:49:19 2013 -0500 > summary: > Touch up exception messaging > [...] > magic = data[:4] > raw_timestamp = data[4:8] > raw_size = data[8:12] > if magic != _MAGIC_BYTES: > - msg = 'bad magic number in {!r}: {!r}'.format(name, magic) > + msg = 'incomplete magic number in {!r}: {!r}'.format(name, magic) Here 2 things could go wrong: 1) magic is less than 4 bytes (so it could be "incomplete"); 2) magic is 4 bytes, but it's different (so it's "invalid" or "bad"); For this to be "incomplete" the size of the whole file should be less than 4 bytes, and it's unlikely that in a 3bytes-long file the content is an incomplete magic number. It's much more likely than it's not a magic number at all, or that it is a bad/wrong/invalid 4-bytes magic number, so the previous error looked better to me. > raise ImportError(msg, **exc_details) > elif len(raw_timestamp) != 4: > - message = 'bad timestamp in {!r}'.format(name) > + message = 'incomplete timestamp in {!r}'.format(name) > _verbose_message(message) > raise EOFError(message) > elif len(raw_size) != 4: > - message = 'bad size in {!r}'.format(name) > + message = 'incomplete size in {!r}'.format(name) If we arrived here the magic number was right, so this are probably the timestamp and size, but for this to fail the whole file should be less than 8 or 12 bytes (unless I misread the code). Something like "reached EOF while reading timestamp/size" would probably be more informative. Best Regards, Ezio Melotti From python-checkins at python.org Sat Jan 26 19:00:35 2013 From: python-checkins at python.org (matthias.klose) Date: Sat, 26 Jan 2013 19:00:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogLSBJc3N1ZSAjMzcx?= =?utf-8?q?8=3A_Use_AC=5FARG=5FVAR_to_set_MACHDEP_in_configure=2Eac=2E?= Message-ID: <3YtlJM55qhzSPN@mail.python.org> http://hg.python.org/cpython/rev/8c49dd8e4d22 changeset: 81763:8c49dd8e4d22 branch: 3.3 parent: 81758:9a98ab22ab95 user: doko at python.org date: Sat Jan 26 18:57:19 2013 +0100 summary: - Issue #3718: Use AC_ARG_VAR to set MACHDEP in configure.ac. files: Misc/NEWS | 2 ++ configure | 2 ++ configure.ac | 2 +- 3 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -547,6 +547,8 @@ Build ----- +- Issue #3718: Use AC_ARG_VAR to set MACHDEP in configure.ac. + - Issue #17031: Fix running regen in cross builds. - Issue #3754: fix typo in pthread AC_CACHE_VAL. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -810,6 +810,7 @@ ac_precious_vars='build_alias host_alias target_alias +MACHDEP CC CFLAGS LDFLAGS @@ -1484,6 +1485,7 @@ default on supported compilers) Some influential environment variables: + MACHDEP name for machine-dependent library files CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -348,7 +348,7 @@ ## [Use (OpenStep|Rhapsody) dynamic linker])) ## # Set name for machine-dependent library files -AC_SUBST(MACHDEP) +AC_ARG_VAR([MACHDEP], [name for machine-dependent library files]) AC_MSG_CHECKING(MACHDEP) if test -z "$MACHDEP" then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sat Jan 26 19:00:37 2013 From: python-checkins at python.org (matthias.klose) Date: Sat, 26 Jan 2013 19:00:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_-_Issue_=233718=3A_Use_AC=5FARG=5FVAR_to_set_MACHDEP_in_?= =?utf-8?q?configure=2Eac=2E?= Message-ID: <3YtlJP1pRbzSSB@mail.python.org> http://hg.python.org/cpython/rev/6866384d9ccb changeset: 81764:6866384d9ccb parent: 81762:3a74ce3dfbf8 parent: 81763:8c49dd8e4d22 user: doko at python.org date: Sat Jan 26 19:00:20 2013 +0100 summary: - Issue #3718: Use AC_ARG_VAR to set MACHDEP in configure.ac. files: Misc/NEWS | 2 ++ configure | 2 ++ configure.ac | 2 +- 3 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -765,6 +765,8 @@ Build ----- +- Issue #3718: Use AC_ARG_VAR to set MACHDEP in configure.ac. + - Issue #16235: Implement python-config as a shell script. - Issue #16769: Remove outdated Visual Studio projects. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -812,6 +812,7 @@ ac_precious_vars='build_alias host_alias target_alias +MACHDEP CC CFLAGS LDFLAGS @@ -1486,6 +1487,7 @@ default on supported compilers) Some influential environment variables: + MACHDEP name for machine-dependent library files CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -348,7 +348,7 @@ ## [Use (OpenStep|Rhapsody) dynamic linker])) ## # Set name for machine-dependent library files -AC_SUBST(MACHDEP) +AC_ARG_VAR([MACHDEP], [name for machine-dependent library files]) AC_MSG_CHECKING(MACHDEP) if test -z "$MACHDEP" then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 00:24:27 2013 From: python-checkins at python.org (sandro.tosi) Date: Sun, 27 Jan 2013 00:24:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogZml4IHR5cG87IHRo?= =?utf-8?q?anks_to_Dmitry_Northerner_from_docs=40?= Message-ID: <3YttV35PCjzSN1@mail.python.org> http://hg.python.org/cpython/rev/43084fa2577c changeset: 81765:43084fa2577c branch: 2.7 parent: 81757:523f309cf558 user: Sandro Tosi date: Sun Jan 27 00:22:33 2013 +0100 summary: fix typo; thanks to Dmitry Northerner from docs@ files: Doc/reference/compound_stmts.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -294,7 +294,7 @@ is executed. If there is a saved exception, it is re-raised at the end of the :keyword:`finally` clause. If the :keyword:`finally` clause raises another exception or executes a :keyword:`return` or :keyword:`break` statement, the -saved exception is dicarded:: +saved exception is discarded:: def f(): try: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 00:33:39 2013 From: python-checkins at python.org (sandro.tosi) Date: Sun, 27 Jan 2013 00:33:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogZml4IHR5cG87IHRo?= =?utf-8?q?anks_to_Andrew_Harrington_from_docs=40?= Message-ID: <3Ytthh00dgzSRy@mail.python.org> http://hg.python.org/cpython/rev/78766fb868fb changeset: 81766:78766fb868fb branch: 3.3 parent: 81763:8c49dd8e4d22 user: Sandro Tosi date: Sun Jan 27 00:33:04 2013 +0100 summary: fix typo; thanks to Andrew Harrington from docs@ files: Doc/library/stdtypes.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1253,7 +1253,7 @@ the formula ``r[i] = start + step*i``, but the constraints are ``i >= 0`` and ``r[i] > stop``. - A range object will be empty if ``r[0]`` does not meant the value + A range object will be empty if ``r[0]`` does not meet the value constraint. Ranges do support negative indices, but these are interpreted as indexing from the end of the sequence determined by the positive indices. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 00:33:41 2013 From: python-checkins at python.org (sandro.tosi) Date: Sun, 27 Jan 2013 00:33:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E3?= Message-ID: <3Ytthj2vNMzSSP@mail.python.org> http://hg.python.org/cpython/rev/525d180a5416 changeset: 81767:525d180a5416 parent: 81764:6866384d9ccb parent: 81766:78766fb868fb user: Sandro Tosi date: Sun Jan 27 00:33:22 2013 +0100 summary: merge with 3.3 files: Doc/library/stdtypes.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1253,7 +1253,7 @@ the formula ``r[i] = start + step*i``, but the constraints are ``i >= 0`` and ``r[i] > stop``. - A range object will be empty if ``r[0]`` does not meant the value + A range object will be empty if ``r[0]`` does not meet the value constraint. Ranges do support negative indices, but these are interpreted as indexing from the end of the sequence determined by the positive indices. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 03:12:32 2013 From: python-checkins at python.org (ned.deily) Date: Sun, 27 Jan 2013 03:12:32 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE0MDE4?= =?utf-8?q?=3A_fix_merge_error?= Message-ID: <3YtyD0509JzSMK@mail.python.org> http://hg.python.org/cpython/rev/49294e55311f changeset: 81768:49294e55311f branch: 2.7 parent: 81765:43084fa2577c user: Ned Deily date: Sat Jan 26 18:08:22 2013 -0800 summary: Issue #14018: fix merge error files: setup.py | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -47,7 +47,6 @@ """ Returns True if 'path' can be located in an OSX SDK """ - return (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/') return ( (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/') or path.startswith('/Library/') ) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 03:12:34 2013 From: python-checkins at python.org (ned.deily) Date: Sun, 27 Jan 2013 03:12:34 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE0MDE4?= =?utf-8?q?=3A_fix_merge_error?= Message-ID: <3YtyD20SVtzSMW@mail.python.org> http://hg.python.org/cpython/rev/58646b0c5226 changeset: 81769:58646b0c5226 branch: 3.2 parent: 81749:f7eda8165e6f user: Ned Deily date: Sat Jan 26 18:09:12 2013 -0800 summary: Issue #14018: fix merge error files: setup.py | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -59,7 +59,6 @@ """ Returns True if 'path' can be located in an OSX SDK """ - return (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/') return ( (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/') or path.startswith('/Library/') ) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 03:12:35 2013 From: python-checkins at python.org (ned.deily) Date: Sun, 27 Jan 2013 03:12:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_null_merge?= Message-ID: <3YtyD332l7zSRh@mail.python.org> http://hg.python.org/cpython/rev/a0756411c527 changeset: 81770:a0756411c527 branch: 3.3 parent: 81766:78766fb868fb parent: 81769:58646b0c5226 user: Ned Deily date: Sat Jan 26 18:11:06 2013 -0800 summary: null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 03:12:36 2013 From: python-checkins at python.org (ned.deily) Date: Sun, 27 Jan 2013 03:12:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_null_merge?= Message-ID: <3YtyD46krwzST9@mail.python.org> http://hg.python.org/cpython/rev/491d7f9b879d changeset: 81771:491d7f9b879d parent: 81767:525d180a5416 parent: 81770:a0756411c527 user: Ned Deily date: Sat Jan 26 18:11:43 2013 -0800 summary: null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 05:21:11 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 27 Jan 2013 05:21:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Fix_a_few_typo?= =?utf-8?q?s_and_a_double_semicolon=2E__Patch_by_Eitan_Adler=2E?= Message-ID: <3Yv14R5h6lzSPg@mail.python.org> http://hg.python.org/cpython/rev/07488c3c85f1 changeset: 81772:07488c3c85f1 branch: 3.3 parent: 81770:a0756411c527 user: Ezio Melotti date: Sun Jan 27 06:20:14 2013 +0200 summary: Fix a few typos and a double semicolon. Patch by Eitan Adler. files: Lib/ipaddress.py | 2 +- Lib/test/test_email/test_headerregistry.py | 2 +- Lib/test/test_isinstance.py | 2 +- Lib/test/test_startfile.py | 2 +- Modules/_datetimemodule.c | 2 +- Modules/_decimal/libmpdec/mpdecimal.c | 2 +- Objects/floatobject.c | 2 +- Tools/gdb/libpython.py | 2 +- Tools/msi/schema.py | 2 +- Tools/msi/uisample.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -723,7 +723,7 @@ other: An IPv4Network or IPv6Network object of the same type. Returns: - An iterator of the the IPv(4|6)Network objects which is self + An iterator of the IPv(4|6)Network objects which is self minus other. Raises: diff --git a/Lib/test/test_email/test_headerregistry.py b/Lib/test/test_email/test_headerregistry.py --- a/Lib/test/test_email/test_headerregistry.py +++ b/Lib/test/test_email/test_headerregistry.py @@ -670,7 +670,7 @@ ), # XXX: I would say this one should default to ascii/en for the - # "encoded" segment, since the the first segment is not encoded and is + # "encoded" segment, since the first segment is not encoded and is # in double quotes, making the value a valid non-encoded string. The # old parser decodes this just like the previous case, which may be the # better Postel rule, but could equally result in borking headers that diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -15,7 +15,7 @@ # (leading to an "undetected error" in the debug build). Set up is, # isinstance(inst, cls) where: # - # - cls isn't a a type, or a tuple + # - cls isn't a type, or a tuple # - cls has a __bases__ attribute # - inst has a __class__ attribute # - inst.__class__ as no __bases__ attribute diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py --- a/Lib/test/test_startfile.py +++ b/Lib/test/test_startfile.py @@ -5,7 +5,7 @@ # # A possible improvement would be to have empty.vbs do something that # we can detect here, to make sure that not only the os.startfile() -# call succeeded, but also the the script actually has run. +# call succeeded, but also the script actually has run. import unittest from test import support diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -3598,7 +3598,7 @@ { char buf[100]; PyObject *result; - int us = TIME_GET_MICROSECOND(self);; + int us = TIME_GET_MICROSECOND(self); if (us) result = PyUnicode_FromFormat("%02d:%02d:%02d.%06d", diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -2084,7 +2084,7 @@ } /* - * Compare a and b, convert the the usual integer result to a decimal and + * Compare a and b, convert the usual integer result to a decimal and * store it in 'result'. For convenience, the integer result of the comparison * is returned. Comparisons involving NaNs return NaN/INT_MAX. */ diff --git a/Objects/floatobject.c b/Objects/floatobject.c --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -289,7 +289,7 @@ * may lose info from fractional bits. Converting the integer to a double * also has two failure modes: (1) a long int may trigger overflow (too * large to fit in the dynamic range of a C double); (2) even a C long may have - * more bits than fit in a C double (e.g., on a a 64-bit box long may have + * more bits than fit in a C double (e.g., on a 64-bit box long may have * 63 bits of precision, but a C double probably has only 53), and then * we can falsely claim equality when low-order integer bits are lost by * coercion to double. So this part is painful too. diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -1463,7 +1463,7 @@ return name.startswith('pthread_cond_timedwait') def is_gc_collect(self): - '''Is this frame "collect" within the the garbage-collector?''' + '''Is this frame "collect" within the garbage-collector?''' return self._gdbframe.name() == 'collect' def get_pyop(self): diff --git a/Tools/msi/schema.py b/Tools/msi/schema.py --- a/Tools/msi/schema.py +++ b/Tools/msi/schema.py @@ -958,7 +958,7 @@ (u'ServiceInstall',u'StartType',u'N',0,4,None, None, None, None, u'Type of the service',), (u'Shortcut',u'Name',u'N',None, None, None, None, u'Filename',None, u'The name of the shortcut to be created.',), (u'Shortcut',u'Description',u'Y',None, None, None, None, u'Text',None, u'The description for the shortcut.',), -(u'Shortcut',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table denoting the component whose selection gates the the shortcut creation/deletion.',), +(u'Shortcut',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table denoting the component whose selection gates the shortcut creation/deletion.',), (u'Shortcut',u'Icon_',u'Y',None, None, u'Icon',1,u'Identifier',None, u'Foreign key into the File table denoting the external icon file for the shortcut.',), (u'Shortcut',u'IconIndex',u'Y',-32767,32767,None, None, None, None, u'The icon index for the shortcut.',), (u'Shortcut',u'Directory_',u'N',None, None, u'Directory',1,u'Identifier',None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.',), diff --git a/Tools/msi/uisample.py b/Tools/msi/uisample.py --- a/Tools/msi/uisample.py +++ b/Tools/msi/uisample.py @@ -1195,7 +1195,7 @@ (u'ServiceInstall', u'StartType', u'N', 0, 4, None, None, None, None, u'Type of the service'), (u'Shortcut', u'Name', u'N', None, None, None, None, u'Filename', None, u'The name of the shortcut to be created.'), (u'Shortcut', u'Description', u'Y', None, None, None, None, u'Text', None, u'The description for the shortcut.'), -(u'Shortcut', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table denoting the component whose selection gates the the shortcut creation/deletion.'), +(u'Shortcut', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table denoting the component whose selection gates the shortcut creation/deletion.'), (u'Shortcut', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Foreign key into the File table denoting the external icon file for the shortcut.'), (u'Shortcut', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'The icon index for the shortcut.'), (u'Shortcut', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.'), -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 05:21:13 2013 From: python-checkins at python.org (ezio.melotti) Date: Sun, 27 Jan 2013 05:21:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge_typo_fixes_from_3=2E3=2E?= Message-ID: <3Yv14T3GVXzSQK@mail.python.org> http://hg.python.org/cpython/rev/2cf89e2e6247 changeset: 81773:2cf89e2e6247 parent: 81771:491d7f9b879d parent: 81772:07488c3c85f1 user: Ezio Melotti date: Sun Jan 27 06:20:51 2013 +0200 summary: Merge typo fixes from 3.3. files: Lib/ipaddress.py | 2 +- Lib/test/test_email/test_headerregistry.py | 2 +- Lib/test/test_isinstance.py | 2 +- Lib/test/test_startfile.py | 2 +- Modules/_datetimemodule.c | 2 +- Modules/_decimal/libmpdec/mpdecimal.c | 2 +- Objects/floatobject.c | 2 +- Tools/gdb/libpython.py | 2 +- Tools/msi/schema.py | 2 +- Tools/msi/uisample.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -723,7 +723,7 @@ other: An IPv4Network or IPv6Network object of the same type. Returns: - An iterator of the the IPv(4|6)Network objects which is self + An iterator of the IPv(4|6)Network objects which is self minus other. Raises: diff --git a/Lib/test/test_email/test_headerregistry.py b/Lib/test/test_email/test_headerregistry.py --- a/Lib/test/test_email/test_headerregistry.py +++ b/Lib/test/test_email/test_headerregistry.py @@ -670,7 +670,7 @@ ), # XXX: I would say this one should default to ascii/en for the - # "encoded" segment, since the the first segment is not encoded and is + # "encoded" segment, since the first segment is not encoded and is # in double quotes, making the value a valid non-encoded string. The # old parser decodes this just like the previous case, which may be the # better Postel rule, but could equally result in borking headers that diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -15,7 +15,7 @@ # (leading to an "undetected error" in the debug build). Set up is, # isinstance(inst, cls) where: # - # - cls isn't a a type, or a tuple + # - cls isn't a type, or a tuple # - cls has a __bases__ attribute # - inst has a __class__ attribute # - inst.__class__ as no __bases__ attribute diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py --- a/Lib/test/test_startfile.py +++ b/Lib/test/test_startfile.py @@ -5,7 +5,7 @@ # # A possible improvement would be to have empty.vbs do something that # we can detect here, to make sure that not only the os.startfile() -# call succeeded, but also the the script actually has run. +# call succeeded, but also the script actually has run. import unittest from test import support diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -3598,7 +3598,7 @@ { char buf[100]; PyObject *result; - int us = TIME_GET_MICROSECOND(self);; + int us = TIME_GET_MICROSECOND(self); if (us) result = PyUnicode_FromFormat("%02d:%02d:%02d.%06d", diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -2084,7 +2084,7 @@ } /* - * Compare a and b, convert the the usual integer result to a decimal and + * Compare a and b, convert the usual integer result to a decimal and * store it in 'result'. For convenience, the integer result of the comparison * is returned. Comparisons involving NaNs return NaN/INT_MAX. */ diff --git a/Objects/floatobject.c b/Objects/floatobject.c --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -289,7 +289,7 @@ * may lose info from fractional bits. Converting the integer to a double * also has two failure modes: (1) a long int may trigger overflow (too * large to fit in the dynamic range of a C double); (2) even a C long may have - * more bits than fit in a C double (e.g., on a a 64-bit box long may have + * more bits than fit in a C double (e.g., on a 64-bit box long may have * 63 bits of precision, but a C double probably has only 53), and then * we can falsely claim equality when low-order integer bits are lost by * coercion to double. So this part is painful too. diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -1463,7 +1463,7 @@ return name.startswith('pthread_cond_timedwait') def is_gc_collect(self): - '''Is this frame "collect" within the the garbage-collector?''' + '''Is this frame "collect" within the garbage-collector?''' return self._gdbframe.name() == 'collect' def get_pyop(self): diff --git a/Tools/msi/schema.py b/Tools/msi/schema.py --- a/Tools/msi/schema.py +++ b/Tools/msi/schema.py @@ -958,7 +958,7 @@ (u'ServiceInstall',u'StartType',u'N',0,4,None, None, None, None, u'Type of the service',), (u'Shortcut',u'Name',u'N',None, None, None, None, u'Filename',None, u'The name of the shortcut to be created.',), (u'Shortcut',u'Description',u'Y',None, None, None, None, u'Text',None, u'The description for the shortcut.',), -(u'Shortcut',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table denoting the component whose selection gates the the shortcut creation/deletion.',), +(u'Shortcut',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table denoting the component whose selection gates the shortcut creation/deletion.',), (u'Shortcut',u'Icon_',u'Y',None, None, u'Icon',1,u'Identifier',None, u'Foreign key into the File table denoting the external icon file for the shortcut.',), (u'Shortcut',u'IconIndex',u'Y',-32767,32767,None, None, None, None, u'The icon index for the shortcut.',), (u'Shortcut',u'Directory_',u'N',None, None, u'Directory',1,u'Identifier',None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.',), diff --git a/Tools/msi/uisample.py b/Tools/msi/uisample.py --- a/Tools/msi/uisample.py +++ b/Tools/msi/uisample.py @@ -1195,7 +1195,7 @@ (u'ServiceInstall', u'StartType', u'N', 0, 4, None, None, None, None, u'Type of the service'), (u'Shortcut', u'Name', u'N', None, None, None, None, u'Filename', None, u'The name of the shortcut to be created.'), (u'Shortcut', u'Description', u'Y', None, None, None, None, u'Text', None, u'The description for the shortcut.'), -(u'Shortcut', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table denoting the component whose selection gates the the shortcut creation/deletion.'), +(u'Shortcut', u'Component_', u'N', None, None, u'Component', 1, u'Identifier', None, u'Foreign key into the Component table denoting the component whose selection gates the shortcut creation/deletion.'), (u'Shortcut', u'Icon_', u'Y', None, None, u'Icon', 1, u'Identifier', None, u'Foreign key into the File table denoting the external icon file for the shortcut.'), (u'Shortcut', u'IconIndex', u'Y', -32767, 32767, None, None, None, None, u'The icon index for the shortcut.'), (u'Shortcut', u'Directory_', u'N', None, None, u'Directory', 1, u'Identifier', None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.'), -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Sun Jan 27 05:59:56 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 27 Jan 2013 05:59:56 +0100 Subject: [Python-checkins] Daily reference leaks (491d7f9b879d): sum=4 Message-ID: results for 491d7f9b879d on branch "default" -------------------------------------------- test_concurrent_futures leaked [0, 0, -2] memory blocks, sum=-2 test_dbm leaked [0, 2, 0] references, sum=2 test_dbm leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflog9Hc5Oy', '-x'] From ncoghlan at gmail.com Sun Jan 27 06:42:30 2013 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sun, 27 Jan 2013 15:42:30 +1000 Subject: [Python-checkins] cpython: Touch up exception messaging In-Reply-To: References: <3Yt8RJ6v3nzSLv@mail.python.org> Message-ID: On Sun, Jan 27, 2013 at 3:25 AM, Ezio Melotti wrote: > Hi, > I'm not sure these changes are an improvement. > > On Fri, Jan 25, 2013 at 8:49 PM, brett.cannon > wrote: >> http://hg.python.org/cpython/rev/792810303239 >> changeset: 81735:792810303239 >> user: Brett Cannon >> date: Fri Jan 25 13:49:19 2013 -0500 >> summary: >> Touch up exception messaging >> [...] >> magic = data[:4] >> raw_timestamp = data[4:8] >> raw_size = data[8:12] >> if magic != _MAGIC_BYTES: >> - msg = 'bad magic number in {!r}: {!r}'.format(name, magic) >> + msg = 'incomplete magic number in {!r}: {!r}'.format(name, magic) > > Here 2 things could go wrong: > 1) magic is less than 4 bytes (so it could be "incomplete"); > 2) magic is 4 bytes, but it's different (so it's "invalid" or "bad"); > For this to be "incomplete" the size of the whole file should be less > than 4 bytes, and it's unlikely that in a 3bytes-long file the content > is an incomplete magic number. It's much more likely than it's not a > magic number at all, or that it is a bad/wrong/invalid 4-bytes magic > number, so the previous error looked better to me. Oops, I missed that - this one wasn't supposed to change. It was only the other two that were misleading. > >> raise ImportError(msg, **exc_details) >> elif len(raw_timestamp) != 4: >> - message = 'bad timestamp in {!r}'.format(name) >> + message = 'incomplete timestamp in {!r}'.format(name) >> _verbose_message(message) >> raise EOFError(message) >> elif len(raw_size) != 4: >> - message = 'bad size in {!r}'.format(name) >> + message = 'incomplete size in {!r}'.format(name) > > If we arrived here the magic number was right, so this are probably > the timestamp and size, but for this to fail the whole file should be > less than 8 or 12 bytes (unless I misread the code). > Something like "reached EOF while reading timestamp/size" would > probably be more informative. I don't mind one way or the other here. "bad" was wrong, since it implied this code actually checked these values against the expected ones, but it doesn't, it merely requires that they exist. "incomplete " or "reached EOF while reading " are both correct and a sufficient hint for anyone already familiar with how the bytecode cache format works. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia From ncoghlan at gmail.com Sun Jan 27 06:43:40 2013 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sun, 27 Jan 2013 15:43:40 +1000 Subject: [Python-checkins] cpython (3.3): Fix a few typos and a double semicolon. Patch by Eitan Adler. In-Reply-To: <3Yv14R5h6lzSPg@mail.python.org> References: <3Yv14R5h6lzSPg@mail.python.org> Message-ID: On Sun, Jan 27, 2013 at 2:21 PM, ezio.melotti wrote: > http://hg.python.org/cpython/rev/07488c3c85f1 > changeset: 81772:07488c3c85f1 > branch: 3.3 > parent: 81770:a0756411c527 > user: Ezio Melotti > date: Sun Jan 27 06:20:14 2013 +0200 > summary: > Fix a few typos and a double semicolon. Patch by Eitan Adler. Misc/ACKS? Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia From python-checkins at python.org Sun Jan 27 11:18:06 2013 From: python-checkins at python.org (mark.dickinson) Date: Sun, 27 Jan 2013 11:18:06 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2316772=3A_in_int?= =?utf-8?q?=28x=2C_base=29=2C_non-integer_bases_must_have_an_=5F=5Findex?= =?utf-8?q?=5F=5F_method=2E?= Message-ID: <3Yv90G0sptzSRZ@mail.python.org> http://hg.python.org/cpython/rev/79db70bd3188 changeset: 81774:79db70bd3188 user: Mark Dickinson date: Sun Jan 27 10:17:52 2013 +0000 summary: Issue #16772: in int(x, base), non-integer bases must have an __index__ method. files: Doc/library/functions.rst | 6 ++++++ Lib/test/test_int.py | 17 +++++++++++++++++ Misc/NEWS | 4 ++++ Objects/longobject.c | 5 ----- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -665,6 +665,12 @@ The integer type is described in :ref:`typesnumeric`. + .. versionchanged:: 3.4 + If *base* is not an instance of :class:`int` and the *base* object has a + :meth:`base.__index__ ` method, that method is called + to obtain an integer for the base. Previous versions used + :meth:`base.__int__ ` instead of :meth:`base.__index__ + `. .. function:: isinstance(object, classinfo) diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py --- a/Lib/test/test_int.py +++ b/Lib/test/test_int.py @@ -260,6 +260,23 @@ with self.assertRaises(TypeError): int('0', 5.0) + def test_int_base_indexable(self): + class MyIndexable(object): + def __init__(self, value): + self.value = value + def __index__(self): + return self.value + + # Check out of range bases. + for base in 2**100, -2**100, 1, 37: + with self.assertRaises(ValueError): + int('43', base) + + # Check in-range bases. + self.assertEqual(int('101', base=MyIndexable(2)), 5) + self.assertEqual(int('101', base=MyIndexable(10)), 101) + self.assertEqual(int('101', base=MyIndexable(36)), 1 + 36**2) + def test_non_numeric_input_types(self): # Test possible non-numeric types for the argument x, including # subclasses of the explicitly documented accepted types. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #16772: The base argument to the int constructor no longer accepts + floats, or other non-integer objects with an __int__ method. Objects + with an __index__ method are now accepted. + - Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4283,11 +4283,6 @@ } if (obase == NULL) return PyNumber_Long(x); - if (!PyLong_Check(obase)) { - PyErr_SetString(PyExc_TypeError, - "int() base must be an integer."); - return NULL; - } base = PyNumber_AsSsize_t(obase, NULL); if (base == -1 && PyErr_Occurred()) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 14:05:01 2013 From: python-checkins at python.org (nadeem.vawda) Date: Sun, 27 Jan 2013 14:05:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEzODg2?= =?utf-8?q?=3A_Fix_input=28=29_to_not_strip_out_supposedly-invalid_input_b?= =?utf-8?q?ytes=2E?= Message-ID: <3YvDhs5tCVzSDM@mail.python.org> http://hg.python.org/cpython/rev/cf0f450b3299 changeset: 81775:cf0f450b3299 branch: 3.2 parent: 81769:58646b0c5226 user: Nadeem Vawda date: Sun Jan 27 14:01:42 2013 +0100 summary: Issue #13886: Fix input() to not strip out supposedly-invalid input bytes. Also fix sporadic failures in test_builtin due to dependence on whether the readline module has previously been imported. files: Lib/test/test_builtin.py | 7 +++++++ Misc/NEWS | 4 ++++ Modules/readline.c | 2 +- 3 files changed, 12 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -18,6 +18,13 @@ import pty, signal except ImportError: pty = signal = None +# Importing this module has the side-effect of changing the behavior of input(). +# Ensure that we always use the readline version (if available), so we don't get +# different results depending on what other tests have already imported. +try: + import readline +except ImportError: + pass class Squares: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #13886: Fix input() to not strip out input bytes that cannot be decoded + using the locale encoding. Also fix sporadic failures in test_builtin due to + dependence on whether the readline module has previously been imported. + - Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. diff --git a/Modules/readline.c b/Modules/readline.c --- a/Modules/readline.c +++ b/Modules/readline.c @@ -1068,7 +1068,7 @@ char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); if (!saved_locale) Py_FatalError("not enough memory to save locale"); - setlocale(LC_CTYPE, ""); + setlocale(LC_CTYPE, "C"); #endif if (sys_stdin != rl_instream || sys_stdout != rl_outstream) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 14:13:36 2013 From: python-checkins at python.org (nadeem.vawda) Date: Sun, 27 Jan 2013 14:13:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2313886=3A_Fix_input=28=29_to_not_strip_out_supposedly-?= =?utf-8?q?invalid_input_bytes=2E?= Message-ID: <3YvDtm4D3nzMKm@mail.python.org> http://hg.python.org/cpython/rev/5c8732049dd5 changeset: 81776:5c8732049dd5 branch: 3.3 parent: 81772:07488c3c85f1 parent: 81775:cf0f450b3299 user: Nadeem Vawda date: Sun Jan 27 14:13:25 2013 +0100 summary: Issue #13886: Fix input() to not strip out supposedly-invalid input bytes. Also fix sporadic failures in test_builtin due to dependence on whether the readline module has previously been imported. files: Lib/test/test_builtin.py | 7 +++++++ Misc/NEWS | 4 ++++ Modules/readline.c | 2 +- 3 files changed, 12 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -20,6 +20,13 @@ import pty, signal except ImportError: pty = signal = None +# Importing this module has the side-effect of changing the behavior of input(). +# Ensure that we always use the readline version (if available), so we don't get +# different results depending on what other tests have already imported. +try: + import readline +except ImportError: + pass class Squares: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,10 @@ Core and Builtins ----------------- +- Issue #13886: Fix input() to not strip out input bytes that cannot be decoded + using the locale encoding. Also fix sporadic failures in test_builtin due to + dependence on whether the readline module has previously been imported. + - Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. diff --git a/Modules/readline.c b/Modules/readline.c --- a/Modules/readline.c +++ b/Modules/readline.c @@ -1067,7 +1067,7 @@ char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); if (!saved_locale) Py_FatalError("not enough memory to save locale"); - setlocale(LC_CTYPE, ""); + setlocale(LC_CTYPE, "C"); #endif if (sys_stdin != rl_instream || sys_stdout != rl_outstream) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 14:17:31 2013 From: python-checkins at python.org (nadeem.vawda) Date: Sun, 27 Jan 2013 14:17:31 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2313886=3A_Fix_input=28=29_to_not_strip_out_suppo?= =?utf-8?q?sedly-invalid_input_bytes=2E?= Message-ID: <3YvDzH1kKqzSLp@mail.python.org> http://hg.python.org/cpython/rev/9774721bfc32 changeset: 81777:9774721bfc32 parent: 81774:79db70bd3188 parent: 81776:5c8732049dd5 user: Nadeem Vawda date: Sun Jan 27 14:17:21 2013 +0100 summary: Issue #13886: Fix input() to not strip out supposedly-invalid input bytes. Also fix sporadic failures in test_builtin due to dependence on whether the readline module has previously been imported. files: Lib/test/test_builtin.py | 7 +++++++ Misc/NEWS | 4 ++++ Modules/readline.c | 2 +- 3 files changed, 12 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -20,6 +20,13 @@ import pty, signal except ImportError: pty = signal = None +# Importing this module has the side-effect of changing the behavior of input(). +# Ensure that we always use the readline version (if available), so we don't get +# different results depending on what other tests have already imported. +try: + import readline +except ImportError: + pass class Squares: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #13886: Fix input() to not strip out input bytes that cannot be decoded + using the locale encoding. Also fix sporadic failures in test_builtin due to + dependence on whether the readline module has previously been imported. + - Issue #16772: The base argument to the int constructor no longer accepts floats, or other non-integer objects with an __int__ method. Objects with an __index__ method are now accepted. diff --git a/Modules/readline.c b/Modules/readline.c --- a/Modules/readline.c +++ b/Modules/readline.c @@ -1063,7 +1063,7 @@ char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); if (!saved_locale) Py_FatalError("not enough memory to save locale"); - setlocale(LC_CTYPE, ""); + setlocale(LC_CTYPE, "C"); #endif if (sys_stdin != rl_instream || sys_stdout != rl_outstream) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 14:21:37 2013 From: python-checkins at python.org (nadeem.vawda) Date: Sun, 27 Jan 2013 14:21:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzEzODg2?= =?utf-8?q?=3A_Fix_input=28=29_to_not_strip_out_supposedly-invalid_input_b?= =?utf-8?q?ytes=2E?= Message-ID: <3YvF4154wyzSMK@mail.python.org> http://hg.python.org/cpython/rev/12223782031f changeset: 81778:12223782031f branch: 2.7 parent: 81768:49294e55311f user: Nadeem Vawda date: Sun Jan 27 14:21:26 2013 +0100 summary: Issue #13886: Fix input() to not strip out supposedly-invalid input bytes. files: Misc/NEWS | 3 +++ Modules/readline.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,9 @@ Core and Builtins ----------------- +- Issue #13886: Fix input() to not strip out input bytes that cannot be decoded + using the locale encoding. + - Issue #10156: In the interpreter's initialization phase, unicode globals are now initialized dynamically as needed. diff --git a/Modules/readline.c b/Modules/readline.c --- a/Modules/readline.c +++ b/Modules/readline.c @@ -1041,7 +1041,7 @@ char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); if (!saved_locale) Py_FatalError("not enough memory to save locale"); - setlocale(LC_CTYPE, ""); + setlocale(LC_CTYPE, "C"); #endif if (sys_stdin != rl_instream || sys_stdout != rl_outstream) { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 18:01:57 2013 From: python-checkins at python.org (stefan.krah) Date: Sun, 27 Jan 2013 18:01:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzExNzI5?= =?utf-8?q?=3A_Backport_commit_bff052d9_from_libffi_upstream_in_order_to_f?= =?utf-8?q?ix?= Message-ID: <3YvKyF4XVNzSG4@mail.python.org> http://hg.python.org/cpython/rev/b9792b27d410 changeset: 81779:b9792b27d410 branch: 2.7 user: Stefan Krah date: Sun Jan 27 18:00:24 2013 +0100 summary: Issue #11729: Backport commit bff052d9 from libffi upstream in order to fix a ctypes build failure with clang. files: Modules/_ctypes/libffi/configure | 6 +++--- Modules/_ctypes/libffi/configure.ac | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/_ctypes/libffi/configure b/Modules/_ctypes/libffi/configure --- a/Modules/_ctypes/libffi/configure +++ b/Modules/_ctypes/libffi/configure @@ -12262,10 +12262,10 @@ $as_echo_n "(cached) " >&6 else - libffi_cv_as_x86_pcrel=yes + libffi_cv_as_x86_pcrel=no echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then - libffi_cv_as_x86_pcrel=no + if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then + libffi_cv_as_x86_pcrel=yes fi fi diff --git a/Modules/_ctypes/libffi/configure.ac b/Modules/_ctypes/libffi/configure.ac --- a/Modules/_ctypes/libffi/configure.ac +++ b/Modules/_ctypes/libffi/configure.ac @@ -274,10 +274,10 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then AC_CACHE_CHECK([assembler supports pc related relocs], libffi_cv_as_x86_pcrel, [ - libffi_cv_as_x86_pcrel=yes + libffi_cv_as_x86_pcrel=no echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then - libffi_cv_as_x86_pcrel=no + if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then + libffi_cv_as_x86_pcrel=yes fi ]) if test "x$libffi_cv_as_x86_pcrel" = xyes; then -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:07:46 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Jan 2013 19:07:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogLSBJc3N1ZSAjMTcw?= =?utf-8?q?41=3A_Fix_testing_when_Python_is_configured_with_the?= Message-ID: <3YvMQB247kzSKv@mail.python.org> http://hg.python.org/cpython/rev/6c0d9d1ce63e changeset: 81780:6c0d9d1ce63e branch: 2.7 user: Serhiy Storchaka date: Sun Jan 27 19:45:49 2013 +0200 summary: - Issue #17041: Fix testing when Python is configured with the --without-doc-strings option. files: Lib/ctypes/test/test_win32.py | 5 +- Lib/distutils/tests/test_build_ext.py | 5 +- Lib/test/test_functools.py | 1 + Lib/test/test_pydoc.py | 32 ++++++++++---- Lib/test/test_support.py | 14 ++++- Misc/NEWS | 3 + 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py --- a/Lib/ctypes/test/test_win32.py +++ b/Lib/ctypes/test/test_win32.py @@ -3,6 +3,7 @@ from ctypes import * from ctypes.test import is_resource_enabled import unittest, sys +from test import test_support as support import _ctypes_test @@ -60,7 +61,9 @@ def test_COMError(self): from _ctypes import COMError - self.assertEqual(COMError.__doc__, "Raised when a COM method call failed.") + if support.HAVE_DOCSTRINGS: + self.assertEqual(COMError.__doc__, + "Raised when a COM method call failed.") ex = COMError(-1, "text", ("details",)) self.assertEqual(ex.hresult, -1) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -77,8 +77,9 @@ self.assertEqual(xx.foo(2, 5), 7) self.assertEqual(xx.foo(13,15), 28) self.assertEqual(xx.new().demo(), None) - doc = 'This is a template module just for instruction.' - self.assertEqual(xx.__doc__, doc) + if test_support.HAVE_DOCSTRINGS: + doc = 'This is a template module just for instruction.' + self.assertEqual(xx.__doc__, doc) self.assertTrue(isinstance(xx.Null(), xx.Null)) self.assertTrue(isinstance(xx.Str(), xx.Str)) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -232,6 +232,7 @@ self.assertEqual(wrapper.attr, 'This is a different test') self.assertEqual(wrapper.dict_attr, f.dict_attr) + @test_support.requires_docstrings def test_builtin_update(self): # Test for bug #1576241 def wrapper(): diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -16,6 +16,14 @@ from test import pydoc_mod +if test.test_support.HAVE_DOCSTRINGS: + expected_data_docstrings = ( + 'dictionary for instance variables (if defined)', + 'list of weak references to the object (if defined)', + ) +else: + expected_data_docstrings = ('', '') + expected_text_pattern = \ """ NAME @@ -40,11 +48,9 @@ class B(__builtin__.object) | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s |\x20\x20 | ---------------------------------------------------------------------- | Data and other attributes defined here: @@ -75,6 +81,9 @@ Nobody """.strip() +expected_text_data_docstrings = tuple('\n | ' + s if s else '' + for s in expected_data_docstrings) + expected_html_pattern = \ """ @@ -121,10 +130,10 @@
     Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

Data and other attributes defined here:
@@ -168,6 +177,8 @@
Nobody
""".strip() +expected_html_data_docstrings = tuple(s.replace(' ', ' ') + for s in expected_data_docstrings) # output pattern for missing module missing_pattern = "no Python documentation found for '%s'" @@ -229,7 +240,9 @@ mod_url = nturl2path.pathname2url(mod_file) else: mod_url = mod_file - expected_html = expected_html_pattern % (mod_url, mod_file, doc_loc) + expected_html = expected_html_pattern % ( + (mod_url, mod_file, doc_loc) + + expected_html_data_docstrings) if result != expected_html: print_diffs(expected_html, result) self.fail("outputs are not equal, see diff above") @@ -238,8 +251,9 @@ "Docstrings are omitted with -O2 and above") def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) - expected_text = expected_text_pattern % \ - (inspect.getabsfile(pydoc_mod), doc_loc) + expected_text = expected_text_pattern % ( + (inspect.getabsfile(pydoc_mod), doc_loc) + + expected_text_data_docstrings) if result != expected_text: print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -1112,10 +1112,6 @@ else: return unittest.skip("resource {0!r} is not enabled".format(resource)) -requires_docstrings = unittest.skipUnless( - sysconfig.get_config_var('WITH_DOC_STRINGS'), - "test requires docstrings") - def cpython_only(test): """ Decorator for tests only applicable on CPython. @@ -1193,6 +1189,16 @@ suite.addTest(unittest.makeSuite(cls)) _run_suite(suite) +#======================================================================= +# Check for the presence of docstrings. + +HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or + sys.platform == 'win32' or + sysconfig.get_config_var('WITH_DOC_STRINGS')) + +requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS, + "test requires docstrings") + #======================================================================= # doctest driver. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -674,6 +674,9 @@ Tests ----- +- Issue #17041: Fix testing when Python is configured with the + --without-doc-strings option. + - Issue #15539: Added regression tests for Tools/scripts/pindent.py. - Issue #15324: Fix regrtest parsing of --fromfile and --randomize options. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:07:47 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Jan 2013 19:07:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE3MDQx?= =?utf-8?q?=3A_Fix_testing_when_Python_is_configured_with_the?= Message-ID: <3YvMQC68yXzSH2@mail.python.org> http://hg.python.org/cpython/rev/241b655c23b6 changeset: 81781:241b655c23b6 branch: 3.2 parent: 81775:cf0f450b3299 user: Serhiy Storchaka date: Sun Jan 27 19:47:45 2013 +0200 summary: Issue #17041: Fix testing when Python is configured with the --without-doc-strings. files: Lib/ctypes/test/test_win32.py | 5 +- Lib/distutils/tests/test_build_ext.py | 5 +- Lib/test/support.py | 10 +++ Lib/test/test_bytes.py | 1 + Lib/test/test_functools.py | 1 + Lib/test/test_pydoc.py | 49 +++++++++----- Misc/NEWS | 3 + 7 files changed, 54 insertions(+), 20 deletions(-) diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py --- a/Lib/ctypes/test/test_win32.py +++ b/Lib/ctypes/test/test_win32.py @@ -3,6 +3,7 @@ from ctypes import * from ctypes.test import is_resource_enabled import unittest, sys +from test import support import _ctypes_test @@ -60,7 +61,9 @@ def test_COMError(self): from _ctypes import COMError - self.assertEqual(COMError.__doc__, "Raised when a COM method call failed.") + if support.HAVE_DOCSTRINGS: + self.assertEqual(COMError.__doc__, + "Raised when a COM method call failed.") ex = COMError(-1, "text", ("details",)) self.assertEqual(ex.hresult, -1) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -73,8 +73,9 @@ self.assertEqual(xx.foo(2, 5), 7) self.assertEqual(xx.foo(13,15), 28) self.assertEqual(xx.new().demo(), None) - doc = 'This is a template module just for instruction.' - self.assertEqual(xx.__doc__, doc) + if support.HAVE_DOCSTRINGS: + doc = 'This is a template module just for instruction.' + self.assertEqual(xx.__doc__, doc) self.assertTrue(isinstance(xx.Null(), xx.Null)) self.assertTrue(isinstance(xx.Str(), xx.Str)) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -1477,6 +1477,16 @@ _filter_suite(suite, case_pred) _run_suite(suite) +#======================================================================= +# Check for the presence of docstrings. + +HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or + sys.platform == 'win32' or + sysconfig.get_config_var('WITH_DOC_STRINGS')) + +requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS, + "test requires docstrings") + #======================================================================= # doctest driver. diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -986,6 +986,7 @@ self.assertEqual(bytes(b"abc") < b"ab", False) self.assertEqual(bytes(b"abc") <= b"ab", False) + @test.support.requires_docstrings def test_doc(self): self.assertIsNotNone(bytearray.__doc__) self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -287,6 +287,7 @@ with self.assertRaises(AttributeError): functools.update_wrapper(wrapper, f, assign, update) + @support.requires_docstrings @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_builtin_update(self): diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -30,6 +30,14 @@ if hasattr(pydoc_mod, "__loader__"): del pydoc_mod.__loader__ +if test.support.HAVE_DOCSTRINGS: + expected_data_docstrings = ( + 'dictionary for instance variables (if defined)', + 'list of weak references to the object (if defined)', + ) * 2 +else: + expected_data_docstrings = ('', '', '', '') + expected_text_pattern = """ NAME test.pydoc_mod - This is a test module for test_pydoc @@ -50,20 +58,16 @@ | ---------------------------------------------------------------------- | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s \x20\x20\x20\x20 class B(builtins.object) | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s |\x20\x20 | ---------------------------------------------------------------------- | Data and other attributes defined here: @@ -95,6 +99,9 @@ %s """.strip() +expected_text_data_docstrings = tuple('\n | ' + s if s else '' + for s in expected_data_docstrings) + expected_html_pattern = """ @@ -134,10 +141,10 @@
Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

@@ -148,10 +155,10 @@
     Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

Data and other attributes defined here:
@@ -193,6 +200,8 @@
Nobody
""".strip() # ' <- emacs turd +expected_html_data_docstrings = tuple(s.replace(' ', ' ') + for s in expected_data_docstrings) # output pattern for missing module missing_pattern = "no Python documentation found for '%s'" @@ -262,7 +271,9 @@ mod_url = nturl2path.pathname2url(mod_file) else: mod_url = mod_file - expected_html = expected_html_pattern % (mod_url, mod_file, doc_loc) + expected_html = expected_html_pattern % ( + (mod_url, mod_file, doc_loc) + + expected_html_data_docstrings) if result != expected_html: print_diffs(expected_html, result) self.fail("outputs are not equal, see diff above") @@ -271,8 +282,10 @@ "Docstrings are omitted with -O2 and above") def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) - expected_text = expected_text_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_text_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) if result != expected_text: print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") @@ -346,8 +359,10 @@ captured_output('stderr') as err: helper.help(module) result = buf.getvalue().strip() - expected_text = expected_help_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_help_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) self.assertEqual('', output.getvalue()) self.assertEqual('', err.getvalue()) self.assertEqual(expected_text, result) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -811,6 +811,9 @@ Tests ----- +- Issue #17041: Fix testing when Python is configured with the + --without-doc-strings. + - Issue #15539: Added regression tests for Tools/scripts/pindent.py. - Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:07:49 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Jan 2013 19:07:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2317041=3A_Fix_testing_when_Python_is_configured_with_t?= =?utf-8?q?he?= Message-ID: <3YvMQF3DL3zSKv@mail.python.org> http://hg.python.org/cpython/rev/b2fa459d95d6 changeset: 81782:b2fa459d95d6 branch: 3.3 parent: 81776:5c8732049dd5 parent: 81781:241b655c23b6 user: Serhiy Storchaka date: Sun Jan 27 20:03:39 2013 +0200 summary: Issue #17041: Fix testing when Python is configured with the --without-doc-strings. files: Lib/ctypes/test/test_win32.py | 5 +- Lib/distutils/tests/test_build_ext.py | 5 +- Lib/test/support.py | 14 ++- Lib/test/test_functools.py | 1 + Lib/test/test_pydoc.py | 53 +++++++++----- Misc/NEWS | 3 + 6 files changed, 53 insertions(+), 28 deletions(-) diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py --- a/Lib/ctypes/test/test_win32.py +++ b/Lib/ctypes/test/test_win32.py @@ -3,6 +3,7 @@ from ctypes import * from ctypes.test import is_resource_enabled import unittest, sys +from test import support import _ctypes_test @@ -60,7 +61,9 @@ def test_COMError(self): from _ctypes import COMError - self.assertEqual(COMError.__doc__, "Raised when a COM method call failed.") + if support.HAVE_DOCSTRINGS: + self.assertEqual(COMError.__doc__, + "Raised when a COM method call failed.") ex = COMError(-1, "text", ("details",)) self.assertEqual(ex.hresult, -1) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -73,8 +73,9 @@ self.assertEqual(xx.foo(2, 5), 7) self.assertEqual(xx.foo(13,15), 28) self.assertEqual(xx.new().demo(), None) - doc = 'This is a template module just for instruction.' - self.assertEqual(xx.__doc__, doc) + if support.HAVE_DOCSTRINGS: + doc = 'This is a template module just for instruction.' + self.assertEqual(xx.__doc__, doc) self.assertTrue(isinstance(xx.Null(), xx.Null)) self.assertTrue(isinstance(xx.Str(), xx.Str)) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -590,10 +590,6 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') -requires_docstrings = unittest.skipUnless( - sysconfig.get_config_var('WITH_DOC_STRINGS'), - "test requires docstrings") - is_jython = sys.platform.startswith('java') # Filename used for testing @@ -1592,6 +1588,16 @@ _filter_suite(suite, case_pred) _run_suite(suite) +#======================================================================= +# Check for the presence of docstrings. + +HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or + sys.platform == 'win32' or + sysconfig.get_config_var('WITH_DOC_STRINGS')) + +requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS, + "test requires docstrings") + #======================================================================= # doctest driver. diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -290,6 +290,7 @@ with self.assertRaises(AttributeError): functools.update_wrapper(wrapper, f, assign, update) + @support.requires_docstrings @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_builtin_update(self): diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -30,6 +30,14 @@ if hasattr(pydoc_mod, "__loader__"): del pydoc_mod.__loader__ +if test.support.HAVE_DOCSTRINGS: + expected_data_docstrings = ( + 'dictionary for instance variables (if defined)', + 'list of weak references to the object (if defined)', + ) * 2 +else: + expected_data_docstrings = ('', '', '', '') + expected_text_pattern = """ NAME test.pydoc_mod - This is a test module for test_pydoc @@ -50,20 +58,16 @@ | ---------------------------------------------------------------------- | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s \x20\x20\x20\x20 class B(builtins.object) | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s |\x20\x20 | ---------------------------------------------------------------------- | Data and other attributes defined here: @@ -95,6 +99,9 @@ %s """.strip() +expected_text_data_docstrings = tuple('\n | ' + s if s else '' + for s in expected_data_docstrings) + expected_html_pattern = """ @@ -134,10 +141,10 @@
Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

@@ -148,10 +155,10 @@
     Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

Data and other attributes defined here:
@@ -193,6 +200,8 @@
Nobody
""".strip() # ' <- emacs turd +expected_html_data_docstrings = tuple(s.replace(' ', ' ') + for s in expected_data_docstrings) # output pattern for missing module missing_pattern = "no Python documentation found for '%s'" @@ -256,7 +265,6 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_html_doc(self): result, doc_loc = get_pydoc_html(pydoc_mod) mod_file = inspect.getabsfile(pydoc_mod) @@ -265,7 +273,9 @@ mod_url = nturl2path.pathname2url(mod_file) else: mod_url = mod_file - expected_html = expected_html_pattern % (mod_url, mod_file, doc_loc) + expected_html = expected_html_pattern % ( + (mod_url, mod_file, doc_loc) + + expected_html_data_docstrings) if result != expected_html: print_diffs(expected_html, result) self.fail("outputs are not equal, see diff above") @@ -274,11 +284,12 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) - expected_text = expected_text_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_text_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) if result != expected_text: print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") @@ -329,7 +340,6 @@ 'Docstrings are omitted with -O2 and above') @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_help_output_redirect(self): # issue 940286, if output is set in Helper, then all output from # Helper.help should be redirected @@ -355,8 +365,10 @@ captured_output('stderr') as err: helper.help(module) result = buf.getvalue().strip() - expected_text = expected_help_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_help_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) self.assertEqual('', output.getvalue()) self.assertEqual('', err.getvalue()) self.assertEqual(expected_text, result) @@ -499,7 +511,6 @@ self.assertRaises(TypeError, f, 'A', '') self.assertRaises(TypeError, f, 'B', 'foobar') - @test.support.requires_docstrings def test_url_requests(self): # Test for the correct title in the html pages returned. # This tests the different parts of the URL handler without diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -488,6 +488,9 @@ Tests ----- +- Issue #17041: Fix testing when Python is configured with the + --without-doc-strings. + - Issue #16923: Fix ResourceWarnings in test_ssl. - Issue #15539: Added regression tests for Tools/scripts/pindent.py. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:07:51 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Jan 2013 19:07:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2317041=3A_Fix_testing_when_Python_is_configured_?= =?utf-8?q?with_the?= Message-ID: <3YvMQH09K0zSK8@mail.python.org> http://hg.python.org/cpython/rev/754112dc3bbb changeset: 81783:754112dc3bbb parent: 81777:9774721bfc32 parent: 81782:b2fa459d95d6 user: Serhiy Storchaka date: Sun Jan 27 20:04:26 2013 +0200 summary: Issue #17041: Fix testing when Python is configured with the --without-doc-strings. files: Lib/ctypes/test/test_win32.py | 5 +- Lib/distutils/tests/test_build_ext.py | 5 +- Lib/test/support.py | 14 ++- Lib/test/test_functools.py | 1 + Lib/test/test_pydoc.py | 53 +++++++++----- Misc/NEWS | 3 + 6 files changed, 53 insertions(+), 28 deletions(-) diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py --- a/Lib/ctypes/test/test_win32.py +++ b/Lib/ctypes/test/test_win32.py @@ -3,6 +3,7 @@ from ctypes import * from ctypes.test import is_resource_enabled import unittest, sys +from test import support import _ctypes_test @@ -60,7 +61,9 @@ def test_COMError(self): from _ctypes import COMError - self.assertEqual(COMError.__doc__, "Raised when a COM method call failed.") + if support.HAVE_DOCSTRINGS: + self.assertEqual(COMError.__doc__, + "Raised when a COM method call failed.") ex = COMError(-1, "text", ("details",)) self.assertEqual(ex.hresult, -1) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -73,8 +73,9 @@ self.assertEqual(xx.foo(2, 5), 7) self.assertEqual(xx.foo(13,15), 28) self.assertEqual(xx.new().demo(), None) - doc = 'This is a template module just for instruction.' - self.assertEqual(xx.__doc__, doc) + if support.HAVE_DOCSTRINGS: + doc = 'This is a template module just for instruction.' + self.assertEqual(xx.__doc__, doc) self.assertTrue(isinstance(xx.Null(), xx.Null)) self.assertTrue(isinstance(xx.Str(), xx.Str)) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -597,10 +597,6 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') -requires_docstrings = unittest.skipUnless( - sysconfig.get_config_var('WITH_DOC_STRINGS'), - "test requires docstrings") - is_jython = sys.platform.startswith('java') # Filename used for testing @@ -1599,6 +1595,16 @@ _filter_suite(suite, case_pred) _run_suite(suite) +#======================================================================= +# Check for the presence of docstrings. + +HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or + sys.platform == 'win32' or + sysconfig.get_config_var('WITH_DOC_STRINGS')) + +requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS, + "test requires docstrings") + #======================================================================= # doctest driver. diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -312,6 +312,7 @@ with self.assertRaises(AttributeError): functools.update_wrapper(wrapper, f, assign, update) + @support.requires_docstrings @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_builtin_update(self): diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -30,6 +30,14 @@ if hasattr(pydoc_mod, "__loader__"): del pydoc_mod.__loader__ +if test.support.HAVE_DOCSTRINGS: + expected_data_docstrings = ( + 'dictionary for instance variables (if defined)', + 'list of weak references to the object (if defined)', + ) * 2 +else: + expected_data_docstrings = ('', '', '', '') + expected_text_pattern = """ NAME test.pydoc_mod - This is a test module for test_pydoc @@ -50,20 +58,16 @@ | ---------------------------------------------------------------------- | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s \x20\x20\x20\x20 class B(builtins.object) | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s |\x20\x20 | ---------------------------------------------------------------------- | Data and other attributes defined here: @@ -95,6 +99,9 @@ %s """.strip() +expected_text_data_docstrings = tuple('\n | ' + s if s else '' + for s in expected_data_docstrings) + expected_html_pattern = """ @@ -134,10 +141,10 @@
Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

@@ -148,10 +155,10 @@
     Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

Data and other attributes defined here:
@@ -193,6 +200,8 @@
Nobody
""".strip() # ' <- emacs turd +expected_html_data_docstrings = tuple(s.replace(' ', ' ') + for s in expected_data_docstrings) # output pattern for missing module missing_pattern = "no Python documentation found for '%s'" @@ -256,7 +265,6 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_html_doc(self): result, doc_loc = get_pydoc_html(pydoc_mod) mod_file = inspect.getabsfile(pydoc_mod) @@ -265,7 +273,9 @@ mod_url = nturl2path.pathname2url(mod_file) else: mod_url = mod_file - expected_html = expected_html_pattern % (mod_url, mod_file, doc_loc) + expected_html = expected_html_pattern % ( + (mod_url, mod_file, doc_loc) + + expected_html_data_docstrings) if result != expected_html: print_diffs(expected_html, result) self.fail("outputs are not equal, see diff above") @@ -274,11 +284,12 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) - expected_text = expected_text_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_text_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) if result != expected_text: print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") @@ -329,7 +340,6 @@ 'Docstrings are omitted with -O2 and above') @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_help_output_redirect(self): # issue 940286, if output is set in Helper, then all output from # Helper.help should be redirected @@ -355,8 +365,10 @@ captured_output('stderr') as err: helper.help(module) result = buf.getvalue().strip() - expected_text = expected_help_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_help_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) self.assertEqual('', output.getvalue()) self.assertEqual('', err.getvalue()) self.assertEqual(expected_text, result) @@ -499,7 +511,6 @@ self.assertRaises(TypeError, f, 'A', '') self.assertRaises(TypeError, f, 'B', 'foobar') - @test.support.requires_docstrings def test_url_requests(self): # Test for the correct title in the html pages returned. # This tests the different parts of the URL handler without diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -700,6 +700,9 @@ Tests ----- +- Issue #17041: Fix testing when Python is configured with the + --without-doc-strings. + - Issue #16923: Fix ResourceWarnings in test_ssl. - Issue #15539: Added regression tests for Tools/scripts/pindent.py. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:08:48 2013 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Jan 2013 19:08:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Tweak_an_exception_message?= Message-ID: <3YvMRN3DPLzSJw@mail.python.org> http://hg.python.org/cpython/rev/0369b352dc85 changeset: 81784:0369b352dc85 parent: 81777:9774721bfc32 user: Brett Cannon date: Sun Jan 27 13:04:56 2013 -0500 summary: Tweak an exception message files: Lib/importlib/_bootstrap.py | 2 +- Python/importlib.h | 5946 +++++++++++----------- 2 files changed, 2974 insertions(+), 2974 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -646,7 +646,7 @@ raw_timestamp = data[4:8] raw_size = data[8:12] if magic != _MAGIC_BYTES: - msg = 'incomplete magic number in {!r}: {!r}'.format(name, magic) + msg = 'bad magic number in {!r}: {!r}'.format(name, magic) raise ImportError(msg, **exc_details) elif len(raw_timestamp) != 4: message = 'incomplete timestamp in {!r}'.format(name) diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:08:49 2013 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Jan 2013 19:08:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Ignore_generated_files_rel?= =?utf-8?q?ated_to_python-config?= Message-ID: <3YvMRP64D3zSH2@mail.python.org> http://hg.python.org/cpython/rev/87d7d8c37417 changeset: 81785:87d7d8c37417 user: Brett Cannon date: Sun Jan 27 13:08:18 2013 -0500 summary: Ignore generated files related to python-config files: .hgignore | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -18,6 +18,8 @@ pyconfig.h$ python$ python.exe$ +python-config$ +python-config.py$ reflog.txt$ tags$ Lib/plat-mac/errors.rsrc.df.rsrc @@ -27,6 +29,7 @@ Doc/tools/jinja2/ Doc/tools/pygments/ Misc/python.pc +Misc/python-config.sh$ Modules/Setup$ Modules/Setup.config Modules/Setup.local -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:08:51 2013 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Jan 2013 19:08:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_merge?= Message-ID: <3YvMRR35XszSGj@mail.python.org> http://hg.python.org/cpython/rev/5ca2692c877f changeset: 81786:5ca2692c877f parent: 81785:87d7d8c37417 parent: 81783:754112dc3bbb user: Brett Cannon date: Sun Jan 27 13:08:40 2013 -0500 summary: merge files: Lib/ctypes/test/test_win32.py | 5 +- Lib/distutils/tests/test_build_ext.py | 5 +- Lib/test/support.py | 14 ++- Lib/test/test_functools.py | 1 + Lib/test/test_pydoc.py | 53 +++++++++----- Misc/NEWS | 3 + 6 files changed, 53 insertions(+), 28 deletions(-) diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py --- a/Lib/ctypes/test/test_win32.py +++ b/Lib/ctypes/test/test_win32.py @@ -3,6 +3,7 @@ from ctypes import * from ctypes.test import is_resource_enabled import unittest, sys +from test import support import _ctypes_test @@ -60,7 +61,9 @@ def test_COMError(self): from _ctypes import COMError - self.assertEqual(COMError.__doc__, "Raised when a COM method call failed.") + if support.HAVE_DOCSTRINGS: + self.assertEqual(COMError.__doc__, + "Raised when a COM method call failed.") ex = COMError(-1, "text", ("details",)) self.assertEqual(ex.hresult, -1) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -73,8 +73,9 @@ self.assertEqual(xx.foo(2, 5), 7) self.assertEqual(xx.foo(13,15), 28) self.assertEqual(xx.new().demo(), None) - doc = 'This is a template module just for instruction.' - self.assertEqual(xx.__doc__, doc) + if support.HAVE_DOCSTRINGS: + doc = 'This is a template module just for instruction.' + self.assertEqual(xx.__doc__, doc) self.assertTrue(isinstance(xx.Null(), xx.Null)) self.assertTrue(isinstance(xx.Str(), xx.Str)) diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -597,10 +597,6 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') -requires_docstrings = unittest.skipUnless( - sysconfig.get_config_var('WITH_DOC_STRINGS'), - "test requires docstrings") - is_jython = sys.platform.startswith('java') # Filename used for testing @@ -1599,6 +1595,16 @@ _filter_suite(suite, case_pred) _run_suite(suite) +#======================================================================= +# Check for the presence of docstrings. + +HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or + sys.platform == 'win32' or + sysconfig.get_config_var('WITH_DOC_STRINGS')) + +requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS, + "test requires docstrings") + #======================================================================= # doctest driver. diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -312,6 +312,7 @@ with self.assertRaises(AttributeError): functools.update_wrapper(wrapper, f, assign, update) + @support.requires_docstrings @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_builtin_update(self): diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -30,6 +30,14 @@ if hasattr(pydoc_mod, "__loader__"): del pydoc_mod.__loader__ +if test.support.HAVE_DOCSTRINGS: + expected_data_docstrings = ( + 'dictionary for instance variables (if defined)', + 'list of weak references to the object (if defined)', + ) * 2 +else: + expected_data_docstrings = ('', '', '', '') + expected_text_pattern = """ NAME test.pydoc_mod - This is a test module for test_pydoc @@ -50,20 +58,16 @@ | ---------------------------------------------------------------------- | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s \x20\x20\x20\x20 class B(builtins.object) | Data descriptors defined here: |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) + | __dict__%s |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) + | __weakref__%s |\x20\x20 | ---------------------------------------------------------------------- | Data and other attributes defined here: @@ -95,6 +99,9 @@ %s """.strip() +expected_text_data_docstrings = tuple('\n | ' + s if s else '' + for s in expected_data_docstrings) + expected_html_pattern = """ @@ -134,10 +141,10 @@
Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

@@ -148,10 +155,10 @@
     Data descriptors defined here:
__dict__
-
dictionary for instance variables (if defined)
+
%s
__weakref__
-
list of weak references to the object (if defined)
+
%s

Data and other attributes defined here:
@@ -193,6 +200,8 @@
Nobody
""".strip() # ' <- emacs turd +expected_html_data_docstrings = tuple(s.replace(' ', ' ') + for s in expected_data_docstrings) # output pattern for missing module missing_pattern = "no Python documentation found for '%s'" @@ -256,7 +265,6 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_html_doc(self): result, doc_loc = get_pydoc_html(pydoc_mod) mod_file = inspect.getabsfile(pydoc_mod) @@ -265,7 +273,9 @@ mod_url = nturl2path.pathname2url(mod_file) else: mod_url = mod_file - expected_html = expected_html_pattern % (mod_url, mod_file, doc_loc) + expected_html = expected_html_pattern % ( + (mod_url, mod_file, doc_loc) + + expected_html_data_docstrings) if result != expected_html: print_diffs(expected_html, result) self.fail("outputs are not equal, see diff above") @@ -274,11 +284,12 @@ "Docstrings are omitted with -O2 and above") @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) - expected_text = expected_text_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_text_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) if result != expected_text: print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") @@ -329,7 +340,6 @@ 'Docstrings are omitted with -O2 and above') @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), 'trace function introduces __locals__ unexpectedly') - @test.support.requires_docstrings def test_help_output_redirect(self): # issue 940286, if output is set in Helper, then all output from # Helper.help should be redirected @@ -355,8 +365,10 @@ captured_output('stderr') as err: helper.help(module) result = buf.getvalue().strip() - expected_text = expected_help_pattern % \ - (doc_loc, inspect.getabsfile(pydoc_mod)) + expected_text = expected_help_pattern % ( + (doc_loc,) + + expected_text_data_docstrings + + (inspect.getabsfile(pydoc_mod),)) self.assertEqual('', output.getvalue()) self.assertEqual('', err.getvalue()) self.assertEqual(expected_text, result) @@ -499,7 +511,6 @@ self.assertRaises(TypeError, f, 'A', '') self.assertRaises(TypeError, f, 'B', 'foobar') - @test.support.requires_docstrings def test_url_requests(self): # Test for the correct title in the html pages returned. # This tests the different parts of the URL handler without diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -700,6 +700,9 @@ Tests ----- +- Issue #17041: Fix testing when Python is configured with the + --without-doc-strings. + - Issue #16923: Fix ResourceWarnings in test_ssl. - Issue #15539: Added regression tests for Tools/scripts/pindent.py. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:10:43 2013 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Jan 2013 19:10:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Drop_the_concept_of_Extens?= =?utf-8?q?ion_Modules_from_Misc/NEWS=3B_the_stdlib_is_the_stdlib?= Message-ID: <3YvMTb3xBwzSKv@mail.python.org> http://hg.python.org/cpython/rev/1fabff717ef4 changeset: 81787:1fabff717ef4 user: Brett Cannon date: Sun Jan 27 13:10:33 2013 -0500 summary: Drop the concept of Extension Modules from Misc/NEWS; the stdlib is the stdlib regardless of implementation language files: Misc/NEWS | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -689,9 +689,6 @@ - Issue #15906: Fix a regression in argparse caused by the preceding change, when ``action='append'``, ``type='str'`` and ``default=[]``. -Extension Modules ------------------ - - Issue #16113: Added sha3 module based on the Keccak reference implementation 3.2. The `hashlib` module has four additional hash algorithms: `sha3_224`, `sha3_256`, `sha3_384` and `sha3_512`. As part of the patch some common -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Sun Jan 27 19:24:37 2013 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Jan 2013 19:24:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_Simplify_test_case_example_co?= =?utf-8?q?de?= Message-ID: <3YvMnd2fySzS9f@mail.python.org> http://hg.python.org/peps/rev/82a98c8abf48 changeset: 4693:82a98c8abf48 user: Brett Cannon date: Sun Jan 27 13:24:31 2013 -0500 summary: Simplify test case example code files: pep-0399.txt | 24 +++++------------------- 1 files changed, 5 insertions(+), 19 deletions(-) diff --git a/pep-0399.txt b/pep-0399.txt --- a/pep-0399.txt +++ b/pep-0399.txt @@ -116,8 +116,7 @@ As an example, to write tests which exercise both the pure Python and C accelerated versions of a module, a basic idiom can be followed:: - import collections.abc - from test.support import import_fresh_module, run_unittest + from test.support import import_fresh_module import unittest c_heapq = import_fresh_module('heapq', fresh=['_heapq']) @@ -126,30 +125,17 @@ class ExampleTest: - def test_heappop_exc_for_non_MutableSequence(self): - # Raise TypeError when heap is not a - # collections.abc.MutableSequence. - class Spam: - """Test class lacking many ABC-required methods - (e.g., pop()).""" - def __len__(self): - return 0 - - heap = Spam() - self.assertIsInstance(heap, collections.abc.MutableSequence) - with self.assertRaises(TypeError): - self.heapq.heappop(heap) + def test_example(self): + self.assertTrue(hasattr(self.module, 'heapify')) class PyExampleTest(ExampleTest, unittest.TestCase): - """Test with just the pure Python code.""" - heapq = py_heapq + module = py_heapq @unittest.skipUnless(c_heapq, 'requires the C _heapq module') class CExampleTest(ExampleTest, unittest.TestCase): - """Test using the accelerated code.""" - heapq = c_heapq + module = c_heapq if __name__ == '__main__': -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Mon Jan 28 00:58:27 2013 From: python-checkins at python.org (brett.cannon) Date: Mon, 28 Jan 2013 00:58:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Tweak_a_comment_to_be_in_l?= =?utf-8?q?ine_with_Python_3?= Message-ID: <3YvWBq1ktbzSDJ@mail.python.org> http://hg.python.org/cpython/rev/a375c3d88c7e changeset: 81788:a375c3d88c7e user: Brett Cannon date: Sun Jan 27 18:58:20 2013 -0500 summary: Tweak a comment to be in line with Python 3 files: Lib/test/test_bisect.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py --- a/Lib/test/test_bisect.py +++ b/Lib/test/test_bisect.py @@ -7,7 +7,7 @@ c_bisect = support.import_fresh_module('bisect', fresh=['_bisect']) class Range(object): - """A trivial range()-like object without any integer width limitations.""" + """A trivial range()-like object that has an insert() method.""" def __init__(self, start, stop): self.start = start self.stop = stop -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Mon Jan 28 05:56:49 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 28 Jan 2013 05:56:49 +0100 Subject: [Python-checkins] Daily reference leaks (a375c3d88c7e): sum=0 Message-ID: results for a375c3d88c7e on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogsm8de8', '-x'] From python-checkins at python.org Mon Jan 28 10:20:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Jan 2013 10:20:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Remove_trailin?= =?utf-8?q?g_whitespaces_in_cStringIO=2Eh=2E?= Message-ID: <3Yvlfy4S2YzRDt@mail.python.org> http://hg.python.org/cpython/rev/3983ca1a9897 changeset: 81789:3983ca1a9897 branch: 2.7 parent: 81780:6c0d9d1ce63e user: Serhiy Storchaka date: Mon Jan 28 11:00:58 2013 +0200 summary: Remove trailing whitespaces in cStringIO.h. files: Include/cStringIO.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/cStringIO.h b/Include/cStringIO.h --- a/Include/cStringIO.h +++ b/Include/cStringIO.h @@ -7,7 +7,7 @@ This header provides access to cStringIO objects from C. Functions are provided for calling cStringIO objects and - macros are provided for testing whether you have cStringIO + macros are provided for testing whether you have cStringIO objects. Before calling any of the functions or macros, you must initialize @@ -28,7 +28,7 @@ /* Basic functions to manipulate cStringIO objects from C */ static struct PycStringIO_CAPI { - + /* Read a string from an input object. If the last argument is -1, the remainder will be read. */ -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 28 12:29:35 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Jan 2013 12:29:35 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_skip_condi?= =?utf-8?q?tions_in_some_docstings_tests=2E?= Message-ID: <3YvpXH2xr6zSJm@mail.python.org> http://hg.python.org/cpython/rev/af354c518b86 changeset: 81790:af354c518b86 branch: 2.7 user: Serhiy Storchaka date: Mon Jan 28 13:24:01 2013 +0200 summary: Fix skip conditions in some docstings tests. files: Lib/test/test_functools.py | 2 +- Lib/test/test_property.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -259,7 +259,7 @@ self.assertEqual(wrapper.__name__, 'f') self.assertEqual(wrapper.attr, 'This is also a test') - @unittest.skipIf(not sys.flags.optimize <= 1, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_default_update_doc(self): wrapper = self._default_update() diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -163,7 +163,7 @@ Foo.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_setter_copies_getter_docstring(self): class Foo(object): @@ -196,7 +196,7 @@ FooSub.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_new_getter_new_docstring(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 28 12:29:36 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Jan 2013 12:29:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Fix_skip_condi?= =?utf-8?q?tions_in_some_docstings_tests=2E?= Message-ID: <3YvpXJ5nKdzSL4@mail.python.org> http://hg.python.org/cpython/rev/d4bdd6ec4594 changeset: 81791:d4bdd6ec4594 branch: 3.2 parent: 81781:241b655c23b6 user: Serhiy Storchaka date: Mon Jan 28 13:25:44 2013 +0200 summary: Fix skip conditions in some docstings tests. files: Lib/test/test_functools.py | 2 +- Lib/test/test_property.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -317,7 +317,7 @@ self.assertEqual(wrapper.__name__, 'f') self.assertEqual(wrapper.attr, 'This is also a test') - @unittest.skipIf(not sys.flags.optimize <= 1, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_default_update_doc(self): wrapper = self._default_update() diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -163,7 +163,7 @@ Foo.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_setter_copies_getter_docstring(self): class Foo(object): @@ -196,7 +196,7 @@ FooSub.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_new_getter_new_docstring(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 28 12:29:38 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Jan 2013 12:29:38 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Fix_skip_conditions_in_some_docstings_tests=2E?= Message-ID: <3YvpXL1J2qzSNv@mail.python.org> http://hg.python.org/cpython/rev/1a6cb184e939 changeset: 81792:1a6cb184e939 branch: 3.3 parent: 81782:b2fa459d95d6 parent: 81791:d4bdd6ec4594 user: Serhiy Storchaka date: Mon Jan 28 13:26:25 2013 +0200 summary: Fix skip conditions in some docstings tests. files: Lib/test/test_functools.py | 2 +- Lib/test/test_property.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -321,7 +321,7 @@ self.assertEqual(wrapper.__qualname__, f.__qualname__) self.assertEqual(wrapper.attr, 'This is also a test') - @unittest.skipIf(not sys.flags.optimize <= 1, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_default_update_doc(self): wrapper, _ = self._default_update() diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -186,7 +186,7 @@ Foo.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_setter_copies_getter_docstring(self): class Foo(object): @@ -219,7 +219,7 @@ FooSub.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_new_getter_new_docstring(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 28 12:29:39 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Jan 2013 12:29:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Fix_skip_conditions_in_some_docstings_tests=2E?= Message-ID: <3YvpXM47xWzSR3@mail.python.org> http://hg.python.org/cpython/rev/5f655369ef06 changeset: 81793:5f655369ef06 parent: 81788:a375c3d88c7e parent: 81792:1a6cb184e939 user: Serhiy Storchaka date: Mon Jan 28 13:27:02 2013 +0200 summary: Fix skip conditions in some docstings tests. files: Lib/test/test_property.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -186,7 +186,7 @@ Foo.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_setter_copies_getter_docstring(self): class Foo(object): @@ -219,7 +219,7 @@ FooSub.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize <= 2, + @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_new_getter_new_docstring(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 28 16:17:29 2013 From: python-checkins at python.org (victor.stinner) Date: Mon, 28 Jan 2013 16:17:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_add_test_scripts?= =?utf-8?q?=3B_performances_results_on_Linux_3=2E6?= Message-ID: <3YvvbF6L1GzSKm@mail.python.org> http://hg.python.org/peps/rev/d269feb2c809 changeset: 4694:d269feb2c809 user: Victor Stinner date: Sun Jan 27 13:35:21 2013 +0100 summary: PEP 433: add test scripts; performances results on Linux 3.6 files: pep-0433.txt | 15 ++++++-- pep-0433/bench_cloexec.py | 45 +++++++++++++++++++++++++++ pep-0433/openbsd_bug.py | 32 +++++++++++++++++++ 3 files changed, 88 insertions(+), 4 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -143,9 +143,8 @@ .. note:: OpenBSD older 5.2 does not close the file descriptor with close-on-exec flag set if ``fork()`` is used before ``exec()``, but - it works correctly if ``exec()`` is called without ``fork()``. - -XXX recheck this OpenBSD bug using a C program. XXX + it works correctly if ``exec()`` is called without ``fork()``. Try + `openbsd_bug.py `_. Scope @@ -446,7 +445,15 @@ * ``fcntl(fd, F_SETFD, flags)``: two addition system calls per file descriptor, one to get old flags and one to set new flags -XXX Benchmark the overhead for these 4 methods. XXX +On Linux, setting the close-on-flag has a low overhead on performances. +Results of +`bench_cloexec.py `_ +on Linux 3.6: + + * close-on-flag not set: 7.8 us + * ``O_CLOEXEC``: 1% slower (7.9 us) + * ``ioctl()``: 3% slower (8.0 us) + * ``fcntl()``: 3% slower (8.0 us) Implementation diff --git a/pep-0433/bench_cloexec.py b/pep-0433/bench_cloexec.py new file mode 100644 --- /dev/null +++ b/pep-0433/bench_cloexec.py @@ -0,0 +1,45 @@ +""" +Linux 3.6, O_CLOEXEC: + +open(cloexec=False) + close(): 7.76 us per call +open(cloexec=True) + close(): 7.87 us per call + +=> 1% slower + +Linux 3.6, ioctl(FIOCLEX): + +open(cloexec=False) + close(): 7.77 us per call +open(cloexec=True) + close(): 8.02 us per call + +=> 3% slower + +Linux 3.6, fnctl(F_GETFD) + fnctl(F_SETFD): + +open(cloexec=False) + close(): 7.77 us per call +open(cloexec=True) + close(): 8.01 us per call + +=> 3% slower +""" +import os, time + +name = __file__ +LOOPS = 10**5 +RUNS = 5 + +for cloexec in (False, True): + best = None + for run in range(RUNS): + print("cloexec", cloexec, "run", run) + time.sleep(1) + start = time.perf_counter() + for loops in range(LOOPS): + fd = os.open(name, os.O_RDONLY, cloexec=cloexec) + os.close(fd) + dt = time.perf_counter() - start + if best is not None: + best = min(best, dt) + else: + best = dt + + seconds = best / LOOPS + print("open(cloexec=%s) + close(): %.2f us per call" % (cloexec, seconds * 1e6)) diff --git a/pep-0433/openbsd_bug.py b/pep-0433/openbsd_bug.py new file mode 100644 --- /dev/null +++ b/pep-0433/openbsd_bug.py @@ -0,0 +1,32 @@ +# Script testing an OpenBSD bug +# +# The script fails with "OS BUG!!!" with OpenBSD older than 5.2. +# It works on any version using USE_FORK = False. +USE_FORK = True + +import fcntl, os, sys + +fd = os.open("/etc/passwd", os.O_RDONLY) +flags = fcntl.fcntl(fd, fcntl.F_GETFD) +flags |= fcntl.FD_CLOEXEC +fcntl.fcntl(fd, fcntl.F_SETFD, flags) + +code = """ +import os, sys +fd = int(sys.argv[1]) +try: + os.fstat(fd) +except OSError: + print("fd %s closed by exec (FD_CLOEXEC works)" % fd) +else: + print("fd %s not closed by exec: FD_CLOEXEC doesn't work, OS BUG!!!" % fd) +""" + +args = [sys.executable, '-c', code, str(fd)] +if USE_FORK: + pid = os.fork() + if pid: + os.waitpid(pid, 0) + sys.exit(0) + +os.execv(args[0], args) -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Mon Jan 28 19:22:50 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Jan 2013 19:22:50 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE3MDUx?= =?utf-8?q?=3A_Fix_a_memory_leak_in_os=2Epath=2Eisdir=28=29=C2=A0on_Window?= =?utf-8?q?s=2E_Patch_by_Robert?= Message-ID: <3Yvzj65sdqzSNd@mail.python.org> http://hg.python.org/cpython/rev/4deb294ff567 changeset: 81794:4deb294ff567 branch: 2.7 parent: 81790:af354c518b86 user: Serhiy Storchaka date: Mon Jan 28 20:19:50 2013 +0200 summary: Issue #17051: Fix a memory leak in os.path.isdir()?on Windows. Patch by Robert Xiao. files: Misc/NEWS | 3 +++ Modules/posixmodule.c | 1 + 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,9 @@ Library ------- +- Issue #17051: Fix a memory leak in os.path.isdir()?on Windows. Patch by + Robert Xiao. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4229,6 +4229,7 @@ return NULL; attributes = GetFileAttributesA(path); + PyMem_Free(path); if (attributes == INVALID_FILE_ATTRIBUTES) Py_RETURN_FALSE; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Mon Jan 28 19:29:22 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Jan 2013 19:29:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Add_Robert_Xia?= =?utf-8?q?o_to_Misc/ACKS_for_issue17051=2E?= Message-ID: <3Yvzrf13jzzRMh@mail.python.org> http://hg.python.org/cpython/rev/51173aba06eb changeset: 81795:51173aba06eb branch: 2.7 user: Serhiy Storchaka date: Mon Jan 28 20:27:28 2013 +0200 summary: Add Robert Xiao to Misc/ACKS for issue17051. files: Misc/ACKS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1098,6 +1098,7 @@ Thomas Wouters Heiko Wundram Doug Wyatt +Robert Xiao Florent Xicluna Hirokazu Yamamoto Ka-Ping Yee -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 00:30:10 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 29 Jan 2013 00:30:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_fix_long_fixer?= =?utf-8?q?_docs_=28=234590=29?= Message-ID: <3Yw6Wk4ytBzSK9@mail.python.org> http://hg.python.org/cpython/rev/d5ee6d13af18 changeset: 81796:d5ee6d13af18 branch: 3.3 parent: 81792:1a6cb184e939 user: Benjamin Peterson date: Mon Jan 28 18:28:38 2013 -0500 summary: fix long fixer docs (#4590) files: Doc/library/2to3.rst | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -264,8 +264,7 @@ .. 2to3fixer:: long - Strips the ``L`` prefix on long literals and renames :class:`long` to - :class:`int`. + Renames :class:`long` to :class:`int`. .. 2to3fixer:: map -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 00:30:12 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 29 Jan 2013 00:30:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy4zICgjNDU5MCk=?= Message-ID: <3Yw6Wm0NcCzSH9@mail.python.org> http://hg.python.org/cpython/rev/8b9910d8d27f changeset: 81797:8b9910d8d27f parent: 81793:5f655369ef06 parent: 81796:d5ee6d13af18 user: Benjamin Peterson date: Mon Jan 28 18:28:53 2013 -0500 summary: merge 3.3 (#4590) files: Doc/library/2to3.rst | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -264,8 +264,7 @@ .. 2to3fixer:: long - Strips the ``L`` prefix on long literals and renames :class:`long` to - :class:`int`. + Renames :class:`long` to :class:`int`. .. 2to3fixer:: map -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 00:30:13 2013 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 29 Jan 2013 00:30:13 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_fix_long_fixer?= =?utf-8?q?_docs_=28=234590=29?= Message-ID: <3Yw6Wn302ZzSKV@mail.python.org> http://hg.python.org/cpython/rev/6904e229833d changeset: 81798:6904e229833d branch: 2.7 parent: 81795:51173aba06eb user: Benjamin Peterson date: Mon Jan 28 18:28:38 2013 -0500 summary: fix long fixer docs (#4590) files: Doc/library/2to3.rst | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -264,8 +264,7 @@ .. 2to3fixer:: long - Strips the ``L`` suffix on long literals and renames :class:`long` to - :class:`int`. + Renames :class:`long` to :class:`int`. .. 2to3fixer:: map -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 04:53:29 2013 From: python-checkins at python.org (daniel.holth) Date: Tue, 29 Jan 2013 04:53:29 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_426=3A_add_Version-Scheme?= Message-ID: <3YwDMY71tqzRCZ@mail.python.org> http://hg.python.org/peps/rev/0516007d4d98 changeset: 4695:0516007d4d98 user: Daniel Holth date: Mon Jan 28 22:53:04 2013 -0500 summary: PEP 426: add Version-Scheme files: pep-0426.txt | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/pep-0426.txt b/pep-0426.txt --- a/pep-0426.txt +++ b/pep-0426.txt @@ -68,7 +68,7 @@ 0 or 1 times. Fields marked with "(multiple use)" may be specified 0, 1 or more times. Only "Metadata-Version", "Name", "Version", and "Summary" must appear exactly once. The fields may appear in any order -within the file. +within the header section of the file. Metadata-Version :::::::::::::::: @@ -93,8 +93,7 @@ Version ::::::: -A string containing the distribution's version number. This -field should be in the format specified in PEP 386. +A string containing the distribution's version number. Example:: @@ -405,7 +404,7 @@ specified in PEP 386: they should correspond to the version scheme used by the external dependency. -Notice that there's is no particular rule on the strings to be used. +Notice that there is no particular rule on the strings to be used. Examples:: @@ -484,6 +483,27 @@ or after its declared tags `Chili/Type:` etc. +Version-Scheme (optional) +::::::::::::::::::::::::: + +A string specifying the sorting method for this distribution's version +numbers. Although straightforward version numbers tend to sort the same in +each scheme, there is disagreement about how to sort patch releases and +versions having alphanumeric components such as "1.0.0rc2" and "1.0.0pre3". + + Version-Scheme: pkg_resources + Version-Scheme: pep386 + Version-Scheme: semver-2.0.0rc1 + Version-Scheme: random + +The four initially supported schemes are: + +* pkg_resources: sort according to setuptools' pkg_resources module +* pep386: sort according to the rules in pep386 +* semver-2.0.0rc1: sort according to http://semver.org/ +* random: do the shuffle + + Version Specifiers ================== @@ -495,7 +515,8 @@ the string ">1.0, !=1.3.4, <2.0" is a legal version declaration. The comma (",") is equivalent to the **and** operator. -Each version number must be in the format specified in PEP 386. +Each version number should be in the format used by the referenced +distribution. When a version is provided, it always includes all versions that starts with the same value. For example the "2.5" version of Python @@ -618,6 +639,7 @@ - Provides-Extra - Setup-Requires-Dist - Obsoleted-By + - Version-Scheme References ========== -- Repository URL: http://hg.python.org/peps From solipsis at pitrou.net Tue Jan 29 06:01:23 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 29 Jan 2013 06:01:23 +0100 Subject: [Python-checkins] Daily reference leaks (8b9910d8d27f): sum=4 Message-ID: results for 8b9910d8d27f on branch "default" -------------------------------------------- test_concurrent_futures leaked [2, 1, 1] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflog6AlUa0', '-x'] From python-checkins at python.org Tue Jan 29 09:19:53 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 29 Jan 2013 09:19:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE0MDE4?= =?utf-8?q?=3A_Backport_OS_X_installer_updates_from_3=2E3=2E?= Message-ID: <3YwLGx0cYhzS7J@mail.python.org> http://hg.python.org/cpython/rev/c2830debb15a changeset: 81799:c2830debb15a branch: 2.7 user: Ned Deily date: Tue Jan 29 00:07:46 2013 -0800 summary: Issue #14018: Backport OS X installer updates from 3.3. files: Mac/BuildScript/README.txt | 88 +- Mac/BuildScript/build-installer.py | 504 ++++++--- Mac/BuildScript/ncurses-5.5.patch | 36 - Mac/BuildScript/resources/ReadMe.txt | 30 +- Mac/BuildScript/scripts/postflight.documentation | 9 - Mac/BuildScript/scripts/postflight.framework | 14 +- Mac/Makefile.in | 4 +- 7 files changed, 408 insertions(+), 277 deletions(-) diff --git a/Mac/BuildScript/README.txt b/Mac/BuildScript/README.txt --- a/Mac/BuildScript/README.txt +++ b/Mac/BuildScript/README.txt @@ -8,70 +8,84 @@ an Installer package from the installation plus other files in ``resources`` and ``scripts`` and placed that on a ``.dmg`` disk image. -As of Python 2.7.x and 3.2, PSF practice is to build two installer variants -for each release: +For Python 2.7.x and 3.2.x, PSF practice is to build two installer variants +for each release. 1. 32-bit-only, i386 and PPC universal, capable on running on all machines - supported by Mac OS X 10.3.9 through (at least) 10.6:: + supported by Mac OS X 10.3.9 through (at least) 10.8:: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \ --universal-archs=32-bit \ --dep-target=10.3 - # These are the current default options - builds the following third-party libraries * Bzip2 + * NCurses + * GNU Readline (GPL) + * SQLite 3.7.13 * Zlib 1.2.3 - * GNU Readline (GPL) - * SQLite 3 - * NCurses * Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building - - current target build environment: + - recommended build environment: * Mac OS X 10.5.8 PPC or Intel - * Xcode 3.1.4 (or later) + * Xcode 3.1.4 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors) * ``MACOSX_DEPLOYMENT_TARGET=10.3`` * Apple ``gcc-4.0`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.5 for documentation build with Sphinx - alternate build environments: - * Mac OS X 10.4.11 with Xcode 2.5 - * Mac OS X 10.6.6 with Xcode 3.2.5 + * Mac OS X 10.6.8 with Xcode 3.2.6 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` + * Note Xcode 4.* does not support building for PPC so cannot be used for this build + 2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ --universal-archs=intel \ --dep-target=10.6 + - builds the following third-party libraries + + * NCurses 5.9 (http://bugs.python.org/issue15037) + * SQLite 3.7.13 + - uses system-supplied versions of third-party libraries - + * readline module links with Apple BSD editline (libedit) * builds Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState Tcl/Tk 8.5.9 (or later) to be installed for building - - current target build environment: - - * Mac OS X 10.6.6 (or later) - * Xcode 3.2.5 (or later) + - recommended build environment: + + * Mac OS X 10.6.8 (or later) + * Xcode 3.2.6 * ``MacOSX10.6`` SDK * ``MACOSX_DEPLOYMENT_TARGET=10.6`` * Apple ``gcc-4.2`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.6 for documentation build with Sphinx - alternate build environments: - * none + * none. Xcode 4.x currently supplies two C compilers. + ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and + produce a non-functional Python executable. As it appears to be + considered a migration aid by Apple and is not likely to be fixed, + its use should be avoided. The other compiler, ``clang``, has been + undergoing rapid development. While it appears to have become + production-ready in the most recent Xcode 4 releases (Xcode 4.5.x + as of this writing), there are still some open issues when + building Python and there has not yet been the level of exposure in + production environments that the Xcode 3 gcc-4.2 compiler has had. General Prerequisites @@ -87,6 +101,11 @@ * It is safest to start each variant build with an empty source directory populated with a fresh copy of the untarred source. +* It is recommended that you remove any existing installed version of the + Python being built:: + + sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n + The Recipe ---------- @@ -107,9 +126,9 @@ ................................... It is also possible to build a 4-way universal installer that runs on -OS X Leopard or later:: +OS X 10.5 Leopard or later:: - python 2.6 /build-installer.py \ + /usr/bin/python /build-installer.py \ --dep-target=10.5 --universal-archs=all --sdk-path=/Developer/SDKs/MacOSX10.5.sdk @@ -120,7 +139,8 @@ variants can only be run on G5 machines running 10.5. Note that, while OS X 10.6 is only supported on Intel-based machines, it is possible to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc -emulation in OS X 10.5 and 10.6. +emulation in OS X 10.5 and 10.6. The 4-way installer variant must be +built with Xcode 3. It is not regularly built or tested. Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options @@ -133,15 +153,21 @@ Ideally, the resulting binaries should be installed and the test suite run on all supported OS X releases and architectures. As a practical matter, that is generally not possible. At a minimum, variant 1 should be run on -at least one Intel, one PPC G4, and one PPC G3 system and one each of -OS X 10.6, 10.5, 10.4, and 10.3.9. Not all tests run on 10.3.9. -Variant 2 should be run on 10.6 in both 32-bit and 64-bit modes.:: +a PPC G4 system with OS X 10.5 and at least one Intel system running OS X +10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 +systems in both 32-bit and 64-bit modes.:: - arch -i386 /usr/local/bin/pythonn.n -m test.regrtest -w -u all - arch -X86_64 /usr/local/bin/pythonn.n -m test.regrtest -w -u all + /usr/local/bin/pythonn.n -m test -w -u all,-largefile + /usr/local/bin/pythonn.n-32 -m test -w -u all Certain tests will be skipped and some cause the interpreter to fail which will likely generate ``Python quit unexpectedly`` alert messages -to be generated at several points during a test run. These can -be ignored. +to be generated at several points during a test run. These are normal +during testing and can be ignored. +It is also recommend to launch IDLE and verify that it is at least +functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. +It should also be tested from the command line:: + + /usr/local/bin/idlen.n + diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This script is used to build "official" universal installers on Mac OS X. -It requires at least Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK for +It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for 32-bit builds. 64-bit or four-way universal builds require at least OS X 10.5 and the 10.5 SDK. @@ -10,18 +10,41 @@ which is used to build the documentation, currently requires at least Python 2.4. +In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script +requires an installed version of hg and a third-party version of +Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5 +(for 10.6 or later) installed in /Library/Frameworks. When installed, +the Python built by this script will attempt to dynamically link first to +Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall +back to the ones in /System/Library/Framework. For the build, we recommend +installing the most recent ActiveTcl 8.4 or 8.5 version. + +32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5 +and the installation of additional components, such as a newer Python +(2.5 is needed for Python parser updates), hg, and svn (for the documentation +build). + Usage: see USAGE variable in the script. """ -import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd -import grp +import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp +try: + import urllib2 as urllib_request +except ImportError: + import urllib.request as urllib_request + +STAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) + +STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) INCLUDE_TIMESTAMP = 1 VERBOSE = 1 from plistlib import Plist -import MacOS - try: from plistlib import writePlist except ImportError: @@ -42,20 +65,35 @@ if ln.startswith(variable): value = ln[len(variable):].strip() return value[1:-1] - raise RuntimeError, "Cannot find variable %s" % variable[:-1] + raise RuntimeError("Cannot find variable %s" % variable[:-1]) + +_cache_getVersion = None def getVersion(): - return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + global _cache_getVersion + if _cache_getVersion is None: + _cache_getVersion = grepValue( + os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + return _cache_getVersion def getVersionTuple(): return tuple([int(n) for n in getVersion().split('.')]) +def getVersionMajorMinor(): + return tuple([int(n) for n in getVersion().split('.', 2)]) + +_cache_getFullVersion = None + def getFullVersion(): + global _cache_getFullVersion + if _cache_getFullVersion is not None: + return _cache_getFullVersion fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') for ln in open(fn): if 'PY_VERSION' in ln: - return ln.split()[-1][1:-1] - raise RuntimeError, "Cannot find full version??" + _cache_getFullVersion = ln.split()[-1][1:-1] + return _cache_getFullVersion + raise RuntimeError("Cannot find full version??") # The directory we'll use to create the build (will be erased and recreated) WORKDIR = "/tmp/_py" @@ -111,13 +149,15 @@ DEPTARGET = '10.3' target_cc_map = { - '10.3': 'gcc-4.0', - '10.4': 'gcc-4.0', - '10.5': 'gcc-4.0', - '10.6': 'gcc-4.2', + '10.3': ('gcc-4.0', 'g++-4.0'), + '10.4': ('gcc-4.0', 'g++-4.0'), + '10.5': ('gcc-4.2', 'g++-4.2'), + '10.6': ('gcc-4.2', 'g++-4.2'), + '10.7': ('clang', 'clang++'), + '10.8': ('clang', 'clang++'), } -CC = target_cc_map[DEPTARGET] +CC, CXX = target_cc_map[DEPTARGET] PYTHON_3 = getVersionTuple() >= (3, 0) @@ -135,6 +175,13 @@ --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r) """)% globals() +# Dict of object file names with shared library names to check after building. +# This is to ensure that we ended up dynamically linking with the shared +# library paths and versions we expected. For example: +# EXPECTED_SHARED_LIBS['_tkinter.so'] = [ +# '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl', +# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk'] +EXPECTED_SHARED_LIBS = {} # Instructions for building libraries that are necessary for building a # batteries included python. @@ -143,6 +190,75 @@ def library_recipes(): result = [] + LT_10_5 = bool(DEPTARGET < '10.5') + + if getVersionTuple() >= (3, 3): + result.extend([ + dict( + name="XZ 5.0.3", + url="http://tukaani.org/xz/xz-5.0.3.tar.gz", + checksum='fefe52f9ecd521de2a8ce38c21a27574', + configure_pre=[ + '--disable-dependency-tracking', + ] + ), + ]) + + result.extend([ + dict( + name="NCurses 5.9", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", + checksum='8cb9c412e5f2d96bc6f459aa8c6282a1', + configure_pre=[ + "--enable-widec", + "--without-cxx", + "--without-cxx-binding", + "--without-ada", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--without-debug", + "--without-normal", + "--without-tests", + "--without-manpages", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + ], + patchscripts=[ + ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2", + "f54bf02a349f96a7c4f0d00922f3a0d4"), + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), + dict( + name="SQLite 3.7.13", + url="http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz", + checksum='c97df403e8a3d5b67bb408fcd6aabd8e', + extra_cflags=('-Os ' + '-DSQLITE_ENABLE_FTS4 ' + '-DSQLITE_ENABLE_FTS3_PARENTHESIS ' + '-DSQLITE_ENABLE_RTREE ' + '-DSQLITE_TCL=0 ' + '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]), + configure_pre=[ + '--enable-threadsafe', + '--enable-shared=no', + '--enable-static=yes', + '--disable-readline', + '--disable-dependency-tracking', + ] + ), + ]) + if DEPTARGET < '10.5': result.extend([ dict( @@ -150,8 +266,8 @@ url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz", checksum='00b516f4704d4a7cb50a1d97e6e8e15b', configure=None, - install='make install CC=%s PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -162,8 +278,8 @@ url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz", checksum='debc62758716a169df9f62e6ab2bc634', configure=None, - install='make install CC=%s prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -178,58 +294,12 @@ patches=[ # The readline maintainers don't do actual micro releases, but # just ship a set of patches. - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', + 'c642f2e84d820884b0bf9fd176bc6c3f'), + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + '1a76781a1ea734e831588285db7ec9b1'), ] ), - dict( - name="SQLite 3.7.4", - url="http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz", - checksum='8f0c690bfb33c3cbbc2471c3d9ba0158', - configure_env=('CFLAGS="-Os' - ' -DSQLITE_ENABLE_FTS3' - ' -DSQLITE_ENABLE_FTS3_PARENTHESIS' - ' -DSQLITE_ENABLE_RTREE' - ' -DSQLITE_TCL=0' - '"'), - configure_pre=[ - '--enable-threadsafe', - '--enable-shared=no', - '--enable-static=yes', - '--disable-readline', - '--disable-dependency-tracking', - ] - ), - dict( - name="NCurses 5.5", - url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", - checksum='e73c1ac10b4bfc46db43b2ddfd6244ef', - configure_pre=[ - "--enable-widec", - "--without-cxx", - "--without-ada", - "--without-progs", - "--without-curses-h", - "--enable-shared", - "--with-shared", - "--datadir=/usr/share", - "--sysconfdir=/etc", - "--sharedstatedir=/usr/com", - "--with-terminfo-dirs=/usr/share/terminfo", - "--with-default-terminfo-dir=/usr/share/terminfo", - "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), - "--enable-termcap", - ], - patches=[ - "ncurses-5.5.patch", - ], - useLDFlags=False, - install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( - shellQuote(os.path.join(WORKDIR, 'libraries')), - shellQuote(os.path.join(WORKDIR, 'libraries')), - getVersion(), - ), - ), ]) if not PYTHON_3: @@ -298,9 +368,7 @@ source="/pydocs", readme="""\ This package installs the python documentation at a location - that is useable for pydoc and IDLE. If you have installed Xcode - it will also install a link to the documentation in - /Developer/Documentation/Python + that is useable for pydoc and IDLE. """, postflight="scripts/postflight.documentation", required=False, @@ -326,7 +394,7 @@ ), ] - if DEPTARGET < '10.4': + if DEPTARGET < '10.4' and not PYTHON_3: result.append( dict( name="PythonSystemFixes", @@ -358,7 +426,7 @@ """ Return the contents of the named file """ - return open(fn, 'rb').read() + return open(fn, 'r').read() def runCommand(commandline): """ @@ -370,7 +438,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) if VERBOSE: sys.stdout.write(data); sys.stdout.flush() @@ -381,7 +449,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) return data @@ -423,39 +491,60 @@ # Because we only support dynamic load of only one major/minor version of # Tcl/Tk, ensure: # 1. there are no user-installed frameworks of Tcl/Tk with version - # higher than the Apple-supplied system version - # 2. there is a user-installed framework in /Library/Frameworks with the - # same version as the system version. This allows users to choose - # to install a newer patch level. + # higher than the Apple-supplied system version in + # SDKROOT/System/Library/Frameworks + # 2. there is a user-installed framework (usually ActiveTcl) in (or linked + # in) SDKROOT/Library/Frameworks with the same version as the system + # version. This allows users to choose to install a newer patch level. + frameworks = {} for framework in ['Tcl', 'Tk']: - #fw = dict(lower=framework.lower(), - # upper=framework.upper(), - # cap=framework.capitalize()) - #fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw - fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current' + fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework sysfw = os.path.join(SDKPATH, 'System', fwpth) - libfw = os.path.join('/', fwpth) + libfw = os.path.join(SDKPATH, fwpth) usrfw = os.path.join(os.getenv('HOME'), fwpth) - #version = "%(upper)s_VERSION" % fw + frameworks[framework] = os.readlink(sysfw) + if not os.path.exists(libfw): + fatal("Please install a link to a current %s %s as %s so " + "the user can override the system framework." + % (framework, frameworks[framework], libfw)) if os.readlink(libfw) != os.readlink(sysfw): fatal("Version of %s must match %s" % (libfw, sysfw) ) if os.path.exists(usrfw): fatal("Please rename %s to avoid possible dynamic load issues." % usrfw) + if frameworks['Tcl'] != frameworks['Tk']: + fatal("The Tcl and Tk frameworks are not the same version.") + + # add files to check after build + EXPECTED_SHARED_LIBS['_tkinter.so'] = [ + "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl" + % frameworks['Tcl'], + "/Library/Frameworks/Tk.framework/Versions/%s/Tk" + % frameworks['Tk'], + ] + # Remove inherited environment variables which might influence build environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_', 'LD_', 'LIBRARY_', 'PATH', 'PYTHON'] for ev in list(os.environ): for prefix in environ_var_prefixes: if ev.startswith(prefix) : - print "INFO: deleting environment variable %s=%s" % ( - ev, os.environ[ev]) + print("INFO: deleting environment variable %s=%s" % ( + ev, os.environ[ev])) del os.environ[ev] - os.environ['PATH'] = '/bin:/sbin:/usr/bin:/usr/sbin' - print "Setting default PATH: %s"%(os.environ['PATH']) + base_path = '/bin:/sbin:/usr/bin:/usr/sbin' + if 'SDK_TOOLS_BIN' in os.environ: + base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path + # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin; + # add its fixed location here if it exists + OLD_DEVELOPER_TOOLS = '/Developer/Tools' + if os.path.isdir(OLD_DEVELOPER_TOOLS): + base_path = base_path + ':' + OLD_DEVELOPER_TOOLS + os.environ['PATH'] = base_path + print("Setting default PATH: %s"%(os.environ['PATH'])) def parseOptions(args=None): @@ -463,7 +552,7 @@ Parse arguments and update global settings. """ global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET - global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC + global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX if args is None: args = sys.argv[1:] @@ -472,18 +561,18 @@ options, args = getopt.getopt(args, '?hb', [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=', 'dep-target=', 'universal-archs=', 'help' ]) - except getopt.error, msg: - print msg + except getopt.GetoptError: + print(sys.exc_info()[1]) sys.exit(1) if args: - print "Additional arguments" + print("Additional arguments") sys.exit(1) deptarget = None for k, v in options: if k in ('-h', '-?', '--help'): - print USAGE + print(USAGE) sys.exit(0) elif k in ('-d', '--build-dir'): @@ -511,27 +600,28 @@ # target DEPTARGET = default_target_map.get(v, '10.3') else: - raise NotImplementedError, v + raise NotImplementedError(v) else: - raise NotImplementedError, k + raise NotImplementedError(k) SRCDIR=os.path.abspath(SRCDIR) WORKDIR=os.path.abspath(WORKDIR) SDKPATH=os.path.abspath(SDKPATH) DEPSRC=os.path.abspath(DEPSRC) - CC=target_cc_map[DEPTARGET] + CC, CXX=target_cc_map[DEPTARGET] - print "Settings:" - print " * Source directory:", SRCDIR - print " * Build directory: ", WORKDIR - print " * SDK location: ", SDKPATH - print " * Third-party source:", DEPSRC - print " * Deployment target:", DEPTARGET - print " * Universal architectures:", ARCHLIST - print " * C compiler:", CC - print "" + print("Settings:") + print(" * Source directory:", SRCDIR) + print(" * Build directory: ", WORKDIR) + print(" * SDK location: ", SDKPATH) + print(" * Third-party source:", DEPSRC) + print(" * Deployment target:", DEPTARGET) + print(" * Universal architectures:", ARCHLIST) + print(" * C compiler:", CC) + print(" * C++ compiler:", CXX) + print("") @@ -576,31 +666,18 @@ xit = fp.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "Cannot extract %s"%(archiveName,) + raise RuntimeError("Cannot extract %s"%(archiveName,)) return os.path.join(builddir, retval) finally: os.chdir(curdir) -KNOWNSIZES = { - "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, - "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, -} - def downloadURL(url, fname): """ Download the contents of the url into the file. """ - try: - size = os.path.getsize(fname) - except OSError: - pass - else: - if KNOWNSIZES.get(url) == size: - print "Using existing file for", url - return - fpIn = urllib2.urlopen(url) + fpIn = urllib_request.urlopen(url) fpOut = open(fname, 'wb') block = fpIn.read(10240) try: @@ -615,6 +692,24 @@ except: pass +def verifyThirdPartyFile(url, checksum, fname): + """ + Download file from url to filename fname if it does not already exist. + Abort if file contents does not match supplied md5 checksum. + """ + name = os.path.basename(fname) + if os.path.exists(fname): + print("Using local copy of %s"%(name,)) + else: + print("Did not find local copy of %s"%(name,)) + print("Downloading %s"%(name,)) + downloadURL(url, fname) + print("Archive for %s stored as %s"%(name, fname)) + if os.system( + 'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"' + % (shellQuote(fname), checksum) ): + fatal('MD5 checksum mismatch for file %s' % fname) + def buildRecipe(recipe, basedir, archList): """ Build software using a recipe. This function does the @@ -635,17 +730,8 @@ if not os.path.exists(DEPSRC): os.mkdir(DEPSRC) - - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Did not find local copy of %s"%(name,) - print "Downloading %s"%(name,) - downloadURL(url, sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - print "Extracting archive for %s"%(name,) + verifyThirdPartyFile(url, recipe['checksum'], sourceArchive) + print("Extracting archive for %s"%(name,)) buildDir=os.path.join(WORKDIR, '_bld') if not os.path.exists(buildDir): os.mkdir(buildDir) @@ -655,18 +741,31 @@ if 'buildDir' in recipe: os.chdir(recipe['buildDir']) - - for fn in recipe.get('patches', ()): - if fn.startswith('http://'): - # Download the patch before applying it. - path = os.path.join(DEPSRC, os.path.basename(fn)) - downloadURL(fn, path) - fn = path - - fn = os.path.join(curdir, fn) + for patch in recipe.get('patches', ()): + if isinstance(patch, tuple): + url, checksum = patch + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patch) runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), shellQuote(fn),)) + for patchscript in recipe.get('patchscripts', ()): + if isinstance(patchscript, tuple): + url, checksum = patchscript + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patchscript) + if fn.endswith('.bz2'): + runCommand('bunzip2 -fk %s' % shellQuote(fn)) + fn = fn[:-4] + runCommand('sh %s' % shellQuote(fn)) + os.unlink(fn) + if configure is not None: configure_args = [ "--prefix=/usr/local", @@ -685,40 +784,44 @@ if recipe.get('useLDFlags', 1): configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), - "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( + "LDFLAGS=-mmacosx-version-min=%s -syslibroot,%s -L%s/usr/local/lib -arch %s"%( + DEPTARGET, shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1], ' -arch '.join(archList)), ]) else: configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), ]) if 'configure_post' in recipe: - configure_args = configure_args = list(recipe['configure_post']) + configure_args = configure_args + list(recipe['configure_post']) configure_args.insert(0, configure) configure_args = [ shellQuote(a) for a in configure_args ] - if 'configure_env' in recipe: - configure_args.insert(0, recipe['configure_env']) - - print "Running configure for %s"%(name,) + print("Running configure for %s"%(name,)) runCommand(' '.join(configure_args) + ' 2>&1') - print "Running install for %s"%(name,) + print("Running install for %s"%(name,)) runCommand('{ ' + install + ' ;} 2>&1') - print "Done %s"%(name,) - print "" + print("Done %s"%(name,)) + print("") os.chdir(curdir) @@ -726,9 +829,9 @@ """ Build our dependencies into $WORKDIR/libraries/usr/local """ - print "" - print "Building required libraries" - print "" + print("") + print("Building required libraries") + print("") universal = os.path.join(WORKDIR, 'libraries') os.mkdir(universal) os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) @@ -742,7 +845,7 @@ def buildPythonDocs(): # This stores the documentation as Resources/English.lproj/Documentation # inside the framwork. pydoc and IDLE will pick it up there. - print "Install python documentation" + print("Install python documentation") rootDir = os.path.join(WORKDIR, '_root') buildDir = os.path.join('../../Doc') docdir = os.path.join(rootDir, 'pydocs') @@ -757,7 +860,7 @@ def buildPython(): - print "Building a universal python for %s architectures" % UNIVERSALARCHS + print("Building a universal python for %s architectures" % UNIVERSALARCHS) buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') @@ -785,7 +888,7 @@ # will find them during its extension import sanity checks. os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR, 'libraries', 'usr', 'local', 'lib') - print "Running configure..." + print("Running configure...") runCommand("%s -C --enable-framework --enable-universalsdk=%s " "--with-universal-archs=%s " "%s " @@ -797,19 +900,19 @@ shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) - print "Running make" + print("Running make") runCommand("make") - print "Running make install" + print("Running make install") runCommand("make install DESTDIR=%s"%( shellQuote(rootDir))) - print "Running make frameworkinstallextras" + print("Running make frameworkinstallextras") runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) del os.environ['DYLD_LIBRARY_PATH'] - print "Copying required shared libraries" + print("Copying required shared libraries") if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( @@ -820,16 +923,16 @@ 'Python.framework', 'Versions', getVersion(), 'lib')))) - print "Fix file modes" + print("Fix file modes") frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') gid = grp.getgrnam('admin').gr_gid + shared_lib_error = False for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: - os.chmod(os.path.join(dirpath, dn), 0775) + os.chmod(os.path.join(dirpath, dn), STAT_0o775) os.chown(os.path.join(dirpath, dn), -1, gid) - for fn in filenames: if os.path.islink(fn): continue @@ -840,6 +943,19 @@ os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) os.chown(p, -1, gid) + if fn in EXPECTED_SHARED_LIBS: + # check to see that this file was linked with the + # expected library path and version + data = captureCommand("otool -L %s" % shellQuote(p)) + for sl in EXPECTED_SHARED_LIBS[fn]: + if ("\t%s " % sl) not in data: + print("Expected shared lib %s was not linked with %s" + % (sl, p)) + shared_lib_error = True + + if shared_lib_error: + fatal("Unexpected shared library errors.") + if PYTHON_3: LDVERSION=None VERSION=None @@ -863,19 +979,26 @@ # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on - # the end-users system. - path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', - 'Versions', version, 'lib', 'python%s'%(version,), - 'config' + config_suffix, 'Makefile') - fp = open(path, 'r') - data = fp.read() - fp.close() + # the end-users system. Also remove the directories from _sysconfigdata.py + # (added in 3.3) if it exists. - data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') - data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') - fp = open(path, 'w') - fp.write(data) - fp.close() + path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks', + 'Python.framework', 'Versions', + version, 'lib', 'python%s'%(version,)) + paths = [os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile'), + os.path.join(path_to_lib, '_sysconfigdata.py')] + for path in paths: + if not os.path.exists(path): + continue + fp = open(path, 'r') + data = fp.read() + fp.close() + + data = data.replace(' -L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace(' -I%s/libraries/usr/local/include'%(WORKDIR,), '') + fp = open(path, 'w') + fp.write(data) + fp.close() # Add symlinks in /usr/local/bin, using relative links usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') @@ -907,17 +1030,17 @@ # This one is not handy as a template variable data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework') - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() def patchScript(inPath, outPath): data = fileContents(inPath) data = data.replace('@PYVER@', getVersion()) - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() - os.chmod(outPath, 0755) + os.chmod(outPath, STAT_0o755) @@ -934,7 +1057,7 @@ readme = textwrap.dedent(recipe['readme']) isRequired = recipe.get('required', True) - print "- building package %s"%(pkgname,) + print("- building package %s"%(pkgname,)) # Substitute some variables textvars = dict( @@ -979,7 +1102,7 @@ patchScript(postflight, os.path.join(rsrcDir, 'postflight')) vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,), CFBundleIdentifier='org.python.Python.%s'%(pkgname,), @@ -1016,7 +1139,7 @@ def makeMpkgPlist(path): vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python %s"%(vers,), @@ -1127,7 +1250,7 @@ # Custom icon for the DMG, shown when the DMG is mounted. shutil.copy("../Icons/Disk Image.icns", os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns")) - runCommand("/Developer/Tools/SetFile -a C %s/"%( + runCommand("SetFile -a C %s/"%( shellQuote(os.path.join(WORKDIR, "mnt", volname)),)) runCommand("hdiutil detach %s"%(shellQuote(os.path.join(WORKDIR, "mnt", volname)))) @@ -1168,6 +1291,7 @@ os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET os.environ['CC'] = CC + os.environ['CXX'] = CXX if os.path.exists(WORKDIR): shutil.rmtree(WORKDIR) @@ -1198,7 +1322,7 @@ folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%( getVersion(),)) - os.chmod(folder, 0755) + os.chmod(folder, STAT_0o755) setIcon(folder, "../Icons/Python Folder.icns") # Create the installer @@ -1211,9 +1335,9 @@ shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') - print >> fp, "# BUILD INFO" - print >> fp, "# Date:", time.ctime() - print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos + fp.write("# BUILD INFO\n") + fp.write("# Date: %s\n" % time.ctime()) + fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos) fp.close() # And copy it to a DMG diff --git a/Mac/BuildScript/ncurses-5.5.patch b/Mac/BuildScript/ncurses-5.5.patch deleted file mode 100644 --- a/Mac/BuildScript/ncurses-5.5.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff -r -u ncurses-5.5-orig/test/Makefile.in ncurses-5.5/test/Makefile.in ---- ncurses-5.5-orig/test/Makefile.in 2006-03-24 12:47:40.000000000 +0100 -+++ ncurses-5.5/test/Makefile.in 2006-03-24 12:47:50.000000000 +0100 -@@ -75,7 +75,7 @@ - MATH_LIB = @MATH_LIB@ - - LD = @LD@ --LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS) -+LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) - - usFLAGS = @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@ - -diff -ru ncurses-5.5-orig/ncurses/tinfo/read_entry.c ncurses-5.5/ncurses/tinfo/read_entry.c ---- ncurses-5.5-orig/ncurses/tinfo/read_entry.c 2004-01-11 02:57:05.000000000 +0100 -+++ ncurses-5.5/ncurses/tinfo/read_entry.c 2006-03-25 22:49:39.000000000 +0100 -@@ -474,7 +474,7 @@ - } - - /* truncate the terminal name to prevent buffer overflow */ -- (void) sprintf(ttn, "%c/%.*s", *tn, (int) sizeof(ttn) - 3, tn); -+ (void) sprintf(ttn, "%x/%.*s", *tn, (int) sizeof(ttn) - 3, tn); - - /* This is System V behavior, in conjunction with our requirements for - * writing terminfo entries. -diff -ru ncurses-5.5-orig/configure ncurses-5.5/configure ---- ncurses-5.5-orig/configure 2005-09-24 23:50:50.000000000 +0200 -+++ ncurses-5.5/configure 2006-03-26 22:24:59.000000000 +0200 -@@ -5027,7 +5027,7 @@ - darwin*) - EXTRA_CFLAGS="-no-cpp-precomp" - CC_SHARED_OPTS="-dynamic" -- MK_SHARED_LIB='$(CC) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' -+ MK_SHARED_LIB='$(CC) $(CFLAGS) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' - test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi - cf_cv_shlib_version_infix=yes - ;; diff --git a/Mac/BuildScript/resources/ReadMe.txt b/Mac/BuildScript/resources/ReadMe.txt --- a/Mac/BuildScript/resources/ReadMe.txt +++ b/Mac/BuildScript/resources/ReadMe.txt @@ -5,8 +5,15 @@ Installation requires approximately $INSTALL_SIZE MB of disk space, ignore the message that it will take zero bytes. -You must install onto your current boot disk, even though the -installer does not enforce this, otherwise things will not work. +If you are attempting to install on an OS X 10.8 system, you may +see a message that Python can't be installed because it is from an +unidentified developer. This is because this Python installer +package is not yet compatible with the Gatekeeper security feature +introduced in OS X 10.8. To allow Python to be installed, you +can override the Gatekeeper policy for this install. In the Finder, +instead of double-clicking, control-click or right click the "Python" +installer package icon. Then select "Open using ... Installer" from +the contextual menu that appears. Python consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users including @@ -16,15 +23,16 @@ **** IMPORTANT **** -Before using IDLE or other programs using the tkinter graphical user -interface toolkit, visit http://www.python.org/download/mac/tcltk/ -for current information about supported and recommended versions -of Tcl/Tk for this version of Python and Mac OS X. +To use IDLE or other programs that use the tkinter graphical user +interface toolkit, you may need to install a third-party version of +the Tcl/Tk frameworks. Visit http://www.python.org/download/mac/tcltk/ +for current information about supported and recommended versions of +Tcl/Tk for this version of Python and of Mac OS X. ******************* The installer puts applications, an "Update Shell Profile" command, -and an Extras folder containing demo programs and tools into the +and a link to the optionally installed Python Documentation into the "Python $VERSION" subfolder of the system Applications folder, and puts the underlying machinery into the folder $PYTHONFRAMEWORKINSTALLDIR. It can @@ -32,5 +40,13 @@ well. Double-click on the "Update Shell Profile" command to add the "bin" directory inside the framework to your shell's search path. +You must install onto your current boot disk, even though the +installer does not enforce this, otherwise things will not work. + +You can verify the integrity of the disk image file containing the +installer package and this ReadMe file by comparing its md5 checksum +and size with the values published on the release page linked at +http://www.python.org/download/ + More information on Python in general can be found at http://www.python.org. diff --git a/Mac/BuildScript/scripts/postflight.documentation b/Mac/BuildScript/scripts/postflight.documentation --- a/Mac/BuildScript/scripts/postflight.documentation +++ b/Mac/BuildScript/scripts/postflight.documentation @@ -5,19 +5,10 @@ FWK_DOCDIR_SUBPATH="Resources/English.lproj/Documentation" FWK_DOCDIR="${FWK}/${FWK_DOCDIR_SUBPATH}" APPDIR="/Applications/Python ${PYVER}" -DEV_DOCDIR="/Developer/Documentation" SHARE_DIR="${FWK}/share" SHARE_DOCDIR="${SHARE_DIR}/doc/python${PYVER}" SHARE_DOCDIR_TO_FWK="../../.." -# make link in /Developer/Documentation/ for Xcode users -if [ -d "${DEV_DOCDIR}" ]; then - if [ ! -d "${DEV_DOCDIR}/Python" ]; then - mkdir -p "${DEV_DOCDIR}/Python" - fi - ln -fhs "${FWK_DOCDIR}" "${DEV_DOCDIR}/Python/Reference Documentation ${PYVER}" -fi - # make link in /Applications/Python m.n/ for Finder users if [ -d "${APPDIR}" ]; then ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html" diff --git a/Mac/BuildScript/scripts/postflight.framework b/Mac/BuildScript/scripts/postflight.framework --- a/Mac/BuildScript/scripts/postflight.framework +++ b/Mac/BuildScript/scripts/postflight.framework @@ -8,14 +8,24 @@ "${FWK}/bin/python at PYVER@" -Wi -tt \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" "${FWK}/bin/python at PYVER@" -Wi -tt -O \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" +"${FWK}/bin/python at PYVER@" -Wi \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + +"${FWK}/bin/python at PYVER@" -Wi -O \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + chgrp -R admin "${FWK}" chmod -R g+w "${FWK}" diff --git a/Mac/Makefile.in b/Mac/Makefile.in --- a/Mac/Makefile.in +++ b/Mac/Makefile.in @@ -38,10 +38,10 @@ INSTALL_DATA=@INSTALL_DATA@ LN=@LN@ STRIPFLAG=-s -CPMAC=/Developer/Tools/CpMac +CPMAC=CpMac APPTEMPLATE=$(srcdir)/Resources/app -APPSUBDIRS=MacOS Resources +APPSUBDIRS=MacOS Resources CACHERSRC=$(srcdir)/scripts/cachersrc.py compileall=$(srcdir)/../Lib/compileall.py -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:19:55 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 29 Jan 2013 09:19:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE0MDE4?= =?utf-8?q?=3A_Backport_OS_X_installer_updates_from_3=2E3=2E?= Message-ID: <3YwLGz1pQ1zSKm@mail.python.org> http://hg.python.org/cpython/rev/d54330c8daaa changeset: 81800:d54330c8daaa branch: 3.2 parent: 81791:d4bdd6ec4594 user: Ned Deily date: Tue Jan 29 00:08:32 2013 -0800 summary: Issue #14018: Backport OS X installer updates from 3.3. files: Mac/BuildScript/README.txt | 89 +- Mac/BuildScript/build-installer.py | 504 ++++++--- Mac/BuildScript/ncurses-5.5.patch | 36 - Mac/BuildScript/resources/ReadMe.txt | 28 +- Mac/BuildScript/resources/Welcome.rtf | 8 +- Mac/BuildScript/scripts/postflight.documentation | 9 - Mac/BuildScript/scripts/postflight.framework | 14 +- Mac/Makefile.in | 15 +- Mac/Tools/fixapplepython23.py | 131 -- 9 files changed, 412 insertions(+), 422 deletions(-) diff --git a/Mac/BuildScript/README.txt b/Mac/BuildScript/README.txt --- a/Mac/BuildScript/README.txt +++ b/Mac/BuildScript/README.txt @@ -8,70 +8,83 @@ an Installer package from the installation plus other files in ``resources`` and ``scripts`` and placed that on a ``.dmg`` disk image. -As of Python 2.7.x and 3.2, PSF practice is to build two installer variants -for each release: +For Python 2.7.x and 3.2.x, PSF practice is to build two installer variants +for each release. 1. 32-bit-only, i386 and PPC universal, capable on running on all machines - supported by Mac OS X 10.3.9 through (at least) 10.6:: + supported by Mac OS X 10.3.9 through (at least) 10.8:: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \ --universal-archs=32-bit \ --dep-target=10.3 - # These are the current default options - builds the following third-party libraries * Bzip2 + * NCurses + * GNU Readline (GPL) + * SQLite 3.7.13 * Zlib 1.2.3 - * GNU Readline (GPL) - * SQLite 3 - * NCurses * Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building - - current target build environment: + - recommended build environment: * Mac OS X 10.5.8 PPC or Intel - * Xcode 3.1.4 (or later) + * Xcode 3.1.4 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors) * ``MACOSX_DEPLOYMENT_TARGET=10.3`` * Apple ``gcc-4.0`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.5 for documentation build with Sphinx - alternate build environments: - * Mac OS X 10.4.11 with Xcode 2.5 - * Mac OS X 10.6.6 with Xcode 3.2.5 + * Mac OS X 10.6.8 with Xcode 3.2.6 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` + * Note Xcode 4.* does not support building for PPC so cannot be used for this build + 2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ --universal-archs=intel \ --dep-target=10.6 + - builds the following third-party libraries + + * NCurses 5.9 (http://bugs.python.org/issue15037) + * SQLite 3.7.13 + - uses system-supplied versions of third-party libraries - + * readline module links with Apple BSD editline (libedit) - * builds Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState Tcl/Tk 8.5.9 (or later) to be installed for building - - current target build environment: - - * Mac OS X 10.6.6 (or later) - * Xcode 3.2.5 (or later) + - recommended build environment: + + * Mac OS X 10.6.8 (or later) + * Xcode 3.2.6 * ``MacOSX10.6`` SDK * ``MACOSX_DEPLOYMENT_TARGET=10.6`` * Apple ``gcc-4.2`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.6 for documentation build with Sphinx - alternate build environments: - * none + * none. Xcode 4.x currently supplies two C compilers. + ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and + produce a non-functional Python executable. As it appears to be + considered a migration aid by Apple and is not likely to be fixed, + its use should be avoided. The other compiler, ``clang``, has been + undergoing rapid development. While it appears to have become + production-ready in the most recent Xcode 4 releases (Xcode 4.5.x + as of this writing), there are still some open issues when + building Python and there has not yet been the level of exposure in + production environments that the Xcode 3 gcc-4.2 compiler has had. General Prerequisites @@ -87,6 +100,11 @@ * It is safest to start each variant build with an empty source directory populated with a fresh copy of the untarred source. +* It is recommended that you remove any existing installed version of the + Python being built:: + + sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n + The Recipe ---------- @@ -107,9 +125,9 @@ ................................... It is also possible to build a 4-way universal installer that runs on -OS X Leopard or later:: +OS X 10.5 Leopard or later:: - python 2.6 /build-installer.py \ + /usr/bin/python /build-installer.py \ --dep-target=10.5 --universal-archs=all --sdk-path=/Developer/SDKs/MacOSX10.5.sdk @@ -120,7 +138,8 @@ variants can only be run on G5 machines running 10.5. Note that, while OS X 10.6 is only supported on Intel-based machines, it is possible to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc -emulation in OS X 10.5 and 10.6. +emulation in OS X 10.5 and 10.6. The 4-way installer variant must be +built with Xcode 3. It is not regularly built or tested. Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options @@ -133,15 +152,21 @@ Ideally, the resulting binaries should be installed and the test suite run on all supported OS X releases and architectures. As a practical matter, that is generally not possible. At a minimum, variant 1 should be run on -at least one Intel, one PPC G4, and one PPC G3 system and one each of -OS X 10.6, 10.5, 10.4, and 10.3.9. Not all tests run on 10.3.9. -Variant 2 should be run on 10.6 in both 32-bit and 64-bit modes.:: +a PPC G4 system with OS X 10.5 and at least one Intel system running OS X +10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 +systems in both 32-bit and 64-bit modes.:: - arch -i386 /usr/local/bin/pythonn.n -m test.regrtest -w -u all - arch -X86_64 /usr/local/bin/pythonn.n -m test.regrtest -w -u all + /usr/local/bin/pythonn.n -m test -w -u all,-largefile + /usr/local/bin/pythonn.n-32 -m test -w -u all Certain tests will be skipped and some cause the interpreter to fail which will likely generate ``Python quit unexpectedly`` alert messages -to be generated at several points during a test run. These can -be ignored. +to be generated at several points during a test run. These are normal +during testing and can be ignored. +It is also recommend to launch IDLE and verify that it is at least +functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. +It should also be tested from the command line:: + + /usr/local/bin/idlen.n + diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This script is used to build "official" universal installers on Mac OS X. -It requires at least Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK for +It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for 32-bit builds. 64-bit or four-way universal builds require at least OS X 10.5 and the 10.5 SDK. @@ -10,18 +10,41 @@ which is used to build the documentation, currently requires at least Python 2.4. +In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script +requires an installed version of hg and a third-party version of +Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5 +(for 10.6 or later) installed in /Library/Frameworks. When installed, +the Python built by this script will attempt to dynamically link first to +Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall +back to the ones in /System/Library/Framework. For the build, we recommend +installing the most recent ActiveTcl 8.4 or 8.5 version. + +32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5 +and the installation of additional components, such as a newer Python +(2.5 is needed for Python parser updates), hg, and svn (for the documentation +build). + Usage: see USAGE variable in the script. """ -import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd -import grp +import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp +try: + import urllib2 as urllib_request +except ImportError: + import urllib.request as urllib_request + +STAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) + +STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) INCLUDE_TIMESTAMP = 1 VERBOSE = 1 from plistlib import Plist -import MacOS - try: from plistlib import writePlist except ImportError: @@ -42,20 +65,35 @@ if ln.startswith(variable): value = ln[len(variable):].strip() return value[1:-1] - raise RuntimeError, "Cannot find variable %s" % variable[:-1] + raise RuntimeError("Cannot find variable %s" % variable[:-1]) + +_cache_getVersion = None def getVersion(): - return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + global _cache_getVersion + if _cache_getVersion is None: + _cache_getVersion = grepValue( + os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + return _cache_getVersion def getVersionTuple(): return tuple([int(n) for n in getVersion().split('.')]) +def getVersionMajorMinor(): + return tuple([int(n) for n in getVersion().split('.', 2)]) + +_cache_getFullVersion = None + def getFullVersion(): + global _cache_getFullVersion + if _cache_getFullVersion is not None: + return _cache_getFullVersion fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') for ln in open(fn): if 'PY_VERSION' in ln: - return ln.split()[-1][1:-1] - raise RuntimeError, "Cannot find full version??" + _cache_getFullVersion = ln.split()[-1][1:-1] + return _cache_getFullVersion + raise RuntimeError("Cannot find full version??") # The directory we'll use to create the build (will be erased and recreated) WORKDIR = "/tmp/_py" @@ -111,13 +149,15 @@ DEPTARGET = '10.3' target_cc_map = { - '10.3': 'gcc-4.0', - '10.4': 'gcc-4.0', - '10.5': 'gcc-4.0', - '10.6': 'gcc-4.2', + '10.3': ('gcc-4.0', 'g++-4.0'), + '10.4': ('gcc-4.0', 'g++-4.0'), + '10.5': ('gcc-4.2', 'g++-4.2'), + '10.6': ('gcc-4.2', 'g++-4.2'), + '10.7': ('clang', 'clang++'), + '10.8': ('clang', 'clang++'), } -CC = target_cc_map[DEPTARGET] +CC, CXX = target_cc_map[DEPTARGET] PYTHON_3 = getVersionTuple() >= (3, 0) @@ -135,6 +175,13 @@ --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r) """)% globals() +# Dict of object file names with shared library names to check after building. +# This is to ensure that we ended up dynamically linking with the shared +# library paths and versions we expected. For example: +# EXPECTED_SHARED_LIBS['_tkinter.so'] = [ +# '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl', +# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk'] +EXPECTED_SHARED_LIBS = {} # Instructions for building libraries that are necessary for building a # batteries included python. @@ -143,6 +190,75 @@ def library_recipes(): result = [] + LT_10_5 = bool(DEPTARGET < '10.5') + + if getVersionTuple() >= (3, 3): + result.extend([ + dict( + name="XZ 5.0.3", + url="http://tukaani.org/xz/xz-5.0.3.tar.gz", + checksum='fefe52f9ecd521de2a8ce38c21a27574', + configure_pre=[ + '--disable-dependency-tracking', + ] + ), + ]) + + result.extend([ + dict( + name="NCurses 5.9", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", + checksum='8cb9c412e5f2d96bc6f459aa8c6282a1', + configure_pre=[ + "--enable-widec", + "--without-cxx", + "--without-cxx-binding", + "--without-ada", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--without-debug", + "--without-normal", + "--without-tests", + "--without-manpages", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + ], + patchscripts=[ + ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2", + "f54bf02a349f96a7c4f0d00922f3a0d4"), + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), + dict( + name="SQLite 3.7.13", + url="http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz", + checksum='c97df403e8a3d5b67bb408fcd6aabd8e', + extra_cflags=('-Os ' + '-DSQLITE_ENABLE_FTS4 ' + '-DSQLITE_ENABLE_FTS3_PARENTHESIS ' + '-DSQLITE_ENABLE_RTREE ' + '-DSQLITE_TCL=0 ' + '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]), + configure_pre=[ + '--enable-threadsafe', + '--enable-shared=no', + '--enable-static=yes', + '--disable-readline', + '--disable-dependency-tracking', + ] + ), + ]) + if DEPTARGET < '10.5': result.extend([ dict( @@ -150,8 +266,8 @@ url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz", checksum='00b516f4704d4a7cb50a1d97e6e8e15b', configure=None, - install='make install CC=%s PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -162,8 +278,8 @@ url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz", checksum='debc62758716a169df9f62e6ab2bc634', configure=None, - install='make install CC=%s prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -178,58 +294,12 @@ patches=[ # The readline maintainers don't do actual micro releases, but # just ship a set of patches. - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', + 'c642f2e84d820884b0bf9fd176bc6c3f'), + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + '1a76781a1ea734e831588285db7ec9b1'), ] ), - dict( - name="SQLite 3.7.4", - url="http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz", - checksum='8f0c690bfb33c3cbbc2471c3d9ba0158', - configure_env=('CFLAGS="-Os' - ' -DSQLITE_ENABLE_FTS3' - ' -DSQLITE_ENABLE_FTS3_PARENTHESIS' - ' -DSQLITE_ENABLE_RTREE' - ' -DSQLITE_TCL=0' - '"'), - configure_pre=[ - '--enable-threadsafe', - '--enable-shared=no', - '--enable-static=yes', - '--disable-readline', - '--disable-dependency-tracking', - ] - ), - dict( - name="NCurses 5.5", - url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", - checksum='e73c1ac10b4bfc46db43b2ddfd6244ef', - configure_pre=[ - "--enable-widec", - "--without-cxx", - "--without-ada", - "--without-progs", - "--without-curses-h", - "--enable-shared", - "--with-shared", - "--datadir=/usr/share", - "--sysconfdir=/etc", - "--sharedstatedir=/usr/com", - "--with-terminfo-dirs=/usr/share/terminfo", - "--with-default-terminfo-dir=/usr/share/terminfo", - "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), - "--enable-termcap", - ], - patches=[ - "ncurses-5.5.patch", - ], - useLDFlags=False, - install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( - shellQuote(os.path.join(WORKDIR, 'libraries')), - shellQuote(os.path.join(WORKDIR, 'libraries')), - getVersion(), - ), - ), ]) if not PYTHON_3: @@ -298,9 +368,7 @@ source="/pydocs", readme="""\ This package installs the python documentation at a location - that is useable for pydoc and IDLE. If you have installed Xcode - it will also install a link to the documentation in - /Developer/Documentation/Python + that is useable for pydoc and IDLE. """, postflight="scripts/postflight.documentation", required=False, @@ -326,7 +394,7 @@ ), ] - if DEPTARGET < '10.4': + if DEPTARGET < '10.4' and not PYTHON_3: result.append( dict( name="PythonSystemFixes", @@ -358,7 +426,7 @@ """ Return the contents of the named file """ - return open(fn, 'rb').read() + return open(fn, 'r').read() def runCommand(commandline): """ @@ -370,7 +438,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) if VERBOSE: sys.stdout.write(data); sys.stdout.flush() @@ -381,7 +449,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) return data @@ -423,39 +491,60 @@ # Because we only support dynamic load of only one major/minor version of # Tcl/Tk, ensure: # 1. there are no user-installed frameworks of Tcl/Tk with version - # higher than the Apple-supplied system version - # 2. there is a user-installed framework in /Library/Frameworks with the - # same version as the system version. This allows users to choose - # to install a newer patch level. + # higher than the Apple-supplied system version in + # SDKROOT/System/Library/Frameworks + # 2. there is a user-installed framework (usually ActiveTcl) in (or linked + # in) SDKROOT/Library/Frameworks with the same version as the system + # version. This allows users to choose to install a newer patch level. + frameworks = {} for framework in ['Tcl', 'Tk']: - #fw = dict(lower=framework.lower(), - # upper=framework.upper(), - # cap=framework.capitalize()) - #fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw - fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current' + fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework sysfw = os.path.join(SDKPATH, 'System', fwpth) - libfw = os.path.join('/', fwpth) + libfw = os.path.join(SDKPATH, fwpth) usrfw = os.path.join(os.getenv('HOME'), fwpth) - #version = "%(upper)s_VERSION" % fw + frameworks[framework] = os.readlink(sysfw) + if not os.path.exists(libfw): + fatal("Please install a link to a current %s %s as %s so " + "the user can override the system framework." + % (framework, frameworks[framework], libfw)) if os.readlink(libfw) != os.readlink(sysfw): fatal("Version of %s must match %s" % (libfw, sysfw) ) if os.path.exists(usrfw): fatal("Please rename %s to avoid possible dynamic load issues." % usrfw) + if frameworks['Tcl'] != frameworks['Tk']: + fatal("The Tcl and Tk frameworks are not the same version.") + + # add files to check after build + EXPECTED_SHARED_LIBS['_tkinter.so'] = [ + "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl" + % frameworks['Tcl'], + "/Library/Frameworks/Tk.framework/Versions/%s/Tk" + % frameworks['Tk'], + ] + # Remove inherited environment variables which might influence build environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_', 'LD_', 'LIBRARY_', 'PATH', 'PYTHON'] for ev in list(os.environ): for prefix in environ_var_prefixes: if ev.startswith(prefix) : - print "INFO: deleting environment variable %s=%s" % ( - ev, os.environ[ev]) + print("INFO: deleting environment variable %s=%s" % ( + ev, os.environ[ev])) del os.environ[ev] - os.environ['PATH'] = '/bin:/sbin:/usr/bin:/usr/sbin' - print "Setting default PATH: %s"%(os.environ['PATH']) + base_path = '/bin:/sbin:/usr/bin:/usr/sbin' + if 'SDK_TOOLS_BIN' in os.environ: + base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path + # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin; + # add its fixed location here if it exists + OLD_DEVELOPER_TOOLS = '/Developer/Tools' + if os.path.isdir(OLD_DEVELOPER_TOOLS): + base_path = base_path + ':' + OLD_DEVELOPER_TOOLS + os.environ['PATH'] = base_path + print("Setting default PATH: %s"%(os.environ['PATH'])) def parseOptions(args=None): @@ -463,7 +552,7 @@ Parse arguments and update global settings. """ global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET - global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC + global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX if args is None: args = sys.argv[1:] @@ -472,18 +561,18 @@ options, args = getopt.getopt(args, '?hb', [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=', 'dep-target=', 'universal-archs=', 'help' ]) - except getopt.error, msg: - print msg + except getopt.GetoptError: + print(sys.exc_info()[1]) sys.exit(1) if args: - print "Additional arguments" + print("Additional arguments") sys.exit(1) deptarget = None for k, v in options: if k in ('-h', '-?', '--help'): - print USAGE + print(USAGE) sys.exit(0) elif k in ('-d', '--build-dir'): @@ -511,27 +600,28 @@ # target DEPTARGET = default_target_map.get(v, '10.3') else: - raise NotImplementedError, v + raise NotImplementedError(v) else: - raise NotImplementedError, k + raise NotImplementedError(k) SRCDIR=os.path.abspath(SRCDIR) WORKDIR=os.path.abspath(WORKDIR) SDKPATH=os.path.abspath(SDKPATH) DEPSRC=os.path.abspath(DEPSRC) - CC=target_cc_map[DEPTARGET] + CC, CXX=target_cc_map[DEPTARGET] - print "Settings:" - print " * Source directory:", SRCDIR - print " * Build directory: ", WORKDIR - print " * SDK location: ", SDKPATH - print " * Third-party source:", DEPSRC - print " * Deployment target:", DEPTARGET - print " * Universal architectures:", ARCHLIST - print " * C compiler:", CC - print "" + print("Settings:") + print(" * Source directory:", SRCDIR) + print(" * Build directory: ", WORKDIR) + print(" * SDK location: ", SDKPATH) + print(" * Third-party source:", DEPSRC) + print(" * Deployment target:", DEPTARGET) + print(" * Universal architectures:", ARCHLIST) + print(" * C compiler:", CC) + print(" * C++ compiler:", CXX) + print("") @@ -576,31 +666,18 @@ xit = fp.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "Cannot extract %s"%(archiveName,) + raise RuntimeError("Cannot extract %s"%(archiveName,)) return os.path.join(builddir, retval) finally: os.chdir(curdir) -KNOWNSIZES = { - "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, - "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, -} - def downloadURL(url, fname): """ Download the contents of the url into the file. """ - try: - size = os.path.getsize(fname) - except OSError: - pass - else: - if KNOWNSIZES.get(url) == size: - print "Using existing file for", url - return - fpIn = urllib2.urlopen(url) + fpIn = urllib_request.urlopen(url) fpOut = open(fname, 'wb') block = fpIn.read(10240) try: @@ -615,6 +692,24 @@ except: pass +def verifyThirdPartyFile(url, checksum, fname): + """ + Download file from url to filename fname if it does not already exist. + Abort if file contents does not match supplied md5 checksum. + """ + name = os.path.basename(fname) + if os.path.exists(fname): + print("Using local copy of %s"%(name,)) + else: + print("Did not find local copy of %s"%(name,)) + print("Downloading %s"%(name,)) + downloadURL(url, fname) + print("Archive for %s stored as %s"%(name, fname)) + if os.system( + 'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"' + % (shellQuote(fname), checksum) ): + fatal('MD5 checksum mismatch for file %s' % fname) + def buildRecipe(recipe, basedir, archList): """ Build software using a recipe. This function does the @@ -635,17 +730,8 @@ if not os.path.exists(DEPSRC): os.mkdir(DEPSRC) - - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Did not find local copy of %s"%(name,) - print "Downloading %s"%(name,) - downloadURL(url, sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - print "Extracting archive for %s"%(name,) + verifyThirdPartyFile(url, recipe['checksum'], sourceArchive) + print("Extracting archive for %s"%(name,)) buildDir=os.path.join(WORKDIR, '_bld') if not os.path.exists(buildDir): os.mkdir(buildDir) @@ -655,18 +741,31 @@ if 'buildDir' in recipe: os.chdir(recipe['buildDir']) - - for fn in recipe.get('patches', ()): - if fn.startswith('http://'): - # Download the patch before applying it. - path = os.path.join(DEPSRC, os.path.basename(fn)) - downloadURL(fn, path) - fn = path - - fn = os.path.join(curdir, fn) + for patch in recipe.get('patches', ()): + if isinstance(patch, tuple): + url, checksum = patch + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patch) runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), shellQuote(fn),)) + for patchscript in recipe.get('patchscripts', ()): + if isinstance(patchscript, tuple): + url, checksum = patchscript + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patchscript) + if fn.endswith('.bz2'): + runCommand('bunzip2 -fk %s' % shellQuote(fn)) + fn = fn[:-4] + runCommand('sh %s' % shellQuote(fn)) + os.unlink(fn) + if configure is not None: configure_args = [ "--prefix=/usr/local", @@ -685,40 +784,44 @@ if recipe.get('useLDFlags', 1): configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), - "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( + "LDFLAGS=-mmacosx-version-min=%s -syslibroot,%s -L%s/usr/local/lib -arch %s"%( + DEPTARGET, shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1], ' -arch '.join(archList)), ]) else: configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), ]) if 'configure_post' in recipe: - configure_args = configure_args = list(recipe['configure_post']) + configure_args = configure_args + list(recipe['configure_post']) configure_args.insert(0, configure) configure_args = [ shellQuote(a) for a in configure_args ] - if 'configure_env' in recipe: - configure_args.insert(0, recipe['configure_env']) - - print "Running configure for %s"%(name,) + print("Running configure for %s"%(name,)) runCommand(' '.join(configure_args) + ' 2>&1') - print "Running install for %s"%(name,) + print("Running install for %s"%(name,)) runCommand('{ ' + install + ' ;} 2>&1') - print "Done %s"%(name,) - print "" + print("Done %s"%(name,)) + print("") os.chdir(curdir) @@ -726,9 +829,9 @@ """ Build our dependencies into $WORKDIR/libraries/usr/local """ - print "" - print "Building required libraries" - print "" + print("") + print("Building required libraries") + print("") universal = os.path.join(WORKDIR, 'libraries') os.mkdir(universal) os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) @@ -742,7 +845,7 @@ def buildPythonDocs(): # This stores the documentation as Resources/English.lproj/Documentation # inside the framwork. pydoc and IDLE will pick it up there. - print "Install python documentation" + print("Install python documentation") rootDir = os.path.join(WORKDIR, '_root') buildDir = os.path.join('../../Doc') docdir = os.path.join(rootDir, 'pydocs') @@ -757,7 +860,7 @@ def buildPython(): - print "Building a universal python for %s architectures" % UNIVERSALARCHS + print("Building a universal python for %s architectures" % UNIVERSALARCHS) buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') @@ -785,7 +888,7 @@ # will find them during its extension import sanity checks. os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR, 'libraries', 'usr', 'local', 'lib') - print "Running configure..." + print("Running configure...") runCommand("%s -C --enable-framework --enable-universalsdk=%s " "--with-universal-archs=%s " "%s " @@ -797,19 +900,19 @@ shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) - print "Running make" + print("Running make") runCommand("make") - print "Running make install" + print("Running make install") runCommand("make install DESTDIR=%s"%( shellQuote(rootDir))) - print "Running make frameworkinstallextras" + print("Running make frameworkinstallextras") runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) del os.environ['DYLD_LIBRARY_PATH'] - print "Copying required shared libraries" + print("Copying required shared libraries") if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( @@ -820,16 +923,16 @@ 'Python.framework', 'Versions', getVersion(), 'lib')))) - print "Fix file modes" + print("Fix file modes") frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') gid = grp.getgrnam('admin').gr_gid + shared_lib_error = False for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: - os.chmod(os.path.join(dirpath, dn), 0775) + os.chmod(os.path.join(dirpath, dn), STAT_0o775) os.chown(os.path.join(dirpath, dn), -1, gid) - for fn in filenames: if os.path.islink(fn): continue @@ -840,6 +943,19 @@ os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) os.chown(p, -1, gid) + if fn in EXPECTED_SHARED_LIBS: + # check to see that this file was linked with the + # expected library path and version + data = captureCommand("otool -L %s" % shellQuote(p)) + for sl in EXPECTED_SHARED_LIBS[fn]: + if ("\t%s " % sl) not in data: + print("Expected shared lib %s was not linked with %s" + % (sl, p)) + shared_lib_error = True + + if shared_lib_error: + fatal("Unexpected shared library errors.") + if PYTHON_3: LDVERSION=None VERSION=None @@ -863,19 +979,26 @@ # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on - # the end-users system. - path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', - 'Versions', version, 'lib', 'python%s'%(version,), - 'config' + config_suffix, 'Makefile') - fp = open(path, 'r') - data = fp.read() - fp.close() + # the end-users system. Also remove the directories from _sysconfigdata.py + # (added in 3.3) if it exists. - data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') - data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') - fp = open(path, 'w') - fp.write(data) - fp.close() + path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks', + 'Python.framework', 'Versions', + version, 'lib', 'python%s'%(version,)) + paths = [os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile'), + os.path.join(path_to_lib, '_sysconfigdata.py')] + for path in paths: + if not os.path.exists(path): + continue + fp = open(path, 'r') + data = fp.read() + fp.close() + + data = data.replace(' -L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace(' -I%s/libraries/usr/local/include'%(WORKDIR,), '') + fp = open(path, 'w') + fp.write(data) + fp.close() # Add symlinks in /usr/local/bin, using relative links usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') @@ -907,17 +1030,17 @@ # This one is not handy as a template variable data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework') - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() def patchScript(inPath, outPath): data = fileContents(inPath) data = data.replace('@PYVER@', getVersion()) - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() - os.chmod(outPath, 0755) + os.chmod(outPath, STAT_0o755) @@ -934,7 +1057,7 @@ readme = textwrap.dedent(recipe['readme']) isRequired = recipe.get('required', True) - print "- building package %s"%(pkgname,) + print("- building package %s"%(pkgname,)) # Substitute some variables textvars = dict( @@ -979,7 +1102,7 @@ patchScript(postflight, os.path.join(rsrcDir, 'postflight')) vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,), CFBundleIdentifier='org.python.Python.%s'%(pkgname,), @@ -1016,7 +1139,7 @@ def makeMpkgPlist(path): vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python %s"%(vers,), @@ -1127,7 +1250,7 @@ # Custom icon for the DMG, shown when the DMG is mounted. shutil.copy("../Icons/Disk Image.icns", os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns")) - runCommand("/Developer/Tools/SetFile -a C %s/"%( + runCommand("SetFile -a C %s/"%( shellQuote(os.path.join(WORKDIR, "mnt", volname)),)) runCommand("hdiutil detach %s"%(shellQuote(os.path.join(WORKDIR, "mnt", volname)))) @@ -1168,6 +1291,7 @@ os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET os.environ['CC'] = CC + os.environ['CXX'] = CXX if os.path.exists(WORKDIR): shutil.rmtree(WORKDIR) @@ -1198,7 +1322,7 @@ folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%( getVersion(),)) - os.chmod(folder, 0755) + os.chmod(folder, STAT_0o755) setIcon(folder, "../Icons/Python Folder.icns") # Create the installer @@ -1211,9 +1335,9 @@ shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') - print >> fp, "# BUILD INFO" - print >> fp, "# Date:", time.ctime() - print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos + fp.write("# BUILD INFO\n") + fp.write("# Date: %s\n" % time.ctime()) + fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos) fp.close() # And copy it to a DMG diff --git a/Mac/BuildScript/ncurses-5.5.patch b/Mac/BuildScript/ncurses-5.5.patch deleted file mode 100644 --- a/Mac/BuildScript/ncurses-5.5.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff -r -u ncurses-5.5-orig/test/Makefile.in ncurses-5.5/test/Makefile.in ---- ncurses-5.5-orig/test/Makefile.in 2006-03-24 12:47:40.000000000 +0100 -+++ ncurses-5.5/test/Makefile.in 2006-03-24 12:47:50.000000000 +0100 -@@ -75,7 +75,7 @@ - MATH_LIB = @MATH_LIB@ - - LD = @LD@ --LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS) -+LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) - - usFLAGS = @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@ - -diff -ru ncurses-5.5-orig/ncurses/tinfo/read_entry.c ncurses-5.5/ncurses/tinfo/read_entry.c ---- ncurses-5.5-orig/ncurses/tinfo/read_entry.c 2004-01-11 02:57:05.000000000 +0100 -+++ ncurses-5.5/ncurses/tinfo/read_entry.c 2006-03-25 22:49:39.000000000 +0100 -@@ -474,7 +474,7 @@ - } - - /* truncate the terminal name to prevent buffer overflow */ -- (void) sprintf(ttn, "%c/%.*s", *tn, (int) sizeof(ttn) - 3, tn); -+ (void) sprintf(ttn, "%x/%.*s", *tn, (int) sizeof(ttn) - 3, tn); - - /* This is System V behavior, in conjunction with our requirements for - * writing terminfo entries. -diff -ru ncurses-5.5-orig/configure ncurses-5.5/configure ---- ncurses-5.5-orig/configure 2005-09-24 23:50:50.000000000 +0200 -+++ ncurses-5.5/configure 2006-03-26 22:24:59.000000000 +0200 -@@ -5027,7 +5027,7 @@ - darwin*) - EXTRA_CFLAGS="-no-cpp-precomp" - CC_SHARED_OPTS="-dynamic" -- MK_SHARED_LIB='$(CC) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' -+ MK_SHARED_LIB='$(CC) $(CFLAGS) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' - test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi - cf_cv_shlib_version_infix=yes - ;; diff --git a/Mac/BuildScript/resources/ReadMe.txt b/Mac/BuildScript/resources/ReadMe.txt --- a/Mac/BuildScript/resources/ReadMe.txt +++ b/Mac/BuildScript/resources/ReadMe.txt @@ -5,8 +5,15 @@ Installation requires approximately $INSTALL_SIZE MB of disk space, ignore the message that it will take zero bytes. -You must install onto your current boot disk, even though the -installer does not enforce this, otherwise things will not work. +If you are attempting to install on an OS X 10.8 system, you may +see a message that Python can't be installed because it is from an +unidentified developer. This is because this Python installer +package is not yet compatible with the Gatekeeper security feature +introduced in OS X 10.8. To allow Python to be installed, you +can override the Gatekeeper policy for this install. In the Finder, +instead of double-clicking, control-click or right click the "Python" +installer package icon. Then select "Open using ... Installer" from +the contextual menu that appears. Python consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users including @@ -16,10 +23,11 @@ **** IMPORTANT **** -Before using IDLE or other programs using the tkinter graphical user -interface toolkit, visit http://www.python.org/download/mac/tcltk/ -for current information about supported and recommended versions -of Tcl/Tk for this version of Python and Mac OS X. +To use IDLE or other programs that use the tkinter graphical user +interface toolkit, you may need to install a third-party version of +the Tcl/Tk frameworks. Visit http://www.python.org/download/mac/tcltk/ +for current information about supported and recommended versions of +Tcl/Tk for this version of Python and of Mac OS X. ******************* @@ -32,5 +40,13 @@ well. Double-click on the "Update Shell Profile" command to add the "bin" directory inside the framework to your shell's search path. +You must install onto your current boot disk, even though the +installer does not enforce this, otherwise things will not work. + +You can verify the integrity of the disk image file containing the +installer package and this ReadMe file by comparing its md5 checksum +and size with the values published on the release page linked at +http://www.python.org/download/ + More information on Python in general can be found at http://www.python.org. diff --git a/Mac/BuildScript/resources/Welcome.rtf b/Mac/BuildScript/resources/Welcome.rtf --- a/Mac/BuildScript/resources/Welcome.rtf +++ b/Mac/BuildScript/resources/Welcome.rtf @@ -1,8 +1,8 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 +{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf470 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} \paperw11904\paperh16836\margl1440\margr1440\vieww9640\viewh10620\viewkind0 -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640 \f0\fs24 \cf0 This package will install \b Python $FULL_VERSION @@ -20,9 +20,9 @@ \ \b NOTE: -\b0 This package will by default not update your shell profile and will also not install files in /usr/local. Double-click +\b0 This package will not update your shell profile by default. Double-click \b Update Shell Profile -\b0 at any time to make $FULL_VERSION the default Python.\ +\b0 at any time to make $FULL_VERSION the default Python 3 version. This version can co-exist with other installed versions of Python 3 and Python 2.\ \ \b IMPORTANT: diff --git a/Mac/BuildScript/scripts/postflight.documentation b/Mac/BuildScript/scripts/postflight.documentation --- a/Mac/BuildScript/scripts/postflight.documentation +++ b/Mac/BuildScript/scripts/postflight.documentation @@ -5,19 +5,10 @@ FWK_DOCDIR_SUBPATH="Resources/English.lproj/Documentation" FWK_DOCDIR="${FWK}/${FWK_DOCDIR_SUBPATH}" APPDIR="/Applications/Python ${PYVER}" -DEV_DOCDIR="/Developer/Documentation" SHARE_DIR="${FWK}/share" SHARE_DOCDIR="${SHARE_DIR}/doc/python${PYVER}" SHARE_DOCDIR_TO_FWK="../../.." -# make link in /Developer/Documentation/ for Xcode users -if [ -d "${DEV_DOCDIR}" ]; then - if [ ! -d "${DEV_DOCDIR}/Python" ]; then - mkdir -p "${DEV_DOCDIR}/Python" - fi - ln -fhs "${FWK_DOCDIR}" "${DEV_DOCDIR}/Python/Reference Documentation ${PYVER}" -fi - # make link in /Applications/Python m.n/ for Finder users if [ -d "${APPDIR}" ]; then ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html" diff --git a/Mac/BuildScript/scripts/postflight.framework b/Mac/BuildScript/scripts/postflight.framework --- a/Mac/BuildScript/scripts/postflight.framework +++ b/Mac/BuildScript/scripts/postflight.framework @@ -8,14 +8,24 @@ "${FWK}/bin/python at PYVER@" -Wi \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" "${FWK}/bin/python at PYVER@" -Wi -O \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" +"${FWK}/bin/python at PYVER@" -Wi \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + +"${FWK}/bin/python at PYVER@" -Wi -O \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + chgrp -R admin "${FWK}" chmod -R g+w "${FWK}" diff --git a/Mac/Makefile.in b/Mac/Makefile.in --- a/Mac/Makefile.in +++ b/Mac/Makefile.in @@ -40,14 +40,13 @@ INSTALL_DATA=@INSTALL_DATA@ LN=@LN@ STRIPFLAG=-s -CPMAC=/Developer/Tools/CpMac +CPMAC=CpMac APPTEMPLATE=$(srcdir)/Resources/app -APPSUBDIRS=MacOS Resources +APPSUBDIRS=MacOS Resources compileall=$(srcdir)/../Lib/compileall.py -installapps: install_Python install_pythonw install_PythonLauncher install_IDLE \ - checkapplepython +installapps: install_Python install_pythonw install_PythonLauncher install_IDLE install_pythonw: pythonw $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)" @@ -196,14 +195,6 @@ "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools" ; \ chmod -R ugo+rX,go-w "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools" - -checkapplepython: $(srcdir)/Tools/fixapplepython23.py - @if ! $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Tools/fixapplepython23.py -n; then \ - echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ - echo "* WARNING: Run $(srcdir)/Tools/fixapplepython23.py with \"sudo\" to fix this."; \ - fi - - clean: rm pythonw cd PythonLauncher && make clean diff --git a/Mac/Tools/fixapplepython23.py b/Mac/Tools/fixapplepython23.py deleted file mode 100644 --- a/Mac/Tools/fixapplepython23.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/python -"""fixapplepython23 - Fix Apple-installed Python 2.3 (on Mac OS X 10.3) - -Python 2.3 (and 2.3.X for X<5) have the problem that building an extension -for a framework installation may accidentally pick up the framework -of a newer Python, in stead of the one that was used to build the extension. - -This script modifies the Makefile (in .../lib/python2.3/config) to use -the newer method of linking extensions with "-undefined dynamic_lookup" -which fixes this problem. - -The script will first check all prerequisites, and return a zero exit -status also when nothing needs to be fixed. -""" -import sys -import os -import platform - -MAKEFILE='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile' -CHANGES=(( - 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', - 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' - ),( - 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', - 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' - ),( - 'CC=\t\tgcc\n', - 'CC=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc\n' - ),( - 'CXX=\t\tc++\n', - 'CXX=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++\n' -)) - -GCC_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc' -GXX_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++' -SCRIPT="""#!/bin/sh -export MACOSX_DEPLOYMENT_TARGET=10.3 -exec %s "${@}" -""" - -def findline(lines, start): - """return line starting with given string or -1""" - for i in range(len(lines)): - if lines[i][:len(start)] == start: - return i - return -1 - -def fix(makefile, do_apply): - """Fix the Makefile, if required.""" - fixed = False - lines = open(makefile).readlines() - - for old, new in CHANGES: - i = findline(lines, new) - if i >= 0: - # Already fixed - continue - i = findline(lines, old) - if i < 0: - print('fixapplepython23: Python installation not fixed (appears broken)') - print('fixapplepython23: missing line:', old) - return 2 - lines[i] = new - fixed = True - - if fixed: - if do_apply: - print('fixapplepython23: Fix to Apple-installed Python 2.3 applied') - os.rename(makefile, makefile + '~') - open(makefile, 'w').writelines(lines) - return 0 - else: - print('fixapplepython23: Fix to Apple-installed Python 2.3 should be applied') - return 1 - else: - print('fixapplepython23: No fix needed, appears to have been applied before') - return 0 - -def makescript(filename, compiler): - """Create a wrapper script for a compiler""" - dirname = os.path.split(filename)[0] - if not os.access(dirname, os.X_OK): - os.mkdir(dirname, 0o755) - fp = open(filename, 'w') - fp.write(SCRIPT % compiler) - fp.close() - os.chmod(filename, 0o755) - print('fixapplepython23: Created', filename) - -def main(): - # Check for -n option - if len(sys.argv) > 1 and sys.argv[1] == '-n': - do_apply = False - else: - do_apply = True - # First check OS version - if sys.byteorder == 'little': - # All intel macs are fine - print("fixapplypython23: no fix is needed on MacOSX on Intel") - sys.exit(0) - - osver = platform.mac_ver() - if osver != '10.3' and os.ver < '10.3.': - print('fixapplepython23: no fix needed on MacOSX < 10.3') - sys.exit(0) - - if osver >= '10.4': - print('fixapplepython23: no fix needed on MacOSX >= 10.4') - sys.exit(0) - - # Test that a framework Python is indeed installed - if not os.path.exists(MAKEFILE): - print('fixapplepython23: Python framework does not appear to be installed (?), nothing fixed') - sys.exit(0) - # Check that we can actually write the file - if do_apply and not os.access(MAKEFILE, os.W_OK): - print('fixapplepython23: No write permission, please run with "sudo"') - sys.exit(2) - # Create the shell scripts - if do_apply: - if not os.access(GCC_SCRIPT, os.X_OK): - makescript(GCC_SCRIPT, "gcc") - if not os.access(GXX_SCRIPT, os.X_OK): - makescript(GXX_SCRIPT, "g++") - # Finally fix the makefile - rv = fix(MAKEFILE, do_apply) - #sys.exit(rv) - sys.exit(0) - -if __name__ == '__main__': - main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:19:56 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 29 Jan 2013 09:19:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2314018=3A_merge_to_3=2E3?= Message-ID: <3YwLH050W3zSKn@mail.python.org> http://hg.python.org/cpython/rev/6e6a76166c47 changeset: 81801:6e6a76166c47 branch: 3.3 parent: 81796:d5ee6d13af18 parent: 81800:d54330c8daaa user: Ned Deily date: Tue Jan 29 00:17:19 2013 -0800 summary: Issue #14018: merge to 3.3 files: Mac/BuildScript/build-installer.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -192,7 +192,8 @@ LT_10_5 = bool(DEPTARGET < '10.5') - result.extend([ + if getVersionTuple() >= (3, 3): + result.extend([ dict( name="XZ 5.0.3", url="http://tukaani.org/xz/xz-5.0.3.tar.gz", @@ -201,6 +202,9 @@ '--disable-dependency-tracking', ] ), + ]) + + result.extend([ dict( name="NCurses 5.9", url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:19:58 2013 From: python-checkins at python.org (ned.deily) Date: Tue, 29 Jan 2013 09:19:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2314018=3A_merge_to_default?= Message-ID: <3YwLH20mHzzSLQ@mail.python.org> http://hg.python.org/cpython/rev/888590641c49 changeset: 81802:888590641c49 parent: 81797:8b9910d8d27f parent: 81801:6e6a76166c47 user: Ned Deily date: Tue Jan 29 00:18:52 2013 -0800 summary: Issue #14018: merge to default files: Mac/BuildScript/build-installer.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -192,7 +192,8 @@ LT_10_5 = bool(DEPTARGET < '10.5') - result.extend([ + if getVersionTuple() >= (3, 3): + result.extend([ dict( name="XZ 5.0.3", url="http://tukaani.org/xz/xz-5.0.3.tar.gz", @@ -201,6 +202,9 @@ '--disable-dependency-tracking', ] ), + ]) + + result.extend([ dict( name="NCurses 5.9", url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:09 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:09 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE2OTc5?= =?utf-8?q?=3A_Fix_error_handling_bugs_in_the_unicode-escape-decode_decode?= =?utf-8?q?r=2E?= Message-ID: <3YwM1K1rFmzR7j@mail.python.org> http://hg.python.org/cpython/rev/a242ac99161f changeset: 81803:a242ac99161f branch: 2.7 parent: 81798:6904e229833d user: Serhiy Storchaka date: Tue Jan 29 10:20:34 2013 +0200 summary: Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. files: Lib/test/test_codeccallbacks.py | 4 +- Lib/test/test_codecs.py | 84 +++++++++++++++++++++ Misc/NEWS | 2 + Objects/unicodeobject.c | 79 +++++++------------ 4 files changed, 116 insertions(+), 53 deletions(-) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -262,12 +262,12 @@ self.assertEqual( "\\u3042\u3xxx".decode("unicode-escape", "test.handler1"), - u"\u3042[<92><117><51><120>]xx" + u"\u3042[<92><117><51>]xxx" ) self.assertEqual( "\\u3042\u3xx".decode("unicode-escape", "test.handler1"), - u"\u3042[<92><117><51><120><120>]" + u"\u3042[<92><117><51>]xx" ) self.assertEqual( diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -4,6 +4,11 @@ import locale import sys, StringIO, _testcapi +def coding_checker(self, coder): + def check(input, expect): + self.assertEqual(coder(input), (expect, len(input))) + return check + class Queue(object): """ queue: write bytes at one end, read bytes from the other end @@ -1786,6 +1791,84 @@ self.assertEqual(srw.read(), u"\xfc") +class UnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.unicode_escape_encode(u""), ("", 0)) + self.assertEqual(codecs.unicode_escape_decode(""), (u"", 0)) + + def test_raw_encode(self): + encode = codecs.unicode_escape_encode + for b in range(32, 127): + if b != ord('\\'): + self.assertEqual(encode(unichr(b)), (chr(b), 1)) + + def test_raw_decode(self): + decode = codecs.unicode_escape_decode + for b in range(256): + if b != ord('\\'): + self.assertEqual(decode(chr(b) + '0'), (unichr(b) + u'0', 2)) + + def test_escape_encode(self): + encode = codecs.unicode_escape_encode + check = coding_checker(self, encode) + check(u'\t', r'\t') + check(u'\n', r'\n') + check(u'\r', r'\r') + check(u'\\', r'\\') + for b in range(32): + if chr(b) not in '\t\n\r': + check(unichr(b), '\\x%02x' % b) + for b in range(127, 256): + check(unichr(b), '\\x%02x' % b) + check(u'\u20ac', r'\u20ac') + check(u'\U0001d120', r'\U0001d120') + + def test_escape_decode(self): + decode = codecs.unicode_escape_decode + check = coding_checker(self, decode) + check("[\\\n]", u"[]") + check(r'[\"]', u'["]') + check(r"[\']", u"[']") + check(r"[\\]", ur"[\]") + check(r"[\a]", u"[\x07]") + check(r"[\b]", u"[\x08]") + check(r"[\t]", u"[\x09]") + check(r"[\n]", u"[\x0a]") + check(r"[\v]", u"[\x0b]") + check(r"[\f]", u"[\x0c]") + check(r"[\r]", u"[\x0d]") + check(r"[\7]", u"[\x07]") + check(r"[\8]", ur"[\8]") + check(r"[\78]", u"[\x078]") + check(r"[\41]", u"[!]") + check(r"[\418]", u"[!8]") + check(r"[\101]", u"[A]") + check(r"[\1010]", u"[A0]") + check(r"[\x41]", u"[A]") + check(r"[\x410]", u"[A0]") + check(r"\u20ac", u"\u20ac") + check(r"\U0001d120", u"\U0001d120") + for b in range(256): + if chr(b) not in '\n"\'\\abtnvfr01234567xuUN': + check('\\' + chr(b), u'\\' + unichr(b)) + + def test_decode_errors(self): + decode = codecs.unicode_escape_decode + for c, d in ('x', 2), ('u', 4), ('U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + "\\" + c + "0"*i) + self.assertRaises(UnicodeDecodeError, decode, + "[\\" + c + "0"*i + "]") + data = "[\\" + c + "0"*i + "]\\" + c + "0"*i + self.assertEqual(decode(data, "ignore"), (u"[]", len(data))) + self.assertEqual(decode(data, "replace"), + (u"[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, r"\U00110000") + self.assertEqual(decode(r"\U00110000", "ignore"), (u"", 10)) + self.assertEqual(decode(r"\U00110000", "replace"), (u"\ufffd", 10)) + + class BomTest(unittest.TestCase): def test_seek0(self): data = u"1234567890" @@ -1871,6 +1954,7 @@ BasicStrTest, CharmapTest, WithStmtTest, + UnicodeEscapeTest, BomTest, ) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,8 @@ Library ------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + - Issue #17051: Fix a memory leak in os.path.isdir()?on Windows. Patch by Robert Xiao. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2738,7 +2738,6 @@ Py_ssize_t startinpos; Py_ssize_t endinpos; Py_ssize_t outpos; - int i; PyUnicodeObject *v; Py_UNICODE *p; const char *end; @@ -2824,29 +2823,19 @@ message = "truncated \\UXXXXXXXX escape"; hexescape: chr = 0; - outpos = p-PyUnicode_AS_UNICODE(v); - if (s+digits>end) { - endinpos = size; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "end of string in escape sequence", - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; - goto nextByte; + if (end - s < digits) { + /* count only hex digits */ + for (; s < end; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; + } + goto error; } - for (i = 0; i < digits; ++i) { - c = (unsigned char) s[i]; - if (!isxdigit(c)) { - endinpos = (s+i+1)-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; - goto nextByte; - } + for (; digits--; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; chr = (chr<<4) & ~0xF; if (c >= '0' && c <= '9') chr += c - '0'; @@ -2855,7 +2844,6 @@ else chr += 10 + c - 'A'; } - s += i; if (chr == 0xffffffff && PyErr_Occurred()) /* _decoding_error will have already written into the target buffer. */ @@ -2876,14 +2864,8 @@ *p++ = 0xDC00 + (Py_UNICODE) (chr & 0x03FF); #endif } else { - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "illegal Unicode character", - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; + message = "illegal Unicode character"; + goto error; } break; @@ -2910,28 +2892,13 @@ goto store; } } - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; - break; + goto error; default: if (s > end) { message = "\\ at end of string"; s--; - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; + goto error; } else { *p++ = '\\'; @@ -2939,8 +2906,18 @@ } break; } - nextByte: - ; + continue; + + error: + endinpos = s-starts; + outpos = p-PyUnicode_AS_UNICODE(v); + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", message, + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) + goto onError; + continue; } if (_PyUnicode_Resize(&v, p - PyUnicode_AS_UNICODE(v)) < 0) goto onError; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:10 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE2OTc5?= =?utf-8?q?=3A_Fix_error_handling_bugs_in_the_unicode-escape-decode_decode?= =?utf-8?q?r=2E?= Message-ID: <3YwM1L64D1zSLB@mail.python.org> http://hg.python.org/cpython/rev/084bec5443d6 changeset: 81804:084bec5443d6 branch: 3.2 parent: 81791:d4bdd6ec4594 user: Serhiy Storchaka date: Tue Jan 29 10:20:44 2013 +0200 summary: Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. files: Lib/test/test_codeccallbacks.py | 4 +- Lib/test/test_codecs.py | 85 +++++++++++++++++++++ Misc/NEWS | 2 + Objects/unicodeobject.c | 79 ++++++------------ 4 files changed, 117 insertions(+), 53 deletions(-) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -262,12 +262,12 @@ self.assertEqual( b"\\u3042\u3xxx".decode("unicode-escape", "test.handler1"), - "\u3042[<92><117><51><120>]xx" + "\u3042[<92><117><51>]xxx" ) self.assertEqual( b"\\u3042\u3xx".decode("unicode-escape", "test.handler1"), - "\u3042[<92><117><51><120><120>]" + "\u3042[<92><117><51>]xx" ) self.assertEqual( diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -4,6 +4,11 @@ import locale import sys, _testcapi, io +def coding_checker(self, coder): + def check(input, expect): + self.assertEqual(coder(input), (expect, len(input))) + return check + class Queue(object): """ queue: write bytes at one end, read bytes from the other end @@ -1846,6 +1851,85 @@ self.assertEqual(codecs.raw_unicode_escape_decode(r"\u1234"), ("\u1234", 6)) self.assertEqual(codecs.raw_unicode_escape_decode(br"\u1234"), ("\u1234", 6)) + +class UnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.unicode_escape_encode(""), (b"", 0)) + self.assertEqual(codecs.unicode_escape_decode(b""), ("", 0)) + + def test_raw_encode(self): + encode = codecs.unicode_escape_encode + for b in range(32, 127): + if b != b'\\'[0]: + self.assertEqual(encode(chr(b)), (bytes([b]), 1)) + + def test_raw_decode(self): + decode = codecs.unicode_escape_decode + for b in range(256): + if b != b'\\'[0]: + self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) + + def test_escape_encode(self): + encode = codecs.unicode_escape_encode + check = coding_checker(self, encode) + check('\t', br'\t') + check('\n', br'\n') + check('\r', br'\r') + check('\\', br'\\') + for b in range(32): + if chr(b) not in '\t\n\r': + check(chr(b), ('\\x%02x' % b).encode()) + for b in range(127, 256): + check(chr(b), ('\\x%02x' % b).encode()) + check('\u20ac', br'\u20ac') + check('\U0001d120', br'\U0001d120') + + def test_escape_decode(self): + decode = codecs.unicode_escape_decode + check = coding_checker(self, decode) + check(b"[\\\n]", "[]") + check(br'[\"]', '["]') + check(br"[\']", "[']") + check(br"[\\]", r"[\]") + check(br"[\a]", "[\x07]") + check(br"[\b]", "[\x08]") + check(br"[\t]", "[\x09]") + check(br"[\n]", "[\x0a]") + check(br"[\v]", "[\x0b]") + check(br"[\f]", "[\x0c]") + check(br"[\r]", "[\x0d]") + check(br"[\7]", "[\x07]") + check(br"[\8]", r"[\8]") + check(br"[\78]", "[\x078]") + check(br"[\41]", "[!]") + check(br"[\418]", "[!8]") + check(br"[\101]", "[A]") + check(br"[\1010]", "[A0]") + check(br"[\x41]", "[A]") + check(br"[\x410]", "[A0]") + check(br"\u20ac", "\u20ac") + check(br"\U0001d120", "\U0001d120") + for b in range(256): + if b not in b'\n"\'\\abtnvfr01234567xuUN': + check(b'\\' + bytes([b]), '\\' + chr(b)) + + def test_decode_errors(self): + decode = codecs.unicode_escape_decode + for c, d in (b'x', 2), (b'u', 4), (b'U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + b"\\" + c + b"0"*i) + self.assertRaises(UnicodeDecodeError, decode, + b"[\\" + c + b"0"*i + b"]") + data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i + self.assertEqual(decode(data, "ignore"), ("[]", len(data))) + self.assertEqual(decode(data, "replace"), + ("[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") + self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) + self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) + + class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self): @@ -2011,6 +2095,7 @@ CharmapTest, WithStmtTest, TypesTest, + UnicodeEscapeTest, SurrogateEscapeTest, BomTest, TransformCodecTest, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -214,6 +214,8 @@ Library ------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3760,7 +3760,6 @@ Py_ssize_t startinpos; Py_ssize_t endinpos; Py_ssize_t outpos; - int i; PyUnicodeObject *v; Py_UNICODE *p; const char *end; @@ -3846,29 +3845,19 @@ message = "truncated \\UXXXXXXXX escape"; hexescape: chr = 0; - outpos = p-PyUnicode_AS_UNICODE(v); - if (s+digits>end) { - endinpos = size; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "end of string in escape sequence", - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; - goto nextByte; - } - for (i = 0; i < digits; ++i) { - c = (unsigned char) s[i]; - if (!Py_ISXDIGIT(c)) { - endinpos = (s+i+1)-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; - goto nextByte; + if (end - s < digits) { + /* count only hex digits */ + for (; s < end; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; } + goto error; + } + for (; digits--; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; chr = (chr<<4) & ~0xF; if (c >= '0' && c <= '9') chr += c - '0'; @@ -3877,7 +3866,6 @@ else chr += 10 + c - 'A'; } - s += i; if (chr == 0xffffffff && PyErr_Occurred()) /* _decoding_error will have already written into the target buffer. */ @@ -3898,14 +3886,8 @@ *p++ = 0xDC00 + (Py_UNICODE) (chr & 0x03FF); #endif } else { - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "illegal Unicode character", - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; + message = "illegal Unicode character"; + goto error; } break; @@ -3932,28 +3914,13 @@ goto store; } } - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; - break; + goto error; default: if (s > end) { message = "\\ at end of string"; s--; - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; + goto error; } else { *p++ = '\\'; @@ -3961,8 +3928,18 @@ } break; } - nextByte: - ; + continue; + + error: + endinpos = s-starts; + outpos = p-PyUnicode_AS_UNICODE(v); + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", message, + &starts, &end, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) + goto onError; + continue; } if (_PyUnicode_Resize(&v, p - PyUnicode_AS_UNICODE(v)) < 0) goto onError; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2316979=3A_Fix_error_handling_bugs_in_the_unicode-escap?= =?utf-8?q?e-decode_decoder=2E?= Message-ID: <3YwM1N3LgkzSL5@mail.python.org> http://hg.python.org/cpython/rev/086defaf16fe changeset: 81805:086defaf16fe branch: 3.3 parent: 81796:d5ee6d13af18 parent: 81804:084bec5443d6 user: Serhiy Storchaka date: Tue Jan 29 10:28:07 2013 +0200 summary: Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. files: Lib/test/test_codeccallbacks.py | 4 +- Lib/test/test_codecs.py | 84 +++++++++++++++++++++ Misc/NEWS | 2 + Objects/unicodeobject.c | 84 +++++++------------- 4 files changed, 119 insertions(+), 55 deletions(-) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -271,12 +271,12 @@ self.assertEqual( b"\\u3042\u3xxx".decode("unicode-escape", "test.handler1"), - "\u3042[<92><117><51><120>]xx" + "\u3042[<92><117><51>]xxx" ) self.assertEqual( b"\\u3042\u3xx".decode("unicode-escape", "test.handler1"), - "\u3042[<92><117><51><120><120>]" + "\u3042[<92><117><51>]xx" ) self.assertEqual( diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -21,6 +21,11 @@ else: SIZEOF_WCHAR_T = ctypes.sizeof(ctypes.c_wchar) +def coding_checker(self, coder): + def check(input, expect): + self.assertEqual(coder(input), (expect, len(input))) + return check + class Queue(object): """ queue: write bytes at one end, read bytes from the other end @@ -2009,6 +2014,85 @@ self.assertRaises(UnicodeDecodeError, codecs.raw_unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) + +class UnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.unicode_escape_encode(""), (b"", 0)) + self.assertEqual(codecs.unicode_escape_decode(b""), ("", 0)) + + def test_raw_encode(self): + encode = codecs.unicode_escape_encode + for b in range(32, 127): + if b != b'\\'[0]: + self.assertEqual(encode(chr(b)), (bytes([b]), 1)) + + def test_raw_decode(self): + decode = codecs.unicode_escape_decode + for b in range(256): + if b != b'\\'[0]: + self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) + + def test_escape_encode(self): + encode = codecs.unicode_escape_encode + check = coding_checker(self, encode) + check('\t', br'\t') + check('\n', br'\n') + check('\r', br'\r') + check('\\', br'\\') + for b in range(32): + if chr(b) not in '\t\n\r': + check(chr(b), ('\\x%02x' % b).encode()) + for b in range(127, 256): + check(chr(b), ('\\x%02x' % b).encode()) + check('\u20ac', br'\u20ac') + check('\U0001d120', br'\U0001d120') + + def test_escape_decode(self): + decode = codecs.unicode_escape_decode + check = coding_checker(self, decode) + check(b"[\\\n]", "[]") + check(br'[\"]', '["]') + check(br"[\']", "[']") + check(br"[\\]", r"[\]") + check(br"[\a]", "[\x07]") + check(br"[\b]", "[\x08]") + check(br"[\t]", "[\x09]") + check(br"[\n]", "[\x0a]") + check(br"[\v]", "[\x0b]") + check(br"[\f]", "[\x0c]") + check(br"[\r]", "[\x0d]") + check(br"[\7]", "[\x07]") + check(br"[\8]", r"[\8]") + check(br"[\78]", "[\x078]") + check(br"[\41]", "[!]") + check(br"[\418]", "[!8]") + check(br"[\101]", "[A]") + check(br"[\1010]", "[A0]") + check(br"[\x41]", "[A]") + check(br"[\x410]", "[A0]") + check(br"\u20ac", "\u20ac") + check(br"\U0001d120", "\U0001d120") + for b in range(256): + if b not in b'\n"\'\\abtnvfr01234567xuUN': + check(b'\\' + bytes([b]), '\\' + chr(b)) + + def test_decode_errors(self): + decode = codecs.unicode_escape_decode + for c, d in (b'x', 2), (b'u', 4), (b'U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + b"\\" + c + b"0"*i) + self.assertRaises(UnicodeDecodeError, decode, + b"[\\" + c + b"0"*i + b"]") + data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i + self.assertEqual(decode(data, "ignore"), ("[]", len(data))) + self.assertEqual(decode(data, "replace"), + ("[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") + self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) + self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) + + class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -162,6 +162,8 @@ Library ------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + - Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) now fills the ``os.environ`` variable correctly. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5508,7 +5508,6 @@ const char *starts = s; Py_ssize_t startinpos; Py_ssize_t endinpos; - int j; PyObject *v; const char *end; char* message; @@ -5630,29 +5629,19 @@ message = "truncated \\UXXXXXXXX escape"; hexescape: chr = 0; - if (s+digits>end) { - endinpos = size; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "end of string in escape sequence", - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &i)) - goto onError; - goto nextByte; - } - for (j = 0; j < digits; ++j) { - c = (unsigned char) s[j]; - if (!Py_ISXDIGIT(c)) { - endinpos = (s+j+1)-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &i)) - goto onError; - len = PyUnicode_GET_LENGTH(v); - goto nextByte; - } + if (end - s < digits) { + /* count only hex digits */ + for (; s < end; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; + } + goto error; + } + for (; digits--; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; chr = (chr<<4) & ~0xF; if (c >= '0' && c <= '9') chr += c - '0'; @@ -5661,24 +5650,16 @@ else chr += 10 + c - 'A'; } - s += j; if (chr == 0xffffffff && PyErr_Occurred()) /* _decoding_error will have already written into the target buffer. */ break; store: /* when we get here, chr is a 32-bit unicode character */ - if (chr <= MAX_UNICODE) { - WRITECHAR(chr); - } else { - endinpos = s-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "illegal Unicode character", - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &i)) - goto onError; - } + message = "illegal Unicode character"; + if (chr > MAX_UNICODE) + goto error; + WRITECHAR(chr); break; /* \N{name} */ @@ -5706,26 +5687,13 @@ goto store; } } - endinpos = s-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &i)) - goto onError; - break; + goto error; default: if (s > end) { message = "\\ at end of string"; s--; - endinpos = s-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &v, &i)) - goto onError; + goto error; } else { WRITECHAR('\\'); @@ -5733,8 +5701,18 @@ } break; } - nextByte: - ; + continue; + + error: + endinpos = s-starts; + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", message, + &starts, &end, &startinpos, &endinpos, &exc, &s, + &v, &i)) + goto onError; + len = PyUnicode_GET_LENGTH(v); + continue; } #undef WRITECHAR -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:14 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316979=3A_Fix_error_handling_bugs_in_the_unicode?= =?utf-8?q?-escape-decode_decoder=2E?= Message-ID: <3YwM1Q0SWQzSM5@mail.python.org> http://hg.python.org/cpython/rev/218da678bb8b changeset: 81806:218da678bb8b parent: 81797:8b9910d8d27f parent: 81805:086defaf16fe user: Serhiy Storchaka date: Tue Jan 29 10:37:39 2013 +0200 summary: Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. files: Lib/test/test_codeccallbacks.py | 4 +- Lib/test/test_codecs.py | 84 +++++++++++++++++++++ Misc/NEWS | 2 + Objects/unicodeobject.c | 80 +++++++------------ 4 files changed, 117 insertions(+), 53 deletions(-) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -271,12 +271,12 @@ self.assertEqual( b"\\u3042\u3xxx".decode("unicode-escape", "test.handler1"), - "\u3042[<92><117><51><120>]xx" + "\u3042[<92><117><51>]xxx" ) self.assertEqual( b"\\u3042\u3xx".decode("unicode-escape", "test.handler1"), - "\u3042[<92><117><51><120><120>]" + "\u3042[<92><117><51>]xx" ) self.assertEqual( diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -21,6 +21,11 @@ else: SIZEOF_WCHAR_T = ctypes.sizeof(ctypes.c_wchar) +def coding_checker(self, coder): + def check(input, expect): + self.assertEqual(coder(input), (expect, len(input))) + return check + class Queue(object): """ queue: write bytes at one end, read bytes from the other end @@ -2009,6 +2014,85 @@ self.assertRaises(UnicodeDecodeError, codecs.raw_unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) + +class UnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.unicode_escape_encode(""), (b"", 0)) + self.assertEqual(codecs.unicode_escape_decode(b""), ("", 0)) + + def test_raw_encode(self): + encode = codecs.unicode_escape_encode + for b in range(32, 127): + if b != b'\\'[0]: + self.assertEqual(encode(chr(b)), (bytes([b]), 1)) + + def test_raw_decode(self): + decode = codecs.unicode_escape_decode + for b in range(256): + if b != b'\\'[0]: + self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) + + def test_escape_encode(self): + encode = codecs.unicode_escape_encode + check = coding_checker(self, encode) + check('\t', br'\t') + check('\n', br'\n') + check('\r', br'\r') + check('\\', br'\\') + for b in range(32): + if chr(b) not in '\t\n\r': + check(chr(b), ('\\x%02x' % b).encode()) + for b in range(127, 256): + check(chr(b), ('\\x%02x' % b).encode()) + check('\u20ac', br'\u20ac') + check('\U0001d120', br'\U0001d120') + + def test_escape_decode(self): + decode = codecs.unicode_escape_decode + check = coding_checker(self, decode) + check(b"[\\\n]", "[]") + check(br'[\"]', '["]') + check(br"[\']", "[']") + check(br"[\\]", r"[\]") + check(br"[\a]", "[\x07]") + check(br"[\b]", "[\x08]") + check(br"[\t]", "[\x09]") + check(br"[\n]", "[\x0a]") + check(br"[\v]", "[\x0b]") + check(br"[\f]", "[\x0c]") + check(br"[\r]", "[\x0d]") + check(br"[\7]", "[\x07]") + check(br"[\8]", r"[\8]") + check(br"[\78]", "[\x078]") + check(br"[\41]", "[!]") + check(br"[\418]", "[!8]") + check(br"[\101]", "[A]") + check(br"[\1010]", "[A0]") + check(br"[\x41]", "[A]") + check(br"[\x410]", "[A0]") + check(br"\u20ac", "\u20ac") + check(br"\U0001d120", "\U0001d120") + for b in range(256): + if b not in b'\n"\'\\abtnvfr01234567xuUN': + check(b'\\' + bytes([b]), '\\' + chr(b)) + + def test_decode_errors(self): + decode = codecs.unicode_escape_decode + for c, d in (b'x', 2), (b'u', 4), (b'U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + b"\\" + c + b"0"*i) + self.assertRaises(UnicodeDecodeError, decode, + b"[\\" + c + b"0"*i + b"]") + data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i + self.assertEqual(decode(data, "ignore"), ("[]", len(data))) + self.assertEqual(decode(data, "replace"), + ("[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") + self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) + self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) + + class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -234,6 +234,8 @@ Library ------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + Have py_compile use importlib as much as possible to avoid code duplication. - Issue #180022: Have site.addpackage() consider already known paths even when diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5378,7 +5378,6 @@ const char *starts = s; Py_ssize_t startinpos; Py_ssize_t endinpos; - int j; _PyUnicodeWriter writer; const char *end; char* message; @@ -5500,28 +5499,19 @@ message = "truncated \\UXXXXXXXX escape"; hexescape: chr = 0; - if (s+digits>end) { - endinpos = size; - if (unicode_decode_call_errorhandler_writer( - errors, &errorHandler, - "unicodeescape", "end of string in escape sequence", - &starts, &end, &startinpos, &endinpos, &exc, &s, - &writer)) - goto onError; - goto nextByte; - } - for (j = 0; j < digits; ++j) { - c = (unsigned char) s[j]; - if (!Py_ISXDIGIT(c)) { - endinpos = (s+j+1)-starts; - if (unicode_decode_call_errorhandler_writer( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &writer)) - goto onError; - goto nextByte; + if (end - s < digits) { + /* count only hex digits */ + for (; s < end; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; } + goto error; + } + for (; digits--; ++s) { + c = (unsigned char)*s; + if (!Py_ISXDIGIT(c)) + goto error; chr = (chr<<4) & ~0xF; if (c >= '0' && c <= '9') chr += c - '0'; @@ -5530,24 +5520,16 @@ else chr += 10 + c - 'A'; } - s += j; if (chr == 0xffffffff && PyErr_Occurred()) /* _decoding_error will have already written into the target buffer. */ break; store: /* when we get here, chr is a 32-bit unicode character */ - if (chr <= MAX_UNICODE) { - WRITECHAR(chr); - } else { - endinpos = s-starts; - if (unicode_decode_call_errorhandler_writer( - errors, &errorHandler, - "unicodeescape", "illegal Unicode character", - &starts, &end, &startinpos, &endinpos, &exc, &s, - &writer)) - goto onError; - } + message = "illegal Unicode character"; + if (chr > MAX_UNICODE) + goto error; + WRITECHAR(chr); break; /* \N{name} */ @@ -5575,26 +5557,13 @@ goto store; } } - endinpos = s-starts; - if (unicode_decode_call_errorhandler_writer( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &writer)) - goto onError; - break; + goto error; default: if (s > end) { message = "\\ at end of string"; s--; - endinpos = s-starts; - if (unicode_decode_call_errorhandler_writer( - errors, &errorHandler, - "unicodeescape", message, - &starts, &end, &startinpos, &endinpos, &exc, &s, - &writer)) - goto onError; + goto error; } else { WRITECHAR('\\'); @@ -5602,8 +5571,17 @@ } break; } - nextByte: - ; + continue; + + error: + endinpos = s-starts; + if (unicode_decode_call_errorhandler_writer( + errors, &errorHandler, + "unicodeescape", message, + &starts, &end, &startinpos, &endinpos, &exc, &s, + &writer)) + goto onError; + continue; } #undef WRITECHAR -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:16 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:16 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YwM1S1CLzzSML@mail.python.org> http://hg.python.org/cpython/rev/b87185de0068 changeset: 81807:b87185de0068 branch: 2.7 parent: 81803:a242ac99161f parent: 81799:c2830debb15a user: Serhiy Storchaka date: Tue Jan 29 10:39:19 2013 +0200 summary: Merge heads files: Mac/BuildScript/README.txt | 88 +- Mac/BuildScript/build-installer.py | 504 ++++++--- Mac/BuildScript/ncurses-5.5.patch | 36 - Mac/BuildScript/resources/ReadMe.txt | 30 +- Mac/BuildScript/scripts/postflight.documentation | 9 - Mac/BuildScript/scripts/postflight.framework | 14 +- Mac/Makefile.in | 4 +- 7 files changed, 408 insertions(+), 277 deletions(-) diff --git a/Mac/BuildScript/README.txt b/Mac/BuildScript/README.txt --- a/Mac/BuildScript/README.txt +++ b/Mac/BuildScript/README.txt @@ -8,70 +8,84 @@ an Installer package from the installation plus other files in ``resources`` and ``scripts`` and placed that on a ``.dmg`` disk image. -As of Python 2.7.x and 3.2, PSF practice is to build two installer variants -for each release: +For Python 2.7.x and 3.2.x, PSF practice is to build two installer variants +for each release. 1. 32-bit-only, i386 and PPC universal, capable on running on all machines - supported by Mac OS X 10.3.9 through (at least) 10.6:: + supported by Mac OS X 10.3.9 through (at least) 10.8:: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \ --universal-archs=32-bit \ --dep-target=10.3 - # These are the current default options - builds the following third-party libraries * Bzip2 + * NCurses + * GNU Readline (GPL) + * SQLite 3.7.13 * Zlib 1.2.3 - * GNU Readline (GPL) - * SQLite 3 - * NCurses * Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building - - current target build environment: + - recommended build environment: * Mac OS X 10.5.8 PPC or Intel - * Xcode 3.1.4 (or later) + * Xcode 3.1.4 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors) * ``MACOSX_DEPLOYMENT_TARGET=10.3`` * Apple ``gcc-4.0`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.5 for documentation build with Sphinx - alternate build environments: - * Mac OS X 10.4.11 with Xcode 2.5 - * Mac OS X 10.6.6 with Xcode 3.2.5 + * Mac OS X 10.6.8 with Xcode 3.2.6 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` + * Note Xcode 4.* does not support building for PPC so cannot be used for this build + 2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ --universal-archs=intel \ --dep-target=10.6 + - builds the following third-party libraries + + * NCurses 5.9 (http://bugs.python.org/issue15037) + * SQLite 3.7.13 + - uses system-supplied versions of third-party libraries - + * readline module links with Apple BSD editline (libedit) * builds Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState Tcl/Tk 8.5.9 (or later) to be installed for building - - current target build environment: - - * Mac OS X 10.6.6 (or later) - * Xcode 3.2.5 (or later) + - recommended build environment: + + * Mac OS X 10.6.8 (or later) + * Xcode 3.2.6 * ``MacOSX10.6`` SDK * ``MACOSX_DEPLOYMENT_TARGET=10.6`` * Apple ``gcc-4.2`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.6 for documentation build with Sphinx - alternate build environments: - * none + * none. Xcode 4.x currently supplies two C compilers. + ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and + produce a non-functional Python executable. As it appears to be + considered a migration aid by Apple and is not likely to be fixed, + its use should be avoided. The other compiler, ``clang``, has been + undergoing rapid development. While it appears to have become + production-ready in the most recent Xcode 4 releases (Xcode 4.5.x + as of this writing), there are still some open issues when + building Python and there has not yet been the level of exposure in + production environments that the Xcode 3 gcc-4.2 compiler has had. General Prerequisites @@ -87,6 +101,11 @@ * It is safest to start each variant build with an empty source directory populated with a fresh copy of the untarred source. +* It is recommended that you remove any existing installed version of the + Python being built:: + + sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n + The Recipe ---------- @@ -107,9 +126,9 @@ ................................... It is also possible to build a 4-way universal installer that runs on -OS X Leopard or later:: +OS X 10.5 Leopard or later:: - python 2.6 /build-installer.py \ + /usr/bin/python /build-installer.py \ --dep-target=10.5 --universal-archs=all --sdk-path=/Developer/SDKs/MacOSX10.5.sdk @@ -120,7 +139,8 @@ variants can only be run on G5 machines running 10.5. Note that, while OS X 10.6 is only supported on Intel-based machines, it is possible to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc -emulation in OS X 10.5 and 10.6. +emulation in OS X 10.5 and 10.6. The 4-way installer variant must be +built with Xcode 3. It is not regularly built or tested. Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options @@ -133,15 +153,21 @@ Ideally, the resulting binaries should be installed and the test suite run on all supported OS X releases and architectures. As a practical matter, that is generally not possible. At a minimum, variant 1 should be run on -at least one Intel, one PPC G4, and one PPC G3 system and one each of -OS X 10.6, 10.5, 10.4, and 10.3.9. Not all tests run on 10.3.9. -Variant 2 should be run on 10.6 in both 32-bit and 64-bit modes.:: +a PPC G4 system with OS X 10.5 and at least one Intel system running OS X +10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 +systems in both 32-bit and 64-bit modes.:: - arch -i386 /usr/local/bin/pythonn.n -m test.regrtest -w -u all - arch -X86_64 /usr/local/bin/pythonn.n -m test.regrtest -w -u all + /usr/local/bin/pythonn.n -m test -w -u all,-largefile + /usr/local/bin/pythonn.n-32 -m test -w -u all Certain tests will be skipped and some cause the interpreter to fail which will likely generate ``Python quit unexpectedly`` alert messages -to be generated at several points during a test run. These can -be ignored. +to be generated at several points during a test run. These are normal +during testing and can be ignored. +It is also recommend to launch IDLE and verify that it is at least +functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. +It should also be tested from the command line:: + + /usr/local/bin/idlen.n + diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This script is used to build "official" universal installers on Mac OS X. -It requires at least Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK for +It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for 32-bit builds. 64-bit or four-way universal builds require at least OS X 10.5 and the 10.5 SDK. @@ -10,18 +10,41 @@ which is used to build the documentation, currently requires at least Python 2.4. +In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script +requires an installed version of hg and a third-party version of +Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5 +(for 10.6 or later) installed in /Library/Frameworks. When installed, +the Python built by this script will attempt to dynamically link first to +Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall +back to the ones in /System/Library/Framework. For the build, we recommend +installing the most recent ActiveTcl 8.4 or 8.5 version. + +32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5 +and the installation of additional components, such as a newer Python +(2.5 is needed for Python parser updates), hg, and svn (for the documentation +build). + Usage: see USAGE variable in the script. """ -import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd -import grp +import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp +try: + import urllib2 as urllib_request +except ImportError: + import urllib.request as urllib_request + +STAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) + +STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) INCLUDE_TIMESTAMP = 1 VERBOSE = 1 from plistlib import Plist -import MacOS - try: from plistlib import writePlist except ImportError: @@ -42,20 +65,35 @@ if ln.startswith(variable): value = ln[len(variable):].strip() return value[1:-1] - raise RuntimeError, "Cannot find variable %s" % variable[:-1] + raise RuntimeError("Cannot find variable %s" % variable[:-1]) + +_cache_getVersion = None def getVersion(): - return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + global _cache_getVersion + if _cache_getVersion is None: + _cache_getVersion = grepValue( + os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + return _cache_getVersion def getVersionTuple(): return tuple([int(n) for n in getVersion().split('.')]) +def getVersionMajorMinor(): + return tuple([int(n) for n in getVersion().split('.', 2)]) + +_cache_getFullVersion = None + def getFullVersion(): + global _cache_getFullVersion + if _cache_getFullVersion is not None: + return _cache_getFullVersion fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') for ln in open(fn): if 'PY_VERSION' in ln: - return ln.split()[-1][1:-1] - raise RuntimeError, "Cannot find full version??" + _cache_getFullVersion = ln.split()[-1][1:-1] + return _cache_getFullVersion + raise RuntimeError("Cannot find full version??") # The directory we'll use to create the build (will be erased and recreated) WORKDIR = "/tmp/_py" @@ -111,13 +149,15 @@ DEPTARGET = '10.3' target_cc_map = { - '10.3': 'gcc-4.0', - '10.4': 'gcc-4.0', - '10.5': 'gcc-4.0', - '10.6': 'gcc-4.2', + '10.3': ('gcc-4.0', 'g++-4.0'), + '10.4': ('gcc-4.0', 'g++-4.0'), + '10.5': ('gcc-4.2', 'g++-4.2'), + '10.6': ('gcc-4.2', 'g++-4.2'), + '10.7': ('clang', 'clang++'), + '10.8': ('clang', 'clang++'), } -CC = target_cc_map[DEPTARGET] +CC, CXX = target_cc_map[DEPTARGET] PYTHON_3 = getVersionTuple() >= (3, 0) @@ -135,6 +175,13 @@ --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r) """)% globals() +# Dict of object file names with shared library names to check after building. +# This is to ensure that we ended up dynamically linking with the shared +# library paths and versions we expected. For example: +# EXPECTED_SHARED_LIBS['_tkinter.so'] = [ +# '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl', +# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk'] +EXPECTED_SHARED_LIBS = {} # Instructions for building libraries that are necessary for building a # batteries included python. @@ -143,6 +190,75 @@ def library_recipes(): result = [] + LT_10_5 = bool(DEPTARGET < '10.5') + + if getVersionTuple() >= (3, 3): + result.extend([ + dict( + name="XZ 5.0.3", + url="http://tukaani.org/xz/xz-5.0.3.tar.gz", + checksum='fefe52f9ecd521de2a8ce38c21a27574', + configure_pre=[ + '--disable-dependency-tracking', + ] + ), + ]) + + result.extend([ + dict( + name="NCurses 5.9", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", + checksum='8cb9c412e5f2d96bc6f459aa8c6282a1', + configure_pre=[ + "--enable-widec", + "--without-cxx", + "--without-cxx-binding", + "--without-ada", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--without-debug", + "--without-normal", + "--without-tests", + "--without-manpages", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + ], + patchscripts=[ + ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2", + "f54bf02a349f96a7c4f0d00922f3a0d4"), + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), + dict( + name="SQLite 3.7.13", + url="http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz", + checksum='c97df403e8a3d5b67bb408fcd6aabd8e', + extra_cflags=('-Os ' + '-DSQLITE_ENABLE_FTS4 ' + '-DSQLITE_ENABLE_FTS3_PARENTHESIS ' + '-DSQLITE_ENABLE_RTREE ' + '-DSQLITE_TCL=0 ' + '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]), + configure_pre=[ + '--enable-threadsafe', + '--enable-shared=no', + '--enable-static=yes', + '--disable-readline', + '--disable-dependency-tracking', + ] + ), + ]) + if DEPTARGET < '10.5': result.extend([ dict( @@ -150,8 +266,8 @@ url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz", checksum='00b516f4704d4a7cb50a1d97e6e8e15b', configure=None, - install='make install CC=%s PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -162,8 +278,8 @@ url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz", checksum='debc62758716a169df9f62e6ab2bc634', configure=None, - install='make install CC=%s prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -178,58 +294,12 @@ patches=[ # The readline maintainers don't do actual micro releases, but # just ship a set of patches. - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', + 'c642f2e84d820884b0bf9fd176bc6c3f'), + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + '1a76781a1ea734e831588285db7ec9b1'), ] ), - dict( - name="SQLite 3.7.4", - url="http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz", - checksum='8f0c690bfb33c3cbbc2471c3d9ba0158', - configure_env=('CFLAGS="-Os' - ' -DSQLITE_ENABLE_FTS3' - ' -DSQLITE_ENABLE_FTS3_PARENTHESIS' - ' -DSQLITE_ENABLE_RTREE' - ' -DSQLITE_TCL=0' - '"'), - configure_pre=[ - '--enable-threadsafe', - '--enable-shared=no', - '--enable-static=yes', - '--disable-readline', - '--disable-dependency-tracking', - ] - ), - dict( - name="NCurses 5.5", - url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", - checksum='e73c1ac10b4bfc46db43b2ddfd6244ef', - configure_pre=[ - "--enable-widec", - "--without-cxx", - "--without-ada", - "--without-progs", - "--without-curses-h", - "--enable-shared", - "--with-shared", - "--datadir=/usr/share", - "--sysconfdir=/etc", - "--sharedstatedir=/usr/com", - "--with-terminfo-dirs=/usr/share/terminfo", - "--with-default-terminfo-dir=/usr/share/terminfo", - "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), - "--enable-termcap", - ], - patches=[ - "ncurses-5.5.patch", - ], - useLDFlags=False, - install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( - shellQuote(os.path.join(WORKDIR, 'libraries')), - shellQuote(os.path.join(WORKDIR, 'libraries')), - getVersion(), - ), - ), ]) if not PYTHON_3: @@ -298,9 +368,7 @@ source="/pydocs", readme="""\ This package installs the python documentation at a location - that is useable for pydoc and IDLE. If you have installed Xcode - it will also install a link to the documentation in - /Developer/Documentation/Python + that is useable for pydoc and IDLE. """, postflight="scripts/postflight.documentation", required=False, @@ -326,7 +394,7 @@ ), ] - if DEPTARGET < '10.4': + if DEPTARGET < '10.4' and not PYTHON_3: result.append( dict( name="PythonSystemFixes", @@ -358,7 +426,7 @@ """ Return the contents of the named file """ - return open(fn, 'rb').read() + return open(fn, 'r').read() def runCommand(commandline): """ @@ -370,7 +438,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) if VERBOSE: sys.stdout.write(data); sys.stdout.flush() @@ -381,7 +449,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) return data @@ -423,39 +491,60 @@ # Because we only support dynamic load of only one major/minor version of # Tcl/Tk, ensure: # 1. there are no user-installed frameworks of Tcl/Tk with version - # higher than the Apple-supplied system version - # 2. there is a user-installed framework in /Library/Frameworks with the - # same version as the system version. This allows users to choose - # to install a newer patch level. + # higher than the Apple-supplied system version in + # SDKROOT/System/Library/Frameworks + # 2. there is a user-installed framework (usually ActiveTcl) in (or linked + # in) SDKROOT/Library/Frameworks with the same version as the system + # version. This allows users to choose to install a newer patch level. + frameworks = {} for framework in ['Tcl', 'Tk']: - #fw = dict(lower=framework.lower(), - # upper=framework.upper(), - # cap=framework.capitalize()) - #fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw - fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current' + fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework sysfw = os.path.join(SDKPATH, 'System', fwpth) - libfw = os.path.join('/', fwpth) + libfw = os.path.join(SDKPATH, fwpth) usrfw = os.path.join(os.getenv('HOME'), fwpth) - #version = "%(upper)s_VERSION" % fw + frameworks[framework] = os.readlink(sysfw) + if not os.path.exists(libfw): + fatal("Please install a link to a current %s %s as %s so " + "the user can override the system framework." + % (framework, frameworks[framework], libfw)) if os.readlink(libfw) != os.readlink(sysfw): fatal("Version of %s must match %s" % (libfw, sysfw) ) if os.path.exists(usrfw): fatal("Please rename %s to avoid possible dynamic load issues." % usrfw) + if frameworks['Tcl'] != frameworks['Tk']: + fatal("The Tcl and Tk frameworks are not the same version.") + + # add files to check after build + EXPECTED_SHARED_LIBS['_tkinter.so'] = [ + "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl" + % frameworks['Tcl'], + "/Library/Frameworks/Tk.framework/Versions/%s/Tk" + % frameworks['Tk'], + ] + # Remove inherited environment variables which might influence build environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_', 'LD_', 'LIBRARY_', 'PATH', 'PYTHON'] for ev in list(os.environ): for prefix in environ_var_prefixes: if ev.startswith(prefix) : - print "INFO: deleting environment variable %s=%s" % ( - ev, os.environ[ev]) + print("INFO: deleting environment variable %s=%s" % ( + ev, os.environ[ev])) del os.environ[ev] - os.environ['PATH'] = '/bin:/sbin:/usr/bin:/usr/sbin' - print "Setting default PATH: %s"%(os.environ['PATH']) + base_path = '/bin:/sbin:/usr/bin:/usr/sbin' + if 'SDK_TOOLS_BIN' in os.environ: + base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path + # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin; + # add its fixed location here if it exists + OLD_DEVELOPER_TOOLS = '/Developer/Tools' + if os.path.isdir(OLD_DEVELOPER_TOOLS): + base_path = base_path + ':' + OLD_DEVELOPER_TOOLS + os.environ['PATH'] = base_path + print("Setting default PATH: %s"%(os.environ['PATH'])) def parseOptions(args=None): @@ -463,7 +552,7 @@ Parse arguments and update global settings. """ global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET - global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC + global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX if args is None: args = sys.argv[1:] @@ -472,18 +561,18 @@ options, args = getopt.getopt(args, '?hb', [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=', 'dep-target=', 'universal-archs=', 'help' ]) - except getopt.error, msg: - print msg + except getopt.GetoptError: + print(sys.exc_info()[1]) sys.exit(1) if args: - print "Additional arguments" + print("Additional arguments") sys.exit(1) deptarget = None for k, v in options: if k in ('-h', '-?', '--help'): - print USAGE + print(USAGE) sys.exit(0) elif k in ('-d', '--build-dir'): @@ -511,27 +600,28 @@ # target DEPTARGET = default_target_map.get(v, '10.3') else: - raise NotImplementedError, v + raise NotImplementedError(v) else: - raise NotImplementedError, k + raise NotImplementedError(k) SRCDIR=os.path.abspath(SRCDIR) WORKDIR=os.path.abspath(WORKDIR) SDKPATH=os.path.abspath(SDKPATH) DEPSRC=os.path.abspath(DEPSRC) - CC=target_cc_map[DEPTARGET] + CC, CXX=target_cc_map[DEPTARGET] - print "Settings:" - print " * Source directory:", SRCDIR - print " * Build directory: ", WORKDIR - print " * SDK location: ", SDKPATH - print " * Third-party source:", DEPSRC - print " * Deployment target:", DEPTARGET - print " * Universal architectures:", ARCHLIST - print " * C compiler:", CC - print "" + print("Settings:") + print(" * Source directory:", SRCDIR) + print(" * Build directory: ", WORKDIR) + print(" * SDK location: ", SDKPATH) + print(" * Third-party source:", DEPSRC) + print(" * Deployment target:", DEPTARGET) + print(" * Universal architectures:", ARCHLIST) + print(" * C compiler:", CC) + print(" * C++ compiler:", CXX) + print("") @@ -576,31 +666,18 @@ xit = fp.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "Cannot extract %s"%(archiveName,) + raise RuntimeError("Cannot extract %s"%(archiveName,)) return os.path.join(builddir, retval) finally: os.chdir(curdir) -KNOWNSIZES = { - "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, - "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, -} - def downloadURL(url, fname): """ Download the contents of the url into the file. """ - try: - size = os.path.getsize(fname) - except OSError: - pass - else: - if KNOWNSIZES.get(url) == size: - print "Using existing file for", url - return - fpIn = urllib2.urlopen(url) + fpIn = urllib_request.urlopen(url) fpOut = open(fname, 'wb') block = fpIn.read(10240) try: @@ -615,6 +692,24 @@ except: pass +def verifyThirdPartyFile(url, checksum, fname): + """ + Download file from url to filename fname if it does not already exist. + Abort if file contents does not match supplied md5 checksum. + """ + name = os.path.basename(fname) + if os.path.exists(fname): + print("Using local copy of %s"%(name,)) + else: + print("Did not find local copy of %s"%(name,)) + print("Downloading %s"%(name,)) + downloadURL(url, fname) + print("Archive for %s stored as %s"%(name, fname)) + if os.system( + 'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"' + % (shellQuote(fname), checksum) ): + fatal('MD5 checksum mismatch for file %s' % fname) + def buildRecipe(recipe, basedir, archList): """ Build software using a recipe. This function does the @@ -635,17 +730,8 @@ if not os.path.exists(DEPSRC): os.mkdir(DEPSRC) - - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Did not find local copy of %s"%(name,) - print "Downloading %s"%(name,) - downloadURL(url, sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - print "Extracting archive for %s"%(name,) + verifyThirdPartyFile(url, recipe['checksum'], sourceArchive) + print("Extracting archive for %s"%(name,)) buildDir=os.path.join(WORKDIR, '_bld') if not os.path.exists(buildDir): os.mkdir(buildDir) @@ -655,18 +741,31 @@ if 'buildDir' in recipe: os.chdir(recipe['buildDir']) - - for fn in recipe.get('patches', ()): - if fn.startswith('http://'): - # Download the patch before applying it. - path = os.path.join(DEPSRC, os.path.basename(fn)) - downloadURL(fn, path) - fn = path - - fn = os.path.join(curdir, fn) + for patch in recipe.get('patches', ()): + if isinstance(patch, tuple): + url, checksum = patch + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patch) runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), shellQuote(fn),)) + for patchscript in recipe.get('patchscripts', ()): + if isinstance(patchscript, tuple): + url, checksum = patchscript + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patchscript) + if fn.endswith('.bz2'): + runCommand('bunzip2 -fk %s' % shellQuote(fn)) + fn = fn[:-4] + runCommand('sh %s' % shellQuote(fn)) + os.unlink(fn) + if configure is not None: configure_args = [ "--prefix=/usr/local", @@ -685,40 +784,44 @@ if recipe.get('useLDFlags', 1): configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), - "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( + "LDFLAGS=-mmacosx-version-min=%s -syslibroot,%s -L%s/usr/local/lib -arch %s"%( + DEPTARGET, shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1], ' -arch '.join(archList)), ]) else: configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), ]) if 'configure_post' in recipe: - configure_args = configure_args = list(recipe['configure_post']) + configure_args = configure_args + list(recipe['configure_post']) configure_args.insert(0, configure) configure_args = [ shellQuote(a) for a in configure_args ] - if 'configure_env' in recipe: - configure_args.insert(0, recipe['configure_env']) - - print "Running configure for %s"%(name,) + print("Running configure for %s"%(name,)) runCommand(' '.join(configure_args) + ' 2>&1') - print "Running install for %s"%(name,) + print("Running install for %s"%(name,)) runCommand('{ ' + install + ' ;} 2>&1') - print "Done %s"%(name,) - print "" + print("Done %s"%(name,)) + print("") os.chdir(curdir) @@ -726,9 +829,9 @@ """ Build our dependencies into $WORKDIR/libraries/usr/local """ - print "" - print "Building required libraries" - print "" + print("") + print("Building required libraries") + print("") universal = os.path.join(WORKDIR, 'libraries') os.mkdir(universal) os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) @@ -742,7 +845,7 @@ def buildPythonDocs(): # This stores the documentation as Resources/English.lproj/Documentation # inside the framwork. pydoc and IDLE will pick it up there. - print "Install python documentation" + print("Install python documentation") rootDir = os.path.join(WORKDIR, '_root') buildDir = os.path.join('../../Doc') docdir = os.path.join(rootDir, 'pydocs') @@ -757,7 +860,7 @@ def buildPython(): - print "Building a universal python for %s architectures" % UNIVERSALARCHS + print("Building a universal python for %s architectures" % UNIVERSALARCHS) buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') @@ -785,7 +888,7 @@ # will find them during its extension import sanity checks. os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR, 'libraries', 'usr', 'local', 'lib') - print "Running configure..." + print("Running configure...") runCommand("%s -C --enable-framework --enable-universalsdk=%s " "--with-universal-archs=%s " "%s " @@ -797,19 +900,19 @@ shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) - print "Running make" + print("Running make") runCommand("make") - print "Running make install" + print("Running make install") runCommand("make install DESTDIR=%s"%( shellQuote(rootDir))) - print "Running make frameworkinstallextras" + print("Running make frameworkinstallextras") runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) del os.environ['DYLD_LIBRARY_PATH'] - print "Copying required shared libraries" + print("Copying required shared libraries") if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( @@ -820,16 +923,16 @@ 'Python.framework', 'Versions', getVersion(), 'lib')))) - print "Fix file modes" + print("Fix file modes") frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') gid = grp.getgrnam('admin').gr_gid + shared_lib_error = False for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: - os.chmod(os.path.join(dirpath, dn), 0775) + os.chmod(os.path.join(dirpath, dn), STAT_0o775) os.chown(os.path.join(dirpath, dn), -1, gid) - for fn in filenames: if os.path.islink(fn): continue @@ -840,6 +943,19 @@ os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) os.chown(p, -1, gid) + if fn in EXPECTED_SHARED_LIBS: + # check to see that this file was linked with the + # expected library path and version + data = captureCommand("otool -L %s" % shellQuote(p)) + for sl in EXPECTED_SHARED_LIBS[fn]: + if ("\t%s " % sl) not in data: + print("Expected shared lib %s was not linked with %s" + % (sl, p)) + shared_lib_error = True + + if shared_lib_error: + fatal("Unexpected shared library errors.") + if PYTHON_3: LDVERSION=None VERSION=None @@ -863,19 +979,26 @@ # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on - # the end-users system. - path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', - 'Versions', version, 'lib', 'python%s'%(version,), - 'config' + config_suffix, 'Makefile') - fp = open(path, 'r') - data = fp.read() - fp.close() + # the end-users system. Also remove the directories from _sysconfigdata.py + # (added in 3.3) if it exists. - data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') - data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') - fp = open(path, 'w') - fp.write(data) - fp.close() + path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks', + 'Python.framework', 'Versions', + version, 'lib', 'python%s'%(version,)) + paths = [os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile'), + os.path.join(path_to_lib, '_sysconfigdata.py')] + for path in paths: + if not os.path.exists(path): + continue + fp = open(path, 'r') + data = fp.read() + fp.close() + + data = data.replace(' -L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace(' -I%s/libraries/usr/local/include'%(WORKDIR,), '') + fp = open(path, 'w') + fp.write(data) + fp.close() # Add symlinks in /usr/local/bin, using relative links usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') @@ -907,17 +1030,17 @@ # This one is not handy as a template variable data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework') - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() def patchScript(inPath, outPath): data = fileContents(inPath) data = data.replace('@PYVER@', getVersion()) - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() - os.chmod(outPath, 0755) + os.chmod(outPath, STAT_0o755) @@ -934,7 +1057,7 @@ readme = textwrap.dedent(recipe['readme']) isRequired = recipe.get('required', True) - print "- building package %s"%(pkgname,) + print("- building package %s"%(pkgname,)) # Substitute some variables textvars = dict( @@ -979,7 +1102,7 @@ patchScript(postflight, os.path.join(rsrcDir, 'postflight')) vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,), CFBundleIdentifier='org.python.Python.%s'%(pkgname,), @@ -1016,7 +1139,7 @@ def makeMpkgPlist(path): vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python %s"%(vers,), @@ -1127,7 +1250,7 @@ # Custom icon for the DMG, shown when the DMG is mounted. shutil.copy("../Icons/Disk Image.icns", os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns")) - runCommand("/Developer/Tools/SetFile -a C %s/"%( + runCommand("SetFile -a C %s/"%( shellQuote(os.path.join(WORKDIR, "mnt", volname)),)) runCommand("hdiutil detach %s"%(shellQuote(os.path.join(WORKDIR, "mnt", volname)))) @@ -1168,6 +1291,7 @@ os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET os.environ['CC'] = CC + os.environ['CXX'] = CXX if os.path.exists(WORKDIR): shutil.rmtree(WORKDIR) @@ -1198,7 +1322,7 @@ folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%( getVersion(),)) - os.chmod(folder, 0755) + os.chmod(folder, STAT_0o755) setIcon(folder, "../Icons/Python Folder.icns") # Create the installer @@ -1211,9 +1335,9 @@ shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') - print >> fp, "# BUILD INFO" - print >> fp, "# Date:", time.ctime() - print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos + fp.write("# BUILD INFO\n") + fp.write("# Date: %s\n" % time.ctime()) + fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos) fp.close() # And copy it to a DMG diff --git a/Mac/BuildScript/ncurses-5.5.patch b/Mac/BuildScript/ncurses-5.5.patch deleted file mode 100644 --- a/Mac/BuildScript/ncurses-5.5.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff -r -u ncurses-5.5-orig/test/Makefile.in ncurses-5.5/test/Makefile.in ---- ncurses-5.5-orig/test/Makefile.in 2006-03-24 12:47:40.000000000 +0100 -+++ ncurses-5.5/test/Makefile.in 2006-03-24 12:47:50.000000000 +0100 -@@ -75,7 +75,7 @@ - MATH_LIB = @MATH_LIB@ - - LD = @LD@ --LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS) -+LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) - - usFLAGS = @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@ - -diff -ru ncurses-5.5-orig/ncurses/tinfo/read_entry.c ncurses-5.5/ncurses/tinfo/read_entry.c ---- ncurses-5.5-orig/ncurses/tinfo/read_entry.c 2004-01-11 02:57:05.000000000 +0100 -+++ ncurses-5.5/ncurses/tinfo/read_entry.c 2006-03-25 22:49:39.000000000 +0100 -@@ -474,7 +474,7 @@ - } - - /* truncate the terminal name to prevent buffer overflow */ -- (void) sprintf(ttn, "%c/%.*s", *tn, (int) sizeof(ttn) - 3, tn); -+ (void) sprintf(ttn, "%x/%.*s", *tn, (int) sizeof(ttn) - 3, tn); - - /* This is System V behavior, in conjunction with our requirements for - * writing terminfo entries. -diff -ru ncurses-5.5-orig/configure ncurses-5.5/configure ---- ncurses-5.5-orig/configure 2005-09-24 23:50:50.000000000 +0200 -+++ ncurses-5.5/configure 2006-03-26 22:24:59.000000000 +0200 -@@ -5027,7 +5027,7 @@ - darwin*) - EXTRA_CFLAGS="-no-cpp-precomp" - CC_SHARED_OPTS="-dynamic" -- MK_SHARED_LIB='$(CC) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' -+ MK_SHARED_LIB='$(CC) $(CFLAGS) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' - test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi - cf_cv_shlib_version_infix=yes - ;; diff --git a/Mac/BuildScript/resources/ReadMe.txt b/Mac/BuildScript/resources/ReadMe.txt --- a/Mac/BuildScript/resources/ReadMe.txt +++ b/Mac/BuildScript/resources/ReadMe.txt @@ -5,8 +5,15 @@ Installation requires approximately $INSTALL_SIZE MB of disk space, ignore the message that it will take zero bytes. -You must install onto your current boot disk, even though the -installer does not enforce this, otherwise things will not work. +If you are attempting to install on an OS X 10.8 system, you may +see a message that Python can't be installed because it is from an +unidentified developer. This is because this Python installer +package is not yet compatible with the Gatekeeper security feature +introduced in OS X 10.8. To allow Python to be installed, you +can override the Gatekeeper policy for this install. In the Finder, +instead of double-clicking, control-click or right click the "Python" +installer package icon. Then select "Open using ... Installer" from +the contextual menu that appears. Python consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users including @@ -16,15 +23,16 @@ **** IMPORTANT **** -Before using IDLE or other programs using the tkinter graphical user -interface toolkit, visit http://www.python.org/download/mac/tcltk/ -for current information about supported and recommended versions -of Tcl/Tk for this version of Python and Mac OS X. +To use IDLE or other programs that use the tkinter graphical user +interface toolkit, you may need to install a third-party version of +the Tcl/Tk frameworks. Visit http://www.python.org/download/mac/tcltk/ +for current information about supported and recommended versions of +Tcl/Tk for this version of Python and of Mac OS X. ******************* The installer puts applications, an "Update Shell Profile" command, -and an Extras folder containing demo programs and tools into the +and a link to the optionally installed Python Documentation into the "Python $VERSION" subfolder of the system Applications folder, and puts the underlying machinery into the folder $PYTHONFRAMEWORKINSTALLDIR. It can @@ -32,5 +40,13 @@ well. Double-click on the "Update Shell Profile" command to add the "bin" directory inside the framework to your shell's search path. +You must install onto your current boot disk, even though the +installer does not enforce this, otherwise things will not work. + +You can verify the integrity of the disk image file containing the +installer package and this ReadMe file by comparing its md5 checksum +and size with the values published on the release page linked at +http://www.python.org/download/ + More information on Python in general can be found at http://www.python.org. diff --git a/Mac/BuildScript/scripts/postflight.documentation b/Mac/BuildScript/scripts/postflight.documentation --- a/Mac/BuildScript/scripts/postflight.documentation +++ b/Mac/BuildScript/scripts/postflight.documentation @@ -5,19 +5,10 @@ FWK_DOCDIR_SUBPATH="Resources/English.lproj/Documentation" FWK_DOCDIR="${FWK}/${FWK_DOCDIR_SUBPATH}" APPDIR="/Applications/Python ${PYVER}" -DEV_DOCDIR="/Developer/Documentation" SHARE_DIR="${FWK}/share" SHARE_DOCDIR="${SHARE_DIR}/doc/python${PYVER}" SHARE_DOCDIR_TO_FWK="../../.." -# make link in /Developer/Documentation/ for Xcode users -if [ -d "${DEV_DOCDIR}" ]; then - if [ ! -d "${DEV_DOCDIR}/Python" ]; then - mkdir -p "${DEV_DOCDIR}/Python" - fi - ln -fhs "${FWK_DOCDIR}" "${DEV_DOCDIR}/Python/Reference Documentation ${PYVER}" -fi - # make link in /Applications/Python m.n/ for Finder users if [ -d "${APPDIR}" ]; then ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html" diff --git a/Mac/BuildScript/scripts/postflight.framework b/Mac/BuildScript/scripts/postflight.framework --- a/Mac/BuildScript/scripts/postflight.framework +++ b/Mac/BuildScript/scripts/postflight.framework @@ -8,14 +8,24 @@ "${FWK}/bin/python at PYVER@" -Wi -tt \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" "${FWK}/bin/python at PYVER@" -Wi -tt -O \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" +"${FWK}/bin/python at PYVER@" -Wi \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + +"${FWK}/bin/python at PYVER@" -Wi -O \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + chgrp -R admin "${FWK}" chmod -R g+w "${FWK}" diff --git a/Mac/Makefile.in b/Mac/Makefile.in --- a/Mac/Makefile.in +++ b/Mac/Makefile.in @@ -38,10 +38,10 @@ INSTALL_DATA=@INSTALL_DATA@ LN=@LN@ STRIPFLAG=-s -CPMAC=/Developer/Tools/CpMac +CPMAC=CpMac APPTEMPLATE=$(srcdir)/Resources/app -APPSUBDIRS=MacOS Resources +APPSUBDIRS=MacOS Resources CACHERSRC=$(srcdir)/scripts/cachersrc.py compileall=$(srcdir)/../Lib/compileall.py -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:18 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:18 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMik6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YwM1V1rJ6zSLv@mail.python.org> http://hg.python.org/cpython/rev/dfcf9edecd3b changeset: 81808:dfcf9edecd3b branch: 3.2 parent: 81804:084bec5443d6 parent: 81800:d54330c8daaa user: Serhiy Storchaka date: Tue Jan 29 10:40:04 2013 +0200 summary: Merge heads files: Mac/BuildScript/README.txt | 89 +- Mac/BuildScript/build-installer.py | 504 ++++++--- Mac/BuildScript/ncurses-5.5.patch | 36 - Mac/BuildScript/resources/ReadMe.txt | 28 +- Mac/BuildScript/resources/Welcome.rtf | 8 +- Mac/BuildScript/scripts/postflight.documentation | 9 - Mac/BuildScript/scripts/postflight.framework | 14 +- Mac/Makefile.in | 15 +- Mac/Tools/fixapplepython23.py | 131 -- 9 files changed, 412 insertions(+), 422 deletions(-) diff --git a/Mac/BuildScript/README.txt b/Mac/BuildScript/README.txt --- a/Mac/BuildScript/README.txt +++ b/Mac/BuildScript/README.txt @@ -8,70 +8,83 @@ an Installer package from the installation plus other files in ``resources`` and ``scripts`` and placed that on a ``.dmg`` disk image. -As of Python 2.7.x and 3.2, PSF practice is to build two installer variants -for each release: +For Python 2.7.x and 3.2.x, PSF practice is to build two installer variants +for each release. 1. 32-bit-only, i386 and PPC universal, capable on running on all machines - supported by Mac OS X 10.3.9 through (at least) 10.6:: + supported by Mac OS X 10.3.9 through (at least) 10.8:: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \ --universal-archs=32-bit \ --dep-target=10.3 - # These are the current default options - builds the following third-party libraries * Bzip2 + * NCurses + * GNU Readline (GPL) + * SQLite 3.7.13 * Zlib 1.2.3 - * GNU Readline (GPL) - * SQLite 3 - * NCurses * Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building - - current target build environment: + - recommended build environment: * Mac OS X 10.5.8 PPC or Intel - * Xcode 3.1.4 (or later) + * Xcode 3.1.4 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors) * ``MACOSX_DEPLOYMENT_TARGET=10.3`` * Apple ``gcc-4.0`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.5 for documentation build with Sphinx - alternate build environments: - * Mac OS X 10.4.11 with Xcode 2.5 - * Mac OS X 10.6.6 with Xcode 3.2.5 + * Mac OS X 10.6.8 with Xcode 3.2.6 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` + * Note Xcode 4.* does not support building for PPC so cannot be used for this build + 2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: - python build-installer.py \ + /usr/bin/python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ --universal-archs=intel \ --dep-target=10.6 + - builds the following third-party libraries + + * NCurses 5.9 (http://bugs.python.org/issue15037) + * SQLite 3.7.13 + - uses system-supplied versions of third-party libraries - + * readline module links with Apple BSD editline (libedit) - * builds Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState Tcl/Tk 8.5.9 (or later) to be installed for building - - current target build environment: - - * Mac OS X 10.6.6 (or later) - * Xcode 3.2.5 (or later) + - recommended build environment: + + * Mac OS X 10.6.8 (or later) + * Xcode 3.2.6 * ``MacOSX10.6`` SDK * ``MACOSX_DEPLOYMENT_TARGET=10.6`` * Apple ``gcc-4.2`` - * Python 2.n (n >= 4) for documentation build with Sphinx + * system Python 2.6 for documentation build with Sphinx - alternate build environments: - * none + * none. Xcode 4.x currently supplies two C compilers. + ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and + produce a non-functional Python executable. As it appears to be + considered a migration aid by Apple and is not likely to be fixed, + its use should be avoided. The other compiler, ``clang``, has been + undergoing rapid development. While it appears to have become + production-ready in the most recent Xcode 4 releases (Xcode 4.5.x + as of this writing), there are still some open issues when + building Python and there has not yet been the level of exposure in + production environments that the Xcode 3 gcc-4.2 compiler has had. General Prerequisites @@ -87,6 +100,11 @@ * It is safest to start each variant build with an empty source directory populated with a fresh copy of the untarred source. +* It is recommended that you remove any existing installed version of the + Python being built:: + + sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n + The Recipe ---------- @@ -107,9 +125,9 @@ ................................... It is also possible to build a 4-way universal installer that runs on -OS X Leopard or later:: +OS X 10.5 Leopard or later:: - python 2.6 /build-installer.py \ + /usr/bin/python /build-installer.py \ --dep-target=10.5 --universal-archs=all --sdk-path=/Developer/SDKs/MacOSX10.5.sdk @@ -120,7 +138,8 @@ variants can only be run on G5 machines running 10.5. Note that, while OS X 10.6 is only supported on Intel-based machines, it is possible to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc -emulation in OS X 10.5 and 10.6. +emulation in OS X 10.5 and 10.6. The 4-way installer variant must be +built with Xcode 3. It is not regularly built or tested. Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options @@ -133,15 +152,21 @@ Ideally, the resulting binaries should be installed and the test suite run on all supported OS X releases and architectures. As a practical matter, that is generally not possible. At a minimum, variant 1 should be run on -at least one Intel, one PPC G4, and one PPC G3 system and one each of -OS X 10.6, 10.5, 10.4, and 10.3.9. Not all tests run on 10.3.9. -Variant 2 should be run on 10.6 in both 32-bit and 64-bit modes.:: +a PPC G4 system with OS X 10.5 and at least one Intel system running OS X +10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 +systems in both 32-bit and 64-bit modes.:: - arch -i386 /usr/local/bin/pythonn.n -m test.regrtest -w -u all - arch -X86_64 /usr/local/bin/pythonn.n -m test.regrtest -w -u all + /usr/local/bin/pythonn.n -m test -w -u all,-largefile + /usr/local/bin/pythonn.n-32 -m test -w -u all Certain tests will be skipped and some cause the interpreter to fail which will likely generate ``Python quit unexpectedly`` alert messages -to be generated at several points during a test run. These can -be ignored. +to be generated at several points during a test run. These are normal +during testing and can be ignored. +It is also recommend to launch IDLE and verify that it is at least +functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. +It should also be tested from the command line:: + + /usr/local/bin/idlen.n + diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This script is used to build "official" universal installers on Mac OS X. -It requires at least Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK for +It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for 32-bit builds. 64-bit or four-way universal builds require at least OS X 10.5 and the 10.5 SDK. @@ -10,18 +10,41 @@ which is used to build the documentation, currently requires at least Python 2.4. +In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script +requires an installed version of hg and a third-party version of +Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5 +(for 10.6 or later) installed in /Library/Frameworks. When installed, +the Python built by this script will attempt to dynamically link first to +Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall +back to the ones in /System/Library/Framework. For the build, we recommend +installing the most recent ActiveTcl 8.4 or 8.5 version. + +32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5 +and the installation of additional components, such as a newer Python +(2.5 is needed for Python parser updates), hg, and svn (for the documentation +build). + Usage: see USAGE variable in the script. """ -import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd -import grp +import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp +try: + import urllib2 as urllib_request +except ImportError: + import urllib.request as urllib_request + +STAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) + +STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR + | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP + | stat.S_IROTH | stat.S_IXOTH ) INCLUDE_TIMESTAMP = 1 VERBOSE = 1 from plistlib import Plist -import MacOS - try: from plistlib import writePlist except ImportError: @@ -42,20 +65,35 @@ if ln.startswith(variable): value = ln[len(variable):].strip() return value[1:-1] - raise RuntimeError, "Cannot find variable %s" % variable[:-1] + raise RuntimeError("Cannot find variable %s" % variable[:-1]) + +_cache_getVersion = None def getVersion(): - return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + global _cache_getVersion + if _cache_getVersion is None: + _cache_getVersion = grepValue( + os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') + return _cache_getVersion def getVersionTuple(): return tuple([int(n) for n in getVersion().split('.')]) +def getVersionMajorMinor(): + return tuple([int(n) for n in getVersion().split('.', 2)]) + +_cache_getFullVersion = None + def getFullVersion(): + global _cache_getFullVersion + if _cache_getFullVersion is not None: + return _cache_getFullVersion fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') for ln in open(fn): if 'PY_VERSION' in ln: - return ln.split()[-1][1:-1] - raise RuntimeError, "Cannot find full version??" + _cache_getFullVersion = ln.split()[-1][1:-1] + return _cache_getFullVersion + raise RuntimeError("Cannot find full version??") # The directory we'll use to create the build (will be erased and recreated) WORKDIR = "/tmp/_py" @@ -111,13 +149,15 @@ DEPTARGET = '10.3' target_cc_map = { - '10.3': 'gcc-4.0', - '10.4': 'gcc-4.0', - '10.5': 'gcc-4.0', - '10.6': 'gcc-4.2', + '10.3': ('gcc-4.0', 'g++-4.0'), + '10.4': ('gcc-4.0', 'g++-4.0'), + '10.5': ('gcc-4.2', 'g++-4.2'), + '10.6': ('gcc-4.2', 'g++-4.2'), + '10.7': ('clang', 'clang++'), + '10.8': ('clang', 'clang++'), } -CC = target_cc_map[DEPTARGET] +CC, CXX = target_cc_map[DEPTARGET] PYTHON_3 = getVersionTuple() >= (3, 0) @@ -135,6 +175,13 @@ --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r) """)% globals() +# Dict of object file names with shared library names to check after building. +# This is to ensure that we ended up dynamically linking with the shared +# library paths and versions we expected. For example: +# EXPECTED_SHARED_LIBS['_tkinter.so'] = [ +# '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl', +# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk'] +EXPECTED_SHARED_LIBS = {} # Instructions for building libraries that are necessary for building a # batteries included python. @@ -143,6 +190,75 @@ def library_recipes(): result = [] + LT_10_5 = bool(DEPTARGET < '10.5') + + if getVersionTuple() >= (3, 3): + result.extend([ + dict( + name="XZ 5.0.3", + url="http://tukaani.org/xz/xz-5.0.3.tar.gz", + checksum='fefe52f9ecd521de2a8ce38c21a27574', + configure_pre=[ + '--disable-dependency-tracking', + ] + ), + ]) + + result.extend([ + dict( + name="NCurses 5.9", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", + checksum='8cb9c412e5f2d96bc6f459aa8c6282a1', + configure_pre=[ + "--enable-widec", + "--without-cxx", + "--without-cxx-binding", + "--without-ada", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--without-debug", + "--without-normal", + "--without-tests", + "--without-manpages", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + ], + patchscripts=[ + ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2", + "f54bf02a349f96a7c4f0d00922f3a0d4"), + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), + dict( + name="SQLite 3.7.13", + url="http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz", + checksum='c97df403e8a3d5b67bb408fcd6aabd8e', + extra_cflags=('-Os ' + '-DSQLITE_ENABLE_FTS4 ' + '-DSQLITE_ENABLE_FTS3_PARENTHESIS ' + '-DSQLITE_ENABLE_RTREE ' + '-DSQLITE_TCL=0 ' + '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]), + configure_pre=[ + '--enable-threadsafe', + '--enable-shared=no', + '--enable-static=yes', + '--disable-readline', + '--disable-dependency-tracking', + ] + ), + ]) + if DEPTARGET < '10.5': result.extend([ dict( @@ -150,8 +266,8 @@ url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz", checksum='00b516f4704d4a7cb50a1d97e6e8e15b', configure=None, - install='make install CC=%s PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -162,8 +278,8 @@ url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz", checksum='debc62758716a169df9f62e6ab2bc634', configure=None, - install='make install CC=%s prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, + install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, CXX, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -178,58 +294,12 @@ patches=[ # The readline maintainers don't do actual micro releases, but # just ship a set of patches. - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', - 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', + 'c642f2e84d820884b0bf9fd176bc6c3f'), + ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', + '1a76781a1ea734e831588285db7ec9b1'), ] ), - dict( - name="SQLite 3.7.4", - url="http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz", - checksum='8f0c690bfb33c3cbbc2471c3d9ba0158', - configure_env=('CFLAGS="-Os' - ' -DSQLITE_ENABLE_FTS3' - ' -DSQLITE_ENABLE_FTS3_PARENTHESIS' - ' -DSQLITE_ENABLE_RTREE' - ' -DSQLITE_TCL=0' - '"'), - configure_pre=[ - '--enable-threadsafe', - '--enable-shared=no', - '--enable-static=yes', - '--disable-readline', - '--disable-dependency-tracking', - ] - ), - dict( - name="NCurses 5.5", - url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", - checksum='e73c1ac10b4bfc46db43b2ddfd6244ef', - configure_pre=[ - "--enable-widec", - "--without-cxx", - "--without-ada", - "--without-progs", - "--without-curses-h", - "--enable-shared", - "--with-shared", - "--datadir=/usr/share", - "--sysconfdir=/etc", - "--sharedstatedir=/usr/com", - "--with-terminfo-dirs=/usr/share/terminfo", - "--with-default-terminfo-dir=/usr/share/terminfo", - "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), - "--enable-termcap", - ], - patches=[ - "ncurses-5.5.patch", - ], - useLDFlags=False, - install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( - shellQuote(os.path.join(WORKDIR, 'libraries')), - shellQuote(os.path.join(WORKDIR, 'libraries')), - getVersion(), - ), - ), ]) if not PYTHON_3: @@ -298,9 +368,7 @@ source="/pydocs", readme="""\ This package installs the python documentation at a location - that is useable for pydoc and IDLE. If you have installed Xcode - it will also install a link to the documentation in - /Developer/Documentation/Python + that is useable for pydoc and IDLE. """, postflight="scripts/postflight.documentation", required=False, @@ -326,7 +394,7 @@ ), ] - if DEPTARGET < '10.4': + if DEPTARGET < '10.4' and not PYTHON_3: result.append( dict( name="PythonSystemFixes", @@ -358,7 +426,7 @@ """ Return the contents of the named file """ - return open(fn, 'rb').read() + return open(fn, 'r').read() def runCommand(commandline): """ @@ -370,7 +438,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) if VERBOSE: sys.stdout.write(data); sys.stdout.flush() @@ -381,7 +449,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "command failed: %s"%(commandline,) + raise RuntimeError("command failed: %s"%(commandline,)) return data @@ -423,39 +491,60 @@ # Because we only support dynamic load of only one major/minor version of # Tcl/Tk, ensure: # 1. there are no user-installed frameworks of Tcl/Tk with version - # higher than the Apple-supplied system version - # 2. there is a user-installed framework in /Library/Frameworks with the - # same version as the system version. This allows users to choose - # to install a newer patch level. + # higher than the Apple-supplied system version in + # SDKROOT/System/Library/Frameworks + # 2. there is a user-installed framework (usually ActiveTcl) in (or linked + # in) SDKROOT/Library/Frameworks with the same version as the system + # version. This allows users to choose to install a newer patch level. + frameworks = {} for framework in ['Tcl', 'Tk']: - #fw = dict(lower=framework.lower(), - # upper=framework.upper(), - # cap=framework.capitalize()) - #fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw - fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current' + fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework sysfw = os.path.join(SDKPATH, 'System', fwpth) - libfw = os.path.join('/', fwpth) + libfw = os.path.join(SDKPATH, fwpth) usrfw = os.path.join(os.getenv('HOME'), fwpth) - #version = "%(upper)s_VERSION" % fw + frameworks[framework] = os.readlink(sysfw) + if not os.path.exists(libfw): + fatal("Please install a link to a current %s %s as %s so " + "the user can override the system framework." + % (framework, frameworks[framework], libfw)) if os.readlink(libfw) != os.readlink(sysfw): fatal("Version of %s must match %s" % (libfw, sysfw) ) if os.path.exists(usrfw): fatal("Please rename %s to avoid possible dynamic load issues." % usrfw) + if frameworks['Tcl'] != frameworks['Tk']: + fatal("The Tcl and Tk frameworks are not the same version.") + + # add files to check after build + EXPECTED_SHARED_LIBS['_tkinter.so'] = [ + "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl" + % frameworks['Tcl'], + "/Library/Frameworks/Tk.framework/Versions/%s/Tk" + % frameworks['Tk'], + ] + # Remove inherited environment variables which might influence build environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_', 'LD_', 'LIBRARY_', 'PATH', 'PYTHON'] for ev in list(os.environ): for prefix in environ_var_prefixes: if ev.startswith(prefix) : - print "INFO: deleting environment variable %s=%s" % ( - ev, os.environ[ev]) + print("INFO: deleting environment variable %s=%s" % ( + ev, os.environ[ev])) del os.environ[ev] - os.environ['PATH'] = '/bin:/sbin:/usr/bin:/usr/sbin' - print "Setting default PATH: %s"%(os.environ['PATH']) + base_path = '/bin:/sbin:/usr/bin:/usr/sbin' + if 'SDK_TOOLS_BIN' in os.environ: + base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path + # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin; + # add its fixed location here if it exists + OLD_DEVELOPER_TOOLS = '/Developer/Tools' + if os.path.isdir(OLD_DEVELOPER_TOOLS): + base_path = base_path + ':' + OLD_DEVELOPER_TOOLS + os.environ['PATH'] = base_path + print("Setting default PATH: %s"%(os.environ['PATH'])) def parseOptions(args=None): @@ -463,7 +552,7 @@ Parse arguments and update global settings. """ global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET - global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC + global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX if args is None: args = sys.argv[1:] @@ -472,18 +561,18 @@ options, args = getopt.getopt(args, '?hb', [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=', 'dep-target=', 'universal-archs=', 'help' ]) - except getopt.error, msg: - print msg + except getopt.GetoptError: + print(sys.exc_info()[1]) sys.exit(1) if args: - print "Additional arguments" + print("Additional arguments") sys.exit(1) deptarget = None for k, v in options: if k in ('-h', '-?', '--help'): - print USAGE + print(USAGE) sys.exit(0) elif k in ('-d', '--build-dir'): @@ -511,27 +600,28 @@ # target DEPTARGET = default_target_map.get(v, '10.3') else: - raise NotImplementedError, v + raise NotImplementedError(v) else: - raise NotImplementedError, k + raise NotImplementedError(k) SRCDIR=os.path.abspath(SRCDIR) WORKDIR=os.path.abspath(WORKDIR) SDKPATH=os.path.abspath(SDKPATH) DEPSRC=os.path.abspath(DEPSRC) - CC=target_cc_map[DEPTARGET] + CC, CXX=target_cc_map[DEPTARGET] - print "Settings:" - print " * Source directory:", SRCDIR - print " * Build directory: ", WORKDIR - print " * SDK location: ", SDKPATH - print " * Third-party source:", DEPSRC - print " * Deployment target:", DEPTARGET - print " * Universal architectures:", ARCHLIST - print " * C compiler:", CC - print "" + print("Settings:") + print(" * Source directory:", SRCDIR) + print(" * Build directory: ", WORKDIR) + print(" * SDK location: ", SDKPATH) + print(" * Third-party source:", DEPSRC) + print(" * Deployment target:", DEPTARGET) + print(" * Universal architectures:", ARCHLIST) + print(" * C compiler:", CC) + print(" * C++ compiler:", CXX) + print("") @@ -576,31 +666,18 @@ xit = fp.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError, "Cannot extract %s"%(archiveName,) + raise RuntimeError("Cannot extract %s"%(archiveName,)) return os.path.join(builddir, retval) finally: os.chdir(curdir) -KNOWNSIZES = { - "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, - "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, -} - def downloadURL(url, fname): """ Download the contents of the url into the file. """ - try: - size = os.path.getsize(fname) - except OSError: - pass - else: - if KNOWNSIZES.get(url) == size: - print "Using existing file for", url - return - fpIn = urllib2.urlopen(url) + fpIn = urllib_request.urlopen(url) fpOut = open(fname, 'wb') block = fpIn.read(10240) try: @@ -615,6 +692,24 @@ except: pass +def verifyThirdPartyFile(url, checksum, fname): + """ + Download file from url to filename fname if it does not already exist. + Abort if file contents does not match supplied md5 checksum. + """ + name = os.path.basename(fname) + if os.path.exists(fname): + print("Using local copy of %s"%(name,)) + else: + print("Did not find local copy of %s"%(name,)) + print("Downloading %s"%(name,)) + downloadURL(url, fname) + print("Archive for %s stored as %s"%(name, fname)) + if os.system( + 'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"' + % (shellQuote(fname), checksum) ): + fatal('MD5 checksum mismatch for file %s' % fname) + def buildRecipe(recipe, basedir, archList): """ Build software using a recipe. This function does the @@ -635,17 +730,8 @@ if not os.path.exists(DEPSRC): os.mkdir(DEPSRC) - - if os.path.exists(sourceArchive): - print "Using local copy of %s"%(name,) - - else: - print "Did not find local copy of %s"%(name,) - print "Downloading %s"%(name,) - downloadURL(url, sourceArchive) - print "Archive for %s stored as %s"%(name, sourceArchive) - - print "Extracting archive for %s"%(name,) + verifyThirdPartyFile(url, recipe['checksum'], sourceArchive) + print("Extracting archive for %s"%(name,)) buildDir=os.path.join(WORKDIR, '_bld') if not os.path.exists(buildDir): os.mkdir(buildDir) @@ -655,18 +741,31 @@ if 'buildDir' in recipe: os.chdir(recipe['buildDir']) - - for fn in recipe.get('patches', ()): - if fn.startswith('http://'): - # Download the patch before applying it. - path = os.path.join(DEPSRC, os.path.basename(fn)) - downloadURL(fn, path) - fn = path - - fn = os.path.join(curdir, fn) + for patch in recipe.get('patches', ()): + if isinstance(patch, tuple): + url, checksum = patch + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patch) runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), shellQuote(fn),)) + for patchscript in recipe.get('patchscripts', ()): + if isinstance(patchscript, tuple): + url, checksum = patchscript + fn = os.path.join(DEPSRC, os.path.basename(url)) + verifyThirdPartyFile(url, checksum, fn) + else: + # patch is a file in the source directory + fn = os.path.join(curdir, patchscript) + if fn.endswith('.bz2'): + runCommand('bunzip2 -fk %s' % shellQuote(fn)) + fn = fn[:-4] + runCommand('sh %s' % shellQuote(fn)) + os.unlink(fn) + if configure is not None: configure_args = [ "--prefix=/usr/local", @@ -685,40 +784,44 @@ if recipe.get('useLDFlags', 1): configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), - "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( + "LDFLAGS=-mmacosx-version-min=%s -syslibroot,%s -L%s/usr/local/lib -arch %s"%( + DEPTARGET, shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1], ' -arch '.join(archList)), ]) else: configure_args.extend([ - "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( + "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " + "-I%s/usr/local/include"%( + recipe.get('extra_cflags', ''), + DEPTARGET, ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), ]) if 'configure_post' in recipe: - configure_args = configure_args = list(recipe['configure_post']) + configure_args = configure_args + list(recipe['configure_post']) configure_args.insert(0, configure) configure_args = [ shellQuote(a) for a in configure_args ] - if 'configure_env' in recipe: - configure_args.insert(0, recipe['configure_env']) - - print "Running configure for %s"%(name,) + print("Running configure for %s"%(name,)) runCommand(' '.join(configure_args) + ' 2>&1') - print "Running install for %s"%(name,) + print("Running install for %s"%(name,)) runCommand('{ ' + install + ' ;} 2>&1') - print "Done %s"%(name,) - print "" + print("Done %s"%(name,)) + print("") os.chdir(curdir) @@ -726,9 +829,9 @@ """ Build our dependencies into $WORKDIR/libraries/usr/local """ - print "" - print "Building required libraries" - print "" + print("") + print("Building required libraries") + print("") universal = os.path.join(WORKDIR, 'libraries') os.mkdir(universal) os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) @@ -742,7 +845,7 @@ def buildPythonDocs(): # This stores the documentation as Resources/English.lproj/Documentation # inside the framwork. pydoc and IDLE will pick it up there. - print "Install python documentation" + print("Install python documentation") rootDir = os.path.join(WORKDIR, '_root') buildDir = os.path.join('../../Doc') docdir = os.path.join(rootDir, 'pydocs') @@ -757,7 +860,7 @@ def buildPython(): - print "Building a universal python for %s architectures" % UNIVERSALARCHS + print("Building a universal python for %s architectures" % UNIVERSALARCHS) buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') @@ -785,7 +888,7 @@ # will find them during its extension import sanity checks. os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR, 'libraries', 'usr', 'local', 'lib') - print "Running configure..." + print("Running configure...") runCommand("%s -C --enable-framework --enable-universalsdk=%s " "--with-universal-archs=%s " "%s " @@ -797,19 +900,19 @@ shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) - print "Running make" + print("Running make") runCommand("make") - print "Running make install" + print("Running make install") runCommand("make install DESTDIR=%s"%( shellQuote(rootDir))) - print "Running make frameworkinstallextras" + print("Running make frameworkinstallextras") runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) del os.environ['DYLD_LIBRARY_PATH'] - print "Copying required shared libraries" + print("Copying required shared libraries") if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( @@ -820,16 +923,16 @@ 'Python.framework', 'Versions', getVersion(), 'lib')))) - print "Fix file modes" + print("Fix file modes") frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') gid = grp.getgrnam('admin').gr_gid + shared_lib_error = False for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: - os.chmod(os.path.join(dirpath, dn), 0775) + os.chmod(os.path.join(dirpath, dn), STAT_0o775) os.chown(os.path.join(dirpath, dn), -1, gid) - for fn in filenames: if os.path.islink(fn): continue @@ -840,6 +943,19 @@ os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) os.chown(p, -1, gid) + if fn in EXPECTED_SHARED_LIBS: + # check to see that this file was linked with the + # expected library path and version + data = captureCommand("otool -L %s" % shellQuote(p)) + for sl in EXPECTED_SHARED_LIBS[fn]: + if ("\t%s " % sl) not in data: + print("Expected shared lib %s was not linked with %s" + % (sl, p)) + shared_lib_error = True + + if shared_lib_error: + fatal("Unexpected shared library errors.") + if PYTHON_3: LDVERSION=None VERSION=None @@ -863,19 +979,26 @@ # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on - # the end-users system. - path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', - 'Versions', version, 'lib', 'python%s'%(version,), - 'config' + config_suffix, 'Makefile') - fp = open(path, 'r') - data = fp.read() - fp.close() + # the end-users system. Also remove the directories from _sysconfigdata.py + # (added in 3.3) if it exists. - data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') - data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') - fp = open(path, 'w') - fp.write(data) - fp.close() + path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks', + 'Python.framework', 'Versions', + version, 'lib', 'python%s'%(version,)) + paths = [os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile'), + os.path.join(path_to_lib, '_sysconfigdata.py')] + for path in paths: + if not os.path.exists(path): + continue + fp = open(path, 'r') + data = fp.read() + fp.close() + + data = data.replace(' -L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace(' -I%s/libraries/usr/local/include'%(WORKDIR,), '') + fp = open(path, 'w') + fp.write(data) + fp.close() # Add symlinks in /usr/local/bin, using relative links usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') @@ -907,17 +1030,17 @@ # This one is not handy as a template variable data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework') - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() def patchScript(inPath, outPath): data = fileContents(inPath) data = data.replace('@PYVER@', getVersion()) - fp = open(outPath, 'wb') + fp = open(outPath, 'w') fp.write(data) fp.close() - os.chmod(outPath, 0755) + os.chmod(outPath, STAT_0o755) @@ -934,7 +1057,7 @@ readme = textwrap.dedent(recipe['readme']) isRequired = recipe.get('required', True) - print "- building package %s"%(pkgname,) + print("- building package %s"%(pkgname,)) # Substitute some variables textvars = dict( @@ -979,7 +1102,7 @@ patchScript(postflight, os.path.join(rsrcDir, 'postflight')) vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,), CFBundleIdentifier='org.python.Python.%s'%(pkgname,), @@ -1016,7 +1139,7 @@ def makeMpkgPlist(path): vers = getFullVersion() - major, minor = map(int, getVersion().split('.', 2)) + major, minor = getVersionMajorMinor() pl = Plist( CFBundleGetInfoString="Python %s"%(vers,), @@ -1127,7 +1250,7 @@ # Custom icon for the DMG, shown when the DMG is mounted. shutil.copy("../Icons/Disk Image.icns", os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns")) - runCommand("/Developer/Tools/SetFile -a C %s/"%( + runCommand("SetFile -a C %s/"%( shellQuote(os.path.join(WORKDIR, "mnt", volname)),)) runCommand("hdiutil detach %s"%(shellQuote(os.path.join(WORKDIR, "mnt", volname)))) @@ -1168,6 +1291,7 @@ os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET os.environ['CC'] = CC + os.environ['CXX'] = CXX if os.path.exists(WORKDIR): shutil.rmtree(WORKDIR) @@ -1198,7 +1322,7 @@ folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%( getVersion(),)) - os.chmod(folder, 0755) + os.chmod(folder, STAT_0o755) setIcon(folder, "../Icons/Python Folder.icns") # Create the installer @@ -1211,9 +1335,9 @@ shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') - print >> fp, "# BUILD INFO" - print >> fp, "# Date:", time.ctime() - print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos + fp.write("# BUILD INFO\n") + fp.write("# Date: %s\n" % time.ctime()) + fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos) fp.close() # And copy it to a DMG diff --git a/Mac/BuildScript/ncurses-5.5.patch b/Mac/BuildScript/ncurses-5.5.patch deleted file mode 100644 --- a/Mac/BuildScript/ncurses-5.5.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff -r -u ncurses-5.5-orig/test/Makefile.in ncurses-5.5/test/Makefile.in ---- ncurses-5.5-orig/test/Makefile.in 2006-03-24 12:47:40.000000000 +0100 -+++ ncurses-5.5/test/Makefile.in 2006-03-24 12:47:50.000000000 +0100 -@@ -75,7 +75,7 @@ - MATH_LIB = @MATH_LIB@ - - LD = @LD@ --LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS) -+LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) - - usFLAGS = @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@ - -diff -ru ncurses-5.5-orig/ncurses/tinfo/read_entry.c ncurses-5.5/ncurses/tinfo/read_entry.c ---- ncurses-5.5-orig/ncurses/tinfo/read_entry.c 2004-01-11 02:57:05.000000000 +0100 -+++ ncurses-5.5/ncurses/tinfo/read_entry.c 2006-03-25 22:49:39.000000000 +0100 -@@ -474,7 +474,7 @@ - } - - /* truncate the terminal name to prevent buffer overflow */ -- (void) sprintf(ttn, "%c/%.*s", *tn, (int) sizeof(ttn) - 3, tn); -+ (void) sprintf(ttn, "%x/%.*s", *tn, (int) sizeof(ttn) - 3, tn); - - /* This is System V behavior, in conjunction with our requirements for - * writing terminfo entries. -diff -ru ncurses-5.5-orig/configure ncurses-5.5/configure ---- ncurses-5.5-orig/configure 2005-09-24 23:50:50.000000000 +0200 -+++ ncurses-5.5/configure 2006-03-26 22:24:59.000000000 +0200 -@@ -5027,7 +5027,7 @@ - darwin*) - EXTRA_CFLAGS="-no-cpp-precomp" - CC_SHARED_OPTS="-dynamic" -- MK_SHARED_LIB='$(CC) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' -+ MK_SHARED_LIB='$(CC) $(CFLAGS) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' - test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi - cf_cv_shlib_version_infix=yes - ;; diff --git a/Mac/BuildScript/resources/ReadMe.txt b/Mac/BuildScript/resources/ReadMe.txt --- a/Mac/BuildScript/resources/ReadMe.txt +++ b/Mac/BuildScript/resources/ReadMe.txt @@ -5,8 +5,15 @@ Installation requires approximately $INSTALL_SIZE MB of disk space, ignore the message that it will take zero bytes. -You must install onto your current boot disk, even though the -installer does not enforce this, otherwise things will not work. +If you are attempting to install on an OS X 10.8 system, you may +see a message that Python can't be installed because it is from an +unidentified developer. This is because this Python installer +package is not yet compatible with the Gatekeeper security feature +introduced in OS X 10.8. To allow Python to be installed, you +can override the Gatekeeper policy for this install. In the Finder, +instead of double-clicking, control-click or right click the "Python" +installer package icon. Then select "Open using ... Installer" from +the contextual menu that appears. Python consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users including @@ -16,10 +23,11 @@ **** IMPORTANT **** -Before using IDLE or other programs using the tkinter graphical user -interface toolkit, visit http://www.python.org/download/mac/tcltk/ -for current information about supported and recommended versions -of Tcl/Tk for this version of Python and Mac OS X. +To use IDLE or other programs that use the tkinter graphical user +interface toolkit, you may need to install a third-party version of +the Tcl/Tk frameworks. Visit http://www.python.org/download/mac/tcltk/ +for current information about supported and recommended versions of +Tcl/Tk for this version of Python and of Mac OS X. ******************* @@ -32,5 +40,13 @@ well. Double-click on the "Update Shell Profile" command to add the "bin" directory inside the framework to your shell's search path. +You must install onto your current boot disk, even though the +installer does not enforce this, otherwise things will not work. + +You can verify the integrity of the disk image file containing the +installer package and this ReadMe file by comparing its md5 checksum +and size with the values published on the release page linked at +http://www.python.org/download/ + More information on Python in general can be found at http://www.python.org. diff --git a/Mac/BuildScript/resources/Welcome.rtf b/Mac/BuildScript/resources/Welcome.rtf --- a/Mac/BuildScript/resources/Welcome.rtf +++ b/Mac/BuildScript/resources/Welcome.rtf @@ -1,8 +1,8 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 +{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf470 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} \paperw11904\paperh16836\margl1440\margr1440\vieww9640\viewh10620\viewkind0 -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640 \f0\fs24 \cf0 This package will install \b Python $FULL_VERSION @@ -20,9 +20,9 @@ \ \b NOTE: -\b0 This package will by default not update your shell profile and will also not install files in /usr/local. Double-click +\b0 This package will not update your shell profile by default. Double-click \b Update Shell Profile -\b0 at any time to make $FULL_VERSION the default Python.\ +\b0 at any time to make $FULL_VERSION the default Python 3 version. This version can co-exist with other installed versions of Python 3 and Python 2.\ \ \b IMPORTANT: diff --git a/Mac/BuildScript/scripts/postflight.documentation b/Mac/BuildScript/scripts/postflight.documentation --- a/Mac/BuildScript/scripts/postflight.documentation +++ b/Mac/BuildScript/scripts/postflight.documentation @@ -5,19 +5,10 @@ FWK_DOCDIR_SUBPATH="Resources/English.lproj/Documentation" FWK_DOCDIR="${FWK}/${FWK_DOCDIR_SUBPATH}" APPDIR="/Applications/Python ${PYVER}" -DEV_DOCDIR="/Developer/Documentation" SHARE_DIR="${FWK}/share" SHARE_DOCDIR="${SHARE_DIR}/doc/python${PYVER}" SHARE_DOCDIR_TO_FWK="../../.." -# make link in /Developer/Documentation/ for Xcode users -if [ -d "${DEV_DOCDIR}" ]; then - if [ ! -d "${DEV_DOCDIR}/Python" ]; then - mkdir -p "${DEV_DOCDIR}/Python" - fi - ln -fhs "${FWK_DOCDIR}" "${DEV_DOCDIR}/Python/Reference Documentation ${PYVER}" -fi - # make link in /Applications/Python m.n/ for Finder users if [ -d "${APPDIR}" ]; then ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html" diff --git a/Mac/BuildScript/scripts/postflight.framework b/Mac/BuildScript/scripts/postflight.framework --- a/Mac/BuildScript/scripts/postflight.framework +++ b/Mac/BuildScript/scripts/postflight.framework @@ -8,14 +8,24 @@ "${FWK}/bin/python at PYVER@" -Wi \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" "${FWK}/bin/python at PYVER@" -Wi -O \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -x badsyntax -x site-packages \ + -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ "${FWK}/lib/python${PYVER}" +"${FWK}/bin/python at PYVER@" -Wi \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + +"${FWK}/bin/python at PYVER@" -Wi -O \ + "${FWK}/lib/python${PYVER}/compileall.py" \ + -f -x badsyntax \ + "${FWK}/lib/python${PYVER}/site-packages" + chgrp -R admin "${FWK}" chmod -R g+w "${FWK}" diff --git a/Mac/Makefile.in b/Mac/Makefile.in --- a/Mac/Makefile.in +++ b/Mac/Makefile.in @@ -40,14 +40,13 @@ INSTALL_DATA=@INSTALL_DATA@ LN=@LN@ STRIPFLAG=-s -CPMAC=/Developer/Tools/CpMac +CPMAC=CpMac APPTEMPLATE=$(srcdir)/Resources/app -APPSUBDIRS=MacOS Resources +APPSUBDIRS=MacOS Resources compileall=$(srcdir)/../Lib/compileall.py -installapps: install_Python install_pythonw install_PythonLauncher install_IDLE \ - checkapplepython +installapps: install_Python install_pythonw install_PythonLauncher install_IDLE install_pythonw: pythonw $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)" @@ -196,14 +195,6 @@ "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools" ; \ chmod -R ugo+rX,go-w "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools" - -checkapplepython: $(srcdir)/Tools/fixapplepython23.py - @if ! $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Tools/fixapplepython23.py -n; then \ - echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ - echo "* WARNING: Run $(srcdir)/Tools/fixapplepython23.py with \"sudo\" to fix this."; \ - fi - - clean: rm pythonw cd PythonLauncher && make clean diff --git a/Mac/Tools/fixapplepython23.py b/Mac/Tools/fixapplepython23.py deleted file mode 100644 --- a/Mac/Tools/fixapplepython23.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/python -"""fixapplepython23 - Fix Apple-installed Python 2.3 (on Mac OS X 10.3) - -Python 2.3 (and 2.3.X for X<5) have the problem that building an extension -for a framework installation may accidentally pick up the framework -of a newer Python, in stead of the one that was used to build the extension. - -This script modifies the Makefile (in .../lib/python2.3/config) to use -the newer method of linking extensions with "-undefined dynamic_lookup" -which fixes this problem. - -The script will first check all prerequisites, and return a zero exit -status also when nothing needs to be fixed. -""" -import sys -import os -import platform - -MAKEFILE='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile' -CHANGES=(( - 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', - 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' - ),( - 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', - 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' - ),( - 'CC=\t\tgcc\n', - 'CC=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc\n' - ),( - 'CXX=\t\tc++\n', - 'CXX=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++\n' -)) - -GCC_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc' -GXX_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++' -SCRIPT="""#!/bin/sh -export MACOSX_DEPLOYMENT_TARGET=10.3 -exec %s "${@}" -""" - -def findline(lines, start): - """return line starting with given string or -1""" - for i in range(len(lines)): - if lines[i][:len(start)] == start: - return i - return -1 - -def fix(makefile, do_apply): - """Fix the Makefile, if required.""" - fixed = False - lines = open(makefile).readlines() - - for old, new in CHANGES: - i = findline(lines, new) - if i >= 0: - # Already fixed - continue - i = findline(lines, old) - if i < 0: - print('fixapplepython23: Python installation not fixed (appears broken)') - print('fixapplepython23: missing line:', old) - return 2 - lines[i] = new - fixed = True - - if fixed: - if do_apply: - print('fixapplepython23: Fix to Apple-installed Python 2.3 applied') - os.rename(makefile, makefile + '~') - open(makefile, 'w').writelines(lines) - return 0 - else: - print('fixapplepython23: Fix to Apple-installed Python 2.3 should be applied') - return 1 - else: - print('fixapplepython23: No fix needed, appears to have been applied before') - return 0 - -def makescript(filename, compiler): - """Create a wrapper script for a compiler""" - dirname = os.path.split(filename)[0] - if not os.access(dirname, os.X_OK): - os.mkdir(dirname, 0o755) - fp = open(filename, 'w') - fp.write(SCRIPT % compiler) - fp.close() - os.chmod(filename, 0o755) - print('fixapplepython23: Created', filename) - -def main(): - # Check for -n option - if len(sys.argv) > 1 and sys.argv[1] == '-n': - do_apply = False - else: - do_apply = True - # First check OS version - if sys.byteorder == 'little': - # All intel macs are fine - print("fixapplypython23: no fix is needed on MacOSX on Intel") - sys.exit(0) - - osver = platform.mac_ver() - if osver != '10.3' and os.ver < '10.3.': - print('fixapplepython23: no fix needed on MacOSX < 10.3') - sys.exit(0) - - if osver >= '10.4': - print('fixapplepython23: no fix needed on MacOSX >= 10.4') - sys.exit(0) - - # Test that a framework Python is indeed installed - if not os.path.exists(MAKEFILE): - print('fixapplepython23: Python framework does not appear to be installed (?), nothing fixed') - sys.exit(0) - # Check that we can actually write the file - if do_apply and not os.access(MAKEFILE, os.W_OK): - print('fixapplepython23: No write permission, please run with "sudo"') - sys.exit(2) - # Create the shell scripts - if do_apply: - if not os.access(GCC_SCRIPT, os.X_OK): - makescript(GCC_SCRIPT, "gcc") - if not os.access(GXX_SCRIPT, os.X_OK): - makescript(GXX_SCRIPT, "g++") - # Finally fix the makefile - rv = fix(MAKEFILE, do_apply) - #sys.exit(rv) - sys.exit(0) - -if __name__ == '__main__': - main() -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:19 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:19 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuMyk6?= =?utf-8?q?_Merge_heads?= Message-ID: <3YwM1W4T8KzQ1x@mail.python.org> http://hg.python.org/cpython/rev/949752546619 changeset: 81809:949752546619 branch: 3.3 parent: 81805:086defaf16fe parent: 81801:6e6a76166c47 user: Serhiy Storchaka date: Tue Jan 29 10:40:16 2013 +0200 summary: Merge heads files: Mac/BuildScript/build-installer.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -192,7 +192,8 @@ LT_10_5 = bool(DEPTARGET < '10.5') - result.extend([ + if getVersionTuple() >= (3, 3): + result.extend([ dict( name="XZ 5.0.3", url="http://tukaani.org/xz/xz-5.0.3.tar.gz", @@ -201,6 +202,9 @@ '--disable-dependency-tracking', ] ), + ]) + + result.extend([ dict( name="NCurses 5.9", url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:21 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:21 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge_heads?= Message-ID: <3YwM1Y07LJzR6S@mail.python.org> http://hg.python.org/cpython/rev/d2f502cf12f4 changeset: 81810:d2f502cf12f4 parent: 81806:218da678bb8b parent: 81802:888590641c49 user: Serhiy Storchaka date: Tue Jan 29 10:40:24 2013 +0200 summary: Merge heads files: Mac/BuildScript/build-installer.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -192,7 +192,8 @@ LT_10_5 = bool(DEPTARGET < '10.5') - result.extend([ + if getVersionTuple() >= (3, 3): + result.extend([ dict( name="XZ 5.0.3", url="http://tukaani.org/xz/xz-5.0.3.tar.gz", @@ -201,6 +202,9 @@ '--disable-dependency-tracking', ] ), + ]) + + result.extend([ dict( name="NCurses 5.9", url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:22 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Null_merge?= Message-ID: <3YwM1Z3NhpzR6S@mail.python.org> http://hg.python.org/cpython/rev/e95c9a9d58f9 changeset: 81811:e95c9a9d58f9 branch: 3.3 parent: 81809:949752546619 parent: 81808:dfcf9edecd3b user: Serhiy Storchaka date: Tue Jan 29 10:44:59 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 09:53:23 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 09:53:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <3YwM1b65sDzSLv@mail.python.org> http://hg.python.org/cpython/rev/22f8e2919943 changeset: 81812:22f8e2919943 parent: 81810:d2f502cf12f4 parent: 81811:e95c9a9d58f9 user: Serhiy Storchaka date: Tue Jan 29 10:45:55 2013 +0200 summary: Null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:10:20 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:10:20 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Clean_up_escap?= =?utf-8?q?e-decode_decoder_tests=2E?= Message-ID: <3YwMP85tcLzR85@mail.python.org> http://hg.python.org/cpython/rev/678113020ae8 changeset: 81813:678113020ae8 branch: 2.7 parent: 81807:b87185de0068 user: Serhiy Storchaka date: Tue Jan 29 11:06:28 2013 +0200 summary: Clean up escape-decode decoder tests. files: Lib/test/test_codecs.py | 76 +++++++++++++++------------- 1 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -736,48 +736,52 @@ self.assertEqual(codecs.escape_decode(""), ("", 0)) def test_raw(self): - for b in ''.join(map(chr, range(256))): + decode = codecs.escape_decode + for b in range(256): + b = chr(b) if b != '\\': - self.assertEqual(codecs.escape_decode(b + '0'), - (b + '0', 2)) + self.assertEqual(decode(b + '0'), (b + '0', 2)) def test_escape(self): - self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) - self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) - self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) - self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) - self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) - self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) - self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) - self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) - self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) - self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) - self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) - self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) - self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) - self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) - self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) - self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) - for b in ''.join(map(chr, range(256))): + decode = codecs.escape_decode + check = coding_checker(self, decode) + check(b"[\\\n]", b"[]") + check(br'[\"]', b'["]') + check(br"[\']", b"[']") + check(br"[\\]", br"[\]") + check(br"[\a]", b"[\x07]") + check(br"[\b]", b"[\x08]") + check(br"[\t]", b"[\x09]") + check(br"[\n]", b"[\x0a]") + check(br"[\v]", b"[\x0b]") + check(br"[\f]", b"[\x0c]") + check(br"[\r]", b"[\x0d]") + check(br"[\7]", b"[\x07]") + check(br"[\8]", br"[\8]") + check(br"[\78]", b"[\x078]") + check(br"[\41]", b"[!]") + check(br"[\418]", b"[!8]") + check(br"[\101]", b"[A]") + check(br"[\1010]", b"[A0]") + check(br"[\501]", b"[A]") + check(br"[\x41]", b"[A]") + check(br"[\X41]", br"[\X41]") + check(br"[\x410]", b"[A0]") + for b in range(256): + b = chr(b) if b not in '\n"\'\\abtnvfr01234567x': - self.assertEqual(codecs.escape_decode('\\' + b), - ('\\' + b, 2)) + check('\\' + b, '\\' + b) def test_errors(self): - self.assertRaises(ValueError, codecs.escape_decode, br"\x") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") - self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) - self.assertRaises(ValueError, codecs.escape_decode, br"\x0") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + decode = codecs.escape_decode + self.assertRaises(ValueError, decode, br"\x") + self.assertRaises(ValueError, decode, br"[\x]") + self.assertEqual(decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, decode, br"\x0") + self.assertRaises(ValueError, decode, br"[\x0]") + self.assertEqual(decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) class RecodingTest(unittest.TestCase): def test_recoding(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:10:22 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:10:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Clean_up_escap?= =?utf-8?q?e-decode_decoder_tests=2E?= Message-ID: <3YwMPB3F5CzSKw@mail.python.org> http://hg.python.org/cpython/rev/946df0c26370 changeset: 81814:946df0c26370 branch: 3.2 parent: 81808:dfcf9edecd3b user: Serhiy Storchaka date: Tue Jan 29 11:06:53 2013 +0200 summary: Clean up escape-decode decoder tests. files: Lib/test/test_codecs.py | 76 +++++++++++++++------------- 1 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -808,51 +808,55 @@ class EscapeDecodeTest(unittest.TestCase): def test_empty(self): - self.assertEqual(codecs.escape_decode(""), (b"", 0)) + self.assertEqual(codecs.escape_decode(b""), (b"", 0)) def test_raw(self): + decode = codecs.escape_decode for b in range(256): - if b != b'\\'[0]: - self.assertEqual(codecs.escape_decode(bytes([b]) + b'0'), - (bytes([b]) + b'0', 2)) + b = bytes([b]) + if b != b'\\': + self.assertEqual(decode(b + b'0'), (b + b'0', 2)) def test_escape(self): - self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) - self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) - self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) - self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) - self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) - self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) - self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) - self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) - self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) - self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) - self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) - self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) - self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) - self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) - self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) - self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) + decode = codecs.escape_decode + check = coding_checker(self, decode) + check(b"[\\\n]", b"[]") + check(br'[\"]', b'["]') + check(br"[\']", b"[']") + check(br"[\\]", br"[\]") + check(br"[\a]", b"[\x07]") + check(br"[\b]", b"[\x08]") + check(br"[\t]", b"[\x09]") + check(br"[\n]", b"[\x0a]") + check(br"[\v]", b"[\x0b]") + check(br"[\f]", b"[\x0c]") + check(br"[\r]", b"[\x0d]") + check(br"[\7]", b"[\x07]") + check(br"[\8]", br"[\8]") + check(br"[\78]", b"[\x078]") + check(br"[\41]", b"[!]") + check(br"[\418]", b"[!8]") + check(br"[\101]", b"[A]") + check(br"[\1010]", b"[A0]") + check(br"[\501]", b"[A]") + check(br"[\x41]", b"[A]") + check(br"[\X41]", br"[\X41]") + check(br"[\x410]", b"[A0]") for b in range(256): if b not in b'\n"\'\\abtnvfr01234567x': - self.assertEqual(codecs.escape_decode(b'\\' + bytes([b])), - (b'\\' + bytes([b]), 2)) + b = bytes([b]) + check(b'\\' + b, b'\\' + b) def test_errors(self): - self.assertRaises(ValueError, codecs.escape_decode, br"\x") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") - self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) - self.assertRaises(ValueError, codecs.escape_decode, br"\x0") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + decode = codecs.escape_decode + self.assertRaises(ValueError, decode, br"\x") + self.assertRaises(ValueError, decode, br"[\x]") + self.assertEqual(decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, decode, br"\x0") + self.assertRaises(ValueError, decode, br"[\x0]") + self.assertEqual(decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) class RecodingTest(unittest.TestCase): def test_recoding(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:10:23 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:10:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Clean_up_escape-decode_decoder_tests=2E?= Message-ID: <3YwMPC6zWrzSJP@mail.python.org> http://hg.python.org/cpython/rev/fbacf8375c76 changeset: 81815:fbacf8375c76 branch: 3.3 parent: 81811:e95c9a9d58f9 parent: 81814:946df0c26370 user: Serhiy Storchaka date: Tue Jan 29 11:07:27 2013 +0200 summary: Clean up escape-decode decoder tests. files: Lib/test/test_codecs.py | 76 +++++++++++++++------------- 1 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -930,51 +930,55 @@ class EscapeDecodeTest(unittest.TestCase): def test_empty(self): - self.assertEqual(codecs.escape_decode(""), (b"", 0)) + self.assertEqual(codecs.escape_decode(b""), (b"", 0)) def test_raw(self): + decode = codecs.escape_decode for b in range(256): - if b != b'\\'[0]: - self.assertEqual(codecs.escape_decode(bytes([b]) + b'0'), - (bytes([b]) + b'0', 2)) + b = bytes([b]) + if b != b'\\': + self.assertEqual(decode(b + b'0'), (b + b'0', 2)) def test_escape(self): - self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) - self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) - self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) - self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) - self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) - self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) - self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) - self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) - self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) - self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) - self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) - self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) - self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) - self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) - self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) - self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) + decode = codecs.escape_decode + check = coding_checker(self, decode) + check(b"[\\\n]", b"[]") + check(br'[\"]', b'["]') + check(br"[\']", b"[']") + check(br"[\\]", br"[\]") + check(br"[\a]", b"[\x07]") + check(br"[\b]", b"[\x08]") + check(br"[\t]", b"[\x09]") + check(br"[\n]", b"[\x0a]") + check(br"[\v]", b"[\x0b]") + check(br"[\f]", b"[\x0c]") + check(br"[\r]", b"[\x0d]") + check(br"[\7]", b"[\x07]") + check(br"[\8]", br"[\8]") + check(br"[\78]", b"[\x078]") + check(br"[\41]", b"[!]") + check(br"[\418]", b"[!8]") + check(br"[\101]", b"[A]") + check(br"[\1010]", b"[A0]") + check(br"[\501]", b"[A]") + check(br"[\x41]", b"[A]") + check(br"[\X41]", br"[\X41]") + check(br"[\x410]", b"[A0]") for b in range(256): if b not in b'\n"\'\\abtnvfr01234567x': - self.assertEqual(codecs.escape_decode(b'\\' + bytes([b])), - (b'\\' + bytes([b]), 2)) + b = bytes([b]) + check(b'\\' + b, b'\\' + b) def test_errors(self): - self.assertRaises(ValueError, codecs.escape_decode, br"\x") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") - self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) - self.assertRaises(ValueError, codecs.escape_decode, br"\x0") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + decode = codecs.escape_decode + self.assertRaises(ValueError, decode, br"\x") + self.assertRaises(ValueError, decode, br"[\x]") + self.assertEqual(decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, decode, br"\x0") + self.assertRaises(ValueError, decode, br"[\x0]") + self.assertEqual(decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) class RecodingTest(unittest.TestCase): def test_recoding(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:10:25 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:10:25 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Clean_up_escape-decode_decoder_tests=2E?= Message-ID: <3YwMPF42vPzSMF@mail.python.org> http://hg.python.org/cpython/rev/1eefab2e05f1 changeset: 81816:1eefab2e05f1 parent: 81812:22f8e2919943 parent: 81815:fbacf8375c76 user: Serhiy Storchaka date: Tue Jan 29 11:08:06 2013 +0200 summary: Clean up escape-decode decoder tests. files: Lib/test/test_codecs.py | 76 +++++++++++++++------------- 1 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -930,51 +930,55 @@ class EscapeDecodeTest(unittest.TestCase): def test_empty(self): - self.assertEqual(codecs.escape_decode(""), (b"", 0)) + self.assertEqual(codecs.escape_decode(b""), (b"", 0)) def test_raw(self): + decode = codecs.escape_decode for b in range(256): - if b != b'\\'[0]: - self.assertEqual(codecs.escape_decode(bytes([b]) + b'0'), - (bytes([b]) + b'0', 2)) + b = bytes([b]) + if b != b'\\': + self.assertEqual(decode(b + b'0'), (b + b'0', 2)) def test_escape(self): - self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4)) - self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4)) - self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4)) - self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4)) - self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4)) - self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4)) - self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4)) - self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4)) - self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4)) - self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4)) - self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4)) - self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4)) - self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5)) - self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5)) - self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6)) - self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7)) - self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6)) - self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7)) + decode = codecs.escape_decode + check = coding_checker(self, decode) + check(b"[\\\n]", b"[]") + check(br'[\"]', b'["]') + check(br"[\']", b"[']") + check(br"[\\]", br"[\]") + check(br"[\a]", b"[\x07]") + check(br"[\b]", b"[\x08]") + check(br"[\t]", b"[\x09]") + check(br"[\n]", b"[\x0a]") + check(br"[\v]", b"[\x0b]") + check(br"[\f]", b"[\x0c]") + check(br"[\r]", b"[\x0d]") + check(br"[\7]", b"[\x07]") + check(br"[\8]", br"[\8]") + check(br"[\78]", b"[\x078]") + check(br"[\41]", b"[!]") + check(br"[\418]", b"[!8]") + check(br"[\101]", b"[A]") + check(br"[\1010]", b"[A0]") + check(br"[\501]", b"[A]") + check(br"[\x41]", b"[A]") + check(br"[\X41]", br"[\X41]") + check(br"[\x410]", b"[A0]") for b in range(256): if b not in b'\n"\'\\abtnvfr01234567x': - self.assertEqual(codecs.escape_decode(b'\\' + bytes([b])), - (b'\\' + bytes([b]), 2)) + b = bytes([b]) + check(b'\\' + b, b'\\' + b) def test_errors(self): - self.assertRaises(ValueError, codecs.escape_decode, br"\x") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x]") - self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6)) - self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6)) - self.assertRaises(ValueError, codecs.escape_decode, br"\x0") - self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]") - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) - self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) + decode = codecs.escape_decode + self.assertRaises(ValueError, decode, br"\x") + self.assertRaises(ValueError, decode, br"[\x]") + self.assertEqual(decode(br"[\x]\x", "ignore"), (b"[]", 6)) + self.assertEqual(decode(br"[\x]\x", "replace"), (b"[?]?", 6)) + self.assertRaises(ValueError, decode, br"\x0") + self.assertRaises(ValueError, decode, br"[\x0]") + self.assertEqual(decode(br"[\x0]\x0", "ignore"), (b"[]", 8)) + self.assertEqual(decode(br"[\x0]\x0", "replace"), (b"[?]?", 8)) class RecodingTest(unittest.TestCase): def test_recoding(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:43:45 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:43:45 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Add_tests_for_?= =?utf-8?q?raw-unicode-escape_codec=2E?= Message-ID: <3YwN7j3NyrzRHx@mail.python.org> http://hg.python.org/cpython/rev/1d21f6be1b58 changeset: 81817:1d21f6be1b58 branch: 2.7 parent: 81813:678113020ae8 user: Serhiy Storchaka date: Tue Jan 29 11:39:44 2013 +0200 summary: Add tests for raw-unicode-escape codec. files: Lib/test/test_codecs.py | 51 +++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1873,6 +1873,56 @@ self.assertEqual(decode(r"\U00110000", "replace"), (u"\ufffd", 10)) +class RawUnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.raw_unicode_escape_encode(u""), ("", 0)) + self.assertEqual(codecs.raw_unicode_escape_decode(""), (u"", 0)) + + def test_raw_encode(self): + encode = codecs.raw_unicode_escape_encode + for b in range(256): + self.assertEqual(encode(unichr(b)), (chr(b), 1)) + + def test_raw_decode(self): + decode = codecs.raw_unicode_escape_decode + for b in range(256): + self.assertEqual(decode(chr(b) + '0'), (unichr(b) + u'0', 2)) + + def test_escape_encode(self): + encode = codecs.raw_unicode_escape_encode + check = coding_checker(self, encode) + for b in range(256): + if chr(b) not in 'uU': + check(u'\\' + unichr(b), '\\' + chr(b)) + check(u'\u20ac', r'\u20ac') + check(u'\U0001d120', r'\U0001d120') + + def test_escape_decode(self): + decode = codecs.raw_unicode_escape_decode + check = coding_checker(self, decode) + for b in range(256): + if chr(b) not in 'uU': + check('\\' + chr(b), u'\\' + unichr(b)) + check(r"\u20ac", u"\u20ac") + check(r"\U0001d120", u"\U0001d120") + + def test_decode_errors(self): + decode = codecs.raw_unicode_escape_decode + for c, d in ('u', 4), ('U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + "\\" + c + "0"*i) + self.assertRaises(UnicodeDecodeError, decode, + "[\\" + c + "0"*i + "]") + data = "[\\" + c + "0"*i + "]\\" + c + "0"*i + self.assertEqual(decode(data, "ignore"), (u"[]", len(data))) + self.assertEqual(decode(data, "replace"), + (u"[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, r"\U00110000") + self.assertEqual(decode(r"\U00110000", "ignore"), (u"", 10)) + self.assertEqual(decode(r"\U00110000", "replace"), (u"\ufffd", 10)) + + class BomTest(unittest.TestCase): def test_seek0(self): data = u"1234567890" @@ -1959,6 +2009,7 @@ CharmapTest, WithStmtTest, UnicodeEscapeTest, + RawUnicodeEscapeTest, BomTest, ) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:43:46 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:43:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Add_tests_for_?= =?utf-8?q?raw-unicode-escape_codec=2E?= Message-ID: <3YwN7k6WmZzRMx@mail.python.org> http://hg.python.org/cpython/rev/eb4ef5c2875d changeset: 81818:eb4ef5c2875d branch: 3.2 parent: 81814:946df0c26370 user: Serhiy Storchaka date: Tue Jan 29 11:40:00 2013 +0200 summary: Add tests for raw-unicode-escape codec. files: Lib/test/test_codecs.py | 51 +++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1934,6 +1934,56 @@ self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) +class RawUnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.raw_unicode_escape_encode(""), (b"", 0)) + self.assertEqual(codecs.raw_unicode_escape_decode(b""), ("", 0)) + + def test_raw_encode(self): + encode = codecs.raw_unicode_escape_encode + for b in range(256): + self.assertEqual(encode(chr(b)), (bytes([b]), 1)) + + def test_raw_decode(self): + decode = codecs.raw_unicode_escape_decode + for b in range(256): + self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) + + def test_escape_encode(self): + encode = codecs.raw_unicode_escape_encode + check = coding_checker(self, encode) + for b in range(256): + if b not in b'uU': + check('\\' + chr(b), b'\\' + bytes([b])) + check('\u20ac', br'\u20ac') + check('\U0001d120', br'\U0001d120') + + def test_escape_decode(self): + decode = codecs.raw_unicode_escape_decode + check = coding_checker(self, decode) + for b in range(256): + if b not in b'uU': + check(b'\\' + bytes([b]), '\\' + chr(b)) + check(br"\u20ac", "\u20ac") + check(br"\U0001d120", "\U0001d120") + + def test_decode_errors(self): + decode = codecs.raw_unicode_escape_decode + for c, d in (b'u', 4), (b'U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + b"\\" + c + b"0"*i) + self.assertRaises(UnicodeDecodeError, decode, + b"[\\" + c + b"0"*i + b"]") + data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i + self.assertEqual(decode(data, "ignore"), ("[]", len(data))) + self.assertEqual(decode(data, "replace"), + ("[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") + self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) + self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) + + class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self): @@ -2100,6 +2150,7 @@ WithStmtTest, TypesTest, UnicodeEscapeTest, + RawUnicodeEscapeTest, SurrogateEscapeTest, BomTest, TransformCodecTest, -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:43:48 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:43:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Add_tests_for_raw-unicode-escape_codec=2E?= Message-ID: <3YwN7m2R5nzSHD@mail.python.org> http://hg.python.org/cpython/rev/0f5fc998d278 changeset: 81819:0f5fc998d278 branch: 3.3 parent: 81815:fbacf8375c76 parent: 81818:eb4ef5c2875d user: Serhiy Storchaka date: Tue Jan 29 11:41:01 2013 +0200 summary: Add tests for raw-unicode-escape codec. files: Lib/test/test_codecs.py | 50 +++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -2097,6 +2097,56 @@ self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) +class RawUnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.raw_unicode_escape_encode(""), (b"", 0)) + self.assertEqual(codecs.raw_unicode_escape_decode(b""), ("", 0)) + + def test_raw_encode(self): + encode = codecs.raw_unicode_escape_encode + for b in range(256): + self.assertEqual(encode(chr(b)), (bytes([b]), 1)) + + def test_raw_decode(self): + decode = codecs.raw_unicode_escape_decode + for b in range(256): + self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) + + def test_escape_encode(self): + encode = codecs.raw_unicode_escape_encode + check = coding_checker(self, encode) + for b in range(256): + if b not in b'uU': + check('\\' + chr(b), b'\\' + bytes([b])) + check('\u20ac', br'\u20ac') + check('\U0001d120', br'\U0001d120') + + def test_escape_decode(self): + decode = codecs.raw_unicode_escape_decode + check = coding_checker(self, decode) + for b in range(256): + if b not in b'uU': + check(b'\\' + bytes([b]), '\\' + chr(b)) + check(br"\u20ac", "\u20ac") + check(br"\U0001d120", "\U0001d120") + + def test_decode_errors(self): + decode = codecs.raw_unicode_escape_decode + for c, d in (b'u', 4), (b'U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + b"\\" + c + b"0"*i) + self.assertRaises(UnicodeDecodeError, decode, + b"[\\" + c + b"0"*i + b"]") + data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i + self.assertEqual(decode(data, "ignore"), ("[]", len(data))) + self.assertEqual(decode(data, "replace"), + ("[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") + self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) + self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) + + class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 10:43:49 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 10:43:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Add_tests_for_raw-unicode-escape_codec=2E?= Message-ID: <3YwN7n5CfqzSHD@mail.python.org> http://hg.python.org/cpython/rev/14004b6ed1f2 changeset: 81820:14004b6ed1f2 parent: 81816:1eefab2e05f1 parent: 81819:0f5fc998d278 user: Serhiy Storchaka date: Tue Jan 29 11:41:34 2013 +0200 summary: Add tests for raw-unicode-escape codec. files: Lib/test/test_codecs.py | 50 +++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -2097,6 +2097,56 @@ self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) +class RawUnicodeEscapeTest(unittest.TestCase): + def test_empty(self): + self.assertEqual(codecs.raw_unicode_escape_encode(""), (b"", 0)) + self.assertEqual(codecs.raw_unicode_escape_decode(b""), ("", 0)) + + def test_raw_encode(self): + encode = codecs.raw_unicode_escape_encode + for b in range(256): + self.assertEqual(encode(chr(b)), (bytes([b]), 1)) + + def test_raw_decode(self): + decode = codecs.raw_unicode_escape_decode + for b in range(256): + self.assertEqual(decode(bytes([b]) + b'0'), (chr(b) + '0', 2)) + + def test_escape_encode(self): + encode = codecs.raw_unicode_escape_encode + check = coding_checker(self, encode) + for b in range(256): + if b not in b'uU': + check('\\' + chr(b), b'\\' + bytes([b])) + check('\u20ac', br'\u20ac') + check('\U0001d120', br'\U0001d120') + + def test_escape_decode(self): + decode = codecs.raw_unicode_escape_decode + check = coding_checker(self, decode) + for b in range(256): + if b not in b'uU': + check(b'\\' + bytes([b]), '\\' + chr(b)) + check(br"\u20ac", "\u20ac") + check(br"\U0001d120", "\U0001d120") + + def test_decode_errors(self): + decode = codecs.raw_unicode_escape_decode + for c, d in (b'u', 4), (b'U', 4): + for i in range(d): + self.assertRaises(UnicodeDecodeError, decode, + b"\\" + c + b"0"*i) + self.assertRaises(UnicodeDecodeError, decode, + b"[\\" + c + b"0"*i + b"]") + data = b"[\\" + c + b"0"*i + b"]\\" + c + b"0"*i + self.assertEqual(decode(data, "ignore"), ("[]", len(data))) + self.assertEqual(decode(data, "replace"), + ("[\ufffd]\ufffd", len(data))) + self.assertRaises(UnicodeDecodeError, decode, br"\U00110000") + self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10)) + self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10)) + + class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self): -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 11:09:56 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 11:09:56 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Move_NEWS_enti?= =?utf-8?q?ty_from_library_to_core_section=2E?= Message-ID: <3YwNjw5cwCzSJY@mail.python.org> http://hg.python.org/cpython/rev/9137e2d1c00c changeset: 81821:9137e2d1c00c branch: 2.7 parent: 81817:1d21f6be1b58 user: Serhiy Storchaka date: Tue Jan 29 12:04:55 2013 +0200 summary: Move NEWS entity from library to core section. files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,8 @@ Core and Builtins ----------------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + - Issue #13886: Fix input() to not strip out input bytes that cannot be decoded using the locale encoding. @@ -200,8 +202,6 @@ Library ------- -- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. - - Issue #17051: Fix a memory leak in os.path.isdir()?on Windows. Patch by Robert Xiao. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 11:09:58 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 11:09:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Move_NEWS_enti?= =?utf-8?q?ty_from_library_to_core_section=2E?= Message-ID: <3YwNjy26CxzSKM@mail.python.org> http://hg.python.org/cpython/rev/e558adb2ebaa changeset: 81822:e558adb2ebaa branch: 3.2 parent: 81818:eb4ef5c2875d user: Serhiy Storchaka date: Tue Jan 29 12:05:46 2013 +0200 summary: Move NEWS entity from library to core section. files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + - Issue #13886: Fix input() to not strip out input bytes that cannot be decoded using the locale encoding. Also fix sporadic failures in test_builtin due to dependence on whether the readline module has previously been imported. @@ -214,8 +216,6 @@ Library ------- -- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. - - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 11:09:59 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 11:09:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Move_NEWS_entity_from_library_to_core_section=2E?= Message-ID: <3YwNjz5hkBzSMQ@mail.python.org> http://hg.python.org/cpython/rev/cbada2ea6dd3 changeset: 81823:cbada2ea6dd3 branch: 3.3 parent: 81819:0f5fc998d278 parent: 81822:e558adb2ebaa user: Serhiy Storchaka date: Tue Jan 29 12:06:28 2013 +0200 summary: Move NEWS entity from library to core section. files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + - Issue #13886: Fix input() to not strip out input bytes that cannot be decoded using the locale encoding. Also fix sporadic failures in test_builtin due to dependence on whether the readline module has previously been imported. @@ -162,8 +164,6 @@ Library ------- -- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. - - Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) now fills the ``os.environ`` variable correctly. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 11:10:01 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 11:10:01 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Move_NEWS_entity_from_library_to_core_section=2E?= Message-ID: <3YwNk11hxZzSLD@mail.python.org> http://hg.python.org/cpython/rev/9b25df066f37 changeset: 81824:9b25df066f37 parent: 81820:14004b6ed1f2 parent: 81823:cbada2ea6dd3 user: Serhiy Storchaka date: Tue Jan 29 12:07:03 2013 +0200 summary: Move NEWS entity from library to core section. files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + - Issue #13886: Fix input() to not strip out input bytes that cannot be decoded using the locale encoding. Also fix sporadic failures in test_builtin due to dependence on whether the readline module has previously been imported. @@ -234,8 +236,6 @@ Library ------- -- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. - Have py_compile use importlib as much as possible to avoid code duplication. - Issue #180022: Have site.addpackage() consider already known paths even when -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 11:17:55 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 11:17:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE2OTcx?= =?utf-8?q?=3A_Fix_a_refleak_in_the_charmap_decoder=2E?= Message-ID: <3YwNv74Z5LzNrc@mail.python.org> http://hg.python.org/cpython/rev/625c397a7283 changeset: 81825:625c397a7283 branch: 3.3 parent: 81823:cbada2ea6dd3 user: Serhiy Storchaka date: Tue Jan 29 12:13:22 2013 +0200 summary: Issue #16971: Fix a refleak in the charmap decoder. files: Objects/unicodeobject.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -7510,14 +7510,18 @@ Py_DECREF(x); goto onError; } - if (unicode_putchar(&v, &outpos, value) < 0) + if (unicode_putchar(&v, &outpos, value) < 0) { + Py_DECREF(x); goto onError; + } } else if (PyUnicode_Check(x)) { Py_ssize_t targetsize; - if (PyUnicode_READY(x) == -1) + if (PyUnicode_READY(x) == -1) { + Py_DECREF(x); goto onError; + } targetsize = PyUnicode_GET_LENGTH(x); if (targetsize == 1) { @@ -7525,8 +7529,10 @@ Py_UCS4 value = PyUnicode_READ_CHAR(x, 0); if (value == 0xFFFE) goto Undefined; - if (unicode_putchar(&v, &outpos, value) < 0) + if (unicode_putchar(&v, &outpos, value) < 0) { + Py_DECREF(x); goto onError; + } } else if (targetsize > 1) { /* 1-n mapping */ @@ -7543,8 +7549,11 @@ goto onError; } } - if (unicode_widen(&v, outpos, PyUnicode_MAX_CHAR_VALUE(x)) < 0) + if (unicode_widen(&v, outpos, + PyUnicode_MAX_CHAR_VALUE(x)) < 0) { + Py_DECREF(x); goto onError; + } PyUnicode_CopyCharacters(v, outpos, x, 0, targetsize); outpos += targetsize; extrachars -= targetsize; -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 11:17:57 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 11:17:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316971=3A_Fix_a_refleak_in_the_charmap_decoder?= =?utf-8?q?=2E?= Message-ID: <3YwNv90V6yzSN1@mail.python.org> http://hg.python.org/cpython/rev/02c4ecc87f74 changeset: 81826:02c4ecc87f74 parent: 81824:9b25df066f37 parent: 81825:625c397a7283 user: Serhiy Storchaka date: Tue Jan 29 12:16:57 2013 +0200 summary: Issue #16971: Fix a refleak in the charmap decoder. files: Objects/unicodeobject.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -7383,27 +7383,35 @@ goto onError; } - if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) + if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) { + Py_DECREF(x); goto onError; + } PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); writer.pos++; } else if (PyUnicode_Check(x)) { - if (PyUnicode_READY(x) == -1) + if (PyUnicode_READY(x) == -1) { + Py_DECREF(x); goto onError; + } if (PyUnicode_GET_LENGTH(x) == 1) { Py_UCS4 value = PyUnicode_READ_CHAR(x, 0); if (value == 0xFFFE) goto Undefined; - if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) + if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) { + Py_DECREF(x); goto onError; + } PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); writer.pos++; } else { writer.overallocate = 1; - if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) + if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) { + Py_DECREF(x); goto onError; + } } } else { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 13:50:55 2013 From: python-checkins at python.org (victor.stinner) Date: Tue, 29 Jan 2013 13:50:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_Add_link_to_the_im?= =?utf-8?q?plementation_issue?= Message-ID: <3YwSHg4JbyzRGG@mail.python.org> http://hg.python.org/peps/rev/ccaa7afb1fc7 changeset: 4696:ccaa7afb1fc7 user: Victor Stinner date: Tue Jan 29 13:49:34 2013 +0100 summary: PEP 433: Add link to the implementation issue files: pep-0433.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -695,6 +695,8 @@ `_ * `Add an 'atfork' module `_ + * `Implementation of the PEP 433 + `_ Ruby: -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Tue Jan 29 17:44:43 2013 From: python-checkins at python.org (victor.stinner) Date: Tue, 29 Jan 2013 17:44:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_change_the_proposa?= =?utf-8?q?l_to_sys=2Esetdefaultcloexec=28cloexec=3A_bool=29?= Message-ID: <3YwYTR2PSRzSX7@mail.python.org> http://hg.python.org/peps/rev/d4075ec8f65b changeset: 4697:d4075ec8f65b user: Victor Stinner date: Tue Jan 29 17:43:17 2013 +0100 summary: PEP 433: change the proposal to sys.setdefaultcloexec(cloexec: bool) files: pep-0433.txt | 394 ++++++++++++++++++-------------------- 1 files changed, 188 insertions(+), 206 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -13,10 +13,14 @@ Abstract ======== -This PEP proposes to add a new optional parameter ``cloexec`` on -functions creating file descriptors in the Python standard library. If -the parameter is ``True``, the close-on-exec flag will be set on the -new file descriptor. +Add a new optional *cloexec* parameter on functions creating file +descriptors, add different ways to change default values of this +parameter, and add four new functions: + + * ``os.get_cloexec(fd)`` + * ``os.set_cloexec(fd, cloexec=True)`` + * ``sys.getdefaultcloexec()`` + * ``sys.setdefaultcloexec(cloexec=True)`` Rationale @@ -25,38 +29,42 @@ A file descriptor has a close-on-exec flag which indicates if the file descriptor will be inherited or not. -On UNIX, the file descriptor will be closed on the execution of child processes -if the close-on-exec flag is set, the file descriptor is inherited by child -processes if the flag is cleared. +On UNIX, if the close-on-exec flag is set, the file descriptor is not +inherited: it will be closed at the execution of child processes; +otherwise the file descriptor is inherited by child processes. -On Windows, the file descriptor is not inherited if the close-on-exec flag is -set, the file descriptor is inherited by child processes if the flag is cleared -and if ``CreateProcess()`` is called with the *bInheritHandles* parameter set -to ``TRUE`` (when ``subprocess.Popen`` is created with ``close_fds=False`` for -example). +On Windows, if the close-on-exec flag is set, the file descriptor is not +inherited; the file descriptor is inherited by child processes if the +close-on-exec flag is cleared and if ``CreateProcess()`` is called with +the *bInheritHandles* parameter set to ``TRUE`` (when +``subprocess.Popen`` is created with ``close_fds=False`` for example). +Windows does now have "close-on-exec" flag but an inherance flag which +is just the opposite value. For example, setting close-on-exec flag set +means clearing the ``HANDLE_FLAG_INHERIT`` flag of an handle. Status in Python 3.3 -------------------- On UNIX, the subprocess module closes file descriptors greater than 2 by -default since Python 3.2 [#subprocess_close]_. All file descriptors created by -the parent process are automatically closed in the child process. +default since Python 3.2 [#subprocess_close]_. All file descriptors +created by the parent process are automatically closed in the child +process. ``xmlrpc.server.SimpleXMLRPCServer`` sets the close-on-exec flag of -the listening socket, the parent class ``socketserver.BaseServer`` +the listening socket, the parent class ``socketserver.TCPServer`` does not set this flag. There are other cases creating a subprocess or executing a new program -where file descriptors are not closed: functions of the os.spawn*() -family and third party modules calling ``exec()`` or ``fork()`` + -``exec()``. In this case, file descriptors are shared between the -parent and the child processes which is usually unexpected and causes -various issues. +where file descriptors are not closed: functions of the ``os.spawn*()`` +and the ``os.exec*()`` families and third party modules calling +``exec()`` or ``fork()`` + ``exec()``. In this case, file descriptors +are shared between the parent and the child processes which is usually +unexpected and causes various issues. This PEP proposes to continue the work started with the change in the -subprocess, to fix the issue in any code, and not just code using -subprocess. +subprocess in Python 3.2, to fix the issue in any code, and not just +code using subprocess. Inherited file descriptors issues @@ -66,15 +74,14 @@ related resource (file, socket, ...) because it is still open in the child process. -The listening socket of TCPServer is not closed on ``exec()``: the -child process is able to get connection from new clients; if the -parent closes the listening socket and create a new listening socket -on the same address, it would get an "address already is used" error. +The listening socket of TCPServer is not closed on ``exec()``: the child +process is able to get connection from new clients; if the parent closes +the listening socket and create a new listening socket on the same +address, it would get an "address already is used" error. Not closing file descriptors can lead to resource exhaustion: even if the parent closes all files, creating a new file descriptor may fail -with "too many files" because files are still open in the child -process. +with "too many files" because files are still open in the child process. See also the following issues: @@ -160,20 +167,6 @@ should be modified to conform to this PEP. The new ``os.set_cloexec()`` function can be used for example. -Impacted functions: - - * ``os.forkpty()`` - * ``http.server.CGIHTTPRequestHandler.run_cgi()`` - -Impacted modules: - - * ``multiprocessing`` - * ``socketserver`` - * ``subprocess`` - * ``tempfile`` - * ``xmlrpc.server`` - * Maybe: ``signal``, ``threading`` - XXX Should ``subprocess.Popen`` clear the close-on-exec flag on file XXX descriptors of the constructor the ``pass_fds`` parameter? @@ -185,78 +178,93 @@ Proposal ======== -This PEP proposes to add a new optional parameter ``cloexec`` on -functions creating file descriptors in the Python standard library. If -the parameter is ``True``, the close-on-exec flag will be set on the -new file descriptor. +Add a new optional *cloexec* parameter on functions creating file +descriptors and different ways to change default values of this +parameter. -Add a new functions: +Add new functions: * ``os.get_cloexec(fd:int) -> bool``: get the - close-on-exec flag of a file descriptor. Not available on all platforms. + close-on-exec flag of a file descriptor. Not available on all + platforms. * ``os.set_cloexec(fd:int, cloexec:bool=True)``: set or clear the - close-on-exec flag on a file descriptor. Not available on all platforms. + close-on-exec flag on a file descriptor. Not available on all + platforms. + * ``sys.getdefaultcloexec() -> bool``: get the current default value + of the *cloexec* parameter + * ``sys.setdefaultcloexec(cloexec: bool=True)``: set the default value + of the *cloexec* parameter -Add a new optional ``cloexec`` parameter to: +Add a new optional *cloexec* parameter to: - * ``open()``: ``os.fdopen()`` is indirectly modified - * ``os.dup()``, ``os.dup2()`` + * ``asyncore.dispatcher.create_socket()`` + * ``io.FileIO`` + * ``io.open()`` + * ``open()`` + * ``os.dup()`` + * ``os.dup2()`` + * ``os.fdopen()`` + * ``os.open()`` + * ``os.openpty()`` * ``os.pipe()`` - * ``socket.socket()``, ``socket.socketpair()``, - ``socket.socket.accept()`` - * Maybe also: ``os.open()``, ``os.openpty()`` - * TODO: + * ``select.devpoll()`` + * ``select.epoll()`` + * ``select.kqueue()`` + * ``socket.socket()`` + * ``socket.socket.accept()`` + * ``socket.socket.dup()`` + * ``socket.socket.fromfd`` + * ``socket.socketpair()`` - * ``select.devpoll()`` - * ``select.poll()`` - * ``select.epoll()`` - * ``select.kqueue()`` - * ``socket.socket.recvmsg()``: use ``MSG_CMSG_CLOEXEC``, - or ``os.set_cloexec()`` +The default value of the *cloexec* parameter is +``sys.getdefaultcloexec()``. -The default value of the ``cloexec`` parameter is ``False`` to keep the -backward compatibility. +Add a new command line option ``-e`` and an environment variable +``PYTHONCLOEXEC`` to the set close-on-exec flag by default. -The close-on-exec flag will not be set on file descriptors 0 (stdin), -1 (stdout) and 2 (stderr), because these files are expected to be -inherited. It would still be possible to set close-on-exec flag -explicitly using ``os.set_cloexec()``. +All functions creating file descriptors in the standard library must +respect the default *cloexec* parameter (``sys.getdefaultcloexec()``). -Drawbacks: +File descriptors 0 (stdin), 1 (stdout) and 2 (stderr) are expected to be +inherited, but Python does not handle them differently. When +``os.dup2()`` is used to replace standard streams, ``cloexec=False`` +must be specified explicitly. - * Many functions of the Python standard library creating file - descriptors cannot be changed by this proposal, because adding - a ``cloexec`` optional parameter would be surprising and too many - functions would need it. For example, ``os.urandom()`` uses a - temporary file on UNIX, but it calls a function of Windows API on - Windows. Adding a ``cloexec`` parameter to ``os.urandom()`` would - not make sense. See `Enable file descriptor inheritance by default`_ - for an incomplete list of functions creating file descriptors. - * Checking if a module creates file descriptors is difficult. For - example, ``os.urandom()`` creates a file descriptor on UNIX to read - ``/dev/urandom`` (and closes it at exit), whereas it is implemented - using a function call on Windows. It is not possible to control - close-on-exec flag of the file descriptor used by ``os.urandom()``, - because ``os.urandom()`` API does not allow it. +Drawbacks of the proposal: + + * It is not more possible to know if the close-on-exec flag will be + set or not on a newly created file descriptor just by reading the + source code. + * If the inherance of a file descriptor matters, the *cloexec* + parameter must now be specified explicitly, or the library or the + application will not work depending on the default value of the + *cloexec* parameter. Alternatives ============ -Bikeshedding on the name of the new parameter ---------------------------------------------- +Enable inherance by default and no configurable default +------------------------------------------------------- - * ``inherit``, ``inherited``: closer to Windows definition - * ``sensitive`` - * ``sterile``: "Does not produce offspring." +Add a new optional parameter *cloexec* on functions creating file +descriptors. The default value of the *cloexec* parameter is ``False``, +and this default cannot be changed. No file descriptor inherance by +default is also the default on POSIX and on Windows. This alternative is +the most convervative option. +This option does solve issues listed in the `Rationale`_ +section, it only provides an helper to fix them. All functions creating +file descriptors have to be modified to set *cloexec=True* in each +module used by an application to fix all these issues. -Enable file descriptor inheritance by default ---------------------------------------------- -Set the close-on-exec flag by default on new file descriptors created -by Python. This alternative just changes the default value of the new -``cloexec`` parameter. +Disable inheritance by default +------------------------------ + +This alternative is based on the proposal: the only difference is that +the default value of the *cloexec* parameter is ``True`` (instead of +``False``). If a file must be inherited by child processes, ``cloexec=False`` parameter can be used. @@ -266,27 +274,6 @@ flag of these file descriptors must be changed with ``os.set_cloexec()``. -Example of functions creating file descriptors which will be modified -to set close-on-exec flag: - - * ``os.urandom()`` (on UNIX) - * ``curses.window.getwin()``, ``curses.window.putwin()`` - * ``mmap.mmap()`` (if ``MAP_ANONYMOUS`` is not defined) - * ``oss.open()`` - * ``Modules/main.c``: ``RunStartupFile()`` - * ``Python/pythonrun.c``: ``PyRun_SimpleFileExFlags()`` - * ``Modules/getpath.c``: ``search_for_exec_prefix()`` - * ``Modules/zipimport.c``: ``read_directory()`` - * ``Modules/_ssl.c``: ``load_dh_params()`` - * ``PC/getpathp.c``: ``calculate_path()`` - * ``Python/errors.c``: ``PyErr_ProgramText()`` - * ``Python/import.c``: ``imp_load_dynamic()`` - * TODO: ``PC/_msi.c`` - -Many functions are impacted indirectly by this alternative. Examples: - - * ``logging.FileHandler`` - Advantages of setting close-on-exec flag by default: * There are far more programs that are bitten by FD inheritance upon @@ -296,6 +283,9 @@ Drawbacks of setting close-on-exec flag by default: + * It violates the principle of least surprise. Developers using the + os module may expect that Python respects the POSIX standard and so + that close-on-exec flag is not set by default. * The os module is written as a thin wrapper to system calls (to functions of the C standard library). If atomic flags to set close-on-exec flag are not supported (see `Appendix: Operating @@ -303,9 +293,6 @@ system calls (see `Performances`_ section). * Extra system calls, if any, may slow down Python: see `Performances`_. - * It violates the principle of least surprise. Developers using the - os module may expect that Python respects the POSIX standard and so - that close-on-exec flag is not set by default. Backward compatibility: only a few programs rely on inherance of file descriptors, and they only pass a few file descriptors, usually just @@ -319,48 +306,19 @@ not need any fix if they use the ``subprocess`` module. -Add a function to set close-on-exec flag by default ---------------------------------------------------- - -An alternative is to add also a function to change globally the -default behaviour. It would be possible to set close-on-exec flag for -the whole application including all modules and the Python standard -library. This alternative is based on the `Proposal`_ and adds extra -changes. - -New functions, command line argument and environment variable: - - * ``sys.getdefaultcloexec() -> bool``: get the default value of the - *cloexec* parameter - * ``sys.setdefaultcloexec()``, ``-e`` command line option, ``PYTHONCLOEXEC`` - environment variable (if set): set the default value of the *cloexec* - parameter to ``True`` - -The major change is that the default value of the ``cloexec`` parameter -is ``sys.getdefaultcloexec()``, instead of ``False``. - -When ``sys.setdefaultcloexec()`` is called to set close-on-exec by default, we -have the same drawbacks as the `Enable file descriptor inheritance by default`_ -alternative. - -There are additionnal drawbacks of having two behaviours depending on -``sys.getdefaultcloexec()`` value: - - * It is not more possible to know if the close-on-exec flag will be - set or not just by reading the source code. - - Close file descriptors after fork --------------------------------- This PEP does not fix issues with applications using ``fork()`` without ``exec()``. Python needs a generic process to register -callbacks which would be called after a fork, see `Add an 'atfork' -module`_. Such registry could be used to close file descriptors just -after a ``fork()``. +callbacks which would be called after a fork, see `#16500: +Add an atfork module`_. Such registry could be used to close file +descriptors just after a ``fork()``. Drawbacks: + * It does not solve the problem on Windows: ``fork()`` does not exist + on Windows * This alternative does not solve the problem for programs using ``exec()`` without ``fork()``. * A third party module may call directly the C function ``fork()`` @@ -390,6 +348,16 @@ flag which uses ``O_NOINHERIT``. +Bikeshedding on the name of the new parameter +--------------------------------------------- + + * ``inherit``, ``inherited``: closer to Windows definition + * ``sensitive`` + * ``sterile``: "Does not produce offspring." + + + + Applications using inherance of file descriptors ================================================ @@ -402,19 +370,20 @@ Network servers using fork may want to pass the client socket to the child process. For example, on UNIX a CGI server pass the socket client through file descriptors 0 (stdin) and 1 (stdout) using -``dup2()``. This specific case is not impacted by this PEP because the -close-on-exec flag is never set on file descriptors smaller than 3. +``dup2()``. To access a restricted resource like creating a socket listening on a TCP port lower than 1024 or reading a file containing sensitive data like passwords, a common practice is: start as the root user, create a -file descriptor, create a child process, pass the file descriptor to -the child process and exit. Security is very important in such use -case: leaking another file descriptor would be a critical security -vulnerability (see `Security`_). The root process may not exit but -monitors the child process instead, and restarts a new child process -and pass the same file descriptor if the previous child process -crashed. +file descriptor, create a child process, drop privileges (ex: change the +current user), pass the file descriptor to the child process and exit +the parent process. + +Security is very important in such use case: leaking another file +descriptor would be a critical security vulnerability (see `Security`_). +The root process may not exit but monitors the child process instead, +and restarts a new child process and pass the same file descriptor if +the previous child process crashed. Example of programs taking file descriptors from the parent process using a command line option: @@ -436,13 +405,13 @@ each creation of new file descriptors. The number of additional system calls depends on the method used to set the flag: - * ``O_NOINHERIT``: no additionnal system call - * ``O_CLOEXEC``: one addition system call, but only at the creation + * ``O_NOINHERIT``: no additional system call + * ``O_CLOEXEC``: one additional system call, but only at the creation of the first file descriptor, to check if the flag is supported. If - no, Python has to fallback to the next method. - * ``ioctl(fd, FIOCLEX)``: one addition system call per file + the flag is not supported, Python has to fallback to the next method. + * ``ioctl(fd, FIOCLEX)``: one additional system call per file descriptor - * ``fcntl(fd, F_SETFD, flags)``: two addition system calls per file + * ``fcntl(fd, F_SETFD, flags)``: two additional system calls per file descriptor, one to get old flags and one to set new flags On Linux, setting the close-on-flag has a low overhead on performances. @@ -560,8 +529,9 @@ os.pipe() --------- - * Windows: ``CreatePipe()`` with ``SECURITY_ATTRIBUTES.bInheritHandle=TRUE``, - or ``_pipe()`` with ``O_NOINHERIT`` flag [atomic] + * Windows: ``CreatePipe()`` with + ``SECURITY_ATTRIBUTES.bInheritHandle=TRUE``, or ``_pipe()`` with + ``O_NOINHERIT`` flag [atomic] * ``pipe2()`` with ``O_CLOEXEC`` flag [atomic] * ``pipe()`` + ``os.set_cloexec(fd, True)`` [best-effort] @@ -569,6 +539,7 @@ --------------- * Windows: ``WSASocket()`` with ``WSA_FLAG_NO_HANDLE_INHERIT`` flag + [atomic] * ``socket()`` with ``SOCK_CLOEXEC`` flag [atomic] * ``socket()`` + ``os.set_cloexec(fd, True)`` [best-effort] @@ -603,56 +574,63 @@ For example, it is supported by ``open()`` and ``_pipe()``. -The value of the flag can be modified using: -``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)``. +The flag can be cleared using +``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 0)``. ``CreateProcess()`` has an ``bInheritHandles`` parameter: if it is -FALSE, the handles are not inherited. It is used by -``subprocess.Popen`` with ``close_fds`` option. +``FALSE``, the handles are not inherited. If it is ``TRUE``, handles +with ``HANDLE_FLAG_INHERIT`` flag set are inherited. +``subprocess.Popen`` uses ``close_fds`` option to define +``bInheritHandles``. + + +ioctl +----- + +Functions: + + * ``ioctl(fd, FIOCLEX, 0)``: set the close-on-exec flag + * ``ioctl(fd, FIONCLEX, 0)``: clear the close-on-exec flag + +Availability: Linux, Mac OS X, QNX, NetBSD, OpenBSD, FreeBSD. + fcntl ----- Functions: - * ``fcntl(fd, F_GETFD)`` - * ``fcntl(fd, F_SETFD, flags | FD_CLOEXEC)`` + * ``flags = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, flags | FD_CLOEXEC)``: + set the close-on-exec flag + * ``flags = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC)``: + clear the close-on-exec flag Availability: AIX, Digital UNIX, FreeBSD, HP-UX, IRIX, Linux, Mac OS X, OpenBSD, Solaris, SunOS, Unicos. -ioctl ------ - -Functions: - - * ``ioctl(fd, FIOCLEX, 0)`` sets close-on-exec flag - * ``ioctl(fd, FIONCLEX, 0)`` clears close-on-exec flag - -Availability: Linux, Mac OS X, QNX, NetBSD, OpenBSD, FreeBSD. - Atomic flags ------------ New flags: - * ``O_CLOEXEC``: available on Linux (2.6.23+), FreeBSD (8.3+), + * ``O_CLOEXEC``: available on Linux (2.6.23), FreeBSD (8.3), OpenBSD 5.0, QNX, BeOS, next NetBSD release (6.1?). This flag is part of POSIX.1-2008. * ``SOCK_CLOEXEC`` flag for ``socket()`` and ``socketpair()``, - available on Linux 2.6.27+, OpenBSD 5.2, NetBSD 6.0. - * ``WSA_FLAG_NO_HANDLE_INHERIT`` flag for ``WSASocket()``: supported on - Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later - * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24+, + available on Linux 2.6.27, OpenBSD 5.2, NetBSD 6.0. + * ``WSA_FLAG_NO_HANDLE_INHERIT`` flag for ``WSASocket()``: supported + on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later + * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24, OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0. This flag is part of POSIX.1-2008. - * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23+, + * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23, NetBSD 6.0. On Linux older than 2.6.23, ``O_CLOEXEC`` flag is simply ignored. So we have to check that the flag is supported by calling ``fcntl()``. If -it does not work, we have to set the flag using ``fcntl()``. +it does not work, we have to set the flag using ``ioctl()`` or +``fcntl()``. On Linux older than 2.6.27, if the ``SOCK_CLOEXEC`` flag is set in the socket type, ``socket()`` or ``socketpair()`` fail and ``errno`` is set @@ -660,9 +638,9 @@ New functions: - * ``dup3()``: available on Linux 2.6.27+ (and glibc 2.9) - * ``pipe2()``: available on Linux 2.6.27+ (and glibc 2.9) - * ``accept4()``: available on Linux 2.6.28+ (and glibc 2.10) + * ``dup3()``: available on Linux 2.6.27 (and glibc 2.9) + * ``pipe2()``: available on Linux 2.6.27 (and glibc 2.9) + * ``accept4()``: available on Linux 2.6.28 (and glibc 2.10) If ``accept4()`` is called on Linux older than 2.6.28, ``accept4()`` returns ``-1`` (fail) and ``errno`` is set to ``ENOSYS``. @@ -683,30 +661,34 @@ Python issues: - * `open() does not able to set flags, such as O_CLOEXEC + * `#10115: Support accept4() for atomic setting of flags at socket + creation `_ + * `#12105: open() does not able to set flags, such as O_CLOEXEC `_ - * `Add "e" mode to open(): close-and-exec (O_CLOEXEC) / O_NOINHERIT - `_ - * `TCP listening sockets created without FD_CLOEXEC flag + * `#12107: TCP listening sockets created without FD_CLOEXEC flag `_ - * `Use O_CLOEXEC in the tempfile module + * `#16500: Add an atfork module + `_ + * `#16850: Add "e" mode to open(): close-and-exec + (O_CLOEXEC) / O_NOINHERIT `_ + * `#16860: Use O_CLOEXEC in the tempfile module `_ - * `Support accept4() for atomic setting of flags at socket creation - `_ - * `Add an 'atfork' module - `_ - * `Implementation of the PEP 433 + * `#17036: Implementation of the PEP 433 `_ + * `#16946: subprocess: _close_open_fd_range_safe() does not set + close-on-exec flag on Linux < 2.6.23 if O_CLOEXEC is defined + `_ + * `#17070: PEP 433: Use the new cloexec to improve security and avoid + bugs `_ Ruby: * `Set FD_CLOEXEC for all fds (except 0, 1, 2) `_ * `O_CLOEXEC flag missing for Kernel::open - `_: - `commit reverted + `_: the + `commit was reverted later `_ - later Footnotes ========= -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Tue Jan 29 17:54:10 2013 From: python-checkins at python.org (victor.stinner) Date: Tue, 29 Jan 2013 17:54:10 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_add_another_altern?= =?utf-8?q?ative?= Message-ID: <3YwYhL3Dv2zPgD@mail.python.org> http://hg.python.org/peps/rev/e28a9e166653 changeset: 4698:e28a9e166653 user: Victor Stinner date: Tue Jan 29 17:47:27 2013 +0100 summary: PEP 433: add another alternative files: pep-0433.txt | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -259,6 +259,14 @@ module used by an application to fix all these issues. +Enable inherance by default, default can only be set to True +------------------------------------------------------------ + +This alternative is based on the proposal: the only difference is that +``sys.setdefaultcloexec()`` does not take any argument, it can only be +used to set the default value of the *cloexec* parameter to ``True``. + + Disable inheritance by default ------------------------------ -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Tue Jan 29 18:00:37 2013 From: python-checkins at python.org (daniel.holth) Date: Tue, 29 Jan 2013 18:00:37 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_426=3A_only_two_Version-S?= =?utf-8?q?cheme=28s=29?= Message-ID: <3YwYqn090ZzSX8@mail.python.org> http://hg.python.org/peps/rev/ec53c190df25 changeset: 4699:ec53c190df25 user: Daniel Holth date: Tue Jan 29 12:00:24 2013 -0500 summary: PEP 426: only two Version-Scheme(s) files: pep-0426.txt | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pep-0426.txt b/pep-0426.txt --- a/pep-0426.txt +++ b/pep-0426.txt @@ -493,15 +493,11 @@ Version-Scheme: pkg_resources Version-Scheme: pep386 - Version-Scheme: semver-2.0.0rc1 - Version-Scheme: random -The four initially supported schemes are: +The two initially supported schemes are: -* pkg_resources: sort according to setuptools' pkg_resources module +* pkg_resources: sort versions compatibly with setuptools' pkg_resources module * pep386: sort according to the rules in pep386 -* semver-2.0.0rc1: sort according to http://semver.org/ -* random: do the shuffle Version Specifiers -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Tue Jan 29 18:18:22 2013 From: python-checkins at python.org (martin.v.loewis) Date: Tue, 29 Jan 2013 18:18:22 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Identify_the_ARM_compiler?= =?utf-8?q?=2E?= Message-ID: <3YwZDG2TVYzNYK@mail.python.org> http://hg.python.org/cpython/rev/82be592d764d changeset: 81827:82be592d764d user: Martin v. L?wis date: Tue Jan 29 18:17:05 2013 +0100 summary: Identify the ARM compiler. files: PC/pyconfig.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/PC/pyconfig.h b/PC/pyconfig.h --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -193,8 +193,10 @@ #define HAVE_SSIZE_T 1 #if defined(MS_WIN32) && !defined(MS_WIN64) -#ifdef _M_IX86 +#if defined(_M_IX86) #define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") +#elif defined(_M_ARM) +#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)") #else #define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") #endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 19:22:41 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 19:22:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEyMDA0?= =?utf-8?q?=3A_Fix_an_internal_error_in_PyZipFile_when_writing_an_invalid?= Message-ID: <3YwbfT0JRNzSZY@mail.python.org> http://hg.python.org/cpython/rev/3a1ac42435f9 changeset: 81828:3a1ac42435f9 branch: 3.2 parent: 81822:e558adb2ebaa user: Serhiy Storchaka date: Tue Jan 29 20:10:28 2013 +0200 summary: Issue #12004: Fix an internal error in PyZipFile when writing an invalid Python file. Patch by Ben Morgan. files: Lib/test/test_zipfile.py | 25 ++++++++++++++++++++++++- Lib/zipfile.py | 2 +- Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -19,7 +19,8 @@ from random import randint, random from unittest import skipUnless -from test.support import TESTFN, run_unittest, findfile, unlink +from test.support import (TESTFN, run_unittest, findfile, unlink, + captured_stdout) TESTFN2 = TESTFN + "2" TESTFNDIR = TESTFN + "d" @@ -735,6 +736,28 @@ self.assertRaises(RuntimeError, zipfp.writepy, TESTFN) os.remove(TESTFN) + def test_write_pyfile_bad_syntax(self): + os.mkdir(TESTFN2) + try: + with open(os.path.join(TESTFN2, "mod1.py"), "w") as fp: + fp.write("Bad syntax in python file\n") + + with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: + # syntax errors are printed to stdout + with captured_stdout() as s: + zipfp.writepy(os.path.join(TESTFN2, "mod1.py")) + + self.assertIn("SyntaxError", s.getvalue()) + + # as it will not have compiled the python file, it will + # include the .py file not .pyc or .pyo + names = zipfp.namelist() + self.assertIn('mod1.py', names) + self.assertNotIn('mod1.pyc', names) + self.assertNotIn('mod1.pyo', names) + + finally: + shutil.rmtree(TESTFN2) class OtherTests(unittest.TestCase): zips_with_bad_crc = { diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1436,7 +1436,7 @@ print("Compiling", file) try: py_compile.compile(file, doraise=True, optimize=optimize) - except py_compile.PyCompileError as error: + except py_compile.PyCompileError as err: print(err.msg) return False return True diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -741,6 +741,7 @@ Skip Montanaro Paul Moore Ross Moore +Ben Morgan Derek Morr James A Morrison Alessandro Moura diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -216,6 +216,9 @@ Library ------- +- Issue #12004: Fix an internal error in PyZipFile when writing an invalid + Python file. Patch by Ben Morgan. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 19:22:42 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 19:22:42 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2312004=3A_Fix_an_internal_error_in_PyZipFile_when_writ?= =?utf-8?q?ing_an_invalid?= Message-ID: <3YwbfV3GNNzSYh@mail.python.org> http://hg.python.org/cpython/rev/678320c7f63d changeset: 81829:678320c7f63d branch: 3.3 parent: 81825:625c397a7283 parent: 81828:3a1ac42435f9 user: Serhiy Storchaka date: Tue Jan 29 20:14:08 2013 +0200 summary: Issue #12004: Fix an internal error in PyZipFile when writing an invalid Python file. Patch by Ben Morgan. files: Lib/test/test_zipfile.py | 26 +++++++++++++++++++++++++- Lib/zipfile.py | 2 +- Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -13,7 +13,9 @@ from random import randint, random from unittest import skipUnless -from test.support import TESTFN, run_unittest, findfile, unlink, requires_zlib, requires_bz2, requires_lzma +from test.support import (TESTFN, run_unittest, findfile, unlink, + requires_zlib, requires_bz2, requires_lzma, + captured_stdout) TESTFN2 = TESTFN + "2" TESTFNDIR = TESTFN + "d" @@ -854,6 +856,28 @@ self.assertRaises(RuntimeError, zipfp.writepy, TESTFN) os.remove(TESTFN) + def test_write_pyfile_bad_syntax(self): + os.mkdir(TESTFN2) + try: + with open(os.path.join(TESTFN2, "mod1.py"), "w") as fp: + fp.write("Bad syntax in python file\n") + + with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: + # syntax errors are printed to stdout + with captured_stdout() as s: + zipfp.writepy(os.path.join(TESTFN2, "mod1.py")) + + self.assertIn("SyntaxError", s.getvalue()) + + # as it will not have compiled the python file, it will + # include the .py file not .pyc or .pyo + names = zipfp.namelist() + self.assertIn('mod1.py', names) + self.assertNotIn('mod1.pyc', names) + self.assertNotIn('mod1.pyo', names) + + finally: + shutil.rmtree(TESTFN2) class OtherTests(unittest.TestCase): zips_with_bad_crc = { diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1604,7 +1604,7 @@ print("Compiling", file) try: py_compile.compile(file, doraise=True, optimize=optimize) - except py_compile.PyCompileError as error: + except py_compile.PyCompileError as err: print(err.msg) return False return True diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -818,6 +818,7 @@ Peter Moody Paul Moore Ross Moore +Ben Morgan Derek Morr James A Morrison Derek McTavish Mounce diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -164,6 +164,9 @@ Library ------- +- Issue #12004: Fix an internal error in PyZipFile when writing an invalid + Python file. Patch by Ben Morgan. + - Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) now fills the ``os.environ`` variable correctly. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 19:22:43 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Jan 2013 19:22:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2312004=3A_Fix_an_internal_error_in_PyZipFile_whe?= =?utf-8?q?n_writing_an_invalid?= Message-ID: <3YwbfW6sTnzSYL@mail.python.org> http://hg.python.org/cpython/rev/e24fd2c35d27 changeset: 81830:e24fd2c35d27 parent: 81827:82be592d764d parent: 81829:678320c7f63d user: Serhiy Storchaka date: Tue Jan 29 20:15:45 2013 +0200 summary: Issue #12004: Fix an internal error in PyZipFile when writing an invalid Python file. Patch by Ben Morgan. files: Lib/test/test_zipfile.py | 26 +++++++++++++++++++++++++- Lib/zipfile.py | 2 +- Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -13,7 +13,9 @@ from random import randint, random from unittest import skipUnless -from test.support import TESTFN, run_unittest, findfile, unlink, requires_zlib, requires_bz2, requires_lzma +from test.support import (TESTFN, run_unittest, findfile, unlink, + requires_zlib, requires_bz2, requires_lzma, + captured_stdout) TESTFN2 = TESTFN + "2" TESTFNDIR = TESTFN + "d" @@ -854,6 +856,28 @@ self.assertRaises(RuntimeError, zipfp.writepy, TESTFN) os.remove(TESTFN) + def test_write_pyfile_bad_syntax(self): + os.mkdir(TESTFN2) + try: + with open(os.path.join(TESTFN2, "mod1.py"), "w") as fp: + fp.write("Bad syntax in python file\n") + + with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: + # syntax errors are printed to stdout + with captured_stdout() as s: + zipfp.writepy(os.path.join(TESTFN2, "mod1.py")) + + self.assertIn("SyntaxError", s.getvalue()) + + # as it will not have compiled the python file, it will + # include the .py file not .pyc or .pyo + names = zipfp.namelist() + self.assertIn('mod1.py', names) + self.assertNotIn('mod1.pyc', names) + self.assertNotIn('mod1.pyo', names) + + finally: + shutil.rmtree(TESTFN2) class OtherTests(unittest.TestCase): zips_with_bad_crc = { diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1604,7 +1604,7 @@ print("Compiling", file) try: py_compile.compile(file, doraise=True, optimize=optimize) - except py_compile.PyCompileError as error: + except py_compile.PyCompileError as err: print(err.msg) return False return True diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -825,6 +825,7 @@ Peter Moody Paul Moore Ross Moore +Ben Morgan Derek Morr James A Morrison Derek McTavish Mounce diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -236,6 +236,9 @@ Library ------- +- Issue #12004: Fix an internal error in PyZipFile when writing an invalid + Python file. Patch by Ben Morgan. + Have py_compile use importlib as much as possible to avoid code duplication. - Issue #180022: Have site.addpackage() consider already known paths even when -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 21:24:55 2013 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 29 Jan 2013 21:24:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzE3MDcx?= =?utf-8?q?=3A_Signature=2Ebind=28=29_now_works_when_one_of_the_keyword_ar?= =?utf-8?q?guments_is?= Message-ID: <3YwfMW6PH2zPRZ@mail.python.org> http://hg.python.org/cpython/rev/49fd1c8aeca5 changeset: 81831:49fd1c8aeca5 branch: 3.3 parent: 81829:678320c7f63d user: Antoine Pitrou date: Tue Jan 29 21:20:57 2013 +0100 summary: Issue #17071: Signature.bind() now works when one of the keyword arguments is named ``self``. files: Lib/inspect.py | 8 ++++---- Lib/test/test_inspect.py | 10 ++++++++++ Misc/NEWS | 3 +++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Lib/inspect.py b/Lib/inspect.py --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2028,19 +2028,19 @@ return self._bound_arguments_cls(self, arguments) - def bind(self, *args, **kwargs): + def bind(__bind_self, *args, **kwargs): '''Get a BoundArguments object, that maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. ''' - return self._bind(args, kwargs) + return __bind_self._bind(args, kwargs) - def bind_partial(self, *args, **kwargs): + def bind_partial(__bind_self, *args, **kwargs): '''Get a BoundArguments object, that partially maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. ''' - return self._bind(args, kwargs, partial=True) + return __bind_self._bind(args, kwargs, partial=True) def __str__(self): result = [] diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -2241,6 +2241,16 @@ with self.assertRaisesRegex(TypeError, "parameter is positional only"): self.call(test, a_po=1, b_po=2) + def test_signature_bind_with_self_arg(self): + # Issue #17071: one of the parameters is named "self + def test(a, self, b): + pass + sig = inspect.signature(test) + ba = sig.bind(1, 2, 3) + self.assertEqual(ba.args, (1, 2, 3)) + ba = sig.bind(1, self=2, b=3) + self.assertEqual(ba.args, (1, 2, 3)) + class TestBoundArguments(unittest.TestCase): def test_signature_bound_arguments_unhashable(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -164,6 +164,9 @@ Library ------- +- Issue #17071: Signature.bind() now works when one of the keyword arguments + is named ``self``. + - Issue #12004: Fix an internal error in PyZipFile when writing an invalid Python file. Patch by Ben Morgan. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 21:24:57 2013 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 29 Jan 2013 21:24:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2317071=3A_Signature=2Ebind=28=29_now_works_when_?= =?utf-8?q?one_of_the_keyword_arguments_is?= Message-ID: <3YwfMY6Rj1zSLg@mail.python.org> http://hg.python.org/cpython/rev/4ff1dc8c0a3c changeset: 81832:4ff1dc8c0a3c parent: 81830:e24fd2c35d27 parent: 81831:49fd1c8aeca5 user: Antoine Pitrou date: Tue Jan 29 21:21:56 2013 +0100 summary: Issue #17071: Signature.bind() now works when one of the keyword arguments is named self. files: Lib/inspect.py | 8 ++++---- Lib/test/test_inspect.py | 10 ++++++++++ Misc/NEWS | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Lib/inspect.py b/Lib/inspect.py --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2028,19 +2028,19 @@ return self._bound_arguments_cls(self, arguments) - def bind(self, *args, **kwargs): + def bind(__bind_self, *args, **kwargs): '''Get a BoundArguments object, that maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. ''' - return self._bind(args, kwargs) + return __bind_self._bind(args, kwargs) - def bind_partial(self, *args, **kwargs): + def bind_partial(__bind_self, *args, **kwargs): '''Get a BoundArguments object, that partially maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. ''' - return self._bind(args, kwargs, partial=True) + return __bind_self._bind(args, kwargs, partial=True) def __str__(self): result = [] diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -2241,6 +2241,16 @@ with self.assertRaisesRegex(TypeError, "parameter is positional only"): self.call(test, a_po=1, b_po=2) + def test_signature_bind_with_self_arg(self): + # Issue #17071: one of the parameters is named "self + def test(a, self, b): + pass + sig = inspect.signature(test) + ba = sig.bind(1, 2, 3) + self.assertEqual(ba.args, (1, 2, 3)) + ba = sig.bind(1, self=2, b=3) + self.assertEqual(ba.args, (1, 2, 3)) + class TestBoundArguments(unittest.TestCase): def test_signature_bound_arguments_unhashable(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -236,10 +236,13 @@ Library ------- +- Issue #17071: Signature.bind() now works when one of the keyword arguments + is named ``self``. + - Issue #12004: Fix an internal error in PyZipFile when writing an invalid Python file. Patch by Ben Morgan. -Have py_compile use importlib as much as possible to avoid code duplication. +- Have py_compile use importlib as much as possible to avoid code duplication. - Issue #180022: Have site.addpackage() consider already known paths even when none are explicitly passed in. Bug report and fix by Kirill. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 23:29:39 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 29 Jan 2013 23:29:39 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Closes_=2317028=3A_Allowed?= =?utf-8?q?_Python_arguments_to_be_supplied_to_launcher=2E?= Message-ID: <3Ywj7R5XVszSLj@mail.python.org> http://hg.python.org/cpython/rev/0880e0f859e0 changeset: 81833:0880e0f859e0 user: Vinay Sajip date: Tue Jan 29 22:29:25 2013 +0000 summary: Closes #17028: Allowed Python arguments to be supplied to launcher. files: PC/launcher.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1208,6 +1208,7 @@ void * version_data; VS_FIXEDFILEINFO * file_info; UINT block_size; + int index; wp = get_env(L"PYLAUNCH_DEBUG"); if ((wp != NULL) && (*wp != L'\0')) @@ -1295,13 +1296,6 @@ else { p = argv[1]; plen = wcslen(p); - if (p[0] != L'-') { - read_commands(); - maybe_handle_shebang(&argv[1], command); - } - /* No file with shebang, or an unrecognised shebang. - * Is the first arg a special version qualifier? - */ valid = (*p == L'-') && validate_version(&p[1]); if (valid) { ip = locate_python(&p[1]); @@ -1311,6 +1305,16 @@ command += wcslen(p); command = skip_whitespace(command); } + else { + for (index = 1; index < argc; ++index) { + if (*argv[index] != L'-') + break; + } + if (index < argc) { + read_commands(); + maybe_handle_shebang(&argv[index], command); + } + } } if (!valid) { ip = locate_python(L""); @@ -1329,7 +1333,7 @@ fwprintf(stdout, L"\ Python Launcher for Windows Version %s\n\n", version_text); fwprintf(stdout, L"\ -usage: %s [ launcher-arguments ] script [ script-arguments ]\n\n", argv[0]); +usage: %s [ launcher-arguments ] [ python-arguments ] script [ script-arguments ]\n\n", argv[0]); fputws(L"\ Launcher arguments:\n\n\ -2 : Launch the latest Python 2.x version\n\ @@ -1362,4 +1366,4 @@ return process(argc, argv); } -#endif \ No newline at end of file +#endif -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 23:37:47 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 29 Jan 2013 23:37:47 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Added_clarific?= =?utf-8?q?ation_to_logging_HOWTO=2E?= Message-ID: <3YwjJq6nphzSLQ@mail.python.org> http://hg.python.org/cpython/rev/c34a761d843a changeset: 81834:c34a761d843a branch: 2.7 parent: 81821:9137e2d1c00c user: Vinay Sajip date: Tue Jan 29 22:36:39 2013 +0000 summary: Added clarification to logging HOWTO. files: Doc/howto/logging.rst | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -738,12 +738,11 @@ When developing a library which uses logging, you should take care to document how the library uses logging - for example, the names of loggers used. Some consideration also needs to be given to its logging configuration. -If the using application does not use logging, and library code makes logging -calls, then (as described in the previous section) events of severity -``WARNING`` and greater will be printed to ``sys.stderr``. This is regarded as -the best default behaviour. +If the using application does not configure logging, and library code makes +logging calls, then (as described in the previous section) an error message +will be printed to ``sys.stderr``. -If for some reason you *don't* want these messages printed in the absence of +If for some reason you *don't* want this message printed in the absence of any logging configuration, you can attach a do-nothing handler to the top-level logger for your library. This avoids the message being printed, since a handler will be always be found for the library's events: it just doesn't produce any @@ -755,7 +754,7 @@ A do-nothing handler is included in the logging package: :class:`~logging.NullHandler` (since Python 2.7). An instance of this handler could be added to the top-level logger of the logging namespace used by the -library (*if* you want to prevent your library's logged events being output to +library (*if* you want to prevent an error message being output to ``sys.stderr`` in the absence of logging configuration). If all logging by a library *foo* is done using loggers with names matching 'foo.x', 'foo.x.y', etc. then the code:: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 23:53:15 2013 From: python-checkins at python.org (vinay.sajip) Date: Tue, 29 Jan 2013 23:53:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_compilation_error_unde?= =?utf-8?q?r_Windows=2E?= Message-ID: <3Ywjfg6cQyzMSH@mail.python.org> http://hg.python.org/cpython/rev/3104cad2d9e6 changeset: 81835:3104cad2d9e6 parent: 81833:0880e0f859e0 user: Vinay Sajip date: Tue Jan 29 22:52:57 2013 +0000 summary: Fix compilation error under Windows. files: PC/launcher.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1257,8 +1257,8 @@ if (!valid) debug(L"GetFileVersionInfo failed: %X\n", GetLastError()); else { - valid = VerQueryValueW(version_data, L"\\", &file_info, - &block_size); + valid = VerQueryValueW(version_data, L"\\", + (LPVOID *) &file_info, &block_size); if (!valid) debug(L"VerQueryValue failed: %X\n", GetLastError()); else { -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Tue Jan 29 23:59:07 2013 From: python-checkins at python.org (michael.foord) Date: Tue, 29 Jan 2013 23:59:07 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgMTU1MDUu?= =?utf-8?q?_unittest=2EinstallHandler_and_non_callable_signal_handlers?= Message-ID: <3YwjnR4895zRBj@mail.python.org> http://hg.python.org/cpython/rev/7e4c5914ba76 changeset: 81836:7e4c5914ba76 branch: 2.7 parent: 81834:c34a761d843a user: Michael Foord date: Tue Jan 29 22:59:02 2013 +0000 summary: Issue 15505. unittest.installHandler and non callable signal handlers files: Lib/unittest/signals.py | 16 +++++++++- Lib/unittest/test/test_break.py | 32 +++++++++++++++++++++ Misc/NEWS | 3 + 3 files changed, 50 insertions(+), 1 deletions(-) diff --git a/Lib/unittest/signals.py b/Lib/unittest/signals.py --- a/Lib/unittest/signals.py +++ b/Lib/unittest/signals.py @@ -9,6 +9,20 @@ class _InterruptHandler(object): def __init__(self, default_handler): self.called = False + self.original_handler = default_handler + if isinstance(default_handler, int): + if default_handler == signal.SIG_DFL: + # Pretend it's signal.default_int_handler instead. + default_handler = signal.default_int_handler + elif default_handler == signal.SIG_IGN: + # Not quite the same thing as SIG_IGN, but the closest we + # can make it: do nothing. + def default_handler(unused_signum, unused_frame): + pass + else: + raise TypeError("expected SIGINT signal handler to be " + "signal.SIG_IGN, signal.SIG_DFL, or a " + "callable object") self.default_handler = default_handler def __call__(self, signum, frame): @@ -54,4 +68,4 @@ global _interrupt_handler if _interrupt_handler is not None: - signal.signal(signal.SIGINT, _interrupt_handler.default_handler) + signal.signal(signal.SIGINT, _interrupt_handler.original_handler) diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py --- a/Lib/unittest/test/test_break.py +++ b/Lib/unittest/test/test_break.py @@ -15,9 +15,12 @@ @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreak(unittest.TestCase): + int_handler = None def setUp(self): self._default_handler = signal.getsignal(signal.SIGINT) + if self.int_handler is not None: + signal.signal(signal.SIGINT, self.int_handler) def tearDown(self): signal.signal(signal.SIGINT, self._default_handler) @@ -74,6 +77,10 @@ def testSecondInterrupt(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") result = unittest.TestResult() unittest.installHandler() unittest.registerResult(result) @@ -123,6 +130,10 @@ def testHandlerReplacedButCalled(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") # If our handler has been replaced (is no longer installed) but is # called by the *new* handler, then it isn't safe to delay the # SIGINT and we should immediately delegate to the default handler @@ -250,3 +261,24 @@ test() self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakDefaultIntHandler(TestBreak): + int_handler = signal.default_int_handler + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalIgnored(TestBreak): + int_handler = signal.SIG_IGN + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalDefault(TestBreak): + int_handler = signal.SIG_DFL diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,9 @@ Library ------- +- Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler is + set to a callable object. + - Issue #17051: Fix a memory leak in os.path.isdir()?on Windows. Patch by Robert Xiao. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 30 00:08:15 2013 From: python-checkins at python.org (michael.foord) Date: Wed, 30 Jan 2013 00:08:15 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Closes_issue_1?= =?utf-8?q?5505=2E_unittest=2EinstallHandler_and_non-callable_signal_handl?= =?utf-8?q?ers=2E?= Message-ID: <3Ywjzz6mSGzPHp@mail.python.org> http://hg.python.org/cpython/rev/48c5c632d212 changeset: 81837:48c5c632d212 branch: 3.2 parent: 81828:3a1ac42435f9 user: Michael Foord date: Tue Jan 29 23:07:57 2013 +0000 summary: Closes issue 15505. unittest.installHandler and non-callable signal handlers. files: Lib/unittest/signals.py | 16 +++++++++- Lib/unittest/test/test_break.py | 32 +++++++++++++++++++++ Misc/NEWS | 3 + 3 files changed, 50 insertions(+), 1 deletions(-) diff --git a/Lib/unittest/signals.py b/Lib/unittest/signals.py --- a/Lib/unittest/signals.py +++ b/Lib/unittest/signals.py @@ -9,6 +9,20 @@ class _InterruptHandler(object): def __init__(self, default_handler): self.called = False + self.original_handler = default_handler + if isinstance(default_handler, int): + if default_handler == signal.SIG_DFL: + # Pretend it's signal.default_int_handler instead. + default_handler = signal.default_int_handler + elif default_handler == signal.SIG_IGN: + # Not quite the same thing as SIG_IGN, but the closest we + # can make it: do nothing. + def default_handler(unused_signum, unused_frame): + pass + else: + raise TypeError("expected SIGINT signal handler to be " + "signal.SIG_IGN, signal.SIG_DFL, or a " + "callable object") self.default_handler = default_handler def __call__(self, signum, frame): @@ -54,4 +68,4 @@ global _interrupt_handler if _interrupt_handler is not None: - signal.signal(signal.SIGINT, _interrupt_handler.default_handler) + signal.signal(signal.SIGINT, _interrupt_handler.original_handler) diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py --- a/Lib/unittest/test/test_break.py +++ b/Lib/unittest/test/test_break.py @@ -13,9 +13,12 @@ @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreak(unittest.TestCase): + int_handler = None def setUp(self): self._default_handler = signal.getsignal(signal.SIGINT) + if self.int_handler is not None: + signal.signal(signal.SIGINT, self.int_handler) def tearDown(self): signal.signal(signal.SIGINT, self._default_handler) @@ -72,6 +75,10 @@ def testSecondInterrupt(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") result = unittest.TestResult() unittest.installHandler() unittest.registerResult(result) @@ -121,6 +128,10 @@ def testHandlerReplacedButCalled(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") # If our handler has been replaced (is no longer installed) but is # called by the *new* handler, then it isn't safe to delay the # SIGINT and we should immediately delegate to the default handler @@ -250,3 +261,24 @@ test() self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakDefaultIntHandler(TestBreak): + int_handler = signal.default_int_handler + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalIgnored(TestBreak): + int_handler = signal.SIG_IGN + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalDefault(TestBreak): + int_handler = signal.SIG_DFL diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -216,6 +216,9 @@ Library ------- +- Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler is + set to a callable object. + - Issue #12004: Fix an internal error in PyZipFile when writing an invalid Python file. Patch by Ben Morgan. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 30 00:15:04 2013 From: python-checkins at python.org (michael.foord) Date: Wed, 30 Jan 2013 00:15:04 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Merge?= Message-ID: <3Ywk7r25C3zLtN@mail.python.org> http://hg.python.org/cpython/rev/f39b69494393 changeset: 81838:f39b69494393 branch: 3.3 parent: 81831:49fd1c8aeca5 parent: 81837:48c5c632d212 user: Michael Foord date: Tue Jan 29 23:14:59 2013 +0000 summary: Merge files: Lib/unittest/signals.py | 16 +++++++++- Lib/unittest/test/test_break.py | 32 +++++++++++++++++++++ Misc/NEWS | 3 + 3 files changed, 50 insertions(+), 1 deletions(-) diff --git a/Lib/unittest/signals.py b/Lib/unittest/signals.py --- a/Lib/unittest/signals.py +++ b/Lib/unittest/signals.py @@ -9,6 +9,20 @@ class _InterruptHandler(object): def __init__(self, default_handler): self.called = False + self.original_handler = default_handler + if isinstance(default_handler, int): + if default_handler == signal.SIG_DFL: + # Pretend it's signal.default_int_handler instead. + default_handler = signal.default_int_handler + elif default_handler == signal.SIG_IGN: + # Not quite the same thing as SIG_IGN, but the closest we + # can make it: do nothing. + def default_handler(unused_signum, unused_frame): + pass + else: + raise TypeError("expected SIGINT signal handler to be " + "signal.SIG_IGN, signal.SIG_DFL, or a " + "callable object") self.default_handler = default_handler def __call__(self, signum, frame): @@ -54,4 +68,4 @@ global _interrupt_handler if _interrupt_handler is not None: - signal.signal(signal.SIGINT, _interrupt_handler.default_handler) + signal.signal(signal.SIGINT, _interrupt_handler.original_handler) diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py --- a/Lib/unittest/test/test_break.py +++ b/Lib/unittest/test/test_break.py @@ -13,9 +13,12 @@ @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreak(unittest.TestCase): + int_handler = None def setUp(self): self._default_handler = signal.getsignal(signal.SIGINT) + if self.int_handler is not None: + signal.signal(signal.SIGINT, self.int_handler) def tearDown(self): signal.signal(signal.SIGINT, self._default_handler) @@ -72,6 +75,10 @@ def testSecondInterrupt(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") result = unittest.TestResult() unittest.installHandler() unittest.registerResult(result) @@ -121,6 +128,10 @@ def testHandlerReplacedButCalled(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") # If our handler has been replaced (is no longer installed) but is # called by the *new* handler, then it isn't safe to delay the # SIGINT and we should immediately delegate to the default handler @@ -250,3 +261,24 @@ test() self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakDefaultIntHandler(TestBreak): + int_handler = signal.default_int_handler + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalIgnored(TestBreak): + int_handler = signal.SIG_IGN + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalDefault(TestBreak): + int_handler = signal.SIG_DFL diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -173,6 +173,9 @@ - Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) now fills the ``os.environ`` variable correctly. +- Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler is + set to a callable object. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 30 00:18:52 2013 From: python-checkins at python.org (michael.foord) Date: Wed, 30 Jan 2013 00:18:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merge?= Message-ID: <3YwkDD2khtzPg5@mail.python.org> http://hg.python.org/cpython/rev/e81cad0c722a changeset: 81839:e81cad0c722a parent: 81835:3104cad2d9e6 parent: 81838:f39b69494393 user: Michael Foord date: Tue Jan 29 23:18:48 2013 +0000 summary: Merge files: Lib/unittest/signals.py | 16 +++++++++- Lib/unittest/test/test_break.py | 32 +++++++++++++++++++++ Misc/NEWS | 3 + 3 files changed, 50 insertions(+), 1 deletions(-) diff --git a/Lib/unittest/signals.py b/Lib/unittest/signals.py --- a/Lib/unittest/signals.py +++ b/Lib/unittest/signals.py @@ -9,6 +9,20 @@ class _InterruptHandler(object): def __init__(self, default_handler): self.called = False + self.original_handler = default_handler + if isinstance(default_handler, int): + if default_handler == signal.SIG_DFL: + # Pretend it's signal.default_int_handler instead. + default_handler = signal.default_int_handler + elif default_handler == signal.SIG_IGN: + # Not quite the same thing as SIG_IGN, but the closest we + # can make it: do nothing. + def default_handler(unused_signum, unused_frame): + pass + else: + raise TypeError("expected SIGINT signal handler to be " + "signal.SIG_IGN, signal.SIG_DFL, or a " + "callable object") self.default_handler = default_handler def __call__(self, signum, frame): @@ -54,4 +68,4 @@ global _interrupt_handler if _interrupt_handler is not None: - signal.signal(signal.SIGINT, _interrupt_handler.default_handler) + signal.signal(signal.SIGINT, _interrupt_handler.original_handler) diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py --- a/Lib/unittest/test/test_break.py +++ b/Lib/unittest/test/test_break.py @@ -13,9 +13,12 @@ @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreak(unittest.TestCase): + int_handler = None def setUp(self): self._default_handler = signal.getsignal(signal.SIGINT) + if self.int_handler is not None: + signal.signal(signal.SIGINT, self.int_handler) def tearDown(self): signal.signal(signal.SIGINT, self._default_handler) @@ -72,6 +75,10 @@ def testSecondInterrupt(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") result = unittest.TestResult() unittest.installHandler() unittest.registerResult(result) @@ -121,6 +128,10 @@ def testHandlerReplacedButCalled(self): + # Can't use skipIf decorator because the signal handler may have + # been changed after defining this method. + if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: + self.skipTest("test requires SIGINT to not be ignored") # If our handler has been replaced (is no longer installed) but is # called by the *new* handler, then it isn't safe to delay the # SIGINT and we should immediately delegate to the default handler @@ -250,3 +261,24 @@ test() self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakDefaultIntHandler(TestBreak): + int_handler = signal.default_int_handler + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalIgnored(TestBreak): + int_handler = signal.SIG_IGN + + at unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") + at unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") + at unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " + "if threads have been used") +class TestBreakSignalDefault(TestBreak): + int_handler = signal.SIG_DFL diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -250,6 +250,9 @@ - Issue #1602133: on Mac OS X a shared library build (``--enable-shared``) now fills the ``os.environ`` variable correctly. +- Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler is + set to a callable object. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase interface and support all mandatory methods and properties. -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Wed Jan 30 06:02:17 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 30 Jan 2013 06:02:17 +0100 Subject: [Python-checkins] Daily reference leaks (e81cad0c722a): sum=0 Message-ID: results for e81cad0c722a on branch "default" -------------------------------------------- Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogS0E25h', '-x'] From python-checkins at python.org Wed Jan 30 09:42:23 2013 From: python-checkins at python.org (victor.stinner) Date: Wed, 30 Jan 2013 09:42:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_fix_typo=2C_sys=2E?= =?utf-8?q?setdefaultcloexec=28=29_has_one_mandatory_parameter?= Message-ID: <3YwykR4dG0zSQk@mail.python.org> http://hg.python.org/peps/rev/c8017823a4dc changeset: 4700:c8017823a4dc user: Victor Stinner date: Wed Jan 30 09:40:36 2013 +0100 summary: PEP 433: fix typo, sys.setdefaultcloexec() has one mandatory parameter files: pep-0433.txt | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -20,7 +20,7 @@ * ``os.get_cloexec(fd)`` * ``os.set_cloexec(fd, cloexec=True)`` * ``sys.getdefaultcloexec()`` - * ``sys.setdefaultcloexec(cloexec=True)`` + * ``sys.setdefaultcloexec(cloexec)`` Rationale @@ -39,7 +39,7 @@ the *bInheritHandles* parameter set to ``TRUE`` (when ``subprocess.Popen`` is created with ``close_fds=False`` for example). Windows does now have "close-on-exec" flag but an inherance flag which -is just the opposite value. For example, setting close-on-exec flag set +is just the opposite value. For example, setting close-on-exec flag means clearing the ``HANDLE_FLAG_INHERIT`` flag of an handle. @@ -192,7 +192,7 @@ platforms. * ``sys.getdefaultcloexec() -> bool``: get the current default value of the *cloexec* parameter - * ``sys.setdefaultcloexec(cloexec: bool=True)``: set the default value + * ``sys.setdefaultcloexec(cloexec: bool)``: set the default value of the *cloexec* parameter Add a new optional *cloexec* parameter to: -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 30 09:52:24 2013 From: python-checkins at python.org (victor.stinner) Date: Wed, 30 Jan 2013 09:52:24 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_inherance_=3D=3E_i?= =?utf-8?q?nheritance?= Message-ID: <3Ywyy03PLjzSRy@mail.python.org> http://hg.python.org/peps/rev/fdf10a400fd9 changeset: 4701:fdf10a400fd9 user: Victor Stinner date: Wed Jan 30 09:51:02 2013 +0100 summary: PEP 433: inherance => inheritance files: pep-0433.txt | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -38,7 +38,7 @@ close-on-exec flag is cleared and if ``CreateProcess()`` is called with the *bInheritHandles* parameter set to ``TRUE`` (when ``subprocess.Popen`` is created with ``close_fds=False`` for example). -Windows does now have "close-on-exec" flag but an inherance flag which +Windows does now have "close-on-exec" flag but an inheritance flag which is just the opposite value. For example, setting close-on-exec flag means clearing the ``HANDLE_FLAG_INHERIT`` flag of an handle. @@ -235,7 +235,7 @@ * It is not more possible to know if the close-on-exec flag will be set or not on a newly created file descriptor just by reading the source code. - * If the inherance of a file descriptor matters, the *cloexec* + * If the inheritance of a file descriptor matters, the *cloexec* parameter must now be specified explicitly, or the library or the application will not work depending on the default value of the *cloexec* parameter. @@ -244,12 +244,12 @@ Alternatives ============ -Enable inherance by default and no configurable default +Inheritance enabled by default, default no configurable ------------------------------------------------------- Add a new optional parameter *cloexec* on functions creating file descriptors. The default value of the *cloexec* parameter is ``False``, -and this default cannot be changed. No file descriptor inherance by +and this default cannot be changed. No file descriptor inheritance by default is also the default on POSIX and on Windows. This alternative is the most convervative option. @@ -259,8 +259,8 @@ module used by an application to fix all these issues. -Enable inherance by default, default can only be set to True ------------------------------------------------------------- +Inheritance enabled by default, default can only be set to True +--------------------------------------------------------------- This alternative is based on the proposal: the only difference is that ``sys.setdefaultcloexec()`` does not take any argument, it can only be @@ -286,7 +286,7 @@ * There are far more programs that are bitten by FD inheritance upon exec (see `Inherited file descriptors issues`_ and `Security`_) - than programs relying on it (see `Applications using inherance of + than programs relying on it (see `Applications using inheritance of file descriptors`_). Drawbacks of setting close-on-exec flag by default: @@ -302,7 +302,7 @@ * Extra system calls, if any, may slow down Python: see `Performances`_. -Backward compatibility: only a few programs rely on inherance of file +Backward compatibility: only a few programs rely on inheritance of file descriptors, and they only pass a few file descriptors, usually just one. These programs will fail immediatly with ``EBADF`` error, and it will be simple to fix them: add ``cloexec=False`` parameter or use @@ -366,11 +366,11 @@ -Applications using inherance of file descriptors -================================================ +Applications using inheritance of file descriptors +================================================== Most developers don't know that file descriptors are inherited by -default. Most programs do not rely on inherance of file descriptors. +default. Most programs do not rely on inheritance of file descriptors. For example, ``subprocess.Popen`` was changed in Python 3.2 to close all file descriptors greater than 2 in the child process by default. No user complained about this behavior change yet. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 30 12:55:51 2013 From: python-checkins at python.org (victor.stinner) Date: Wed, 30 Jan 2013 12:55:51 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_more_references?= Message-ID: <3Yx31g4SCxzSTb@mail.python.org> http://hg.python.org/peps/rev/651cc14404e8 changeset: 4702:651cc14404e8 user: Victor Stinner date: Wed Jan 30 12:54:34 2013 +0100 summary: PEP 433: more references files: pep-0433.txt | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -632,6 +632,7 @@ * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24, OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0. This flag is part of POSIX.1-2008. + * ``fcntl()``: ``F_DUP2FD_CLOEXEC`` flag, available on FreeBSD 9.1. * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23, NetBSD 6.0. @@ -644,6 +645,9 @@ socket type, ``socket()`` or ``socketpair()`` fail and ``errno`` is set to ``EINVAL``. +On Windows XPS3, ``WSASocket()`` with with ``WSAEPROTOTYPE`` when +``WSA_FLAG_NO_HANDLE_INHERIT`` flag is used. + New functions: * ``dup3()``: available on Linux 2.6.27 (and glibc 2.9) @@ -666,6 +670,8 @@ `_: emulate fcntl(fd, F_SETFD, FD_CLOEXEC) using ``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)`` + * `LKML: [PATCH] nextfd(2) + `_ Python issues: @@ -689,14 +695,24 @@ * `#17070: PEP 433: Use the new cloexec to improve security and avoid bugs `_ -Ruby: +Other languages: - * `Set FD_CLOEXEC for all fds (except 0, 1, 2) + * Perl sets the close-on-exec flag on newly created file decriptor if + their number is greater than ``$SYSTEM_FD_MAX`` (``$^F``). + See `$SYSTEM_FD_MAX documentation + `_. Perl does + this since the creation of Perl (it was already present in Perl 1). + * Ruby: `Set FD_CLOEXEC for all fds (except 0, 1, 2) `_ - * `O_CLOEXEC flag missing for Kernel::open + * Ruby: `O_CLOEXEC flag missing for Kernel::open `_: the `commit was reverted later `_ + * OCaml: `PR#5256: Processes opened using Unix.open_process* inherit + all opened file descriptors (including sockets) + `_. OCaml has a + ``Unix.set_close_on_exec`` function. + Footnotes ========= -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 30 13:24:11 2013 From: python-checkins at python.org (victor.stinner) Date: Wed, 30 Jan 2013 13:24:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_more_info_on_apach?= =?utf-8?q?e/php_and_cloexec?= Message-ID: <3Yx3fM3HCnzPRf@mail.python.org> http://hg.python.org/peps/rev/ffd254c46e55 changeset: 4703:ffd254c46e55 user: Victor Stinner date: Wed Jan 30 13:22:54 2013 +0100 summary: PEP 433: more info on apache/php and cloexec files: pep-0433.txt | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -119,6 +119,13 @@ * `Hijacking Apache https by mod_php `_ (Dec 2003) + * Apache: `Apr should set FD_CLOEXEC if APR_FOPEN_NOCLEANUP is not set + `_ + (fixed in 2009) + * PHP: `system() (and similar) don't cleanup opened handles of Apache + `_ (not fixed in january + 2013) + Atomicity --------- -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Wed Jan 30 14:44:46 2013 From: python-checkins at python.org (vinay.sajip) Date: Wed, 30 Jan 2013 14:44:46 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_Updated_venv_d?= =?utf-8?q?ocumentation_with_an_example=2E?= Message-ID: <3Yx5RL5B2QzMjc@mail.python.org> http://hg.python.org/cpython/rev/91435b4dc8d4 changeset: 81840:91435b4dc8d4 branch: 3.3 parent: 81838:f39b69494393 user: Vinay Sajip date: Wed Jan 30 13:44:00 2013 +0000 summary: Updated venv documentation with an example. files: Doc/library/venv.rst | 213 +++++++++++++++++++++++++++++++ 1 files changed, 213 insertions(+), 0 deletions(-) diff --git a/Doc/library/venv.rst b/Doc/library/venv.rst --- a/Doc/library/venv.rst +++ b/Doc/library/venv.rst @@ -178,3 +178,216 @@ Create an :class:`EnvBuilder` with the given keyword arguments, and call its :meth:`~EnvBuilder.create` method with the *env_dir* argument. + +An example of extending ``EnvBuilder`` +-------------------------------------- + +The following script shows how to extend :class:`EnvBuilder` by implementing a +subclass which installs Distribute and pip into a created venv:: + + import os + import os.path + from subprocess import Popen, PIPE + import sys + from threading import Thread + from urllib.parse import urlparse + from urllib.request import urlretrieve + import venv + + class DistributeEnvBuilder(venv.EnvBuilder): + """ + This builder installs Distribute and pip so that you can pip or + easy_install other packages into the created environment. + + :param nodist: If True, Distribute is not installed into the created + environment. + :param nopip: If True, pip is not installed into the created + environment. + :param progress: If Distribute or pip are installed, the progress of the + installation can be monitored by passing a progress + callable. If specified, it is called with two + arguments: a string indicating some progress, and a + context indicating where the string is coming from. + The context argument can have one of three values: + 'main', indicating that it is called from virtualize() + itself, and 'stdout' and 'stderr', which are obtained + by reading lines from the output streams of a subprocess + which is used to install the app. + + If a callable is not specified, default progress + information is output to sys.stderr. + """ + + def __init__(self, *args, **kwargs): + self.nodist = kwargs.pop('nodist', False) + self.nopip = kwargs.pop('nopip', False) + self.progress = kwargs.pop('progress', None) + self.verbose = kwargs.pop('verbose', False) + super().__init__(*args, **kwargs) + + def post_setup(self, context): + """ + Set up any packages which need to be pre-installed into the + environment being created. + + :param context: The information for the environment creation request + being processed. + """ + if not self.nodist: + self.install_distribute(context) + if not self.nopip: + self.install_pip(context) + + def reader(self, stream, context): + """ + Read lines from a subprocess' output stream and either pass to a progress + callable (if specified) or write progress information to sys.stderr. + """ + progress = self.progress + while True: + s = stream.readline() + if not s: + break + if progress is not None: + progress(s, context) + else: + if not self.verbose: + sys.stderr.write('.') + else: + sys.stderr.write(s.decode('utf-8')) + sys.stderr.flush() + + def install_script(self, context, name, url): + _, _, path, _, _, _ = urlparse(url) + fn = os.path.split(path)[-1] + binpath = context.bin_path + distpath = os.path.join(binpath, fn) + # Download script into the env's binaries folder + urlretrieve(url, distpath) + progress = self.progress + if progress is not None: + progress('Installing %s' %name, 'main') + else: + sys.stderr.write('Installing %s ' % name) + sys.stderr.flush() + # Install in the env + args = [context.env_exe, fn] + p = Popen(args, stdout=PIPE, stderr=PIPE, cwd=binpath) + t1 = Thread(target=self.reader, args=(p.stdout, 'stdout')) + t1.start() + t2 = Thread(target=self.reader, args=(p.stderr, 'stderr')) + t2.start() + p.wait() + t1.join() + t2.join() + if progress is not None: + progress('done.', 'main') + else: + sys.stderr.write('done.\n') + # Clean up - no longer needed + os.unlink(distpath) + + def install_distribute(self, context): + """ + Install Distribute in the environment. + + :param context: The information for the environment creation request + being processed. + """ + url = 'http://python-distribute.org/distribute_setup.py' + self.install_script(context, 'distribute', url) + # clear up the distribute archive which gets downloaded + pred = lambda o: o.startswith('distribute-') and o.endswith('.tar.gz') + files = filter(pred, os.listdir(context.bin_path)) + for f in files: + f = os.path.join(context.bin_path, f) + os.unlink(f) + + def install_pip(self, context): + """ + Install pip in the environment. + + :param context: The information for the environment creation request + being processed. + """ + url = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' + self.install_script(context, 'pip', url) + + def main(args=None): + compatible = True + if sys.version_info < (3, 3): + compatible = False + elif not hasattr(sys, 'base_prefix'): + compatible = False + if not compatible: + raise ValueError('This script is only for use with ' + 'Python 3.3 or later') + else: + import argparse + + parser = argparse.ArgumentParser(prog=__name__, + description='Creates virtual Python ' + 'environments in one or ' + 'more target ' + 'directories.') + parser.add_argument('dirs', metavar='ENV_DIR', nargs='+', + help='A directory to create the environment in.') + parser.add_argument('--no-distribute', default=False, + action='store_true', dest='nodist', + help="Don't install Distribute in the virtual " + "environment.") + parser.add_argument('--no-pip', default=False, + action='store_true', dest='nopip', + help="Don't install pip in the virtual " + "environment.") + parser.add_argument('--system-site-packages', default=False, + action='store_true', dest='system_site', + help='Give the virtual environment access to the ' + 'system site-packages dir.') + if os.name == 'nt': + use_symlinks = False + else: + use_symlinks = True + parser.add_argument('--symlinks', default=use_symlinks, + action='store_true', dest='symlinks', + help='Try to use symlinks rather than copies, ' + 'when symlinks are not the default for ' + 'the platform.') + parser.add_argument('--clear', default=False, action='store_true', + dest='clear', help='Delete the contents of the ' + 'environment directory if it ' + 'already exists, before ' + 'environment creation.') + parser.add_argument('--upgrade', default=False, action='store_true', + dest='upgrade', help='Upgrade the environment ' + 'directory to use this version ' + 'of Python, assuming Python ' + 'has been upgraded in-place.') + parser.add_argument('--verbose', default=False, action='store_true', + dest='verbose', help='Display the output ' + 'from the scripts which ' + 'install Distribute and pip.') + options = parser.parse_args(args) + if options.upgrade and options.clear: + raise ValueError('you cannot supply --upgrade and --clear together.') + builder = DistributeEnvBuilder(system_site_packages=options.system_site, + clear=options.clear, + symlinks=options.symlinks, + upgrade=options.upgrade, + nodist=options.nodist, + nopip=options.nopip, + verbose=options.verbose) + for d in options.dirs: + builder.create(d) + + if __name__ == '__main__': + rc = 1 + try: + main() + rc = 0 + except Exception as e: + print('Error: %s' % e, file=sys.stderr) + sys.exit(rc) + +This script is also available for download `online +`_. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 30 14:44:48 2013 From: python-checkins at python.org (vinay.sajip) Date: Wed, 30 Jan 2013 14:44:48 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Merged_documentation_update_from_3=2E3=2E?= Message-ID: <3Yx5RN2H4XzN1J@mail.python.org> http://hg.python.org/cpython/rev/ae6c77a883c6 changeset: 81841:ae6c77a883c6 parent: 81839:e81cad0c722a parent: 81840:91435b4dc8d4 user: Vinay Sajip date: Wed Jan 30 13:44:34 2013 +0000 summary: Merged documentation update from 3.3. files: Doc/library/venv.rst | 213 +++++++++++++++++++++++++++++++ 1 files changed, 213 insertions(+), 0 deletions(-) diff --git a/Doc/library/venv.rst b/Doc/library/venv.rst --- a/Doc/library/venv.rst +++ b/Doc/library/venv.rst @@ -177,3 +177,216 @@ Create an :class:`EnvBuilder` with the given keyword arguments, and call its :meth:`~EnvBuilder.create` method with the *env_dir* argument. + +An example of extending ``EnvBuilder`` +-------------------------------------- + +The following script shows how to extend :class:`EnvBuilder` by implementing a +subclass which installs Distribute and pip into a created venv:: + + import os + import os.path + from subprocess import Popen, PIPE + import sys + from threading import Thread + from urllib.parse import urlparse + from urllib.request import urlretrieve + import venv + + class DistributeEnvBuilder(venv.EnvBuilder): + """ + This builder installs Distribute and pip so that you can pip or + easy_install other packages into the created environment. + + :param nodist: If True, Distribute is not installed into the created + environment. + :param nopip: If True, pip is not installed into the created + environment. + :param progress: If Distribute or pip are installed, the progress of the + installation can be monitored by passing a progress + callable. If specified, it is called with two + arguments: a string indicating some progress, and a + context indicating where the string is coming from. + The context argument can have one of three values: + 'main', indicating that it is called from virtualize() + itself, and 'stdout' and 'stderr', which are obtained + by reading lines from the output streams of a subprocess + which is used to install the app. + + If a callable is not specified, default progress + information is output to sys.stderr. + """ + + def __init__(self, *args, **kwargs): + self.nodist = kwargs.pop('nodist', False) + self.nopip = kwargs.pop('nopip', False) + self.progress = kwargs.pop('progress', None) + self.verbose = kwargs.pop('verbose', False) + super().__init__(*args, **kwargs) + + def post_setup(self, context): + """ + Set up any packages which need to be pre-installed into the + environment being created. + + :param context: The information for the environment creation request + being processed. + """ + if not self.nodist: + self.install_distribute(context) + if not self.nopip: + self.install_pip(context) + + def reader(self, stream, context): + """ + Read lines from a subprocess' output stream and either pass to a progress + callable (if specified) or write progress information to sys.stderr. + """ + progress = self.progress + while True: + s = stream.readline() + if not s: + break + if progress is not None: + progress(s, context) + else: + if not self.verbose: + sys.stderr.write('.') + else: + sys.stderr.write(s.decode('utf-8')) + sys.stderr.flush() + + def install_script(self, context, name, url): + _, _, path, _, _, _ = urlparse(url) + fn = os.path.split(path)[-1] + binpath = context.bin_path + distpath = os.path.join(binpath, fn) + # Download script into the env's binaries folder + urlretrieve(url, distpath) + progress = self.progress + if progress is not None: + progress('Installing %s' %name, 'main') + else: + sys.stderr.write('Installing %s ' % name) + sys.stderr.flush() + # Install in the env + args = [context.env_exe, fn] + p = Popen(args, stdout=PIPE, stderr=PIPE, cwd=binpath) + t1 = Thread(target=self.reader, args=(p.stdout, 'stdout')) + t1.start() + t2 = Thread(target=self.reader, args=(p.stderr, 'stderr')) + t2.start() + p.wait() + t1.join() + t2.join() + if progress is not None: + progress('done.', 'main') + else: + sys.stderr.write('done.\n') + # Clean up - no longer needed + os.unlink(distpath) + + def install_distribute(self, context): + """ + Install Distribute in the environment. + + :param context: The information for the environment creation request + being processed. + """ + url = 'http://python-distribute.org/distribute_setup.py' + self.install_script(context, 'distribute', url) + # clear up the distribute archive which gets downloaded + pred = lambda o: o.startswith('distribute-') and o.endswith('.tar.gz') + files = filter(pred, os.listdir(context.bin_path)) + for f in files: + f = os.path.join(context.bin_path, f) + os.unlink(f) + + def install_pip(self, context): + """ + Install pip in the environment. + + :param context: The information for the environment creation request + being processed. + """ + url = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' + self.install_script(context, 'pip', url) + + def main(args=None): + compatible = True + if sys.version_info < (3, 3): + compatible = False + elif not hasattr(sys, 'base_prefix'): + compatible = False + if not compatible: + raise ValueError('This script is only for use with ' + 'Python 3.3 or later') + else: + import argparse + + parser = argparse.ArgumentParser(prog=__name__, + description='Creates virtual Python ' + 'environments in one or ' + 'more target ' + 'directories.') + parser.add_argument('dirs', metavar='ENV_DIR', nargs='+', + help='A directory to create the environment in.') + parser.add_argument('--no-distribute', default=False, + action='store_true', dest='nodist', + help="Don't install Distribute in the virtual " + "environment.") + parser.add_argument('--no-pip', default=False, + action='store_true', dest='nopip', + help="Don't install pip in the virtual " + "environment.") + parser.add_argument('--system-site-packages', default=False, + action='store_true', dest='system_site', + help='Give the virtual environment access to the ' + 'system site-packages dir.') + if os.name == 'nt': + use_symlinks = False + else: + use_symlinks = True + parser.add_argument('--symlinks', default=use_symlinks, + action='store_true', dest='symlinks', + help='Try to use symlinks rather than copies, ' + 'when symlinks are not the default for ' + 'the platform.') + parser.add_argument('--clear', default=False, action='store_true', + dest='clear', help='Delete the contents of the ' + 'environment directory if it ' + 'already exists, before ' + 'environment creation.') + parser.add_argument('--upgrade', default=False, action='store_true', + dest='upgrade', help='Upgrade the environment ' + 'directory to use this version ' + 'of Python, assuming Python ' + 'has been upgraded in-place.') + parser.add_argument('--verbose', default=False, action='store_true', + dest='verbose', help='Display the output ' + 'from the scripts which ' + 'install Distribute and pip.') + options = parser.parse_args(args) + if options.upgrade and options.clear: + raise ValueError('you cannot supply --upgrade and --clear together.') + builder = DistributeEnvBuilder(system_site_packages=options.system_site, + clear=options.clear, + symlinks=options.symlinks, + upgrade=options.upgrade, + nodist=options.nodist, + nopip=options.nopip, + verbose=options.verbose) + for d in options.dirs: + builder.create(d) + + if __name__ == '__main__': + rc = 1 + try: + main() + rc = 0 + except Exception as e: + print('Error: %s' % e, file=sys.stderr) + sys.exit(rc) + +This script is also available for download `online +`_. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Wed Jan 30 23:26:59 2013 From: python-checkins at python.org (vinay.sajip) Date: Wed, 30 Jan 2013 23:26:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython=3A_Updated_NEWS_with_fix_for_?= =?utf-8?q?=2317028=2E?= Message-ID: <3YxK1v3nTLzPj1@mail.python.org> http://hg.python.org/cpython/rev/58e72cb89848 changeset: 81842:58e72cb89848 user: Vinay Sajip date: Wed Jan 30 22:26:49 2013 +0000 summary: Updated NEWS with fix for #17028. files: Misc/NEWS | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -891,6 +891,9 @@ Tools/Demos ----------- +- Issue #17028: Allowed Python arguments to be supplied to the Windows + launcher. + - Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now pindent.py works with a "with" statement. pindent.py no longer produces improper indentation. pindent.py now works with continued lines broken after -- Repository URL: http://hg.python.org/cpython From solipsis at pitrou.net Thu Jan 31 06:00:06 2013 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 31 Jan 2013 06:00:06 +0100 Subject: [Python-checkins] Daily reference leaks (58e72cb89848): sum=6 Message-ID: results for 58e72cb89848 on branch "default" -------------------------------------------- test_dbm leaked [0, 2, 0] references, sum=2 test_dbm leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogE1TgxI', '-x'] From python-checkins at python.org Thu Jan 31 10:37:49 2013 From: python-checkins at python.org (ned.deily) Date: Thu, 31 Jan 2013 10:37:49 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzEzNTkw?= =?utf-8?q?=3A_OS_X_Xcode_4_-_improve_support_for_universal_extension_modu?= =?utf-8?q?les?= Message-ID: <3Yxbvx6mMnzPdY@mail.python.org> http://hg.python.org/cpython/rev/1d061f83a6bf changeset: 81843:1d061f83a6bf branch: 2.7 parent: 81836:7e4c5914ba76 user: Ned Deily date: Thu Jan 31 01:24:55 2013 -0800 summary: Issue #13590: OS X Xcode 4 - improve support for universal extension modules In particular, fix extension module build failures when trying to use 32-bit-only installer Pythons on systems with Xcode 4 (currently OS X 10.8, 10.7, and optionally 10.6). * Backport 3.3.0 fixes to 2.7 branch (for release in 2.7.4) * Since Xcode 4 removes ppc support, extension module builds now check for ppc compiler support and by default remove ppc and ppc64 archs when they are not available. * Extension module builds now revert to using system installed headers and libs (/usr and /System/Library) if the SDK used to build the interpreter is not installed or has moved. * Try to avoid building extension modules with deprecated and problematic Apple llvm-gcc compiler. If original compiler is not available, use clang instead by default. files: Lib/_osx_support.py | 488 ++++++++++++++ Lib/distutils/sysconfig.py | 111 +-- Lib/distutils/tests/test_sysconfig.py | 29 + Lib/distutils/unixccompiler.py | 70 +- Lib/distutils/util.py | 92 +-- Lib/sysconfig.py | 150 +---- Lib/test/test__osx_support.py | 279 ++++++++ Lib/test/test_sysconfig.py | 9 + Misc/NEWS | 15 + 9 files changed, 859 insertions(+), 384 deletions(-) diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py new file mode 100644 --- /dev/null +++ b/Lib/_osx_support.py @@ -0,0 +1,488 @@ +"""Shared OS X support functions.""" + +import os +import re +import sys + +__all__ = [ + 'compiler_fixup', + 'customize_config_vars', + 'customize_compiler', + 'get_platform_osx', +] + +# configuration variables that may contain universal build flags, +# like "-arch" or "-isdkroot", that may need customization for +# the user environment +_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS', + 'BLDSHARED', 'LDSHARED', 'CC', 'CXX', + 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS', + 'PY_CORE_CFLAGS') + +# configuration variables that may contain compiler calls +_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX') + +# prefix added to original configuration variable names +_INITPRE = '_OSX_SUPPORT_INITIAL_' + + +def _find_executable(executable, path=None): + """Tries to find 'executable' in the directories listed in 'path'. + + A string listing directories separated by 'os.pathsep'; defaults to + os.environ['PATH']. Returns the complete filename or None if not found. + """ + if path is None: + path = os.environ['PATH'] + + paths = path.split(os.pathsep) + base, ext = os.path.splitext(executable) + + if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'): + executable = executable + '.exe' + + if not os.path.isfile(executable): + for p in paths: + f = os.path.join(p, executable) + if os.path.isfile(f): + # the file exists, we have a shot at spawn working + return f + return None + else: + return executable + + +def _read_output(commandstring): + """Output from succesful command execution or None""" + # Similar to os.popen(commandstring, "r").read(), + # but without actually using os.popen because that + # function is not usable during python bootstrap. + # tempfile is also not available then. + import contextlib + try: + import tempfile + fp = tempfile.NamedTemporaryFile() + except ImportError: + fp = open("/tmp/_osx_support.%s"%( + os.getpid(),), "w+b") + + with contextlib.closing(fp) as fp: + cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name) + return fp.read().decode('utf-8').strip() if not os.system(cmd) else None + + +def _find_build_tool(toolname): + """Find a build tool on current path or using xcrun""" + return (_find_executable(toolname) + or _read_output("/usr/bin/xcrun -find %s" % (toolname,)) + or '' + ) + +_SYSTEM_VERSION = None + +def _get_system_version(): + """Return the OS X system version as a string""" + # Reading this plist is a documented way to get the system + # version (see the documentation for the Gestalt Manager) + # We avoid using platform.mac_ver to avoid possible bootstrap issues during + # the build of Python itself (distutils is used to build standard library + # extensions). + + global _SYSTEM_VERSION + + if _SYSTEM_VERSION is None: + _SYSTEM_VERSION = '' + try: + f = open('/System/Library/CoreServices/SystemVersion.plist') + except IOError: + # We're on a plain darwin box, fall back to the default + # behaviour. + pass + else: + try: + m = re.search(r'ProductUserVisibleVersion\s*' + r'(.*?)', f.read()) + finally: + f.close() + if m is not None: + _SYSTEM_VERSION = '.'.join(m.group(1).split('.')[:2]) + # else: fall back to the default behaviour + + return _SYSTEM_VERSION + +def _remove_original_values(_config_vars): + """Remove original unmodified values for testing""" + # This is needed for higher-level cross-platform tests of get_platform. + for k in list(_config_vars): + if k.startswith(_INITPRE): + del _config_vars[k] + +def _save_modified_value(_config_vars, cv, newvalue): + """Save modified and original unmodified value of configuration var""" + + oldvalue = _config_vars.get(cv, '') + if (oldvalue != newvalue) and (_INITPRE + cv not in _config_vars): + _config_vars[_INITPRE + cv] = oldvalue + _config_vars[cv] = newvalue + +def _supports_universal_builds(): + """Returns True if universal builds are supported on this system""" + # As an approximation, we assume that if we are running on 10.4 or above, + # then we are running with an Xcode environment that supports universal + # builds, in particular -isysroot and -arch arguments to the compiler. This + # is in support of allowing 10.4 universal builds to run on 10.3.x systems. + + osx_version = _get_system_version() + if osx_version: + try: + osx_version = tuple(int(i) for i in osx_version.split('.')) + except ValueError: + osx_version = '' + return bool(osx_version >= (10, 4)) if osx_version else False + + +def _find_appropriate_compiler(_config_vars): + """Find appropriate C compiler for extension module builds""" + + # Issue #13590: + # The OSX location for the compiler varies between OSX + # (or rather Xcode) releases. With older releases (up-to 10.5) + # the compiler is in /usr/bin, with newer releases the compiler + # can only be found inside Xcode.app if the "Command Line Tools" + # are not installed. + # + # Futhermore, the compiler that can be used varies between + # Xcode releases. Upto Xcode 4 it was possible to use 'gcc-4.2' + # as the compiler, after that 'clang' should be used because + # gcc-4.2 is either not present, or a copy of 'llvm-gcc' that + # miscompiles Python. + + # skip checks if the compiler was overriden with a CC env variable + if 'CC' in os.environ: + return _config_vars + + # The CC config var might contain additional arguments. + # Ignore them while searching. + cc = oldcc = _config_vars['CC'].split()[0] + if not _find_executable(cc): + # Compiler is not found on the shell search PATH. + # Now search for clang, first on PATH (if the Command LIne + # Tools have been installed in / or if the user has provided + # another location via CC). If not found, try using xcrun + # to find an uninstalled clang (within a selected Xcode). + + # NOTE: Cannot use subprocess here because of bootstrap + # issues when building Python itself (and os.popen is + # implemented on top of subprocess and is therefore not + # usable as well) + + cc = _find_build_tool('clang') + + elif os.path.basename(cc).startswith('gcc'): + # Compiler is GCC, check if it is LLVM-GCC + data = _read_output("'%s' --version" + % (cc.replace("'", "'\"'\"'"),)) + if 'llvm-gcc' in data: + # Found LLVM-GCC, fall back to clang + cc = _find_build_tool('clang') + + if not cc: + raise SystemError( + "Cannot locate working compiler") + + if cc != oldcc: + # Found a replacement compiler. + # Modify config vars using new compiler, if not already explictly + # overriden by an env variable, preserving additional arguments. + for cv in _COMPILER_CONFIG_VARS: + if cv in _config_vars and cv not in os.environ: + cv_split = _config_vars[cv].split() + cv_split[0] = cc if cv != 'CXX' else cc + '++' + _save_modified_value(_config_vars, cv, ' '.join(cv_split)) + + return _config_vars + + +def _remove_universal_flags(_config_vars): + """Remove all universal build arguments from config vars""" + + for cv in _UNIVERSAL_CONFIG_VARS: + # Do not alter a config var explicitly overriden by env var + if cv in _config_vars and cv not in os.environ: + flags = _config_vars[cv] + flags = re.sub('-arch\s+\w+\s', ' ', flags) + flags = re.sub('-isysroot [^ \t]*', ' ', flags) + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def _remove_unsupported_archs(_config_vars): + """Remove any unsupported archs from config vars""" + # Different Xcode releases support different sets for '-arch' + # flags. In particular, Xcode 4.x no longer supports the + # PPC architectures. + # + # This code automatically removes '-arch ppc' and '-arch ppc64' + # when these are not supported. That makes it possible to + # build extensions on OSX 10.7 and later with the prebuilt + # 32-bit installer on the python.org website. + + # skip checks if the compiler was overriden with a CC env variable + if 'CC' in os.environ: + return _config_vars + + if re.search('-arch\s+ppc', _config_vars['CFLAGS']) is not None: + # NOTE: Cannot use subprocess here because of bootstrap + # issues when building Python itself + status = os.system("'%s' -arch ppc -x c /dev/null 2>/dev/null"%( + _config_vars['CC'].replace("'", "'\"'\"'"),)) + # The Apple compiler drivers return status 255 if no PPC + if (status >> 8) == 255: + # Compiler doesn't support PPC, remove the related + # '-arch' flags if not explicitly overridden by an + # environment variable + for cv in _UNIVERSAL_CONFIG_VARS: + if cv in _config_vars and cv not in os.environ: + flags = _config_vars[cv] + flags = re.sub('-arch\s+ppc\w*\s', ' ', flags) + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def _override_all_archs(_config_vars): + """Allow override of all archs with ARCHFLAGS env var""" + # NOTE: This name was introduced by Apple in OSX 10.5 and + # is used by several scripting languages distributed with + # that OS release. + if 'ARCHFLAGS' in os.environ: + arch = os.environ['ARCHFLAGS'] + for cv in _UNIVERSAL_CONFIG_VARS: + if cv in _config_vars and '-arch' in _config_vars[cv]: + flags = _config_vars[cv] + flags = re.sub('-arch\s+\w+\s', ' ', flags) + flags = flags + ' ' + arch + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def _check_for_unavailable_sdk(_config_vars): + """Remove references to any SDKs not available""" + # If we're on OSX 10.5 or later and the user tries to + # compile an extension using an SDK that is not present + # on the current machine it is better to not use an SDK + # than to fail. This is particularly important with + # the standalong Command Line Tools alternative to a + # full-blown Xcode install since the CLT packages do not + # provide SDKs. If the SDK is not present, it is assumed + # that the header files and dev libs have been installed + # to /usr and /System/Library by either a standalone CLT + # package or the CLT component within Xcode. + cflags = _config_vars.get('CFLAGS', '') + m = re.search(r'-isysroot\s+(\S+)', cflags) + if m is not None: + sdk = m.group(1) + if not os.path.exists(sdk): + for cv in _UNIVERSAL_CONFIG_VARS: + # Do not alter a config var explicitly overriden by env var + if cv in _config_vars and cv not in os.environ: + flags = _config_vars[cv] + flags = re.sub(r'-isysroot\s+\S+(?:\s|$)', ' ', flags) + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def compiler_fixup(compiler_so, cc_args): + """ + This function will strip '-isysroot PATH' and '-arch ARCH' from the + compile flags if the user has specified one them in extra_compile_flags. + + This is needed because '-arch ARCH' adds another architecture to the + build, without a way to remove an architecture. Furthermore GCC will + barf if multiple '-isysroot' arguments are present. + """ + stripArch = stripSysroot = False + + compiler_so = list(compiler_so) + + if not _supports_universal_builds(): + # OSX before 10.4.0, these don't support -arch and -isysroot at + # all. + stripArch = stripSysroot = True + else: + stripArch = '-arch' in cc_args + stripSysroot = '-isysroot' in cc_args + + if stripArch or 'ARCHFLAGS' in os.environ: + while True: + try: + index = compiler_so.index('-arch') + # Strip this argument and the next one: + del compiler_so[index:index+2] + except ValueError: + break + + if 'ARCHFLAGS' in os.environ and not stripArch: + # User specified different -arch flags in the environ, + # see also distutils.sysconfig + compiler_so = compiler_so + os.environ['ARCHFLAGS'].split() + + if stripSysroot: + while True: + try: + index = compiler_so.index('-isysroot') + # Strip this argument and the next one: + del compiler_so[index:index+2] + except ValueError: + break + + # Check if the SDK that is used during compilation actually exists, + # the universal build requires the usage of a universal SDK and not all + # users have that installed by default. + sysroot = None + if '-isysroot' in cc_args: + idx = cc_args.index('-isysroot') + sysroot = cc_args[idx+1] + elif '-isysroot' in compiler_so: + idx = compiler_so.index('-isysroot') + sysroot = compiler_so[idx+1] + + if sysroot and not os.path.isdir(sysroot): + from distutils import log + log.warn("Compiling with an SDK that doesn't seem to exist: %s", + sysroot) + log.warn("Please check your Xcode installation") + + return compiler_so + + +def customize_config_vars(_config_vars): + """Customize Python build configuration variables. + + Called internally from sysconfig with a mutable mapping + containing name/value pairs parsed from the configured + makefile used to build this interpreter. Returns + the mapping updated as needed to reflect the environment + in which the interpreter is running; in the case of + a Python from a binary installer, the installed + environment may be very different from the build + environment, i.e. different OS levels, different + built tools, different available CPU architectures. + + This customization is performed whenever + distutils.sysconfig.get_config_vars() is first + called. It may be used in environments where no + compilers are present, i.e. when installing pure + Python dists. Customization of compiler paths + and detection of unavailable archs is deferred + until the first extention module build is + requested (in distutils.sysconfig.customize_compiler). + + Currently called from distutils.sysconfig + """ + + if not _supports_universal_builds(): + # On Mac OS X before 10.4, check if -arch and -isysroot + # are in CFLAGS or LDFLAGS and remove them if they are. + # This is needed when building extensions on a 10.3 system + # using a universal build of python. + _remove_universal_flags(_config_vars) + + # Allow user to override all archs with ARCHFLAGS env var + _override_all_archs(_config_vars) + + # Remove references to sdks that are not found + _check_for_unavailable_sdk(_config_vars) + + return _config_vars + + +def customize_compiler(_config_vars): + """Customize compiler path and configuration variables. + + This customization is performed when the first + extension module build is requested + in distutils.sysconfig.customize_compiler). + """ + + # Find a compiler to use for extension module builds + _find_appropriate_compiler(_config_vars) + + # Remove ppc arch flags if not supported here + _remove_unsupported_archs(_config_vars) + + # Allow user to override all archs with ARCHFLAGS env var + _override_all_archs(_config_vars) + + return _config_vars + + +def get_platform_osx(_config_vars, osname, release, machine): + """Filter values for get_platform()""" + # called from get_platform() in sysconfig and distutils.util + # + # For our purposes, we'll assume that the system version from + # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set + # to. This makes the compatibility story a bit more sane because the + # machine is going to compile and link as if it were + # MACOSX_DEPLOYMENT_TARGET. + + macver = _config_vars.get('MACOSX_DEPLOYMENT_TARGET', '') + macrelease = _get_system_version() or macver + macver = macver or macrelease + + if macver: + release = macver + osname = "macosx" + + # Use the original CFLAGS value, if available, so that we + # return the same machine type for the platform string. + # Otherwise, distutils may consider this a cross-compiling + # case and disallow installs. + cflags = _config_vars.get(_INITPRE+'CFLAGS', + _config_vars.get('CFLAGS', '')) + if ((macrelease + '.') >= '10.4.' and + '-arch' in cflags.strip()): + # The universal build will build fat binaries, but not on + # systems before 10.4 + + machine = 'fat' + + archs = re.findall('-arch\s+(\S+)', cflags) + archs = tuple(sorted(set(archs))) + + if len(archs) == 1: + machine = archs[0] + elif archs == ('i386', 'ppc'): + machine = 'fat' + elif archs == ('i386', 'x86_64'): + machine = 'intel' + elif archs == ('i386', 'ppc', 'x86_64'): + machine = 'fat3' + elif archs == ('ppc64', 'x86_64'): + machine = 'fat64' + elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'): + machine = 'universal' + else: + raise ValueError( + "Don't know machine value for archs=%r" % (archs,)) + + elif machine == 'i386': + # On OSX the machine type returned by uname is always the + # 32-bit variant, even if the executable architecture is + # the 64-bit variant + if sys.maxint >= 2**32: + machine = 'x86_64' + + elif machine in ('PowerPC', 'Power_Macintosh'): + # Pick a sane name for the PPC architecture. + # See 'i386' case + if sys.maxint >= 2**32: + machine = 'ppc64' + else: + machine = 'ppc' + + return (osname, release, machine) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -141,7 +141,7 @@ "I don't know where Python installs its library " "on platform '%s'" % os.name) -_USE_CLANG = None + def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. @@ -150,6 +150,21 @@ varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": + if sys.platform == "darwin": + # Perform first-time customization of compiler-related + # config vars on OS X now that we know we need a compiler. + # This is primarily to support Pythons from binary + # installers. The kind and paths to build tools on + # the user system may vary significantly from the system + # that Python itself was built on. Also the user OS + # version and build tools may not support the same set + # of CPU architectures for universal builds. + global _config_vars + if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): + import _osx_support + _osx_support.customize_compiler(_config_vars) + _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' + (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', @@ -157,36 +172,7 @@ newcc = None if 'CC' in os.environ: - newcc = os.environ['CC'] - elif sys.platform == 'darwin' and cc == 'gcc-4.2': - # Issue #13590: - # Since Apple removed gcc-4.2 in Xcode 4.2, we can no - # longer assume it is available for extension module builds. - # If Python was built with gcc-4.2, check first to see if - # it is available on this system; if not, try to use clang - # instead unless the caller explicitly set CC. - global _USE_CLANG - if _USE_CLANG is None: - from distutils import log - from subprocess import Popen, PIPE - p = Popen("! type gcc-4.2 && type clang && exit 2", - shell=True, stdout=PIPE, stderr=PIPE) - p.wait() - if p.returncode == 2: - _USE_CLANG = True - log.warn("gcc-4.2 not found, using clang instead") - else: - _USE_CLANG = False - if _USE_CLANG: - newcc = 'clang' - if newcc: - # On OS X, if CC is overridden, use that as the default - # command for LDSHARED as well - if (sys.platform == 'darwin' - and 'LDSHARED' not in os.environ - and ldshared.startswith(cc)): - ldshared = newcc + ldshared[len(cc):] - cc = newcc + cc = os.environ['CC'] if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: @@ -518,66 +504,11 @@ _config_vars['prefix'] = PREFIX _config_vars['exec_prefix'] = EXEC_PREFIX + # OS X platforms require special customization to handle + # multi-architecture, multi-os-version installers if sys.platform == 'darwin': - kernel_version = os.uname()[2] # Kernel version (8.4.3) - major_version = int(kernel_version.split('.')[0]) - - if major_version < 8: - # On Mac OS X before 10.4, check if -arch and -isysroot - # are in CFLAGS or LDFLAGS and remove them if they are. - # This is needed when building extensions on a 10.3 system - # using a universal build of python. - for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - flags = _config_vars[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags) - flags = re.sub('-isysroot [^ \t]*', ' ', flags) - _config_vars[key] = flags - - else: - - # Allow the user to override the architecture flags using - # an environment variable. - # NOTE: This name was introduced by Apple in OSX 10.5 and - # is used by several scripting languages distributed with - # that OS release. - - if 'ARCHFLAGS' in os.environ: - arch = os.environ['ARCHFLAGS'] - for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - - flags = _config_vars[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags) - flags = flags + ' ' + arch - _config_vars[key] = flags - - # If we're on OSX 10.5 or later and the user tries to - # compiles an extension using an SDK that is not present - # on the current machine it is better to not use an SDK - # than to fail. - # - # The major usecase for this is users using a Python.org - # binary installer on OSX 10.6: that installer uses - # the 10.4u SDK, but that SDK is not installed by default - # when you install Xcode. - # - m = re.search('-isysroot\s+(\S+)', _config_vars['CFLAGS']) - if m is not None: - sdk = m.group(1) - if not os.path.exists(sdk): - for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - - flags = _config_vars[key] - flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags) - _config_vars[key] = flags + import _osx_support + _osx_support.customize_config_vars(_config_vars) if args: vals = [] diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -72,6 +72,35 @@ 'OTHER': 'foo'}) + def test_sysconfig_module(self): + import sysconfig as global_sysconfig + self.assertEqual(global_sysconfig.get_config_var('CFLAGS'), sysconfig.get_config_var('CFLAGS')) + self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'), sysconfig.get_config_var('LDFLAGS')) + + @unittest.skipIf(sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'),'compiler flags customized') + def test_sysconfig_compiler_vars(self): + # On OS X, binary installers support extension module building on + # various levels of the operating system with differing Xcode + # configurations. This requires customization of some of the + # compiler configuration directives to suit the environment on + # the installed machine. Some of these customizations may require + # running external programs and, so, are deferred until needed by + # the first extension module build. With Python 3.3, only + # the Distutils version of sysconfig is used for extension module + # builds, which happens earlier in the Distutils tests. This may + # cause the following tests to fail since no tests have caused + # the global version of sysconfig to call the customization yet. + # The solution for now is to simply skip this test in this case. + # The longer-term solution is to only have one version of sysconfig. + + import sysconfig as global_sysconfig + if sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'): + return + self.assertEqual(global_sysconfig.get_config_var('LDSHARED'), sysconfig.get_config_var('LDSHARED')) + self.assertEqual(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC')) + + + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(SysconfigTestCase)) diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -26,6 +26,9 @@ DistutilsExecError, CompileError, LibError, LinkError from distutils import log +if sys.platform == 'darwin': + import _osx_support + # XXX Things not currently handled: # * optimization/debug/warning flags; we just use whatever's in Python's # Makefile and live with it. Is this adequate? If not, we might @@ -41,68 +44,6 @@ # should just happily stuff them into the preprocessor/compiler/linker # options and carry on. -def _darwin_compiler_fixup(compiler_so, cc_args): - """ - This function will strip '-isysroot PATH' and '-arch ARCH' from the - compile flags if the user has specified one them in extra_compile_flags. - - This is needed because '-arch ARCH' adds another architecture to the - build, without a way to remove an architecture. Furthermore GCC will - barf if multiple '-isysroot' arguments are present. - """ - stripArch = stripSysroot = 0 - - compiler_so = list(compiler_so) - kernel_version = os.uname()[2] # 8.4.3 - major_version = int(kernel_version.split('.')[0]) - - if major_version < 8: - # OSX before 10.4.0, these don't support -arch and -isysroot at - # all. - stripArch = stripSysroot = True - else: - stripArch = '-arch' in cc_args - stripSysroot = '-isysroot' in cc_args - - if stripArch or 'ARCHFLAGS' in os.environ: - while 1: - try: - index = compiler_so.index('-arch') - # Strip this argument and the next one: - del compiler_so[index:index+2] - except ValueError: - break - - if 'ARCHFLAGS' in os.environ and not stripArch: - # User specified different -arch flags in the environ, - # see also distutils.sysconfig - compiler_so = compiler_so + os.environ['ARCHFLAGS'].split() - - if stripSysroot: - try: - index = compiler_so.index('-isysroot') - # Strip this argument and the next one: - del compiler_so[index:index+2] - except ValueError: - pass - - # Check if the SDK that is used during compilation actually exists, - # the universal build requires the usage of a universal SDK and not all - # users have that installed by default. - sysroot = None - if '-isysroot' in cc_args: - idx = cc_args.index('-isysroot') - sysroot = cc_args[idx+1] - elif '-isysroot' in compiler_so: - idx = compiler_so.index('-isysroot') - sysroot = compiler_so[idx+1] - - if sysroot and not os.path.isdir(sysroot): - log.warn("Compiling with an SDK that doesn't seem to exist: %s", - sysroot) - log.warn("Please check your Xcode installation") - - return compiler_so class UnixCCompiler(CCompiler): @@ -172,7 +113,8 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): compiler_so = self.compiler_so if sys.platform == 'darwin': - compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) + compiler_so = _osx_support.compiler_fixup(compiler_so, + cc_args + extra_postargs) try: self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) @@ -251,7 +193,7 @@ linker[i] = self.compiler_cxx[i] if sys.platform == 'darwin': - linker = _darwin_compiler_fixup(linker, ld_args) + linker = _osx_support.compiler_fixup(linker, ld_args) self.spawn(linker + ld_args) except DistutilsExecError, msg: diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -93,94 +93,10 @@ if m: release = m.group() elif osname[:6] == "darwin": - # - # For our purposes, we'll assume that the system version from - # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set - # to. This makes the compatibility story a bit more sane because the - # machine is going to compile and link as if it were - # MACOSX_DEPLOYMENT_TARGET. - from distutils.sysconfig import get_config_vars - cfgvars = get_config_vars() - - macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') - - if 1: - # Always calculate the release of the running machine, - # needed to determine if we can build fat binaries or not. - - macrelease = macver - # Get the system version. Reading this plist is a documented - # way to get the system version (see the documentation for - # the Gestalt Manager) - try: - f = open('/System/Library/CoreServices/SystemVersion.plist') - except IOError: - # We're on a plain darwin box, fall back to the default - # behaviour. - pass - else: - try: - m = re.search( - r'ProductUserVisibleVersion\s*' + - r'(.*?)', f.read()) - if m is not None: - macrelease = '.'.join(m.group(1).split('.')[:2]) - # else: fall back to the default behaviour - finally: - f.close() - - if not macver: - macver = macrelease - - if macver: - from distutils.sysconfig import get_config_vars - release = macver - osname = "macosx" - - if (macrelease + '.') >= '10.4.' and \ - '-arch' in get_config_vars().get('CFLAGS', '').strip(): - # The universal build will build fat binaries, but not on - # systems before 10.4 - # - # Try to detect 4-way universal builds, those have machine-type - # 'universal' instead of 'fat'. - - machine = 'fat' - cflags = get_config_vars().get('CFLAGS') - - archs = re.findall('-arch\s+(\S+)', cflags) - archs = tuple(sorted(set(archs))) - - if len(archs) == 1: - machine = archs[0] - elif archs == ('i386', 'ppc'): - machine = 'fat' - elif archs == ('i386', 'x86_64'): - machine = 'intel' - elif archs == ('i386', 'ppc', 'x86_64'): - machine = 'fat3' - elif archs == ('ppc64', 'x86_64'): - machine = 'fat64' - elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'): - machine = 'universal' - else: - raise ValueError( - "Don't know machine value for archs=%r"%(archs,)) - - elif machine == 'i386': - # On OSX the machine type returned by uname is always the - # 32-bit variant, even if the executable architecture is - # the 64-bit variant - if sys.maxint >= 2**32: - machine = 'x86_64' - - elif machine in ('PowerPC', 'Power_Macintosh'): - # Pick a sane name for the PPC architecture. - machine = 'ppc' - - # See 'i386' case - if sys.maxint >= 2**32: - machine = 'ppc64' + import _osx_support, distutils.sysconfig + osname, release, machine = _osx_support.get_platform_osx( + distutils.sysconfig.get_config_vars(), + osname, release, machine) return "%s-%s-%s" % (osname, release, machine) diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -445,64 +445,11 @@ srcdir = os.path.join(base, _CONFIG_VARS['srcdir']) _CONFIG_VARS['srcdir'] = os.path.normpath(srcdir) + # OS X platforms require special customization to handle + # multi-architecture, multi-os-version installers if sys.platform == 'darwin': - kernel_version = os.uname()[2] # Kernel version (8.4.3) - major_version = int(kernel_version.split('.')[0]) - - if major_version < 8: - # On Mac OS X before 10.4, check if -arch and -isysroot - # are in CFLAGS or LDFLAGS and remove them if they are. - # This is needed when building extensions on a 10.3 system - # using a universal build of python. - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - flags = _CONFIG_VARS[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags) - flags = re.sub('-isysroot [^ \t]*', ' ', flags) - _CONFIG_VARS[key] = flags - else: - # Allow the user to override the architecture flags using - # an environment variable. - # NOTE: This name was introduced by Apple in OSX 10.5 and - # is used by several scripting languages distributed with - # that OS release. - if 'ARCHFLAGS' in os.environ: - arch = os.environ['ARCHFLAGS'] - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - - flags = _CONFIG_VARS[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags) - flags = flags + ' ' + arch - _CONFIG_VARS[key] = flags - - # If we're on OSX 10.5 or later and the user tries to - # compiles an extension using an SDK that is not present - # on the current machine it is better to not use an SDK - # than to fail. - # - # The major usecase for this is users using a Python.org - # binary installer on OSX 10.6: that installer uses - # the 10.4u SDK, but that SDK is not installed by default - # when you install Xcode. - # - CFLAGS = _CONFIG_VARS.get('CFLAGS', '') - m = re.search('-isysroot\s+(\S+)', CFLAGS) - if m is not None: - sdk = m.group(1) - if not os.path.exists(sdk): - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - - flags = _CONFIG_VARS[key] - flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags) - _CONFIG_VARS[key] = flags + import _osx_support + _osx_support.customize_config_vars(_CONFIG_VARS) if args: vals = [] @@ -600,91 +547,10 @@ if m: release = m.group() elif osname[:6] == "darwin": - # - # For our purposes, we'll assume that the system version from - # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set - # to. This makes the compatibility story a bit more sane because the - # machine is going to compile and link as if it were - # MACOSX_DEPLOYMENT_TARGET. - cfgvars = get_config_vars() - macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') - - if 1: - # Always calculate the release of the running machine, - # needed to determine if we can build fat binaries or not. - - macrelease = macver - # Get the system version. Reading this plist is a documented - # way to get the system version (see the documentation for - # the Gestalt Manager) - try: - f = open('/System/Library/CoreServices/SystemVersion.plist') - except IOError: - # We're on a plain darwin box, fall back to the default - # behaviour. - pass - else: - try: - m = re.search( - r'ProductUserVisibleVersion\s*' + - r'(.*?)', f.read()) - if m is not None: - macrelease = '.'.join(m.group(1).split('.')[:2]) - # else: fall back to the default behaviour - finally: - f.close() - - if not macver: - macver = macrelease - - if macver: - release = macver - osname = "macosx" - - if (macrelease + '.') >= '10.4.' and \ - '-arch' in get_config_vars().get('CFLAGS', '').strip(): - # The universal build will build fat binaries, but not on - # systems before 10.4 - # - # Try to detect 4-way universal builds, those have machine-type - # 'universal' instead of 'fat'. - - machine = 'fat' - cflags = get_config_vars().get('CFLAGS') - - archs = re.findall('-arch\s+(\S+)', cflags) - archs = tuple(sorted(set(archs))) - - if len(archs) == 1: - machine = archs[0] - elif archs == ('i386', 'ppc'): - machine = 'fat' - elif archs == ('i386', 'x86_64'): - machine = 'intel' - elif archs == ('i386', 'ppc', 'x86_64'): - machine = 'fat3' - elif archs == ('ppc64', 'x86_64'): - machine = 'fat64' - elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'): - machine = 'universal' - else: - raise ValueError( - "Don't know machine value for archs=%r"%(archs,)) - - elif machine == 'i386': - # On OSX the machine type returned by uname is always the - # 32-bit variant, even if the executable architecture is - # the 64-bit variant - if sys.maxint >= 2**32: - machine = 'x86_64' - - elif machine in ('PowerPC', 'Power_Macintosh'): - # Pick a sane name for the PPC architecture. - # See 'i386' case - if sys.maxint >= 2**32: - machine = 'ppc64' - else: - machine = 'ppc' + import _osx_support + osname, release, machine = _osx_support.get_platform_osx( + get_config_vars(), + osname, release, machine) return "%s-%s-%s" % (osname, release, machine) diff --git a/Lib/test/test__osx_support.py b/Lib/test/test__osx_support.py new file mode 100644 --- /dev/null +++ b/Lib/test/test__osx_support.py @@ -0,0 +1,279 @@ +""" +Test suite for _osx_support: shared OS X support functions. +""" + +import os +import platform +import shutil +import stat +import sys +import unittest + +import test.test_support + +import _osx_support + + at unittest.skipUnless(sys.platform.startswith("darwin"), "requires OS X") +class Test_OSXSupport(unittest.TestCase): + + def setUp(self): + self.maxDiff = None + self.prog_name = 'bogus_program_xxxx' + self.temp_path_dir = os.path.abspath(os.getcwd()) + self.env = test.test_support.EnvironmentVarGuard() + self.addCleanup(self.env.__exit__) + for cv in ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', + 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'CC', + 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS', + 'PY_CORE_CFLAGS'): + if cv in self.env: + self.env.unset(cv) + + def add_expected_saved_initial_values(self, config_vars, expected_vars): + # Ensure that the initial values for all modified config vars + # are also saved with modified keys. + expected_vars.update(('_OSX_SUPPORT_INITIAL_'+ k, + config_vars[k]) for k in config_vars + if config_vars[k] != expected_vars[k]) + + def test__find_executable(self): + if self.env['PATH']: + self.env['PATH'] = self.env['PATH'] + ':' + self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir) + test.test_support.unlink(self.prog_name) + self.assertIsNone(_osx_support._find_executable(self.prog_name)) + self.addCleanup(test.test_support.unlink, self.prog_name) + with open(self.prog_name, 'w') as f: + f.write("#!/bin/sh\n/bin/echo OK\n") + os.chmod(self.prog_name, stat.S_IRWXU) + self.assertEqual(self.prog_name, + _osx_support._find_executable(self.prog_name)) + + def test__read_output(self): + if self.env['PATH']: + self.env['PATH'] = self.env['PATH'] + ':' + self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir) + test.test_support.unlink(self.prog_name) + self.addCleanup(test.test_support.unlink, self.prog_name) + with open(self.prog_name, 'w') as f: + f.write("#!/bin/sh\n/bin/echo ExpectedOutput\n") + os.chmod(self.prog_name, stat.S_IRWXU) + self.assertEqual('ExpectedOutput', + _osx_support._read_output(self.prog_name)) + + def test__find_build_tool(self): + out = _osx_support._find_build_tool('cc') + self.assertTrue(os.path.isfile(out), + 'cc not found - check xcode-select') + + def test__get_system_version(self): + self.assertTrue(platform.mac_ver()[0].startswith( + _osx_support._get_system_version())) + + def test__remove_original_values(self): + config_vars = { + 'CC': 'gcc-test -pthreads', + } + expected_vars = { + 'CC': 'clang -pthreads', + } + cv = 'CC' + newvalue = 'clang -pthreads' + _osx_support._save_modified_value(config_vars, cv, newvalue) + self.assertNotEqual(expected_vars, config_vars) + _osx_support._remove_original_values(config_vars) + self.assertEqual(expected_vars, config_vars) + + def test__save_modified_value(self): + config_vars = { + 'CC': 'gcc-test -pthreads', + } + expected_vars = { + 'CC': 'clang -pthreads', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + cv = 'CC' + newvalue = 'clang -pthreads' + _osx_support._save_modified_value(config_vars, cv, newvalue) + self.assertEqual(expected_vars, config_vars) + + def test__save_modified_value_unchanged(self): + config_vars = { + 'CC': 'gcc-test -pthreads', + } + expected_vars = config_vars.copy() + cv = 'CC' + newvalue = 'gcc-test -pthreads' + _osx_support._save_modified_value(config_vars, cv, newvalue) + self.assertEqual(expected_vars, config_vars) + + def test__supports_universal_builds(self): + import platform + self.assertEqual(platform.mac_ver()[0].split('.') >= ['10', '4'], + _osx_support._supports_universal_builds()) + + def test__find_appropriate_compiler(self): + compilers = ( + ('gcc-test', 'i686-apple-darwin11-llvm-gcc-4.2'), + ('clang', 'clang version 3.1'), + ) + config_vars = { + 'CC': 'gcc-test -pthreads', + 'CXX': 'cc++-test', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-test -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-test -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CC': 'clang -pthreads', + 'CXX': 'clang++', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'clang -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'clang -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + suffix = (':' + self.env['PATH']) if self.env['PATH'] else '' + self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix + for c_name, c_output in compilers: + test.test_support.unlink(c_name) + self.addCleanup(test.test_support.unlink, c_name) + with open(c_name, 'w') as f: + f.write("#!/bin/sh\n/bin/echo " + c_output) + os.chmod(c_name, stat.S_IRWXU) + self.assertEqual(expected_vars, + _osx_support._find_appropriate_compiler( + config_vars)) + + def test__remove_universal_flags(self): + config_vars = { + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CFLAGS': '-fno-strict-aliasing -g -O3 ', + 'LDFLAGS': ' -g', + 'CPPFLAGS': '-I. ', + 'BLDSHARED': 'gcc-4.0 -bundle -g', + 'LDSHARED': 'gcc-4.0 -bundle -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + self.assertEqual(expected_vars, + _osx_support._remove_universal_flags( + config_vars)) + + def test__remove_unsupported_archs(self): + config_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch i386 ', + 'LDFLAGS': ' -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + suffix = (':' + self.env['PATH']) if self.env['PATH'] else '' + self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix + c_name = 'clang' + test.test_support.unlink(c_name) + self.addCleanup(test.test_support.unlink, c_name) + # exit status 255 means no PPC support in this compiler chain + with open(c_name, 'w') as f: + f.write("#!/bin/sh\nexit 255") + os.chmod(c_name, stat.S_IRWXU) + self.assertEqual(expected_vars, + _osx_support._remove_unsupported_archs( + config_vars)) + + def test__override_all_archs(self): + self.env['ARCHFLAGS'] = '-arch x86_64' + config_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch x86_64', + 'LDFLAGS': ' -g -arch x86_64', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -g -arch x86_64', + 'LDSHARED': 'gcc-4.0 -bundle -isysroot ' + '/Developer/SDKs/MacOSX10.4u.sdk -g -arch x86_64', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + self.assertEqual(expected_vars, + _osx_support._override_all_archs( + config_vars)) + + def test__check_for_unavailable_sdk(self): + config_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.1.sdk', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.1.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.1.sdk -g', + } + expected_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ' + ' ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. ', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + ' -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + self.assertEqual(expected_vars, + _osx_support._check_for_unavailable_sdk( + config_vars)) + + def test_get_platform_osx(self): + # Note, get_platform_osx is currently tested more extensively + # indirectly by test_sysconfig and test_distutils + config_vars = { + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.1.sdk', + 'MACOSX_DEPLOYMENT_TARGET': '10.6', + } + result = _osx_support.get_platform_osx(config_vars, ' ', ' ', ' ') + self.assertEqual(('macosx', '10.6', 'fat'), result) + +def test_main(): + if sys.platform == 'darwin': + test.test_support.run_unittest(Test_OSXSupport) + +if __name__ == "__main__": + test_main() diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -14,6 +14,7 @@ get_path, get_path_names, _INSTALL_SCHEMES, _get_default_scheme, _expand_vars, get_scheme_names, get_config_var) +import _osx_support class TestSysConfig(unittest.TestCase): @@ -137,6 +138,7 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC')) + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' @@ -156,6 +158,7 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' @@ -171,6 +174,7 @@ sys.maxint = maxint # macbook with fat binaries (fat, universal or fat64) + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' @@ -179,6 +183,7 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -186,18 +191,21 @@ self.assertEqual(get_platform(), 'macosx-10.4-intel') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-fat3') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-universal') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -206,6 +214,7 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat64') for arch in ('ppc', 'i386', 'x86_64', 'ppc64'): + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch %s -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -679,6 +679,21 @@ - Issue #16012: Fix a regression in pyexpat. The parser's UseForeignDTD() method doesn't require an argument again. +- Issue #13590: OS X Xcode 4 - improve support for universal extension modules + In particular, fix extension module build failures when trying to use + 32-bit-only installer Pythons on systems with Xcode 4 (currently + OS X 10.8, 10.7, and optionally 10.6). + * Backport 3.3.0 fixes to 2.7 branch (for release in 2.7.4) + * Since Xcode 4 removes ppc support, extension module builds now + check for ppc compiler support and by default remove ppc and + ppc64 archs when they are not available. + * Extension module builds now revert to using system installed + headers and libs (/usr and /System/Library) if the SDK used + to build the interpreter is not installed or has moved. + * Try to avoid building extension modules with deprecated + and problematic Apple llvm-gcc compiler. If original compiler + is not available, use clang instead by default. + Tests ----- -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 10:37:52 2013 From: python-checkins at python.org (ned.deily) Date: Thu, 31 Jan 2013 10:37:52 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzEzNTkw?= =?utf-8?q?=3A_OS_X_Xcode_4_-_improve_support_for_universal_extension_modu?= =?utf-8?q?les?= Message-ID: <3Yxbw00RZDzPhX@mail.python.org> http://hg.python.org/cpython/rev/502b139b3b19 changeset: 81844:502b139b3b19 branch: 3.2 parent: 81837:48c5c632d212 user: Ned Deily date: Thu Jan 31 01:28:23 2013 -0800 summary: Issue #13590: OS X Xcode 4 - improve support for universal extension modules In particular, fix extension module build failures when trying to use 32-bit-only installer Pythons on systems with Xcode 4 (currently OS X 10.8, 10.7, and optionally 10.6). * Backport 3.3.0 fixes to 3.2 branch (for release in 3.2.4) * Since Xcode 4 removes ppc support, extension module builds now check for ppc compiler support and by default remove ppc and ppc64 archs when they are not available. * Extension module builds now revert to using system installed headers and libs (/usr and /System/Library) if the SDK used to build the interpreter is not installed or has moved. * Try to avoid building extension modules with deprecated and problematic Apple llvm-gcc compiler. If original compiler is not available, use clang instead by default. files: Lib/_osx_support.py | 488 ++++++++++++++ Lib/distutils/sysconfig.py | 88 +- Lib/distutils/tests/test_sysconfig.py | 22 +- Lib/distutils/tests/test_util.py | 9 + Lib/distutils/unixccompiler.py | 70 +- Lib/distutils/util.py | 92 +-- Lib/sysconfig.py | 151 +---- Lib/test/test__osx_support.py | 279 ++++++++ Lib/test/test_sysconfig.py | 17 +- Misc/NEWS | 15 + 10 files changed, 862 insertions(+), 369 deletions(-) diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py new file mode 100644 --- /dev/null +++ b/Lib/_osx_support.py @@ -0,0 +1,488 @@ +"""Shared OS X support functions.""" + +import os +import re +import sys + +__all__ = [ + 'compiler_fixup', + 'customize_config_vars', + 'customize_compiler', + 'get_platform_osx', +] + +# configuration variables that may contain universal build flags, +# like "-arch" or "-isdkroot", that may need customization for +# the user environment +_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS', + 'BLDSHARED', 'LDSHARED', 'CC', 'CXX', + 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS', + 'PY_CORE_CFLAGS') + +# configuration variables that may contain compiler calls +_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX') + +# prefix added to original configuration variable names +_INITPRE = '_OSX_SUPPORT_INITIAL_' + + +def _find_executable(executable, path=None): + """Tries to find 'executable' in the directories listed in 'path'. + + A string listing directories separated by 'os.pathsep'; defaults to + os.environ['PATH']. Returns the complete filename or None if not found. + """ + if path is None: + path = os.environ['PATH'] + + paths = path.split(os.pathsep) + base, ext = os.path.splitext(executable) + + if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'): + executable = executable + '.exe' + + if not os.path.isfile(executable): + for p in paths: + f = os.path.join(p, executable) + if os.path.isfile(f): + # the file exists, we have a shot at spawn working + return f + return None + else: + return executable + + +def _read_output(commandstring): + """Output from succesful command execution or None""" + # Similar to os.popen(commandstring, "r").read(), + # but without actually using os.popen because that + # function is not usable during python bootstrap. + # tempfile is also not available then. + import contextlib + try: + import tempfile + fp = tempfile.NamedTemporaryFile() + except ImportError: + fp = open("/tmp/_osx_support.%s"%( + os.getpid(),), "w+b") + + with contextlib.closing(fp) as fp: + cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name) + return fp.read().decode('utf-8').strip() if not os.system(cmd) else None + + +def _find_build_tool(toolname): + """Find a build tool on current path or using xcrun""" + return (_find_executable(toolname) + or _read_output("/usr/bin/xcrun -find %s" % (toolname,)) + or '' + ) + +_SYSTEM_VERSION = None + +def _get_system_version(): + """Return the OS X system version as a string""" + # Reading this plist is a documented way to get the system + # version (see the documentation for the Gestalt Manager) + # We avoid using platform.mac_ver to avoid possible bootstrap issues during + # the build of Python itself (distutils is used to build standard library + # extensions). + + global _SYSTEM_VERSION + + if _SYSTEM_VERSION is None: + _SYSTEM_VERSION = '' + try: + f = open('/System/Library/CoreServices/SystemVersion.plist') + except IOError: + # We're on a plain darwin box, fall back to the default + # behaviour. + pass + else: + try: + m = re.search(r'ProductUserVisibleVersion\s*' + r'(.*?)', f.read()) + finally: + f.close() + if m is not None: + _SYSTEM_VERSION = '.'.join(m.group(1).split('.')[:2]) + # else: fall back to the default behaviour + + return _SYSTEM_VERSION + +def _remove_original_values(_config_vars): + """Remove original unmodified values for testing""" + # This is needed for higher-level cross-platform tests of get_platform. + for k in list(_config_vars): + if k.startswith(_INITPRE): + del _config_vars[k] + +def _save_modified_value(_config_vars, cv, newvalue): + """Save modified and original unmodified value of configuration var""" + + oldvalue = _config_vars.get(cv, '') + if (oldvalue != newvalue) and (_INITPRE + cv not in _config_vars): + _config_vars[_INITPRE + cv] = oldvalue + _config_vars[cv] = newvalue + +def _supports_universal_builds(): + """Returns True if universal builds are supported on this system""" + # As an approximation, we assume that if we are running on 10.4 or above, + # then we are running with an Xcode environment that supports universal + # builds, in particular -isysroot and -arch arguments to the compiler. This + # is in support of allowing 10.4 universal builds to run on 10.3.x systems. + + osx_version = _get_system_version() + if osx_version: + try: + osx_version = tuple(int(i) for i in osx_version.split('.')) + except ValueError: + osx_version = '' + return bool(osx_version >= (10, 4)) if osx_version else False + + +def _find_appropriate_compiler(_config_vars): + """Find appropriate C compiler for extension module builds""" + + # Issue #13590: + # The OSX location for the compiler varies between OSX + # (or rather Xcode) releases. With older releases (up-to 10.5) + # the compiler is in /usr/bin, with newer releases the compiler + # can only be found inside Xcode.app if the "Command Line Tools" + # are not installed. + # + # Futhermore, the compiler that can be used varies between + # Xcode releases. Upto Xcode 4 it was possible to use 'gcc-4.2' + # as the compiler, after that 'clang' should be used because + # gcc-4.2 is either not present, or a copy of 'llvm-gcc' that + # miscompiles Python. + + # skip checks if the compiler was overriden with a CC env variable + if 'CC' in os.environ: + return _config_vars + + # The CC config var might contain additional arguments. + # Ignore them while searching. + cc = oldcc = _config_vars['CC'].split()[0] + if not _find_executable(cc): + # Compiler is not found on the shell search PATH. + # Now search for clang, first on PATH (if the Command LIne + # Tools have been installed in / or if the user has provided + # another location via CC). If not found, try using xcrun + # to find an uninstalled clang (within a selected Xcode). + + # NOTE: Cannot use subprocess here because of bootstrap + # issues when building Python itself (and os.popen is + # implemented on top of subprocess and is therefore not + # usable as well) + + cc = _find_build_tool('clang') + + elif os.path.basename(cc).startswith('gcc'): + # Compiler is GCC, check if it is LLVM-GCC + data = _read_output("'%s' --version" + % (cc.replace("'", "'\"'\"'"),)) + if 'llvm-gcc' in data: + # Found LLVM-GCC, fall back to clang + cc = _find_build_tool('clang') + + if not cc: + raise SystemError( + "Cannot locate working compiler") + + if cc != oldcc: + # Found a replacement compiler. + # Modify config vars using new compiler, if not already explictly + # overriden by an env variable, preserving additional arguments. + for cv in _COMPILER_CONFIG_VARS: + if cv in _config_vars and cv not in os.environ: + cv_split = _config_vars[cv].split() + cv_split[0] = cc if cv != 'CXX' else cc + '++' + _save_modified_value(_config_vars, cv, ' '.join(cv_split)) + + return _config_vars + + +def _remove_universal_flags(_config_vars): + """Remove all universal build arguments from config vars""" + + for cv in _UNIVERSAL_CONFIG_VARS: + # Do not alter a config var explicitly overriden by env var + if cv in _config_vars and cv not in os.environ: + flags = _config_vars[cv] + flags = re.sub('-arch\s+\w+\s', ' ', flags, re.ASCII) + flags = re.sub('-isysroot [^ \t]*', ' ', flags) + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def _remove_unsupported_archs(_config_vars): + """Remove any unsupported archs from config vars""" + # Different Xcode releases support different sets for '-arch' + # flags. In particular, Xcode 4.x no longer supports the + # PPC architectures. + # + # This code automatically removes '-arch ppc' and '-arch ppc64' + # when these are not supported. That makes it possible to + # build extensions on OSX 10.7 and later with the prebuilt + # 32-bit installer on the python.org website. + + # skip checks if the compiler was overriden with a CC env variable + if 'CC' in os.environ: + return _config_vars + + if re.search('-arch\s+ppc', _config_vars['CFLAGS']) is not None: + # NOTE: Cannot use subprocess here because of bootstrap + # issues when building Python itself + status = os.system("'%s' -arch ppc -x c /dev/null 2>/dev/null"%( + _config_vars['CC'].replace("'", "'\"'\"'"),)) + # The Apple compiler drivers return status 255 if no PPC + if (status >> 8) == 255: + # Compiler doesn't support PPC, remove the related + # '-arch' flags if not explicitly overridden by an + # environment variable + for cv in _UNIVERSAL_CONFIG_VARS: + if cv in _config_vars and cv not in os.environ: + flags = _config_vars[cv] + flags = re.sub('-arch\s+ppc\w*\s', ' ', flags) + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def _override_all_archs(_config_vars): + """Allow override of all archs with ARCHFLAGS env var""" + # NOTE: This name was introduced by Apple in OSX 10.5 and + # is used by several scripting languages distributed with + # that OS release. + if 'ARCHFLAGS' in os.environ: + arch = os.environ['ARCHFLAGS'] + for cv in _UNIVERSAL_CONFIG_VARS: + if cv in _config_vars and '-arch' in _config_vars[cv]: + flags = _config_vars[cv] + flags = re.sub('-arch\s+\w+\s', ' ', flags) + flags = flags + ' ' + arch + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def _check_for_unavailable_sdk(_config_vars): + """Remove references to any SDKs not available""" + # If we're on OSX 10.5 or later and the user tries to + # compile an extension using an SDK that is not present + # on the current machine it is better to not use an SDK + # than to fail. This is particularly important with + # the standalong Command Line Tools alternative to a + # full-blown Xcode install since the CLT packages do not + # provide SDKs. If the SDK is not present, it is assumed + # that the header files and dev libs have been installed + # to /usr and /System/Library by either a standalone CLT + # package or the CLT component within Xcode. + cflags = _config_vars.get('CFLAGS', '') + m = re.search(r'-isysroot\s+(\S+)', cflags) + if m is not None: + sdk = m.group(1) + if not os.path.exists(sdk): + for cv in _UNIVERSAL_CONFIG_VARS: + # Do not alter a config var explicitly overriden by env var + if cv in _config_vars and cv not in os.environ: + flags = _config_vars[cv] + flags = re.sub(r'-isysroot\s+\S+(?:\s|$)', ' ', flags) + _save_modified_value(_config_vars, cv, flags) + + return _config_vars + + +def compiler_fixup(compiler_so, cc_args): + """ + This function will strip '-isysroot PATH' and '-arch ARCH' from the + compile flags if the user has specified one them in extra_compile_flags. + + This is needed because '-arch ARCH' adds another architecture to the + build, without a way to remove an architecture. Furthermore GCC will + barf if multiple '-isysroot' arguments are present. + """ + stripArch = stripSysroot = False + + compiler_so = list(compiler_so) + + if not _supports_universal_builds(): + # OSX before 10.4.0, these don't support -arch and -isysroot at + # all. + stripArch = stripSysroot = True + else: + stripArch = '-arch' in cc_args + stripSysroot = '-isysroot' in cc_args + + if stripArch or 'ARCHFLAGS' in os.environ: + while True: + try: + index = compiler_so.index('-arch') + # Strip this argument and the next one: + del compiler_so[index:index+2] + except ValueError: + break + + if 'ARCHFLAGS' in os.environ and not stripArch: + # User specified different -arch flags in the environ, + # see also distutils.sysconfig + compiler_so = compiler_so + os.environ['ARCHFLAGS'].split() + + if stripSysroot: + while True: + try: + index = compiler_so.index('-isysroot') + # Strip this argument and the next one: + del compiler_so[index:index+2] + except ValueError: + break + + # Check if the SDK that is used during compilation actually exists, + # the universal build requires the usage of a universal SDK and not all + # users have that installed by default. + sysroot = None + if '-isysroot' in cc_args: + idx = cc_args.index('-isysroot') + sysroot = cc_args[idx+1] + elif '-isysroot' in compiler_so: + idx = compiler_so.index('-isysroot') + sysroot = compiler_so[idx+1] + + if sysroot and not os.path.isdir(sysroot): + from distutils import log + log.warn("Compiling with an SDK that doesn't seem to exist: %s", + sysroot) + log.warn("Please check your Xcode installation") + + return compiler_so + + +def customize_config_vars(_config_vars): + """Customize Python build configuration variables. + + Called internally from sysconfig with a mutable mapping + containing name/value pairs parsed from the configured + makefile used to build this interpreter. Returns + the mapping updated as needed to reflect the environment + in which the interpreter is running; in the case of + a Python from a binary installer, the installed + environment may be very different from the build + environment, i.e. different OS levels, different + built tools, different available CPU architectures. + + This customization is performed whenever + distutils.sysconfig.get_config_vars() is first + called. It may be used in environments where no + compilers are present, i.e. when installing pure + Python dists. Customization of compiler paths + and detection of unavailable archs is deferred + until the first extention module build is + requested (in distutils.sysconfig.customize_compiler). + + Currently called from distutils.sysconfig + """ + + if not _supports_universal_builds(): + # On Mac OS X before 10.4, check if -arch and -isysroot + # are in CFLAGS or LDFLAGS and remove them if they are. + # This is needed when building extensions on a 10.3 system + # using a universal build of python. + _remove_universal_flags(_config_vars) + + # Allow user to override all archs with ARCHFLAGS env var + _override_all_archs(_config_vars) + + # Remove references to sdks that are not found + _check_for_unavailable_sdk(_config_vars) + + return _config_vars + + +def customize_compiler(_config_vars): + """Customize compiler path and configuration variables. + + This customization is performed when the first + extension module build is requested + in distutils.sysconfig.customize_compiler). + """ + + # Find a compiler to use for extension module builds + _find_appropriate_compiler(_config_vars) + + # Remove ppc arch flags if not supported here + _remove_unsupported_archs(_config_vars) + + # Allow user to override all archs with ARCHFLAGS env var + _override_all_archs(_config_vars) + + return _config_vars + + +def get_platform_osx(_config_vars, osname, release, machine): + """Filter values for get_platform()""" + # called from get_platform() in sysconfig and distutils.util + # + # For our purposes, we'll assume that the system version from + # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set + # to. This makes the compatibility story a bit more sane because the + # machine is going to compile and link as if it were + # MACOSX_DEPLOYMENT_TARGET. + + macver = _config_vars.get('MACOSX_DEPLOYMENT_TARGET', '') + macrelease = _get_system_version() or macver + macver = macver or macrelease + + if macver: + release = macver + osname = "macosx" + + # Use the original CFLAGS value, if available, so that we + # return the same machine type for the platform string. + # Otherwise, distutils may consider this a cross-compiling + # case and disallow installs. + cflags = _config_vars.get(_INITPRE+'CFLAGS', + _config_vars.get('CFLAGS', '')) + if ((macrelease + '.') >= '10.4.' and + '-arch' in cflags.strip()): + # The universal build will build fat binaries, but not on + # systems before 10.4 + + machine = 'fat' + + archs = re.findall('-arch\s+(\S+)', cflags) + archs = tuple(sorted(set(archs))) + + if len(archs) == 1: + machine = archs[0] + elif archs == ('i386', 'ppc'): + machine = 'fat' + elif archs == ('i386', 'x86_64'): + machine = 'intel' + elif archs == ('i386', 'ppc', 'x86_64'): + machine = 'fat3' + elif archs == ('ppc64', 'x86_64'): + machine = 'fat64' + elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'): + machine = 'universal' + else: + raise ValueError( + "Don't know machine value for archs=%r" % (archs,)) + + elif machine == 'i386': + # On OSX the machine type returned by uname is always the + # 32-bit variant, even if the executable architecture is + # the 64-bit variant + if sys.maxsize >= 2**32: + machine = 'x86_64' + + elif machine in ('PowerPC', 'Power_Macintosh'): + # Pick a sane name for the PPC architecture. + # See 'i386' case + if sys.maxsize >= 2**32: + machine = 'ppc64' + else: + machine = 'ppc' + + return (osname, release, machine) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -146,7 +146,7 @@ "I don't know where Python installs its library " "on platform '%s'" % os.name) -_USE_CLANG = None + def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. @@ -155,42 +155,28 @@ varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": + if sys.platform == "darwin": + # Perform first-time customization of compiler-related + # config vars on OS X now that we know we need a compiler. + # This is primarily to support Pythons from binary + # installers. The kind and paths to build tools on + # the user system may vary significantly from the system + # that Python itself was built on. Also the user OS + # version and build tools may not support the same set + # of CPU architectures for universal builds. + global _config_vars + if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): + import _osx_support + _osx_support.customize_compiler(_config_vars) + _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' + (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') newcc = None if 'CC' in os.environ: - newcc = os.environ['CC'] - elif sys.platform == 'darwin' and cc == 'gcc-4.2': - # Issue #13590: - # Since Apple removed gcc-4.2 in Xcode 4.2, we can no - # longer assume it is available for extension module builds. - # If Python was built with gcc-4.2, check first to see if - # it is available on this system; if not, try to use clang - # instead unless the caller explicitly set CC. - global _USE_CLANG - if _USE_CLANG is None: - from distutils import log - from subprocess import Popen, PIPE - p = Popen("! type gcc-4.2 && type clang && exit 2", - shell=True, stdout=PIPE, stderr=PIPE) - p.wait() - if p.returncode == 2: - _USE_CLANG = True - log.warn("gcc-4.2 not found, using clang instead") - else: - _USE_CLANG = False - if _USE_CLANG: - newcc = 'clang' - if newcc: - # On OS X, if CC is overridden, use that as the default - # command for LDSHARED as well - if (sys.platform == 'darwin' - and 'LDSHARED' not in os.environ - and ldshared.startswith(cc)): - ldshared = newcc + ldshared[len(cc):] - cc = newcc + cc = os.environ['CC'] if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: @@ -543,43 +529,11 @@ srcdir = os.path.join(base, _config_vars['srcdir']) _config_vars['srcdir'] = os.path.normpath(srcdir) + # OS X platforms require special customization to handle + # multi-architecture, multi-os-version installers if sys.platform == 'darwin': - kernel_version = os.uname()[2] # Kernel version (8.4.3) - major_version = int(kernel_version.split('.')[0]) - - if major_version < 8: - # On Mac OS X before 10.4, check if -arch and -isysroot - # are in CFLAGS or LDFLAGS and remove them if they are. - # This is needed when building extensions on a 10.3 system - # using a universal build of python. - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - flags = _config_vars[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags, re.ASCII) - flags = re.sub('-isysroot [^ \t]*', ' ', flags) - _config_vars[key] = flags - - else: - - # Allow the user to override the architecture flags using - # an environment variable. - # NOTE: This name was introduced by Apple in OSX 10.5 and - # is used by several scripting languages distributed with - # that OS release. - - if 'ARCHFLAGS' in os.environ: - arch = os.environ['ARCHFLAGS'] - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - - flags = _config_vars[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags) - flags = flags + ' ' + arch - _config_vars[key] = flags + import _osx_support + _osx_support.customize_config_vars(_config_vars) if args: vals = [] diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -102,7 +102,27 @@ import sysconfig as global_sysconfig self.assertEqual(global_sysconfig.get_config_var('CFLAGS'), sysconfig.get_config_var('CFLAGS')) self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'), sysconfig.get_config_var('LDFLAGS')) - self.assertEqual(global_sysconfig.get_config_var('LDSHARED'),sysconfig.get_config_var('LDSHARED')) + + @unittest.skipIf(sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'),'compiler flags customized') + def test_sysconfig_compiler_vars(self): + # On OS X, binary installers support extension module building on + # various levels of the operating system with differing Xcode + # configurations. This requires customization of some of the + # compiler configuration directives to suit the environment on + # the installed machine. Some of these customizations may require + # running external programs and, so, are deferred until needed by + # the first extension module build. With Python 3.3, only + # the Distutils version of sysconfig is used for extension module + # builds, which happens earlier in the Distutils tests. This may + # cause the following tests to fail since no tests have caused + # the global version of sysconfig to call the customization yet. + # The solution for now is to simply skip this test in this case. + # The longer-term solution is to only have one version of sysconfig. + + import sysconfig as global_sysconfig + if sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'): + return + self.assertEqual(global_sysconfig.get_config_var('LDSHARED'), sysconfig.get_config_var('LDSHARED')) self.assertEqual(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC')) diff --git a/Lib/distutils/tests/test_util.py b/Lib/distutils/tests/test_util.py --- a/Lib/distutils/tests/test_util.py +++ b/Lib/distutils/tests/test_util.py @@ -13,6 +13,7 @@ from distutils.sysconfig import get_config_vars from distutils import sysconfig from distutils.tests import support +import _osx_support class UtilTestCase(support.EnvironGuard, unittest.TestCase): @@ -92,6 +93,7 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' @@ -105,6 +107,7 @@ sys.maxsize = cursize # macbook with fat binaries (fat, universal or fat64) + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' @@ -113,10 +116,12 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat') + _osx_support._remove_original_values(get_config_vars()) os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.1' self.assertEqual(get_platform(), 'macosx-10.4-fat') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -124,18 +129,21 @@ self.assertEqual(get_platform(), 'macosx-10.4-intel') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-fat3') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-universal') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -144,6 +152,7 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat64') for arch in ('ppc', 'i386', 'x86_64', 'ppc64'): + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch %s -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -23,6 +23,9 @@ DistutilsExecError, CompileError, LibError, LinkError from distutils import log +if sys.platform == 'darwin': + import _osx_support + # XXX Things not currently handled: # * optimization/debug/warning flags; we just use whatever's in Python's # Makefile and live with it. Is this adequate? If not, we might @@ -38,68 +41,6 @@ # should just happily stuff them into the preprocessor/compiler/linker # options and carry on. -def _darwin_compiler_fixup(compiler_so, cc_args): - """ - This function will strip '-isysroot PATH' and '-arch ARCH' from the - compile flags if the user has specified one them in extra_compile_flags. - - This is needed because '-arch ARCH' adds another architecture to the - build, without a way to remove an architecture. Furthermore GCC will - barf if multiple '-isysroot' arguments are present. - """ - stripArch = stripSysroot = False - - compiler_so = list(compiler_so) - kernel_version = os.uname()[2] # 8.4.3 - major_version = int(kernel_version.split('.')[0]) - - if major_version < 8: - # OSX before 10.4.0, these don't support -arch and -isysroot at - # all. - stripArch = stripSysroot = True - else: - stripArch = '-arch' in cc_args - stripSysroot = '-isysroot' in cc_args - - if stripArch or 'ARCHFLAGS' in os.environ: - while True: - try: - index = compiler_so.index('-arch') - # Strip this argument and the next one: - del compiler_so[index:index+2] - except ValueError: - break - - if 'ARCHFLAGS' in os.environ and not stripArch: - # User specified different -arch flags in the environ, - # see also distutils.sysconfig - compiler_so = compiler_so + os.environ['ARCHFLAGS'].split() - - if stripSysroot: - try: - index = compiler_so.index('-isysroot') - # Strip this argument and the next one: - del compiler_so[index:index+2] - except ValueError: - pass - - # Check if the SDK that is used during compilation actually exists, - # the universal build requires the usage of a universal SDK and not all - # users have that installed by default. - sysroot = None - if '-isysroot' in cc_args: - idx = cc_args.index('-isysroot') - sysroot = cc_args[idx+1] - elif '-isysroot' in compiler_so: - idx = compiler_so.index('-isysroot') - sysroot = compiler_so[idx+1] - - if sysroot and not os.path.isdir(sysroot): - log.warn("Compiling with an SDK that doesn't seem to exist: %s", - sysroot) - log.warn("Please check your Xcode installation") - - return compiler_so class UnixCCompiler(CCompiler): @@ -168,7 +109,8 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): compiler_so = self.compiler_so if sys.platform == 'darwin': - compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) + compiler_so = _osx_support.compiler_fixup(compiler_so, + cc_args + extra_postargs) try: self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) @@ -247,7 +189,7 @@ linker[i] = self.compiler_cxx[i] if sys.platform == 'darwin': - linker = _darwin_compiler_fixup(linker, ld_args) + linker = _osx_support.compiler_fixup(linker, ld_args) self.spawn(linker + ld_args) except DistutilsExecError as msg: diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -94,94 +94,10 @@ if m: release = m.group() elif osname[:6] == "darwin": - # - # For our purposes, we'll assume that the system version from - # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set - # to. This makes the compatibility story a bit more sane because the - # machine is going to compile and link as if it were - # MACOSX_DEPLOYMENT_TARGET. - from distutils.sysconfig import get_config_vars - cfgvars = get_config_vars() - - macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') - - if 1: - # Always calculate the release of the running machine, - # needed to determine if we can build fat binaries or not. - - macrelease = macver - # Get the system version. Reading this plist is a documented - # way to get the system version (see the documentation for - # the Gestalt Manager) - try: - f = open('/System/Library/CoreServices/SystemVersion.plist') - except IOError: - # We're on a plain darwin box, fall back to the default - # behaviour. - pass - else: - try: - m = re.search( - r'ProductUserVisibleVersion\s*' + - r'(.*?)', f.read()) - if m is not None: - macrelease = '.'.join(m.group(1).split('.')[:2]) - # else: fall back to the default behaviour - finally: - f.close() - - if not macver: - macver = macrelease - - if macver: - from distutils.sysconfig import get_config_vars - release = macver - osname = "macosx" - - if (macrelease + '.') >= '10.4.' and \ - '-arch' in get_config_vars().get('CFLAGS', '').strip(): - # The universal build will build fat binaries, but not on - # systems before 10.4 - # - # Try to detect 4-way universal builds, those have machine-type - # 'universal' instead of 'fat'. - - machine = 'fat' - cflags = get_config_vars().get('CFLAGS') - - archs = re.findall('-arch\s+(\S+)', cflags) - archs = tuple(sorted(set(archs))) - - if len(archs) == 1: - machine = archs[0] - elif archs == ('i386', 'ppc'): - machine = 'fat' - elif archs == ('i386', 'x86_64'): - machine = 'intel' - elif archs == ('i386', 'ppc', 'x86_64'): - machine = 'fat3' - elif archs == ('ppc64', 'x86_64'): - machine = 'fat64' - elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'): - machine = 'universal' - else: - raise ValueError( - "Don't know machine value for archs=%r"%(archs,)) - - elif machine == 'i386': - # On OSX the machine type returned by uname is always the - # 32-bit variant, even if the executable architecture is - # the 64-bit variant - if sys.maxsize >= 2**32: - machine = 'x86_64' - - elif machine in ('PowerPC', 'Power_Macintosh'): - # Pick a sane name for the PPC architecture. - machine = 'ppc' - - # See 'i386' case - if sys.maxsize >= 2**32: - machine = 'ppc64' + import _osx_support, distutils.sysconfig + osname, release, machine = _osx_support.get_platform_osx( + distutils.sysconfig.get_config_vars(), + osname, release, machine) return "%s-%s-%s" % (osname, release, machine) diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -501,64 +501,11 @@ srcdir = os.path.join(base, _CONFIG_VARS['srcdir']) _CONFIG_VARS['srcdir'] = os.path.normpath(srcdir) + # OS X platforms require special customization to handle + # multi-architecture, multi-os-version installers if sys.platform == 'darwin': - kernel_version = os.uname()[2] # Kernel version (8.4.3) - major_version = int(kernel_version.split('.')[0]) - - if major_version < 8: - # On Mac OS X before 10.4, check if -arch and -isysroot - # are in CFLAGS or LDFLAGS and remove them if they are. - # This is needed when building extensions on a 10.3 system - # using a universal build of python. - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - flags = _CONFIG_VARS[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags) - flags = re.sub('-isysroot [^ \t]*', ' ', flags) - _CONFIG_VARS[key] = flags - else: - # Allow the user to override the architecture flags using - # an environment variable. - # NOTE: This name was introduced by Apple in OSX 10.5 and - # is used by several scripting languages distributed with - # that OS release. - if 'ARCHFLAGS' in os.environ: - arch = os.environ['ARCHFLAGS'] - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - - flags = _CONFIG_VARS[key] - flags = re.sub('-arch\s+\w+\s', ' ', flags) - flags = flags + ' ' + arch - _CONFIG_VARS[key] = flags - - # If we're on OSX 10.5 or later and the user tries to - # compiles an extension using an SDK that is not present - # on the current machine it is better to not use an SDK - # than to fail. - # - # The major usecase for this is users using a Python.org - # binary installer on OSX 10.6: that installer uses - # the 10.4u SDK, but that SDK is not installed by default - # when you install Xcode. - # - CFLAGS = _CONFIG_VARS.get('CFLAGS', '') - m = re.search('-isysroot\s+(\S+)', CFLAGS) - if m is not None: - sdk = m.group(1) - if not os.path.exists(sdk): - for key in ('LDFLAGS', 'BASECFLAGS', - # a number of derived variables. These need to be - # patched up as well. - 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): - - flags = _CONFIG_VARS[key] - flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags) - _CONFIG_VARS[key] = flags + import _osx_support + _osx_support.customize_config_vars(_CONFIG_VARS) if args: vals = [] @@ -656,92 +603,10 @@ if m: release = m.group() elif osname[:6] == "darwin": - # - # For our purposes, we'll assume that the system version from - # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set - # to. This makes the compatibility story a bit more sane because the - # machine is going to compile and link as if it were - # MACOSX_DEPLOYMENT_TARGET. - # - cfgvars = get_config_vars() - macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET') - - if 1: - # Always calculate the release of the running machine, - # needed to determine if we can build fat binaries or not. - - macrelease = macver - # Get the system version. Reading this plist is a documented - # way to get the system version (see the documentation for - # the Gestalt Manager) - try: - f = open('/System/Library/CoreServices/SystemVersion.plist') - except IOError: - # We're on a plain darwin box, fall back to the default - # behaviour. - pass - else: - try: - m = re.search( - r'ProductUserVisibleVersion\s*' + - r'(.*?)', f.read()) - if m is not None: - macrelease = '.'.join(m.group(1).split('.')[:2]) - # else: fall back to the default behaviour - finally: - f.close() - - if not macver: - macver = macrelease - - if macver: - release = macver - osname = "macosx" - - if (macrelease + '.') >= '10.4.' and \ - '-arch' in get_config_vars().get('CFLAGS', '').strip(): - # The universal build will build fat binaries, but not on - # systems before 10.4 - # - # Try to detect 4-way universal builds, those have machine-type - # 'universal' instead of 'fat'. - - machine = 'fat' - cflags = get_config_vars().get('CFLAGS') - - archs = re.findall('-arch\s+(\S+)', cflags) - archs = tuple(sorted(set(archs))) - - if len(archs) == 1: - machine = archs[0] - elif archs == ('i386', 'ppc'): - machine = 'fat' - elif archs == ('i386', 'x86_64'): - machine = 'intel' - elif archs == ('i386', 'ppc', 'x86_64'): - machine = 'fat3' - elif archs == ('ppc64', 'x86_64'): - machine = 'fat64' - elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'): - machine = 'universal' - else: - raise ValueError( - "Don't know machine value for archs=%r"%(archs,)) - - elif machine == 'i386': - # On OSX the machine type returned by uname is always the - # 32-bit variant, even if the executable architecture is - # the 64-bit variant - if sys.maxsize >= 2**32: - machine = 'x86_64' - - elif machine in ('PowerPC', 'Power_Macintosh'): - # Pick a sane name for the PPC architecture. - # See 'i386' case - if sys.maxsize >= 2**32: - machine = 'ppc64' - else: - machine = 'ppc' + import _osx_support + osname, release, machine = _osx_support.get_platform_osx( + get_config_vars(), + osname, release, machine) return "%s-%s-%s" % (osname, release, machine) diff --git a/Lib/test/test__osx_support.py b/Lib/test/test__osx_support.py new file mode 100644 --- /dev/null +++ b/Lib/test/test__osx_support.py @@ -0,0 +1,279 @@ +""" +Test suite for _osx_support: shared OS X support functions. +""" + +import os +import platform +import shutil +import stat +import sys +import unittest + +import test.support + +import _osx_support + + at unittest.skipUnless(sys.platform.startswith("darwin"), "requires OS X") +class Test_OSXSupport(unittest.TestCase): + + def setUp(self): + self.maxDiff = None + self.prog_name = 'bogus_program_xxxx' + self.temp_path_dir = os.path.abspath(os.getcwd()) + self.env = test.support.EnvironmentVarGuard() + self.addCleanup(self.env.__exit__) + for cv in ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', + 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'CC', + 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS', + 'PY_CORE_CFLAGS'): + if cv in self.env: + self.env.unset(cv) + + def add_expected_saved_initial_values(self, config_vars, expected_vars): + # Ensure that the initial values for all modified config vars + # are also saved with modified keys. + expected_vars.update(('_OSX_SUPPORT_INITIAL_'+ k, + config_vars[k]) for k in config_vars + if config_vars[k] != expected_vars[k]) + + def test__find_executable(self): + if self.env['PATH']: + self.env['PATH'] = self.env['PATH'] + ':' + self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir) + test.support.unlink(self.prog_name) + self.assertIsNone(_osx_support._find_executable(self.prog_name)) + self.addCleanup(test.support.unlink, self.prog_name) + with open(self.prog_name, 'w') as f: + f.write("#!/bin/sh\n/bin/echo OK\n") + os.chmod(self.prog_name, stat.S_IRWXU) + self.assertEqual(self.prog_name, + _osx_support._find_executable(self.prog_name)) + + def test__read_output(self): + if self.env['PATH']: + self.env['PATH'] = self.env['PATH'] + ':' + self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir) + test.support.unlink(self.prog_name) + self.addCleanup(test.support.unlink, self.prog_name) + with open(self.prog_name, 'w') as f: + f.write("#!/bin/sh\n/bin/echo ExpectedOutput\n") + os.chmod(self.prog_name, stat.S_IRWXU) + self.assertEqual('ExpectedOutput', + _osx_support._read_output(self.prog_name)) + + def test__find_build_tool(self): + out = _osx_support._find_build_tool('cc') + self.assertTrue(os.path.isfile(out), + 'cc not found - check xcode-select') + + def test__get_system_version(self): + self.assertTrue(platform.mac_ver()[0].startswith( + _osx_support._get_system_version())) + + def test__remove_original_values(self): + config_vars = { + 'CC': 'gcc-test -pthreads', + } + expected_vars = { + 'CC': 'clang -pthreads', + } + cv = 'CC' + newvalue = 'clang -pthreads' + _osx_support._save_modified_value(config_vars, cv, newvalue) + self.assertNotEqual(expected_vars, config_vars) + _osx_support._remove_original_values(config_vars) + self.assertEqual(expected_vars, config_vars) + + def test__save_modified_value(self): + config_vars = { + 'CC': 'gcc-test -pthreads', + } + expected_vars = { + 'CC': 'clang -pthreads', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + cv = 'CC' + newvalue = 'clang -pthreads' + _osx_support._save_modified_value(config_vars, cv, newvalue) + self.assertEqual(expected_vars, config_vars) + + def test__save_modified_value_unchanged(self): + config_vars = { + 'CC': 'gcc-test -pthreads', + } + expected_vars = config_vars.copy() + cv = 'CC' + newvalue = 'gcc-test -pthreads' + _osx_support._save_modified_value(config_vars, cv, newvalue) + self.assertEqual(expected_vars, config_vars) + + def test__supports_universal_builds(self): + import platform + self.assertEqual(platform.mac_ver()[0].split('.') >= ['10', '4'], + _osx_support._supports_universal_builds()) + + def test__find_appropriate_compiler(self): + compilers = ( + ('gcc-test', 'i686-apple-darwin11-llvm-gcc-4.2'), + ('clang', 'clang version 3.1'), + ) + config_vars = { + 'CC': 'gcc-test -pthreads', + 'CXX': 'cc++-test', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-test -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-test -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CC': 'clang -pthreads', + 'CXX': 'clang++', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'clang -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'clang -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + suffix = (':' + self.env['PATH']) if self.env['PATH'] else '' + self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix + for c_name, c_output in compilers: + test.support.unlink(c_name) + self.addCleanup(test.support.unlink, c_name) + with open(c_name, 'w') as f: + f.write("#!/bin/sh\n/bin/echo " + c_output) + os.chmod(c_name, stat.S_IRWXU) + self.assertEqual(expected_vars, + _osx_support._find_appropriate_compiler( + config_vars)) + + def test__remove_universal_flags(self): + config_vars = { + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CFLAGS': '-fno-strict-aliasing -g -O3 ', + 'LDFLAGS': ' -g', + 'CPPFLAGS': '-I. ', + 'BLDSHARED': 'gcc-4.0 -bundle -g', + 'LDSHARED': 'gcc-4.0 -bundle -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + self.assertEqual(expected_vars, + _osx_support._remove_universal_flags( + config_vars)) + + def test__remove_unsupported_archs(self): + config_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch i386 ', + 'LDFLAGS': ' -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + suffix = (':' + self.env['PATH']) if self.env['PATH'] else '' + self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix + c_name = 'clang' + test.support.unlink(c_name) + self.addCleanup(test.support.unlink, c_name) + # exit status 255 means no PPC support in this compiler chain + with open(c_name, 'w') as f: + f.write("#!/bin/sh\nexit 255") + os.chmod(c_name, stat.S_IRWXU) + self.assertEqual(expected_vars, + _osx_support._remove_unsupported_archs( + config_vars)) + + def test__override_all_archs(self): + self.env['ARCHFLAGS'] = '-arch x86_64' + config_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g', + } + expected_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch x86_64', + 'LDFLAGS': ' -g -arch x86_64', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -g -arch x86_64', + 'LDSHARED': 'gcc-4.0 -bundle -isysroot ' + '/Developer/SDKs/MacOSX10.4u.sdk -g -arch x86_64', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + self.assertEqual(expected_vars, + _osx_support._override_all_archs( + config_vars)) + + def test__check_for_unavailable_sdk(self): + config_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.1.sdk', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.1.sdk', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.1.sdk -g', + } + expected_vars = { + 'CC': 'clang', + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ' + ' ', + 'LDFLAGS': '-arch ppc -arch i386 -g', + 'CPPFLAGS': '-I. ', + 'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g', + 'LDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 ' + ' -g', + } + self.add_expected_saved_initial_values(config_vars, expected_vars) + + self.assertEqual(expected_vars, + _osx_support._check_for_unavailable_sdk( + config_vars)) + + def test_get_platform_osx(self): + # Note, get_platform_osx is currently tested more extensively + # indirectly by test_sysconfig and test_distutils + config_vars = { + 'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ' + '-isysroot /Developer/SDKs/MacOSX10.1.sdk', + 'MACOSX_DEPLOYMENT_TARGET': '10.6', + } + result = _osx_support.get_platform_osx(config_vars, ' ', ' ', ' ') + self.assertEqual(('macosx', '10.6', 'fat'), result) + +def test_main(): + if sys.platform == 'darwin': + test.support.run_unittest(Test_OSXSupport) + +if __name__ == "__main__": + test_main() diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -15,6 +15,7 @@ get_path, get_path_names, _INSTALL_SCHEMES, _get_default_scheme, _expand_vars, get_scheme_names, get_config_var, _main) +import _osx_support class TestSysConfig(unittest.TestCase): @@ -135,8 +136,7 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC')) - - + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' @@ -151,12 +151,11 @@ finally: sys.maxsize = maxint - self._set_uname(('Darwin', 'macziade', '8.11.1', ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) - get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' @@ -171,6 +170,7 @@ sys.maxsize = maxint # macbook with fat binaries (fat, universal or fat64) + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' @@ -179,6 +179,7 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -186,18 +187,21 @@ self.assertEqual(get_platform(), 'macosx-10.4-intel') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-fat3') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-universal') + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -206,12 +210,13 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat64') for arch in ('ppc', 'i386', 'x86_64', 'ppc64'): + _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch %s -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' - '-dynamic -DNDEBUG -g -O3'%(arch,)) + '-dynamic -DNDEBUG -g -O3' % arch) - self.assertEqual(get_platform(), 'macosx-10.4-%s'%(arch,)) + self.assertEqual(get_platform(), 'macosx-10.4-%s' % arch) # linux debian sarge os.name = 'posix' diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -792,6 +792,21 @@ - Issue #8033: sqlite3: Fix 64-bit integer handling in user functions on 32-bit architectures. Initial patch by Philippe Devalkeneer. +- Issue #13590: OS X Xcode 4 - improve support for universal extension modules + In particular, fix extension module build failures when trying to use + 32-bit-only installer Pythons on systems with Xcode 4 (currently + OS X 10.8, 10.7, and optionally 10.6). + * Backport 3.3.0 fixes to 3.2 branch (for release in 3.2.4) + * Since Xcode 4 removes ppc support, extension module builds now + check for ppc compiler support and by default remove ppc and + ppc64 archs when they are not available. + * Extension module builds now revert to using system installed + headers and libs (/usr and /System/Library) if the SDK used + to build the interpreter is not installed or has moved. + * Try to avoid building extension modules with deprecated + and problematic Apple llvm-gcc compiler. If original compiler + is not available, use clang instead by default. + Extension Modules ----------------- -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 10:37:53 2013 From: python-checkins at python.org (ned.deily) Date: Thu, 31 Jan 2013 10:37:53 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_null_merge?= Message-ID: <3Yxbw135qdzPlR@mail.python.org> http://hg.python.org/cpython/rev/d218ecb7392d changeset: 81845:d218ecb7392d branch: 3.3 parent: 81840:91435b4dc8d4 parent: 81844:502b139b3b19 user: Ned Deily date: Thu Jan 31 01:34:02 2013 -0800 summary: null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 10:37:54 2013 From: python-checkins at python.org (ned.deily) Date: Thu, 31 Jan 2013 10:37:54 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_null_merge?= Message-ID: <3Yxbw25nygzPgD@mail.python.org> http://hg.python.org/cpython/rev/022477b09dc3 changeset: 81846:022477b09dc3 parent: 81842:58e72cb89848 parent: 81845:d218ecb7392d user: Ned Deily date: Thu Jan 31 01:36:22 2013 -0800 summary: null merge files: -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 14:33:40 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 14:33:40 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzQ4NDQ6?= =?utf-8?q?_ZipFile_now_raises_BadZipfile_when_opens_a_ZIP_file_with_an?= Message-ID: <3Yxj841FMlzP7C@mail.python.org> http://hg.python.org/cpython/rev/32de35f0f877 changeset: 81847:32de35f0f877 branch: 2.7 parent: 81843:1d061f83a6bf user: Serhiy Storchaka date: Thu Jan 31 15:26:55 2013 +0200 summary: Issue #4844: ZipFile now raises BadZipfile when opens a ZIP file with an incomplete "End of Central Directory" record. Original patch by Guilherme Polo and Alan McIntyre. files: Lib/test/test_zipfile.py | 14 ++++++++++++++ Lib/zipfile.py | 27 ++++++++++++++++++++------- Misc/NEWS | 4 ++++ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -760,6 +760,20 @@ chk = zipfile.is_zipfile(fp) self.assertTrue(not chk) + def test_damaged_zipfile(self): + """Check that zipfiles with missing bytes at the end raise BadZipFile.""" + # - Create a valid zip file + fp = io.BytesIO() + with zipfile.ZipFile(fp, mode="w") as zipf: + zipf.writestr("foo.txt", b"O, for a Muse of Fire!") + zipfiledata = fp.getvalue() + + # - Now create copies of it missing the last N bytes and make sure + # a BadZipFile exception is raised when we try to open it + for N in range(len(zipfiledata)): + fp = io.BytesIO(zipfiledata[:N]) + self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, fp) + def test_is_zip_valid_file(self): """Check that is_zipfile() correctly identifies zip files.""" # - passing a filename diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -166,6 +166,8 @@ return endrec data = fpin.read(sizeEndCentDir64Locator) + if len(data) != sizeEndCentDir64Locator: + return endrec sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data) if sig != stringEndArchive64Locator: return endrec @@ -176,6 +178,8 @@ # Assume no 'zip64 extensible data' fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2) data = fpin.read(sizeEndCentDir64) + if len(data) != sizeEndCentDir64: + return endrec sig, sz, create_version, read_version, disk_num, disk_dir, \ dircount, dircount2, dirsize, diroffset = \ struct.unpack(structEndArchive64, data) @@ -211,7 +215,9 @@ except IOError: return None data = fpin.read() - if data[0:4] == stringEndArchive and data[-2:] == "\000\000": + if (len(data) == sizeEndCentDir and + data[0:4] == stringEndArchive and + data[-2:] == b"\000\000"): # the signature is correct and there's no comment, unpack structure endrec = struct.unpack(structEndArchive, data) endrec=list(endrec) @@ -235,6 +241,9 @@ if start >= 0: # found the magic number; attempt to unpack and interpret recData = data[start:start+sizeEndCentDir] + if len(recData) != sizeEndCentDir: + # Zip file is corrupted. + return None endrec = list(struct.unpack(structEndArchive, recData)) commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize] @@ -246,7 +255,7 @@ endrec) # Unable to find a valid end of central directory structure - return + return None class ZipInfo (object): @@ -818,9 +827,11 @@ total = 0 while total < size_cd: centdir = fp.read(sizeCentralDir) - if centdir[0:4] != stringCentralDir: - raise BadZipfile, "Bad magic number for central directory" + if len(centdir) != sizeCentralDir: + raise BadZipfile("Truncated central directory") centdir = struct.unpack(structCentralDir, centdir) + if centdir[_CD_SIGNATURE] != stringCentralDir: + raise BadZipfile("Bad magic number for central directory") if self.debug > 2: print centdir filename = fp.read(centdir[_CD_FILENAME_LENGTH]) @@ -948,10 +959,12 @@ # Skip the file header: fheader = zef_file.read(sizeFileHeader) - if fheader[0:4] != stringFileHeader: - raise BadZipfile, "Bad magic number for file header" + if len(fheader) != sizeFileHeader: + raise BadZipfile("Truncated file header") + fheader = struct.unpack(structFileHeader, fheader) + if fheader[_FH_SIGNATURE] != stringFileHeader: + raise BadZipfile("Bad magic number for file header") - fheader = struct.unpack(structFileHeader, fheader) fname = zef_file.read(fheader[_FH_FILENAME_LENGTH]) if fheader[_FH_EXTRA_FIELD_LENGTH]: zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH]) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,10 @@ Library ------- +- Issue #4844: ZipFile now raises BadZipfile when opens a ZIP file with an + incomplete "End of Central Directory" record. Original patch by Guilherme + Polo and Alan McIntyre. + - Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler is set to a callable object. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 14:33:41 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 14:33:41 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzQ4NDQ6?= =?utf-8?q?_ZipFile_now_raises_BadZipFile_when_opens_a_ZIP_file_with_an?= Message-ID: <3Yxj855YkjzPcq@mail.python.org> http://hg.python.org/cpython/rev/01147e468c8c changeset: 81848:01147e468c8c branch: 3.2 parent: 81844:502b139b3b19 user: Serhiy Storchaka date: Thu Jan 31 15:27:07 2013 +0200 summary: Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an incomplete "End of Central Directory" record. Original patch by Guilherme Polo and Alan McIntyre. files: Lib/test/test_zipfile.py | 14 ++++++++++++++ Lib/zipfile.py | 25 +++++++++++++++++++------ Misc/NEWS | 4 ++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -844,6 +844,20 @@ chk = zipfile.is_zipfile(fp) self.assertTrue(not chk) + def test_damaged_zipfile(self): + """Check that zipfiles with missing bytes at the end raise BadZipFile.""" + # - Create a valid zip file + fp = io.BytesIO() + with zipfile.ZipFile(fp, mode="w") as zipf: + zipf.writestr("foo.txt", b"O, for a Muse of Fire!") + zipfiledata = fp.getvalue() + + # - Now create copies of it missing the last N bytes and make sure + # a BadZipFile exception is raised when we try to open it + for N in range(len(zipfiledata)): + fp = io.BytesIO(zipfiledata[:N]) + self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, fp) + def test_is_zip_valid_file(self): """Check that is_zipfile() correctly identifies zip files.""" # - passing a filename diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -176,6 +176,8 @@ return endrec data = fpin.read(sizeEndCentDir64Locator) + if len(data) != sizeEndCentDir64Locator: + return endrec sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data) if sig != stringEndArchive64Locator: return endrec @@ -186,6 +188,8 @@ # Assume no 'zip64 extensible data' fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2) data = fpin.read(sizeEndCentDir64) + if len(data) != sizeEndCentDir64: + return endrec sig, sz, create_version, read_version, disk_num, disk_dir, \ dircount, dircount2, dirsize, diroffset = \ struct.unpack(structEndArchive64, data) @@ -221,7 +225,9 @@ except IOError: return None data = fpin.read() - if data[0:4] == stringEndArchive and data[-2:] == b"\000\000": + if (len(data) == sizeEndCentDir and + data[0:4] == stringEndArchive and + data[-2:] == b"\000\000"): # the signature is correct and there's no comment, unpack structure endrec = struct.unpack(structEndArchive, data) endrec=list(endrec) @@ -245,6 +251,9 @@ if start >= 0: # found the magic number; attempt to unpack and interpret recData = data[start:start+sizeEndCentDir] + if len(recData) != sizeEndCentDir: + # Zip file is corrupted. + return None endrec = list(struct.unpack(structEndArchive, recData)) commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize] @@ -256,7 +265,7 @@ endrec) # Unable to find a valid end of central directory structure - return + return None class ZipInfo (object): @@ -819,9 +828,11 @@ total = 0 while total < size_cd: centdir = fp.read(sizeCentralDir) - if centdir[0:4] != stringCentralDir: + if len(centdir) != sizeCentralDir: + raise BadZipFile("Truncated central directory") + centdir = struct.unpack(structCentralDir, centdir) + if centdir[_CD_SIGNATURE] != stringCentralDir: raise BadZipFile("Bad magic number for central directory") - centdir = struct.unpack(structCentralDir, centdir) if self.debug > 2: print(centdir) filename = fp.read(centdir[_CD_FILENAME_LENGTH]) @@ -964,10 +975,12 @@ # Skip the file header: fheader = zef_file.read(sizeFileHeader) - if fheader[0:4] != stringFileHeader: + if len(fheader) != sizeFileHeader: + raise BadZipFile("Truncated file header") + fheader = struct.unpack(structFileHeader, fheader) + if fheader[_FH_SIGNATURE] != stringFileHeader: raise BadZipFile("Bad magic number for file header") - fheader = struct.unpack(structFileHeader, fheader) fname = zef_file.read(fheader[_FH_FILENAME_LENGTH]) if fheader[_FH_EXTRA_FIELD_LENGTH]: zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH]) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -216,6 +216,10 @@ Library ------- +- Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an + incomplete "End of Central Directory" record. Original patch by Guilherme + Polo and Alan McIntyre. + - Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler is set to a callable object. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 14:33:43 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 14:33:43 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=234844=3A_ZipFile_now_raises_BadZipFile_when_opens_a_ZI?= =?utf-8?q?P_file_with_an?= Message-ID: <3Yxj872QSZzPYT@mail.python.org> http://hg.python.org/cpython/rev/46f24a18a4ab changeset: 81849:46f24a18a4ab branch: 3.3 parent: 81845:d218ecb7392d parent: 81848:01147e468c8c user: Serhiy Storchaka date: Thu Jan 31 15:29:20 2013 +0200 summary: Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an incomplete "End of Central Directory" record. Original patch by Guilherme Polo and Alan McIntyre. files: Lib/test/test_zipfile.py | 14 ++++++++++++++ Lib/zipfile.py | 25 +++++++++++++++++++------ Misc/NEWS | 4 ++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -996,6 +996,20 @@ chk = zipfile.is_zipfile(fp) self.assertTrue(not chk) + def test_damaged_zipfile(self): + """Check that zipfiles with missing bytes at the end raise BadZipFile.""" + # - Create a valid zip file + fp = io.BytesIO() + with zipfile.ZipFile(fp, mode="w") as zipf: + zipf.writestr("foo.txt", b"O, for a Muse of Fire!") + zipfiledata = fp.getvalue() + + # - Now create copies of it missing the last N bytes and make sure + # a BadZipFile exception is raised when we try to open it + for N in range(len(zipfiledata)): + fp = io.BytesIO(zipfiledata[:N]) + self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, fp) + def test_is_zip_valid_file(self): """Check that is_zipfile() correctly identifies zip files.""" # - passing a filename diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -196,6 +196,8 @@ return endrec data = fpin.read(sizeEndCentDir64Locator) + if len(data) != sizeEndCentDir64Locator: + return endrec sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data) if sig != stringEndArchive64Locator: return endrec @@ -206,6 +208,8 @@ # Assume no 'zip64 extensible data' fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2) data = fpin.read(sizeEndCentDir64) + if len(data) != sizeEndCentDir64: + return endrec sig, sz, create_version, read_version, disk_num, disk_dir, \ dircount, dircount2, dirsize, diroffset = \ struct.unpack(structEndArchive64, data) @@ -241,7 +245,9 @@ except IOError: return None data = fpin.read() - if data[0:4] == stringEndArchive and data[-2:] == b"\000\000": + if (len(data) == sizeEndCentDir and + data[0:4] == stringEndArchive and + data[-2:] == b"\000\000"): # the signature is correct and there's no comment, unpack structure endrec = struct.unpack(structEndArchive, data) endrec=list(endrec) @@ -265,6 +271,9 @@ if start >= 0: # found the magic number; attempt to unpack and interpret recData = data[start:start+sizeEndCentDir] + if len(recData) != sizeEndCentDir: + # Zip file is corrupted. + return None endrec = list(struct.unpack(structEndArchive, recData)) commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize] @@ -276,7 +285,7 @@ endrec) # Unable to find a valid end of central directory structure - return + return None class ZipInfo (object): @@ -978,9 +987,11 @@ total = 0 while total < size_cd: centdir = fp.read(sizeCentralDir) - if centdir[0:4] != stringCentralDir: + if len(centdir) != sizeCentralDir: + raise BadZipFile("Truncated central directory") + centdir = struct.unpack(structCentralDir, centdir) + if centdir[_CD_SIGNATURE] != stringCentralDir: raise BadZipFile("Bad magic number for central directory") - centdir = struct.unpack(structCentralDir, centdir) if self.debug > 2: print(centdir) filename = fp.read(centdir[_CD_FILENAME_LENGTH]) @@ -1123,10 +1134,12 @@ # Skip the file header: fheader = zef_file.read(sizeFileHeader) - if fheader[0:4] != stringFileHeader: + if len(fheader) != sizeFileHeader: + raise BadZipFile("Truncated file header") + fheader = struct.unpack(structFileHeader, fheader) + if fheader[_FH_SIGNATURE] != stringFileHeader: raise BadZipFile("Bad magic number for file header") - fheader = struct.unpack(structFileHeader, fheader) fname = zef_file.read(fheader[_FH_FILENAME_LENGTH]) if fheader[_FH_EXTRA_FIELD_LENGTH]: zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH]) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -164,6 +164,10 @@ Library ------- +- Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an + incomplete "End of Central Directory" record. Original patch by Guilherme + Polo and Alan McIntyre. + - Issue #17071: Signature.bind() now works when one of the keyword arguments is named ``self``. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 14:33:44 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 14:33:44 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=234844=3A_ZipFile_now_raises_BadZipFile_when_open?= =?utf-8?q?s_a_ZIP_file_with_an?= Message-ID: <3Yxj886XspzPfK@mail.python.org> http://hg.python.org/cpython/rev/e406b8bd7b38 changeset: 81850:e406b8bd7b38 parent: 81846:022477b09dc3 parent: 81849:46f24a18a4ab user: Serhiy Storchaka date: Thu Jan 31 15:30:36 2013 +0200 summary: Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an incomplete "End of Central Directory" record. Original patch by Guilherme Polo and Alan McIntyre. files: Lib/test/test_zipfile.py | 14 ++++++++++++++ Lib/zipfile.py | 25 +++++++++++++++++++------ Misc/NEWS | 4 ++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -996,6 +996,20 @@ chk = zipfile.is_zipfile(fp) self.assertTrue(not chk) + def test_damaged_zipfile(self): + """Check that zipfiles with missing bytes at the end raise BadZipFile.""" + # - Create a valid zip file + fp = io.BytesIO() + with zipfile.ZipFile(fp, mode="w") as zipf: + zipf.writestr("foo.txt", b"O, for a Muse of Fire!") + zipfiledata = fp.getvalue() + + # - Now create copies of it missing the last N bytes and make sure + # a BadZipFile exception is raised when we try to open it + for N in range(len(zipfiledata)): + fp = io.BytesIO(zipfiledata[:N]) + self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, fp) + def test_is_zip_valid_file(self): """Check that is_zipfile() correctly identifies zip files.""" # - passing a filename diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -196,6 +196,8 @@ return endrec data = fpin.read(sizeEndCentDir64Locator) + if len(data) != sizeEndCentDir64Locator: + return endrec sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data) if sig != stringEndArchive64Locator: return endrec @@ -206,6 +208,8 @@ # Assume no 'zip64 extensible data' fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2) data = fpin.read(sizeEndCentDir64) + if len(data) != sizeEndCentDir64: + return endrec sig, sz, create_version, read_version, disk_num, disk_dir, \ dircount, dircount2, dirsize, diroffset = \ struct.unpack(structEndArchive64, data) @@ -241,7 +245,9 @@ except OSError: return None data = fpin.read() - if data[0:4] == stringEndArchive and data[-2:] == b"\000\000": + if (len(data) == sizeEndCentDir and + data[0:4] == stringEndArchive and + data[-2:] == b"\000\000"): # the signature is correct and there's no comment, unpack structure endrec = struct.unpack(structEndArchive, data) endrec=list(endrec) @@ -265,6 +271,9 @@ if start >= 0: # found the magic number; attempt to unpack and interpret recData = data[start:start+sizeEndCentDir] + if len(recData) != sizeEndCentDir: + # Zip file is corrupted. + return None endrec = list(struct.unpack(structEndArchive, recData)) commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize] @@ -276,7 +285,7 @@ endrec) # Unable to find a valid end of central directory structure - return + return None class ZipInfo (object): @@ -978,9 +987,11 @@ total = 0 while total < size_cd: centdir = fp.read(sizeCentralDir) - if centdir[0:4] != stringCentralDir: + if len(centdir) != sizeCentralDir: + raise BadZipFile("Truncated central directory") + centdir = struct.unpack(structCentralDir, centdir) + if centdir[_CD_SIGNATURE] != stringCentralDir: raise BadZipFile("Bad magic number for central directory") - centdir = struct.unpack(structCentralDir, centdir) if self.debug > 2: print(centdir) filename = fp.read(centdir[_CD_FILENAME_LENGTH]) @@ -1123,10 +1134,12 @@ # Skip the file header: fheader = zef_file.read(sizeFileHeader) - if fheader[0:4] != stringFileHeader: + if len(fheader) != sizeFileHeader: + raise BadZipFile("Truncated file header") + fheader = struct.unpack(structFileHeader, fheader) + if fheader[_FH_SIGNATURE] != stringFileHeader: raise BadZipFile("Bad magic number for file header") - fheader = struct.unpack(structFileHeader, fheader) fname = zef_file.read(fheader[_FH_FILENAME_LENGTH]) if fheader[_FH_EXTRA_FIELD_LENGTH]: zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH]) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -236,6 +236,10 @@ Library ------- +- Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an + incomplete "End of Central Directory" record. Original patch by Guilherme + Polo and Alan McIntyre. + - Issue #17071: Signature.bind() now works when one of the keyword arguments is named ``self``. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 14:58:36 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 14:58:36 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE3MDQ5?= =?utf-8?q?=3A_Localized_calendar_methods_now_return_unicode_if_a_locale?= Message-ID: <3Yxjhr1xJ1zPTM@mail.python.org> http://hg.python.org/cpython/rev/af41eca1959e changeset: 81851:af41eca1959e branch: 2.7 parent: 81847:32de35f0f877 user: Serhiy Storchaka date: Thu Jan 31 15:57:51 2013 +0200 summary: Issue #17049: Localized calendar methods now return unicode if a locale includes an encoding and the result string contains month or weekday (was regression from Python 2.6). files: Lib/calendar.py | 1 + Lib/test/test_calendar.py | 18 +++++++++++++++--- Misc/NEWS | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Lib/calendar.py b/Lib/calendar.py --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -492,6 +492,7 @@ def __enter__(self): self.oldlocale = _locale.getlocale(_locale.LC_TIME) _locale.setlocale(_locale.LC_TIME, self.locale) + return _locale.getlocale(_locale.LC_TIME)[1] def __exit__(self, *args): _locale.setlocale(_locale.LC_TIME, self.oldlocale) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -255,11 +255,23 @@ # (it is still not thread-safe though) old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) try: - calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10) + cal = calendar.LocaleTextCalendar(locale='') + local_weekday = cal.formatweekday(1, 10) + local_month = cal.formatmonthname(2010, 10, 10) except locale.Error: # cannot set the system default locale -- skip rest of test - return - calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10) + raise unittest.SkipTest('cannot set the system default locale') + # should be encodable + local_weekday.encode('utf-8') + local_month.encode('utf-8') + self.assertEqual(len(local_weekday), 10) + self.assertGreaterEqual(len(local_month), 10) + cal = calendar.LocaleHTMLCalendar(locale='') + local_weekday = cal.formatweekday(1) + local_month = cal.formatmonthname(2010, 10) + # should be encodable + local_weekday.encode('utf-8') + local_month.encode('utf-8') new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) self.assertEqual(old_october, new_october) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -202,6 +202,10 @@ Library ------- +- Issue #17049: Localized calendar methods now return unicode if a locale + includes an encoding and the result string contains month or weekday (was + regression from Python 2.6). + - Issue #4844: ZipFile now raises BadZipfile when opens a ZIP file with an incomplete "End of Central Directory" record. Original patch by Guilherme Polo and Alan McIntyre. -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 15:03:11 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 15:03:11 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_Added_test_to_?= =?utf-8?q?ensure_localized_calendar_methods_return_strings_and_not_bytes?= =?utf-8?q?=2E?= Message-ID: <3Yxjp729ZnzPrM@mail.python.org> http://hg.python.org/cpython/rev/b45da1761567 changeset: 81852:b45da1761567 branch: 3.2 parent: 81848:01147e468c8c user: Serhiy Storchaka date: Thu Jan 31 16:00:42 2013 +0200 summary: Added test to ensure localized calendar methods return strings and not bytes. files: Lib/test/test_calendar.py | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -258,11 +258,21 @@ # (it is still not thread-safe though) old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) try: - calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10) + cal = calendar.LocaleTextCalendar(locale='') + local_weekday = cal.formatweekday(1, 10) + local_month = cal.formatmonthname(2010, 10, 10) except locale.Error: # cannot set the system default locale -- skip rest of test - return - calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10) + raise unittest.SkipTest('cannot set the system default locale') + self.assertIsInstance(local_weekday, str) + self.assertIsInstance(local_month, str) + self.assertEqual(len(local_weekday), 10) + self.assertGreaterEqual(len(local_month), 10) + cal = calendar.LocaleHTMLCalendar(locale='') + local_weekday = cal.formatweekday(1) + local_month = cal.formatmonthname(2010, 10) + self.assertIsInstance(local_weekday, str) + self.assertIsInstance(local_month, str) new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) self.assertEqual(old_october, new_october) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 15:03:12 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 15:03:12 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Added_test_to_ensure_localized_calendar_methods_return_strings?= =?utf-8?q?_and_not_bytes=2E?= Message-ID: <3Yxjp84pXwzPlK@mail.python.org> http://hg.python.org/cpython/rev/5bad2c422315 changeset: 81853:5bad2c422315 branch: 3.3 parent: 81849:46f24a18a4ab parent: 81852:b45da1761567 user: Serhiy Storchaka date: Thu Jan 31 16:01:21 2013 +0200 summary: Added test to ensure localized calendar methods return strings and not bytes. files: Lib/test/test_calendar.py | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -457,11 +457,21 @@ # (it is still not thread-safe though) old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) try: - calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10) + cal = calendar.LocaleTextCalendar(locale='') + local_weekday = cal.formatweekday(1, 10) + local_month = cal.formatmonthname(2010, 10, 10) except locale.Error: # cannot set the system default locale -- skip rest of test - return - calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10) + raise unittest.SkipTest('cannot set the system default locale') + self.assertIsInstance(local_weekday, str) + self.assertIsInstance(local_month, str) + self.assertEqual(len(local_weekday), 10) + self.assertGreaterEqual(len(local_month), 10) + cal = calendar.LocaleHTMLCalendar(locale='') + local_weekday = cal.formatweekday(1) + local_month = cal.formatmonthname(2010, 10) + self.assertIsInstance(local_weekday, str) + self.assertIsInstance(local_month, str) new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) self.assertEqual(old_october, new_october) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 15:03:14 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 15:03:14 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Added_test_to_ensure_localized_calendar_methods_return_s?= =?utf-8?q?trings_and_not_bytes=2E?= Message-ID: <3YxjpB0Z27zPlN@mail.python.org> http://hg.python.org/cpython/rev/e460dedf8633 changeset: 81854:e460dedf8633 parent: 81850:e406b8bd7b38 parent: 81853:5bad2c422315 user: Serhiy Storchaka date: Thu Jan 31 16:01:46 2013 +0200 summary: Added test to ensure localized calendar methods return strings and not bytes. files: Lib/test/test_calendar.py | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -457,11 +457,21 @@ # (it is still not thread-safe though) old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) try: - calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10) + cal = calendar.LocaleTextCalendar(locale='') + local_weekday = cal.formatweekday(1, 10) + local_month = cal.formatmonthname(2010, 10, 10) except locale.Error: # cannot set the system default locale -- skip rest of test - return - calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10) + raise unittest.SkipTest('cannot set the system default locale') + self.assertIsInstance(local_weekday, str) + self.assertIsInstance(local_month, str) + self.assertEqual(len(local_weekday), 10) + self.assertGreaterEqual(len(local_month), 10) + cal = calendar.LocaleHTMLCalendar(locale='') + local_weekday = cal.formatweekday(1) + local_month = cal.formatmonthname(2010, 10) + self.assertIsInstance(local_weekday, str) + self.assertIsInstance(local_month, str) new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) self.assertEqual(old_october, new_october) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 15:13:55 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 15:13:55 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE3MDQx?= =?utf-8?q?=3A_Fix_doctesting_when_Python_is_configured_with_the?= Message-ID: <3Yxk2W5CNfzPlN@mail.python.org> http://hg.python.org/cpython/rev/df9f8feb7444 changeset: 81855:df9f8feb7444 branch: 2.7 parent: 81851:af41eca1959e user: Serhiy Storchaka date: Thu Jan 31 16:10:15 2013 +0200 summary: Issue #17041: Fix doctesting when Python is configured with the --without-doc-strings. files: Lib/test/test_generators.py | 3 ++- Lib/test/test_genexps.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -383,7 +383,8 @@ >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_code', 'gi_frame', 'gi_running', 'next', 'send', 'throw'] ->>> print i.next.__doc__ +>>> from test.test_support import HAVE_DOCSTRINGS +>>> print(i.next.__doc__ if HAVE_DOCSTRINGS else 'x.next() -> the next value, or raise StopIteration') x.next() -> the next value, or raise StopIteration >>> iter(i) is i True diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -223,7 +223,8 @@ >>> set(attr for attr in dir(g) if not attr.startswith('__')) >= expected True - >>> print g.next.__doc__ + >>> from test.test_support import HAVE_DOCSTRINGS + >>> print(g.next.__doc__ if HAVE_DOCSTRINGS else 'x.next() -> the next value, or raise StopIteration') x.next() -> the next value, or raise StopIteration >>> import types >>> isinstance(g, types.GeneratorType) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 15:13:57 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 15:13:57 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4yKTogSXNzdWUgIzE3MDQx?= =?utf-8?q?=3A_Fix_doctesting_when_Python_is_configured_with_the?= Message-ID: <3Yxk2Y0q4gzPlN@mail.python.org> http://hg.python.org/cpython/rev/9c0cd608464e changeset: 81856:9c0cd608464e branch: 3.2 parent: 81852:b45da1761567 user: Serhiy Storchaka date: Thu Jan 31 16:11:04 2013 +0200 summary: Issue #17041: Fix doctesting when Python is configured with the --without-doc-strings. files: Lib/test/test_generators.py | 3 ++- Lib/test/test_genexps.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -383,7 +383,8 @@ >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_code', 'gi_frame', 'gi_running', 'send', 'throw'] ->>> print(i.__next__.__doc__) +>>> from test.support import HAVE_DOCSTRINGS +>>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'x.__next__() <==> next(x)') x.__next__() <==> next(x) >>> iter(i) is i True diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -221,7 +221,8 @@ >>> set(attr for attr in dir(g) if not attr.startswith('__')) >= expected True - >>> print(g.__next__.__doc__) + >>> from test.support import HAVE_DOCSTRINGS + >>> print(g.__next__.__doc__ if HAVE_DOCSTRINGS else 'x.__next__() <==> next(x)') x.__next__() <==> next(x) >>> import types >>> isinstance(g, types.GeneratorType) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 15:13:58 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 15:13:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_Issue_=2317041=3A_Fix_doctesting_when_Python_is_configured_wit?= =?utf-8?q?h_the?= Message-ID: <3Yxk2Z3N7rzPhX@mail.python.org> http://hg.python.org/cpython/rev/886f48754f7e changeset: 81857:886f48754f7e branch: 3.3 parent: 81853:5bad2c422315 parent: 81856:9c0cd608464e user: Serhiy Storchaka date: Thu Jan 31 16:11:28 2013 +0200 summary: Issue #17041: Fix doctesting when Python is configured with the --without-doc-strings. files: Lib/test/test_generators.py | 3 ++- Lib/test/test_genexps.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -383,7 +383,8 @@ >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_code', 'gi_frame', 'gi_running', 'send', 'throw'] ->>> print(i.__next__.__doc__) +>>> from test.support import HAVE_DOCSTRINGS +>>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'x.__next__() <==> next(x)') x.__next__() <==> next(x) >>> iter(i) is i True diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -221,7 +221,8 @@ >>> set(attr for attr in dir(g) if not attr.startswith('__')) >= expected True - >>> print(g.__next__.__doc__) + >>> from test.support import HAVE_DOCSTRINGS + >>> print(g.__next__.__doc__ if HAVE_DOCSTRINGS else 'x.__next__() <==> next(x)') x.__next__() <==> next(x) >>> import types >>> isinstance(g, types.GeneratorType) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 15:13:59 2013 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Jan 2013 15:13:59 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E3_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2317041=3A_Fix_doctesting_when_Python_is_configur?= =?utf-8?q?ed_with_the?= Message-ID: <3Yxk2b5z24zPsH@mail.python.org> http://hg.python.org/cpython/rev/e6cc582cafce changeset: 81858:e6cc582cafce parent: 81854:e460dedf8633 parent: 81857:886f48754f7e user: Serhiy Storchaka date: Thu Jan 31 16:11:47 2013 +0200 summary: Issue #17041: Fix doctesting when Python is configured with the --without-doc-strings. files: Lib/test/test_generators.py | 3 ++- Lib/test/test_genexps.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -383,7 +383,8 @@ >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_code', 'gi_frame', 'gi_running', 'send', 'throw'] ->>> print(i.__next__.__doc__) +>>> from test.support import HAVE_DOCSTRINGS +>>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'x.__next__() <==> next(x)') x.__next__() <==> next(x) >>> iter(i) is i True diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -221,7 +221,8 @@ >>> set(attr for attr in dir(g) if not attr.startswith('__')) >= expected True - >>> print(g.__next__.__doc__) + >>> from test.support import HAVE_DOCSTRINGS + >>> print(g.__next__.__doc__ if HAVE_DOCSTRINGS else 'x.__next__() <==> next(x)') x.__next__() <==> next(x) >>> import types >>> isinstance(g, types.GeneratorType) -- Repository URL: http://hg.python.org/cpython From python-checkins at python.org Thu Jan 31 17:36:58 2013 From: python-checkins at python.org (daniel.holth) Date: Thu, 31 Jan 2013 17:36:58 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP-0426_formatting=2C_defaul?= =?utf-8?q?t?= Message-ID: <3YxnCZ23gFzPMc@mail.python.org> http://hg.python.org/peps/rev/7cc20e6f85d8 changeset: 4704:7cc20e6f85d8 user: Daniel Holth date: Thu Jan 31 11:36:46 2013 -0500 summary: PEP-0426 formatting, default files: pep-0426.txt | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/pep-0426.txt b/pep-0426.txt --- a/pep-0426.txt +++ b/pep-0426.txt @@ -489,7 +489,7 @@ A string specifying the sorting method for this distribution's version numbers. Although straightforward version numbers tend to sort the same in each scheme, there is disagreement about how to sort patch releases and -versions having alphanumeric components such as "1.0.0rc2" and "1.0.0pre3". +versions having alphanumeric components such as "1.0.0rc2" and "1.0.0pre3":: Version-Scheme: pkg_resources Version-Scheme: pep386 @@ -499,6 +499,8 @@ * pkg_resources: sort versions compatibly with setuptools' pkg_resources module * pep386: sort according to the rules in pep386 +The default is pep386. + Version Specifiers ================== -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 31 20:38:23 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 31 Jan 2013 20:38:23 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_F=5FDUPFD=5FCLOEXE?= =?utf-8?q?C_=26_F=5FDUP2FD=5FCLOEXEC?= Message-ID: <3YxsDv6LsTzPhX@mail.python.org> http://hg.python.org/peps/rev/7da29736faee changeset: 4705:7da29736faee user: Victor Stinner date: Thu Jan 31 20:37:04 2013 +0100 summary: PEP 433: F_DUPFD_CLOEXEC & F_DUP2FD_CLOEXEC files: pep-0433.txt | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -637,9 +637,10 @@ * ``WSA_FLAG_NO_HANDLE_INHERIT`` flag for ``WSASocket()``: supported on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24, - OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0. This flag is part of - POSIX.1-2008. - * ``fcntl()``: ``F_DUP2FD_CLOEXEC`` flag, available on FreeBSD 9.1. + OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0, Solaris 11. This flag is part + of POSIX.1-2008. + * ``fcntl()``: ``F_DUP2FD_CLOEXEC`` flag, available on FreeBSD 9.1 + and Solaris 11. * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23, NetBSD 6.0. -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 31 21:07:08 2013 From: python-checkins at python.org (victor.stinner) Date: Thu, 31 Jan 2013 21:07:08 +0100 (CET) Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_433=3A_Solaris_11_support?= =?utf-8?q?s_also_O=5FCLOEXEC?= Message-ID: <3Yxst45bN7zM4D@mail.python.org> http://hg.python.org/peps/rev/0427ac157038 changeset: 4706:0427ac157038 user: Victor Stinner date: Thu Jan 31 21:05:49 2013 +0100 summary: PEP 433: Solaris 11 supports also O_CLOEXEC files: pep-0433.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -630,8 +630,8 @@ New flags: * ``O_CLOEXEC``: available on Linux (2.6.23), FreeBSD (8.3), - OpenBSD 5.0, QNX, BeOS, next NetBSD release (6.1?). This flag is - part of POSIX.1-2008. + OpenBSD 5.0, Solaris 11, QNX, BeOS, next NetBSD release (6.1?). + This flag is part of POSIX.1-2008. * ``SOCK_CLOEXEC`` flag for ``socket()`` and ``socketpair()``, available on Linux 2.6.27, OpenBSD 5.2, NetBSD 6.0. * ``WSA_FLAG_NO_HANDLE_INHERIT`` flag for ``WSASocket()``: supported -- Repository URL: http://hg.python.org/peps From python-checkins at python.org Thu Jan 31 23:52:27 2013 From: python-checkins at python.org (matthias.klose) Date: Thu, 31 Jan 2013 23:52:27 +0100 (CET) Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogLSBJc3N1ZSAjMTcw?= =?utf-8?q?86=3A_Backport_the_patches_from_the_3=2E3_branch_to_cross-build?= Message-ID: <3YxxXq44T7zQ28@mail.python.org> http://hg.python.org/cpython/rev/8ee6d96a1019 changeset: 81859:8ee6d96a1019 branch: 2.7 parent: 81855:df9f8feb7444 user: doko at python.org date: Thu Jan 31 23:52:03 2013 +0100 summary: - Issue #17086: Backport the patches from the 3.3 branch to cross-build the package. files: Lib/distutils/sysconfig.py | 7 +- Lib/distutils/util.py | 4 + Lib/plat-generic/regen | 2 +- Lib/sysconfig.py | 8 + Makefile.pre.in | 72 +- Misc/NEWS | 3 + config.guess | 1530 ++++++++++++++++++++ config.sub | 1782 ++++++++++++++++++++++++ configure | 675 +++++++- configure.ac | 199 +- pyconfig.h.in | 4 +- setup.py | 214 +- 12 files changed, 4238 insertions(+), 262 deletions(-) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -37,6 +37,11 @@ project_base = os.path.abspath(os.path.join(project_base, os.path.pardir, os.path.pardir)) +# set for cross builds +if "_PYTHON_PROJECT_BASE" in os.environ: + # this is the build directory, at least for posix + project_base = os.path.normpath(os.environ["_PYTHON_PROJECT_BASE"]) + # python_build: (Boolean) if true, we're either building Python or # building an extension with an un-installed Python, so we use # different (hard-wired) directories. @@ -230,7 +235,7 @@ def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: - return os.path.join(os.path.dirname(sys.executable), "Makefile") + return os.path.join(project_base, "Makefile") lib_dir = get_python_lib(plat_specific=1, standard_lib=1) return os.path.join(lib_dir, "config", "Makefile") diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -51,6 +51,10 @@ return 'win-ia64' return sys.platform + # Set for cross builds explicitly + if "_PYTHON_HOST_PLATFORM" in os.environ: + return os.environ["_PYTHON_HOST_PLATFORM"] + if os.name != "posix" or not hasattr(os, 'uname'): # XXX what about the architecture? NT is Intel or Alpha, # Mac OS is M68k or PPC, etc. diff --git a/Lib/plat-generic/regen b/Lib/plat-generic/regen --- a/Lib/plat-generic/regen +++ b/Lib/plat-generic/regen @@ -1,3 +1,3 @@ #! /bin/sh set -v -python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h +eval $PYTHON_FOR_BUILD ../../Tools/scripts/h2py.py -i "'(u_long)'" /usr/include/netinet/in.h diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -116,6 +116,10 @@ if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower(): _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir)) +# set for cross builds +if "_PYTHON_PROJECT_BASE" in os.environ: + # the build directory for posix builds + _PROJECT_BASE = os.path.normpath(os.path.abspath(".")) def is_python_build(): for fn in ("Setup.dist", "Setup.local"): if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)): @@ -507,6 +511,10 @@ return 'win-ia64' return sys.platform + # Set for cross builds explicitly + if "_PYTHON_HOST_PLATFORM" in os.environ: + return os.environ["_PYTHON_HOST_PLATFORM"] + if os.name != "posix" or not hasattr(os, 'uname'): # XXX what about the architecture? NT is Intel or Alpha, # Mac OS is M68k or PPC, etc. diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -29,6 +29,8 @@ VPATH= @srcdir@ abs_srcdir= @abs_srcdir@ abs_builddir= @abs_builddir@ +build= @build@ +host= @host@ CC= @CC@ CXX= @CXX@ @@ -190,6 +192,10 @@ PYTHON= python$(EXE) BUILDPYTHON= python$(BUILDEXE) +PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ +_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ +HOST_GNU_TYPE= @host@ + # The task to run while instrument when building the profile-opt target PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck #PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py @@ -222,6 +228,19 @@ # Parser PGEN= Parser/pgen$(EXE) +PSRCS= \ + Parser/acceler.c \ + Parser/grammar1.c \ + Parser/listnode.c \ + Parser/node.c \ + Parser/parser.c \ + Parser/parsetok.c \ + Parser/bitset.c \ + Parser/metagrammar.c \ + Parser/firstsets.c \ + Parser/grammar.c \ + Parser/pgen.c + POBJS= \ Parser/acceler.o \ Parser/grammar1.o \ @@ -237,6 +256,14 @@ PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/tokenizer.o +PGSRCS= \ + Objects/obmalloc.c \ + Python/mysnprintf.c \ + Python/pyctype.c \ + Parser/tokenizer_pgen.c \ + Parser/printgrammar.c \ + Parser/pgenmain.c + PGOBJS= \ Objects/obmalloc.o \ Python/mysnprintf.o \ @@ -249,7 +276,8 @@ Parser/parser.h \ Parser/tokenizer.h -PGENOBJS= $(PGENMAIN) $(POBJS) $(PGOBJS) +PGENSRCS= $(PSRCS) $(PGSRCS) +PGENOBJS= $(POBJS) $(PGOBJS) ########################################################################## # AST @@ -391,6 +419,7 @@ $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov" run_profile_task: + : # FIXME: can't run for a cross build ./$(BUILDPYTHON) $(PROFILE_TASK) build_all_use_profile: @@ -409,7 +438,7 @@ $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) platform: $(BUILDPYTHON) - $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform + $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform # Build the shared modules @@ -422,7 +451,7 @@ *) quiet="";; \ esac; \ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ - ./$(BUILDPYTHON) -E $(srcdir)/setup.py $$quiet build + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build # Build static library # avoid long command lines, same as LIBRARY_OBJS @@ -551,12 +580,13 @@ $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c -# Use a stamp file to prevent make -j invoking pgen twice -$(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp -Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT) - -@$(INSTALL) -d Include +$(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGENSRCS) + @$(MKDIR_P) Include + $(MAKE) $(PGEN) $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) - -touch Parser/pgen.stamp +$(GRAMMAR_C): $(GRAMMAR_H) $(GRAMMAR_INPUT) $(PGENSRCS) + $(MAKE) $(GRAMMAR_H) + touch $(GRAMMAR_C) $(PGEN): $(PGENOBJS) $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) @@ -953,37 +983,43 @@ $(DESTDIR)$(LIBDEST)/distutils/tests ; \ fi PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST) -f \ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ $(DESTDIR)$(LIBDEST) PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST) -f \ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ $(DESTDIR)$(LIBDEST) -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ + $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt + $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt + $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt # Create the PLATDIR source directory, if one wasn't distributed.. $(srcdir)/Lib/$(PLATDIR): mkdir $(srcdir)/Lib/$(PLATDIR) cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen export PATH; PATH="`pwd`:$$PATH"; \ - export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \ + export PYTHONPATH; PYTHONPATH="$(srcdir)/Lib:$(abs_builddir)/`cat pybuilddir.txt`"; \ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ export EXE; EXE="$(BUILDEXE)"; \ if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \ + export PYTHON_FOR_BUILD; \ + if [ "$(build)" = "$(host)" ]; then \ + PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \ + else \ + PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \ + fi; \ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen python-config: $(srcdir)/Misc/python-config.in @@ -1079,7 +1115,7 @@ # Install the dynamically loadable modules # This goes into $(exec_prefix) sharedinstall: sharedmods - $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ + $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --install-platlib=$(DESTSHARED) \ @@ -1152,7 +1188,7 @@ # This installs a few of the useful scripts in Tools/scripts scriptsinstall: SRCDIR=$(srcdir) $(RUNSHARED) \ - ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \ + $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --root=$(DESTDIR)/ @@ -1219,7 +1255,7 @@ clobber: clean profile-removal -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ - tags TAGS Parser/pgen.stamp \ + tags TAGS \ config.cache config.log pyconfig.h Modules/config.c -rm -rf build platform -rm -rf $(PYTHONFRAMEWORKDIR) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -754,6 +754,9 @@ Build ----- +- Issue #17086: Backport the patches from the 3.3 branch to cross-build + the package. + - Issue #3754: fix typo in pthread AC_CACHE_VAL. - Issue #17029: Let h2py search the multiarch system include directory. diff --git a/config.guess b/config.guess new file mode 100644 --- /dev/null +++ b/config.guess @@ -0,0 +1,1530 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012 Free Software Foundation, Inc. + +timestamp='2012-02-10' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi at noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf at swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green at stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green at stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.sub b/config.sub new file mode 100644 --- /dev/null +++ b/config.sub @@ -0,0 +1,1782 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012 Free Software Foundation, Inc. + +timestamp='2012-04-18' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted GNU ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | be32 | be64 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 \ + | ns16k | ns32k \ + | open8 \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze) + basic_machine=microblaze-xilinx + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i386-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure --- a/configure +++ b/configure @@ -671,6 +671,7 @@ BASECPPFLAGS SVNVERSION ARFLAGS +ac_ct_AR AR RANLIB GNULD @@ -687,6 +688,7 @@ GREP CPP MULTIARCH +ac_ct_CXX MAINCC CXX OBJEXT @@ -701,6 +703,7 @@ EXTRAMACHDEPPATH EXTRAPLATDIR SGI_ABI +_PYTHON_HOST_PLATFORM MACHDEP FRAMEWORKINSTALLAPPSPREFIX FRAMEWORKUNIXTOOLSPREFIX @@ -719,6 +722,15 @@ CONFIG_ARGS SOVERSION VERSION +PYTHON_FOR_BUILD +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build target_alias host_alias build_alias @@ -1397,6 +1409,10 @@ _ACEOF cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi @@ -2730,6 +2746,134 @@ ac_config_headers="$ac_config_headers pyconfig.h" +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + + + +if test "$cross_compiling" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 +$as_echo_n "checking for python interpreter for cross build... " >&6; } + if test -z "$PYTHON_FOR_BUILD"; then + for interp in python$PACKAGE_VERSION python2 python; do + which $interp >/dev/null 2>&1 || continue + if $interp -c 'import sys;sys.exit(not (sys.version_info[:2] >= (2,7) and sys.version_info[0] < 3))'; then + break + fi + interp= + done + if test x$interp = x; then + as_fn_error $? "python$PACKAGE_VERSION interpreter not found" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 +$as_echo "$interp" >&6; } + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + fi +elif test "$cross_compiling" = maybe; then + as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 +else + PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' +fi + + if test "$prefix" != "/"; then prefix=`echo "$prefix" | sed -e 's/\/$//g'` @@ -3018,6 +3162,25 @@ $as_echo_n "checking MACHDEP... " >&6; } if test -z "$MACHDEP" then + # avoid using uname for cross builds + if test "$cross_compiling" = yes; then + # ac_sys_system and ac_sys_release are only used for setting + # `define_xopen_source' in the case statement below. For the + # current supported cross builds, this macro is not adjusted. + case "$host" in + *-*-linux*) + ac_sys_system=Linux + ;; + *-*-cygwin*) + ac_sys_system=Cygwin + ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" + as_fn_error $? "cross build not supported for $host" "$LINENO" 5 + esac + ac_sys_release= + else ac_sys_system=`uname -s` if test "$ac_sys_system" = "AIX" \ -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then @@ -3025,20 +3188,44 @@ else ac_sys_release=`uname -r` fi - ac_md_system=`echo $ac_sys_system | - tr -d '/ ' | tr '[A-Z]' '[a-z]'` - ac_md_release=`echo $ac_sys_release | - tr -d '/ ' | sed 's/^[A-Z]\.//' | sed 's/\..*//'` - MACHDEP="$ac_md_system$ac_md_release" - - case $MACHDEP in + fi + ac_md_system=`echo $ac_sys_system | + tr -d '/ ' | tr '[A-Z]' '[a-z]'` + ac_md_release=`echo $ac_sys_release | + tr -d '/ ' | sed 's/^[A-Z]\.//' | sed 's/\..*//'` + MACHDEP="$ac_md_system$ac_md_release" + + case $MACHDEP in linux*) MACHDEP="linux2";; cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; + esac +fi + + +if test "$cross_compiling" = yes; then + case "$host" in + *-*-linux*) + case "$host_cpu" in + arm*) + _host_cpu=arm + ;; + *) + _host_cpu=$host_cpu + esac + ;; + *-*-cygwin*) + _host_cpu= + ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" + as_fn_error $? "cross build not supported for $host" "$LINENO" 5 esac + _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" fi # Some systems cannot stand _XOPEN_SOURCE being defined at all; they @@ -3195,12 +3382,6 @@ CONFIGURE_MACOSX_DEPLOYMENT_TARGET= EXPORT_MACOSX_DEPLOYMENT_TARGET='#' -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking machine type as reported by uname -m" >&5 -$as_echo_n "checking machine type as reported by uname -m... " >&6; } -ac_sys_machine=`uname -m` -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_sys_machine" >&5 -$as_echo "$ac_sys_machine" >&6; } - # checks for alternative programs # compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just @@ -4130,8 +4311,9 @@ if test -z "$CXX" then case "$CC" in - gcc) # Extract the first word of "g++", so it can be a program name with args. -set dummy g++; ac_word=$2 + gcc) if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args. +set dummy ${ac_tool_prefix}g++; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_CXX+:} false; then : @@ -4157,7 +4339,6 @@ done IFS=$as_save_IFS - test -z "$ac_cv_path_CXX" && ac_cv_path_CXX="g++" ;; esac fi @@ -4170,9 +4351,67 @@ $as_echo "no" >&6; } fi + +fi +if test -z "$ac_cv_path_CXX"; then + ac_pt_CXX=$CXX + # Extract the first word of "g++", so it can be a program name with args. +set dummy g++; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_CXX="$ac_pt_CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in notfound +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_CXX="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_CXX=$ac_cv_path_ac_pt_CXX +if test -n "$ac_pt_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CXX" >&5 +$as_echo "$ac_pt_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_pt_CXX + fi +else + CXX="$ac_cv_path_CXX" +fi ;; - cc) # Extract the first word of "c++", so it can be a program name with args. -set dummy c++; ac_word=$2 + cc) if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}c++", so it can be a program name with args. +set dummy ${ac_tool_prefix}c++; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_CXX+:} false; then : @@ -4198,7 +4437,6 @@ done IFS=$as_save_IFS - test -z "$ac_cv_path_CXX" && ac_cv_path_CXX="c++" ;; esac fi @@ -4211,6 +4449,63 @@ $as_echo "no" >&6; } fi + +fi +if test -z "$ac_cv_path_CXX"; then + ac_pt_CXX=$CXX + # Extract the first word of "c++", so it can be a program name with args. +set dummy c++; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_CXX="$ac_pt_CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in notfound +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_CXX="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_CXX=$ac_cv_path_ac_pt_CXX +if test -n "$ac_pt_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CXX" >&5 +$as_echo "$ac_pt_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_CXX" = x; then + CXX="c++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_pt_CXX + fi +else + CXX="$ac_cv_path_CXX" +fi ;; esac if test "$CXX" = "notfound" @@ -4220,10 +4515,11 @@ fi if test -z "$CXX" then - for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 + if test -n "$ac_tool_prefix"; then + for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : @@ -4239,7 +4535,7 @@ test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_prog" + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4259,9 +4555,65 @@ fi - test -n "$CXX" && break -done -test -n "$CXX" || CXX="notfound" + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="notfound" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi if test "$CXX" = "notfound" then @@ -4924,36 +5276,34 @@ $as_echo_n "checking for --enable-profiling... " >&6; } # Check whether --enable-profiling was given. if test "${enable_profiling+set}" = set; then : - enableval=$enable_profiling; ac_save_cc="$CC" - CC="$CC -pg" - if test "$cross_compiling" = yes; then : - ac_enable_profiling="no" -else + enableval=$enable_profiling; +fi + +if test "x$enable_profiling" = xyes; then + ac_save_cc="$CC" + CC="$(CC) -pg" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main() { return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_enable_profiling="yes" -else - ac_enable_profiling="no" -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - CC="$ac_save_cc" -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_enable_profiling" >&5 -$as_echo "$ac_enable_profiling" >&6; } - -case "$ac_enable_profiling" in - "yes") - BASECFLAGS="-pg $BASECFLAGS" - LDFLAGS="-pg $LDFLAGS" - ;; -esac +if ac_fn_c_try_link "$LINENO"; then : + +else + enable_profiling=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CC="$ac_save_cc" +else + enable_profiling=no +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_profiling" >&5 +$as_echo "$enable_profiling" >&6; } + +if test "x$enable_profiling" = xyes; then + BASECFLAGS="-pg $BASECFLAGS" + LDFLAGS="-pg $LDFLAGS" +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking LDLIBRARY" >&5 $as_echo_n "checking LDLIBRARY... " >&6; } @@ -5045,6 +5395,10 @@ esac fi +if test "$cross_compiling" = yes; then + RUNSHARED= +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDLIBRARY" >&5 $as_echo "$LDLIBRARY" >&6; } @@ -5141,10 +5495,11 @@ fi -for ac_prog in ar aal -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 +if test -n "$ac_tool_prefix"; then + for ac_prog in ar aal + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : @@ -5160,7 +5515,7 @@ test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="$ac_prog" + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5180,9 +5535,65 @@ fi - test -n "$AR" && break -done -test -n "$AR" || AR="ar" + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar aal +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="ar" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi # tweak ARFLAGS only if the user didn't set it on the command line @@ -5312,35 +5723,6 @@ INSTALL="${srcdir}/install-sh -c" fi esac -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -5621,7 +6003,7 @@ # if using gcc on alpha, use -mieee to get (near) full IEEE 754 # support. Without this, treatment of subnormals doesn't follow # the standard. - case $ac_sys_machine in + case $host in alpha*) BASECFLAGS="$BASECFLAGS -mieee" ;; @@ -10974,7 +11356,12 @@ $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : + +if test "${enable_ipv6+set}" = set; then + ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" +else ac_cv_buggy_getaddrinfo=yes +fi else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -13840,34 +14227,73 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for device files" >&5 +$as_echo "$as_me: checking for device files" >&6;} + +if test "x$cross_compiling" = xyes; then + if test "${ac_cv_file__dev_ptmx+set}" != set; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5 +$as_echo_n "checking for /dev/ptmx... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5 +$as_echo "not set" >&6; } + as_fn_error $? "set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling" "$LINENO" 5 + fi + if test "${ac_cv_file__dev_ptc+set}" != set; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptc" >&5 +$as_echo_n "checking for /dev/ptc... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5 +$as_echo "not set" >&6; } + as_fn_error $? "set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling" "$LINENO" 5 + fi +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5 $as_echo_n "checking for /dev/ptmx... " >&6; } - -if test -r /dev/ptmx -then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +if ${ac_cv_file__dev_ptmx+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "/dev/ptmx"; then + ac_cv_file__dev_ptmx=yes +else + ac_cv_file__dev_ptmx=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_ptmx" >&5 +$as_echo "$ac_cv_file__dev_ptmx" >&6; } +if test "x$ac_cv_file__dev_ptmx" = xyes; then : + +fi + +if test "x$ac_cv_file__dev_ptmx" = xyes; then $as_echo "#define HAVE_DEV_PTMX 1" >>confdefs.h -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptc" >&5 $as_echo_n "checking for /dev/ptc... " >&6; } - -if test -r /dev/ptc -then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +if ${ac_cv_file__dev_ptc+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "/dev/ptc"; then + ac_cv_file__dev_ptc=yes +else + ac_cv_file__dev_ptc=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_ptc" >&5 +$as_echo "$ac_cv_file__dev_ptc" >&6; } +if test "x$ac_cv_file__dev_ptc" = xyes; then : + +fi + +if test "x$ac_cv_file__dev_ptc" = xyes; then $as_echo "#define HAVE_DEV_PTC 1" >>confdefs.h -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } fi if test "$have_long_long" = yes @@ -13878,7 +14304,36 @@ $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : - ac_cv_have_long_long_format=no + ac_cv_have_long_long_format="cross -- assuming no" + if test x$GCC = xyes; then + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror -Wformat" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + char *buffer; + sprintf(buffer, "%lld", (long long)123); + sprintf(buffer, "%lld", (long long)-123); + sprintf(buffer, "%llu", (unsigned long long)123); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_have_long_long_format=yes + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$save_CFLAGS + fi else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,33 @@ AC_CONFIG_SRCDIR([Include/object.h]) AC_CONFIG_HEADER(pyconfig.h) +AC_CANONICAL_HOST +AC_SUBST(build) +AC_SUBST(host) + +if test "$cross_compiling" = yes; then + AC_MSG_CHECKING([for python interpreter for cross build]) + if test -z "$PYTHON_FOR_BUILD"; then + for interp in python$PACKAGE_VERSION python2 python; do + which $interp >/dev/null 2>&1 || continue + if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then + break + fi + interp= + done + if test x$interp = x; then + AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) + fi + AC_MSG_RESULT($interp) + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + fi +elif test "$cross_compiling" = maybe; then + AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) +else + PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' +fi +AC_SUBST(PYTHON_FOR_BUILD) + dnl Ensure that if prefix is specified, it does not end in a slash. If dnl it does, we get path names containing '//' which is both ugly and dnl can cause trouble. @@ -279,6 +306,25 @@ AC_MSG_CHECKING(MACHDEP) if test -z "$MACHDEP" then + # avoid using uname for cross builds + if test "$cross_compiling" = yes; then + # ac_sys_system and ac_sys_release are only used for setting + # `define_xopen_source' in the case statement below. For the + # current supported cross builds, this macro is not adjusted. + case "$host" in + *-*-linux*) + ac_sys_system=Linux + ;; + *-*-cygwin*) + ac_sys_system=Cygwin + ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" + AC_MSG_ERROR([cross build not supported for $host]) + esac + ac_sys_release= + else ac_sys_system=`uname -s` if test "$ac_sys_system" = "AIX" \ -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then @@ -286,20 +332,44 @@ else ac_sys_release=`uname -r` fi - ac_md_system=`echo $ac_sys_system | - tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'` - ac_md_release=`echo $ac_sys_release | - tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'` - MACHDEP="$ac_md_system$ac_md_release" - - case $MACHDEP in + fi + ac_md_system=`echo $ac_sys_system | + tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'` + ac_md_release=`echo $ac_sys_release | + tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'` + MACHDEP="$ac_md_system$ac_md_release" + + case $MACHDEP in linux*) MACHDEP="linux2";; cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; + esac +fi + +AC_SUBST(_PYTHON_HOST_PLATFORM) +if test "$cross_compiling" = yes; then + case "$host" in + *-*-linux*) + case "$host_cpu" in + arm*) + _host_cpu=arm + ;; + *) + _host_cpu=$host_cpu + esac + ;; + *-*-cygwin*) + _host_cpu= + ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" + AC_MSG_ERROR([cross build not supported for $host]) esac + _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" fi # Some systems cannot stand _XOPEN_SOURCE being defined at all; they @@ -446,10 +516,6 @@ CONFIGURE_MACOSX_DEPLOYMENT_TARGET= EXPORT_MACOSX_DEPLOYMENT_TARGET='#' -AC_MSG_CHECKING(machine type as reported by uname -m) -ac_sys_machine=`uname -m` -AC_MSG_RESULT($ac_sys_machine) - # checks for alternative programs # compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just @@ -578,8 +644,8 @@ if test -z "$CXX" then case "$CC" in - gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;; - cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;; + gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;; + cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;; esac if test "$CXX" = "notfound" then @@ -588,7 +654,7 @@ fi if test -z "$CXX" then - AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) + AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) if test "$CXX" = "notfound" then CXX="" @@ -764,22 +830,23 @@ AC_MSG_CHECKING(for --enable-profiling) AC_ARG_ENABLE(profiling, - AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]), -[ac_save_cc="$CC" - CC="$CC -pg" - AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], - [ac_enable_profiling="yes"], - [ac_enable_profiling="no"], - [ac_enable_profiling="no"]) - CC="$ac_save_cc"]) -AC_MSG_RESULT($ac_enable_profiling) - -case "$ac_enable_profiling" in - "yes") - BASECFLAGS="-pg $BASECFLAGS" - LDFLAGS="-pg $LDFLAGS" - ;; -esac + AS_HELP_STRING([--enable-profiling], [enable C-level code profiling])) +if test "x$enable_profiling" = xyes; then + ac_save_cc="$CC" + CC="$(CC) -pg" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], + [], + [enable_profiling=no]) + CC="$ac_save_cc" +else + enable_profiling=no +fi +AC_MSG_RESULT($enable_profiling) + +if test "x$enable_profiling" = xyes; then + BASECFLAGS="-pg $BASECFLAGS" + LDFLAGS="-pg $LDFLAGS" +fi AC_MSG_CHECKING(LDLIBRARY) @@ -868,11 +935,15 @@ esac fi +if test "$cross_compiling" = yes; then + RUNSHARED= +fi + AC_MSG_RESULT($LDLIBRARY) AC_PROG_RANLIB AC_SUBST(AR) -AC_CHECK_PROGS(AR, ar aal, ar) +AC_CHECK_TOOLS(AR, ar aal, ar) # tweak ARFLAGS only if the user didn't set it on the command line AC_SUBST(ARFLAGS) @@ -1046,7 +1117,7 @@ # if using gcc on alpha, use -mieee to get (near) full IEEE 754 # support. Without this, treatment of subnormals doesn't follow # the standard. - case $ac_sys_machine in + case $host in alpha*) BASECFLAGS="$BASECFLAGS -mieee" ;; @@ -3216,7 +3287,12 @@ ]]])], [ac_cv_buggy_getaddrinfo=no], [ac_cv_buggy_getaddrinfo=yes], -[ac_cv_buggy_getaddrinfo=yes])) +[ +if test "${enable_ipv6+set}" = set; then + ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" +else + ac_cv_buggy_getaddrinfo=yes +fi])) fi AC_MSG_RESULT($ac_cv_buggy_getaddrinfo) @@ -4246,26 +4322,31 @@ [AC_MSG_RESULT(no)] ) -AC_MSG_CHECKING(for /dev/ptmx) - -if test -r /dev/ptmx -then - AC_MSG_RESULT(yes) +AC_MSG_NOTICE([checking for device files]) + +dnl NOTE: Inform user how to proceed with files when cross compiling. +if test "x$cross_compiling" = xyes; then + if test "${ac_cv_file__dev_ptmx+set}" != set; then + AC_MSG_CHECKING([for /dev/ptmx]) + AC_MSG_RESULT([not set]) + AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling]) + fi + if test "${ac_cv_file__dev_ptc+set}" != set; then + AC_MSG_CHECKING([for /dev/ptc]) + AC_MSG_RESULT([not set]) + AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling]) + fi +fi + +AC_CHECK_FILE(/dev/ptmx, [], []) +if test "x$ac_cv_file__dev_ptmx" = xyes; then AC_DEFINE(HAVE_DEV_PTMX, 1, - [Define if we have /dev/ptmx.]) -else - AC_MSG_RESULT(no) + [Define to 1 if you have the /dev/ptmx device file.]) fi - -AC_MSG_CHECKING(for /dev/ptc) - -if test -r /dev/ptc -then - AC_MSG_RESULT(yes) +AC_CHECK_FILE(/dev/ptc, [], []) +if test "x$ac_cv_file__dev_ptc" = xyes; then AC_DEFINE(HAVE_DEV_PTC, 1, - [Define if we have /dev/ptc.]) -else - AC_MSG_RESULT(no) + [Define to 1 if you have the /dev/ptc device file.]) fi if test "$have_long_long" = yes @@ -4305,7 +4386,23 @@ ]]])], [ac_cv_have_long_long_format=yes], [ac_cv_have_long_long_format=no], - [ac_cv_have_long_long_format=no]) + [ac_cv_have_long_long_format="cross -- assuming no" + if test x$GCC = xyes; then + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror -Wformat" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]], [[ + char *buffer; + sprintf(buffer, "%lld", (long long)123); + sprintf(buffer, "%lld", (long long)-123); + sprintf(buffer, "%llu", (unsigned long long)123); + ]])], + ac_cv_have_long_long_format=yes + ) + CFLAGS=$save_CFLAGS + fi]) ) AC_MSG_RESULT($ac_cv_have_long_long_format) fi diff --git a/pyconfig.h.in b/pyconfig.h.in --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -161,10 +161,10 @@ /* Define to 1 if you have the device macros. */ #undef HAVE_DEVICE_MACROS -/* Define if we have /dev/ptc. */ +/* Define to 1 if you have the /dev/ptc device file. */ #undef HAVE_DEV_PTC -/* Define if we have /dev/ptmx. */ +/* Define to 1 if you have the /dev/ptmx device file. */ #undef HAVE_DEV_PTMX /* Define to 1 if you have the header file. */ diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -17,8 +17,20 @@ from distutils.command.install_lib import install_lib from distutils.spawn import find_executable +cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ + +def get_platform(): + # cross build + if "_PYTHON_HOST_PLATFORM" in os.environ: + return os.environ["_PYTHON_HOST_PLATFORM"] + # Get value of sys.platform + if sys.platform.startswith('osf1'): + return 'osf1' + return sys.platform +host_platform = get_platform() + # Were we compiled --with-pydebug or with #define Py_DEBUG? -COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') +COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS")) # This global variable is used to hold the list of modules to be disabled. disabled_module_list = [] @@ -62,7 +74,7 @@ 'paths' is a list of additional locations to check; if the file is found in one of them, the resulting list will contain the directory. """ - if sys.platform == 'darwin': + if host_platform == 'darwin': # Honor the MacOSX SDK setting when one was specified. # An SDK is a directory with the same structure as a real # system, but with only header files and libraries. @@ -72,7 +84,7 @@ for dir in std_dirs: f = os.path.join(dir, filename) - if sys.platform == 'darwin' and is_macosx_sdk_path(dir): + if host_platform == 'darwin' and is_macosx_sdk_path(dir): f = os.path.join(sysroot, dir[1:], filename) if os.path.exists(f): return [] @@ -81,7 +93,7 @@ for dir in paths: f = os.path.join(dir, filename) - if sys.platform == 'darwin' and is_macosx_sdk_path(dir): + if host_platform == 'darwin' and is_macosx_sdk_path(dir): f = os.path.join(sysroot, dir[1:], filename) if os.path.exists(f): @@ -95,7 +107,7 @@ if result is None: return None - if sys.platform == 'darwin': + if host_platform == 'darwin': sysroot = macosx_sdk_root() # Check whether the found file is in one of the standard directories @@ -104,7 +116,7 @@ # Ensure path doesn't end with path separator p = p.rstrip(os.sep) - if sys.platform == 'darwin' and is_macosx_sdk_path(p): + if host_platform == 'darwin' and is_macosx_sdk_path(p): if os.path.join(sysroot, p[1:]) == dirname: return [ ] @@ -117,7 +129,7 @@ # Ensure path doesn't end with path separator p = p.rstrip(os.sep) - if sys.platform == 'darwin' and is_macosx_sdk_path(p): + if host_platform == 'darwin' and is_macosx_sdk_path(p): if os.path.join(sysroot, p[1:]) == dirname: return [ p ] @@ -174,8 +186,8 @@ # Platform-dependent module source and include directories incdirlist = [] - platform = self.get_platform() - if platform == 'darwin' and ("--disable-toolbox-glue" not in + + if host_platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): # Mac OS X also includes some mac-specific modules macmoddir = os.path.join(srcdir, 'Mac/Modules') @@ -288,7 +300,7 @@ ext.name) return - if self.get_platform() == 'darwin' and ( + if host_platform == 'darwin' and ( sys.maxint > 2**32 and '-arch' in ext.extra_link_args): # Don't bother doing an import check when an extension was # build with an explicit '-arch' flag on OSX. That's currently @@ -302,13 +314,18 @@ # Workaround for Cygwin: Cygwin currently has fork issues when many # modules have been imported - if self.get_platform() == 'cygwin': + if host_platform == 'cygwin': self.announce('WARNING: skipping import check for Cygwin-based "%s"' % ext.name) return ext_filename = os.path.join( self.build_lib, self.get_ext_filename(self.get_ext_fullname(ext.name))) + + # Don't try to load extensions for cross builds + if cross_compiling: + return + try: imp.load_dynamic(ext.name, ext_filename) except ImportError, why: @@ -340,13 +357,6 @@ level=3) self.failed.append(ext.name) - def get_platform(self): - # Get value of sys.platform - for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']: - if sys.platform.startswith(platform): - return platform - return sys.platform - def add_multiarch_paths(self): # Debian/Ubuntu multiarch support. # https://wiki.ubuntu.com/MultiarchSpec @@ -373,12 +383,15 @@ if not find_executable('dpkg-architecture'): return + opt = '' + if cross_compiling: + opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE') tmpfile = os.path.join(self.build_temp, 'multiarch') if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) ret = os.system( - 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % - tmpfile) + 'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % + (opt, tmpfile)) try: if ret >> 8 == 0: with open(tmpfile) as fp: @@ -390,6 +403,38 @@ finally: os.unlink(tmpfile) + def add_gcc_paths(self): + gcc = sysconfig.get_config_var('CC') + tmpfile = os.path.join(self.build_temp, 'gccpaths') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + ret = os.system('%s -E -v - %s 1>/dev/null' % (gcc, tmpfile)) + is_gcc = False + in_incdirs = False + inc_dirs = [] + lib_dirs = [] + try: + if ret >> 8 == 0: + with open(tmpfile) as fp: + for line in fp.readlines(): + if line.startswith("gcc version"): + is_gcc = True + elif line.startswith("#include <...>"): + in_incdirs = True + elif line.startswith("End of search list"): + in_incdirs = False + elif is_gcc and line.startswith("LIBRARY_PATH"): + for d in line.strip().split("=")[1].split(":"): + d = os.path.normpath(d) + if '/gcc/' not in d: + add_dir_to_list(self.compiler.library_dirs, + d) + elif is_gcc and in_incdirs and '/gcc/' not in line: + add_dir_to_list(self.compiler.include_dirs, + line.strip()) + finally: + os.unlink(tmpfile) + def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') @@ -449,36 +494,42 @@ # lib_dirs and inc_dirs are used to search for files; # if a file is found in one of those directories, it can # be assumed that no additional -I,-L directives are needed. - lib_dirs = self.compiler.library_dirs + [ - '/lib64', '/usr/lib64', - '/lib', '/usr/lib', - ] - inc_dirs = self.compiler.include_dirs + ['/usr/include'] + inc_dirs = self.compiler.include_dirs[:] + lib_dirs = self.compiler.library_dirs[:] + if not cross_compiling: + for d in ( + '/usr/include', + ): + add_dir_to_list(inc_dirs, d) + for d in ( + '/lib64', '/usr/lib64', + '/lib', '/usr/lib', + ): + add_dir_to_list(lib_dirs, d) exts = [] missing = [] config_h = sysconfig.get_config_h_filename() config_h_vars = sysconfig.parse_config_h(open(config_h)) - platform = self.get_platform() srcdir = sysconfig.get_config_var('srcdir') # Check for AtheOS which has libraries in non-standard locations - if platform == 'atheos': + if host_platform == 'atheos': lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) inc_dirs += ['/system/include', '/atheos/autolnk/include'] inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) - if platform in ['osf1', 'unixware7', 'openunix8']: + if host_platform in ['osf1', 'unixware7', 'openunix8']: lib_dirs += ['/usr/ccs/lib'] # HP-UX11iv3 keeps files in lib/hpux folders. - if platform == 'hp-ux11': + if host_platform == 'hp-ux11': lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] - if platform == 'darwin': + if host_platform == 'darwin': # This should work on any unixy platform ;-) # If the user has bothered specifying additional -I and -L flags # in OPT and LDFLAGS we might as well use them here. @@ -497,7 +548,7 @@ # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] - if platform in ['darwin', 'beos']: + if host_platform in ['darwin', 'beos']: math_libs = [] # XXX Omitted modules: gl, pure, dl, SGI-specific modules @@ -569,7 +620,7 @@ locale_libs = ['intl'] else: locale_libs = [] - if platform == 'darwin': + if host_platform == 'darwin': locale_extra_link_args = ['-framework', 'CoreFoundation'] else: locale_extra_link_args = [] @@ -611,7 +662,7 @@ exts.append( Extension('cPickle', ['cPickle.c']) ) # Memory-mapped files (also works on Win32). - if platform not in ['atheos']: + if host_platform not in ['atheos']: exts.append( Extension('mmap', ['mmapmodule.c']) ) else: missing.append('mmap') @@ -676,7 +727,7 @@ elif self.compiler.find_library_file(lib_dirs, 'curses'): curses_library = 'curses' - if platform == 'darwin': + if host_platform == 'darwin': os_release = int(os.uname()[2].split('.')[0]) dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') if dep_target and dep_target.split('.') < ['10', '5']: @@ -688,7 +739,7 @@ if find_file('readline/rlconf.h', inc_dirs, []) is None: do_readline = False if do_readline: - if platform == 'darwin' and os_release < 9: + if host_platform == 'darwin' and os_release < 9: # In every directory on the search path search for a dynamic # library and then a static library, instead of first looking # for dynamic libraries on the entiry path. @@ -766,7 +817,7 @@ inc_dirs + search_for_ssl_incs_in) if opensslv_h: name = os.path.join(opensslv_h[0], 'openssl/opensslv.h') - if sys.platform == 'darwin' and is_macosx_sdk_path(name): + if host_platform == 'darwin' and is_macosx_sdk_path(name): name = os.path.join(macosx_sdk_root(), name[1:]) try: incfile = open(name, 'r') @@ -890,6 +941,9 @@ db_inc_paths.append('/pkg/db-3.%d/include' % x) db_inc_paths.append('/opt/db-3.%d/include' % x) + if cross_compiling: + db_inc_paths = [] + # Add some common subdirectories for Sleepycat DB to the list, # based on the standard include directories. This way DB3/4 gets # picked up when it is installed in a non-standard prefix and @@ -910,7 +964,7 @@ db_ver_inc_map = {} - if sys.platform == 'darwin': + if host_platform == 'darwin': sysroot = macosx_sdk_root() class db_found(Exception): pass @@ -920,7 +974,7 @@ for d in inc_dirs + db_inc_paths: f = os.path.join(d, "db.h") - if sys.platform == 'darwin' and is_macosx_sdk_path(d): + if host_platform == 'darwin' and is_macosx_sdk_path(d): f = os.path.join(sysroot, d[1:], "db.h") if db_setup_debug: print "db: looking for db.h in", f @@ -970,7 +1024,7 @@ db_incdir.replace("include", 'lib'), ] - if sys.platform != 'darwin': + if host_platform != 'darwin': db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check) else: @@ -1038,6 +1092,8 @@ '/usr/local/include/sqlite', '/usr/local/include/sqlite3', ] + if cross_compiling: + sqlite_inc_paths = [] MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) MIN_SQLITE_VERSION = ".".join([str(x) for x in MIN_SQLITE_VERSION_NUMBER]) @@ -1045,12 +1101,12 @@ # Scan the default include directories before the SQLite specific # ones. This allows one to override the copy of sqlite on OSX, # where /usr/include contains an old version of sqlite. - if sys.platform == 'darwin': + if host_platform == 'darwin': sysroot = macosx_sdk_root() for d_ in inc_dirs + sqlite_inc_paths: d = d_ - if sys.platform == 'darwin' and is_macosx_sdk_path(d): + if host_platform == 'darwin' and is_macosx_sdk_path(d): d = os.path.join(sysroot, d[1:]) f = os.path.join(d, "sqlite3.h") @@ -1100,7 +1156,7 @@ '_sqlite/util.c', ] sqlite_defines = [] - if sys.platform != "win32": + if host_platform != "win32": sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) else: sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) @@ -1108,7 +1164,7 @@ # Comment this out if you want the sqlite3 module to be able to load extensions. sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) - if sys.platform == 'darwin': + if host_platform == 'darwin': # In every directory on the search path search for a dynamic # library and then a static library, instead of first looking # for dynamic libraries on the entire path. @@ -1142,7 +1198,7 @@ # when attempting to compile and it will fail. f = "/usr/include/db.h" - if sys.platform == 'darwin': + if host_platform == 'darwin': if is_macosx_sdk_path(f): sysroot = macosx_sdk_root() f = os.path.join(sysroot, f[1:]) @@ -1155,7 +1211,7 @@ ### XXX this should be fixed to not be platform-dependent ### but I don't have direct access to an osf1 platform and ### seemed to be muffing the search somehow - libraries = platform == "osf1" and ['db'] or None + libraries = host_platform == "osf1" and ['db'] or None if libraries is not None: exts.append(Extension('bsddb185', ['bsddbmodule.c'], libraries=libraries)) @@ -1168,7 +1224,7 @@ dbm_order = ['gdbm'] # The standard Unix dbm module: - if platform not in ['cygwin']: + if host_platform not in ['cygwin']: config_args = [arg.strip("'") for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] dbm_args = [arg for arg in config_args @@ -1250,17 +1306,17 @@ missing.append('gdbm') # Unix-only modules - if platform not in ['win32']: + if host_platform not in ['win32']: # Steen Lumholt's termios module exts.append( Extension('termios', ['termios.c']) ) # Jeremy Hylton's rlimit interface - if platform not in ['atheos']: + if host_platform not in ['atheos']: exts.append( Extension('resource', ['resource.c']) ) else: missing.append('resource') # Sun yellow pages. Some systems have the functions in libc. - if (platform not in ['cygwin', 'atheos', 'qnx6'] and + if (host_platform not in ['cygwin', 'atheos', 'qnx6'] and find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): if (self.compiler.find_library_file(lib_dirs, 'nsl')): libs = ['nsl'] @@ -1284,7 +1340,7 @@ curses_libs = [curses_library] exts.append( Extension('_curses', ['_cursesmodule.c'], libraries = curses_libs) ) - elif curses_library == 'curses' and platform != 'darwin': + elif curses_library == 'curses' and host_platform != 'darwin': # OSX has an old Berkeley curses, not good enough for # the _curses module. if (self.compiler.find_library_file(lib_dirs, 'terminfo')): @@ -1335,7 +1391,7 @@ break if version >= version_req: if (self.compiler.find_library_file(lib_dirs, 'z')): - if sys.platform == "darwin": + if host_platform == "darwin": zlib_extra_link_args = ('-Wl,-search_paths_first',) else: zlib_extra_link_args = () @@ -1367,7 +1423,7 @@ # Gustavo Niemeyer's bz2 module. if (self.compiler.find_library_file(lib_dirs, 'bz2')): - if sys.platform == "darwin": + if host_platform == "darwin": bz2_extra_link_args = ('-Wl,-search_paths_first',) else: bz2_extra_link_args = () @@ -1440,7 +1496,7 @@ if sys.maxint == 0x7fffffff: # This requires sizeof(int) == sizeof(long) == sizeof(char*) dl_inc = find_file('dlfcn.h', [], inc_dirs) - if (dl_inc is not None) and (platform not in ['atheos']): + if (dl_inc is not None) and (host_platform not in ['atheos']): exts.append( Extension('dl', ['dlmodule.c']) ) else: missing.append('dl') @@ -1451,29 +1507,29 @@ self.detect_ctypes(inc_dirs, lib_dirs) # Richard Oudkerk's multiprocessing module - if platform == 'win32': # Windows + if host_platform == 'win32': # Windows macros = dict() libraries = ['ws2_32'] - elif platform == 'darwin': # Mac OSX + elif host_platform == 'darwin': # Mac OSX macros = dict() libraries = [] - elif platform == 'cygwin': # Cygwin + elif host_platform == 'cygwin': # Cygwin macros = dict() libraries = [] - elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'): + elif host_platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'): # FreeBSD's P1003.1b semaphore support is very experimental # and has many known problems. (as of June 2008) macros = dict() libraries = [] - elif platform.startswith('openbsd'): + elif host_platform.startswith('openbsd'): macros = dict() libraries = [] - elif platform.startswith('netbsd'): + elif host_platform.startswith('netbsd'): macros = dict() libraries = [] @@ -1481,7 +1537,7 @@ macros = dict() libraries = ['rt'] - if platform == 'win32': + if host_platform == 'win32': multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', '_multiprocessing/semaphore.c', '_multiprocessing/pipe_connection.c', @@ -1508,26 +1564,26 @@ # Platform-specific libraries - if platform == 'linux2': + if host_platform == 'linux2': # Linux-specific modules exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) else: missing.append('linuxaudiodev') - if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', + if (host_platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8') - or platform.startswith("gnukfreebsd")): + or host_platform.startswith("gnukfreebsd")): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) else: missing.append('ossaudiodev') - if platform == 'sunos5': + if host_platform == 'sunos5': # SunOS specific modules exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) else: missing.append('sunaudiodev') - if platform == 'darwin': + if host_platform == 'darwin': # _scproxy exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules/_scproxy.c")], extra_link_args= [ @@ -1536,7 +1592,7 @@ ])) - if platform == 'darwin' and ("--disable-toolbox-glue" not in + if host_platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): if int(os.uname()[2].split('.')[0]) >= 8: @@ -1732,8 +1788,7 @@ # Rather than complicate the code below, detecting and building # AquaTk is a separate method. Only one Tkinter will be built on # Darwin - either AquaTk, if it is found, or X11 based Tk. - platform = self.get_platform() - if (platform == 'darwin' and + if (host_platform == 'darwin' and self.detect_tkinter_darwin(inc_dirs, lib_dirs)): return @@ -1756,7 +1811,7 @@ # Check for the include files on Debian and {Free,Open}BSD, where # they're put in /usr/include/{tcl,tk}X.Y dotversion = version - if '.' not in dotversion and "bsd" in sys.platform.lower(): + if '.' not in dotversion and "bsd" in host_platform.lower(): # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, # but the include subdirs are named like .../include/tcl8.3. dotversion = dotversion[:-1] + '.' + dotversion[-1] @@ -1782,7 +1837,7 @@ include_dirs.append(dir) # Check for various platform-specific directories - if platform == 'sunos5': + if host_platform == 'sunos5': include_dirs.append('/usr/openwin/include') added_lib_dirs.append('/usr/openwin/lib') elif os.path.exists('/usr/X11R6/include'): @@ -1798,7 +1853,7 @@ added_lib_dirs.append('/usr/X11/lib') # If Cygwin, then verify that X is installed before proceeding - if platform == 'cygwin': + if host_platform == 'cygwin': x11_inc = find_file('X11/Xlib.h', [], include_dirs) if x11_inc is None: return @@ -1817,11 +1872,11 @@ libs.append('tk'+ version) libs.append('tcl'+ version) - if platform in ['aix3', 'aix4']: + if host_platform in ['aix3', 'aix4']: libs.append('ld') # Finally, link with the X11 libraries (not appropriate on cygwin) - if platform != "cygwin": + if host_platform != "cygwin": libs.append('X11') ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], @@ -1873,7 +1928,7 @@ def configure_ctypes(self, ext): if not self.use_system_libffi: - if sys.platform == 'darwin': + if host_platform == 'darwin': return self.configure_ctypes_darwin(ext) srcdir = sysconfig.get_config_var('srcdir') @@ -1891,7 +1946,8 @@ ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) - config_args = [] + config_args = [arg for arg in sysconfig.get_config_var("CONFIG_ARGS").split() + if (('--host=' in arg) or ('--build=' in arg))] if not self.verbose: config_args.append("-q") @@ -1935,7 +1991,7 @@ '_ctypes/cfield.c'] depends = ['_ctypes/ctypes.h'] - if sys.platform == 'darwin': + if host_platform == 'darwin': sources.append('_ctypes/malloc_closure.c') sources.append('_ctypes/darwin/dlfcn_simple.c') extra_compile_args.append('-DMACOSX') @@ -1943,7 +1999,7 @@ # XXX Is this still needed? ## extra_link_args.extend(['-read_only_relocs', 'warning']) - elif sys.platform == 'sunos5': + elif host_platform == 'sunos5': # XXX This shouldn't be necessary; it appears that some # of the assembler code is non-PIC (i.e. it has relocations # when it shouldn't. The proper fix would be to rewrite @@ -1954,7 +2010,7 @@ # finding some -z option for the Sun compiler. extra_link_args.append('-mimpure-text') - elif sys.platform.startswith('hp-ux'): + elif host_platform.startswith('hp-ux'): extra_link_args.append('-fPIC') ext = Extension('_ctypes', @@ -1971,7 +2027,7 @@ if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): return - if sys.platform == 'darwin': + if host_platform == 'darwin': # OS X 10.5 comes with libffi.dylib; the include files are # in /usr/include/ffi inc_dirs.append('/usr/include/ffi') -- Repository URL: http://hg.python.org/cpython